#help-development

1 messages · Page 993 of 1

eternal oxide
#

lore is a String list so will never match a String

sleek estuary
#

to avoid exceptions

sleek estuary
wintry elk
#

i indeed am

obsidian wolf
#

Unlike me, a pro

eternal oxide
#

change .equals to .contains

obsidian wolf
#

😂😭

sleek estuary
eternal oxide
#

he already checks it has lore

#

and has meta

sleek estuary
#

oh yes

#

I am sleeping

#

im sorry

#

just need to check the item yourself

tender shard
#

what's the issue? getContents() might return null items iirc so you can't just call getType()

eternal oxide
#

Actually, do NOT loop the inventory contents. You shoudl get the consumed item from the event

#

you are literally tryign to check the item they just consumed

obsidian wolf
#

I have a question, can you still run all that code and have a .json file and a custom texture?

eternal oxide
#

not a random one from their inventory

tender shard
#

what even is the issue besides "just don't work"?

wintry elk
#

i just couldnt figure out how to grab an items lore without getting an error about it being null

eternal oxide
#

do not use inventoyr

tender shard
eternal oxide
#

use the item from teh event and replace .equals with .contains

#

done

tender shard
#

and this ^ still important information to not blindly call getType() on everything that Inventory#getContents() returns because some of them might be null

obsidian wolf
tender shard
#

no need to ask every 1.5 minutes

tender shard
#

you can bump your question again in 10 minutes or something but don't ask every 30 seconds pls

eternal oxide
#

I have no idea what he is asking

next dew
tender shard
#

i also dont get the question

next dew
#

Things dont even seem related

wintry elk
#

i think he means like a custom model for it or something

tender shard
#

ah they're probably talking about custom model data + resource pack

obsidian wolf
#

yessir

#

exactly

eternal oxide
#

We still have no idea what you are actually asking though

obsidian wolf
#

Okay, so basically can you import a 3d model texture onto a plug-in?

#

Or does it have to be a completely seperate texture pack

#

like

#

using the client

#

idk

next dew
#

A plugin is a thing and a texture pack is another

obsidian wolf
#

nvm pretend like I was never here

#

and I don’t exist

tender shard
obsidian wolf
eternal oxide
#

I believe you can now specify multiple (I think)

slender elbow
#

but what about my 1.3.2 server

tender shard
eternal oxide
#

play chess!?

potent atlas
#

when someone gets a chance I am struggling with custom config files, keeps rejecting the path I give it. I can show the file. I know the code, I just can't seem to find an example of how to write the path. thanks!

young knoll
#

Yeah you can have multiple server resource packs as of 1.20.3

tender shard
#
File chestsYml = new File(myPluginInstance.getDataFolder(), "chests.yml");
young knoll
#

They just layer like normal packs do

#

They also get downloaded async

tender shard
#

that means I can stop updating my resource pack merger haha

potent atlas
#

oh my bad I said my question wrong

#

I'm writing paths -inside- the file to get the values

tender shard
#
persons:
  mfnalex:
    age: 29
    address: Münster

myConfig.getInt("persons.mfnalex.age") -> 29

or what's your question?

#

or do you rather mean something like this:

#
persons:
  mfnalex:
    something: asd
  someoneElse:
     something: asd

and now you want a list of "mfnalex, someoneElse"?

#

If so you do it like this:

ConfigurationSection persons = myConfig.getConfigurationSection("persons");
Collection<String> personNames = persons.getKeys(false);
potent atlas
#

the first example is the closest

tender shard
#

maybe you could show us your config and then tell us which data you need, that'd be helpful

potent atlas
#

yep

#

one sec

#

I need the x, y, z etc. for each point

tender shard
#

I see, gimme a minute. Let's assume you got a class like this:

public class TeleportPoint {
  public int x, y, z;

  public TeleportPoint(int x, int y, int z) {
    this.x = x;
    // etc
  }
tender shard
#

example:

#
List<TeleportPoint> tpList = new ArrayList<>();

// This is the whole "teleport-points" section
ConfigurationSection tpPoints = myConfig.getConfigurationSection("steps.step1.teleport-points");

// This loops over "point1", "point2", etc
for(String tpName : tpPoints.getKeys(false)) {

  // This gets you the section for each point
  ConfigurationSection teleportPoint = tpPoints.getConfigurationSection(tpName);
  // Now you can get each point's values
  tpList.add(new TeleportPoint(tpPoint.getInt(x), tpPoint.getInt(y), ...);
#

sth like this, sorry I'm on the phone. But I hope you get the idea

potent atlas
#

ohhh I'm stupid, I see where I went wrong. I can work with that! thank you!

tender shard
#

alternatively, if do not need the names (point1, point2) etv you can use a map list

#
points:
  - x: 1
    y: 2
    z: 3
  - x: 100
    y: 200
    z: 300
potent atlas
#

oh smart

tender shard
#

then you can use getMapList("points")

#

just a suggestion

#

hope that helps, I'm going to bed now, good night everyone!

potent atlas
#

goodnight ❤️

zinc moat
#

Edible blocks?

twilit coral
#

nope

zinc moat
#

Also question

twilit coral
#

it's the material you're .

zinc moat
#

how do i check the type like
Psueodo code
if block.type is diamond_ore

twilit coral
#

it is not assumed that the material that is returned from the block is a food item

#

type == Material.DIAMOND_ORE

zinc moat
twilit coral
glacial moth
#

Trying to set the max stack size, but doesn't seem to be setting

public static void setStackSize(ItemStack item){
        if(item == null) return;
        ItemMeta meta = item.getItemMeta();
        if(meta == null) return;
        meta.setMaxStackSize(1);
    }```

Running this of different events that cause new items, like ItemSpawn, PickUp, InventoryClick
twilit coral
#

did you set the itemmeta to the item

#

item.setitemmeta(x)

tender shard
#

Sniped

glacial moth
#

dam, sorry for the stupid mistake 🤦‍♂️ thank you

young knoll
#

NVM forgot about air

zinc moat
#

why is there nothing to break a block not natural, im trying to make it when a block gets mined it turns into a different block and then waits ... seconds to turn back

young knoll
#

setType

zinc moat
#

Ahhh

kindred sentinel
#

I want to remake text from 1 page of book to the lore, and after that an opposite -> lore to the text of books page, but I always have problems with enters (\n) if I'm trying to save them like new line, and after that add them for each line, then they're duplicating

mortal hare
#

couple years ago i thought that 16gb of ram would be enough for my usage

#

but now i peak at 15 gb of ram with no problems

#

fuck me

#

intellij eats ram like its disk space

#

4gb of ram

#

just for one project

slender elbow
#

i give it the minimum that i can and it works fine lol

autumn ingot
#

not entirely sure if this is a spigot question but is there any library to translate 3d models (e.g. from blockbench) into display entities?

echo basalt
#

ModelEngine v4 does it

#

Pretty sure magmaguy has something for it too

autumn ingot
#

oh hey illusion long time no see lol

autumn ingot
worthy yarrow
#

Some days I wish illusion would be in a call so I can voulenteer myself to get yelled at

echo basalt
#

20 bucks and I yell at you for an hour how about that

echo basalt
#

Keep in mind I was like 15 when we met so a lot has changed

worthy yarrow
#

20 bucks is like my weekly gas amount and to be fair, off 12 hours of work a week I need it D:

echo basalt
#

it's like half my net worth

worthy yarrow
#

It's like double mine

worldly ingot
#

Are you driving a small motorcycle?

slender elbow
#

are you?

worldly ingot
#

No. My gas bill is like $100 per tank :(

minor garnet
#

does anyone know what math would apply to this, i have a vector (0, 0, -1) that would represent north (0 degrees or 360), but if i rotated this vector 45 degrees to the right, it would represent a vector x, how i get that degrees number i have that code,

        float yaw = (float) Math.toDegrees(Math.atan2(FRONT_DIRECTION.getX(), FRONT_DIRECTION.getZ()));
        yaw = (yaw + 360) % 360;```

which is returning wrong numbers
wintry elk
#

can someone tell me how to fix the error that says "Required Type : Collection | Provided : PotionEffect"

echo basalt
#

p sure that's it

meager spoke
#

hello i enabled all config files for sand duplication (unsafe teleportation) but my sand is not duping, can someone help?

i'm playing on paperMC 1.20.6

echo basalt
#

but also

#

?whereami

glad prawn
wintry elk
glad prawn
#

if you didnt know, then pls learn about the Collection.

wintry elk
glad prawn
wintry elk
glad prawn
fierce whale
#

Is there a way to fade out sound(music) volume?

worthy yarrow
#

3 gal tank, 1 gal reserve

worldly ingot
#

Yeah that tracks

worthy yarrow
#

But that’s when it’s not raining, gas bill goes up to 35$ a week if it’s rainy

#

That’s when I bring the focus out and let me tell you 45 mpg city - 60 mpg highways is quite nice in that thing

wintry elk
eternal oxide
#

wrong import? Do you use nms too?

#

There is no FAST_DIGGING in the PotionEffectType Enum

#

in Spigot thats HASTE

#

ah I see, old version

eternal oxide
#

In pre 1.13 Spigot STRENGTH was called INCREASE_DAMAGE

tropic totem
#

hello this is a weird question but can i ask a help about my problem because i try to create command on my plugin and when i try it , it was not register on my server

eternal oxide
#

check your latest.log for errors

tropic totem
tall dragon
eternal oxide
#

I'm putting money on a missing plugin.yml from the jar due to wrong build method

eternal oxide
#

command is not in the plugin.yml you are using. show code where you register the command

#

Ghostbreeding.java:20

karmic sapphire
#

I keep on trying to build ImageFrames, but it isn't finding the dependenices in intellej. I have already build craftbukkit, and Spigot up to 1.17. https://github.com/LOOHP/ImageFrame I was wondering if anyone had any advice for me?

#

I'm also in vc lol

#

👀

eternal oxide
#

What error do you get building?

tropic totem
karmic sapphire
eternal oxide
tropic totem
eternal oxide
#

your plugin.yml is not the one in yoru jar. run clean before Package in maven

karmic sapphire
karmic sapphire
eternal oxide
karmic sapphire
eternal oxide
#

did you build spigot using Buildtools?

karmic sapphire
eternal oxide
#

its wierd as this design is rubbish in ImageFrame

#

it shoudl be using Spigot not spigot-api and there shoudl be no craftbukkit dependency at all

karmic sapphire
#

yea tbh idek whats going on there

eternal oxide
#

Buildtools doesn;t even build CB by default now

karmic sapphire
#

Yea, but it was easy enough to select the option to build it

eternal oxide
#

are you 100% certain you build 1.16.1?

karmic sapphire
#

YEa

#

is that something I can send here lol

#

the build?

eternal oxide
#

the build?

karmic sapphire
#

In any case yes

eternal oxide
#

its failing building the abstraction

#

those are CB, what about spigot?

#

they are also downloads not maven repos

karmic sapphire
eternal oxide
#

it must be installed in yoru local maven repo to be seen by maven

karmic sapphire
#

I had to download java 14 to build all the dependencies for this lol

eternal oxide
#

browse to C:\users\yourname\.m2\repository\org\spigotmc

#

you should have a spigot-api folder if you built with BT

karmic sapphire
eternal oxide
#

Buildtools

#

?bt

undone axleBOT
karmic sapphire
#

Ohh

#

ok

eternal oxide
#

you can double click it to run as it now has a UI

karmic sapphire
eternal oxide
#

then you did not build using BuildTools

karmic sapphire
eternal oxide
#

my spigotmc folder

shadow night
#

Interesting lol

karmic sapphire
#

Thx, that was a good guide

#

Im basically there now lol

#

I didn't go into the .m2 folder

#

at first

eternal oxide
#

ah

karmic sapphire
#

lol

tardy delta
#

Windows 7 hehe

eternal oxide
#

This is my spigot-api

karmic sapphire
#

Oh god

eternal oxide
tardy delta
#

Linux is the best apart from windows

eternal oxide
#

I have never liked Linux. I've tried it a few times but it's just not as comfortable as Win7

tardy delta
#

Takes a while to get used to the missing pieces

karmic sapphire
eternal oxide
#

no

karmic sapphire
#

Damn

eternal oxide
#

there is a command you can install with though

#

I'm sure alex has a post about it, one sec

#

?nms for me

karmic sapphire
eternal oxide
#

the one I posted is about installing jars to maven repo

#
mvn install:install-file \
    -Dfile=somejar-1.0.jar \
    -DgroupId=com.github.someuser \
    -DartifactId=somejar \
    -Dversion=1.0 \
    -Dpackaging=jar```
karmic sapphire
#

Tyy

#

I’ll have to try this (:

eternal oxide
#

just change args to match what you are installing

#

or, just run buildtools for each version you need

#

it auto installs to maven repo

karmic sapphire
#

Yea, what I originally did is build it on one pc, then transfer the jars to the other.

#

I am just doing it on the pc I built it on orignally

#

instead.

stoic parrot
#

If anyone could help (:

lilac dagger
#

Wrong task?

worthy yarrow
#

Also that is a funky way of doing tasks

eternal oxide
#

you constantly reset the timeInterval to teh config setting so it never really decreases

stoic parrot
worthy yarrow
#
public static void applySweatEffect(Player player) {
        applySweatEffect = new BukkitRunnable() {
            @Override
            public void run() {
                player.spawnParticle(Particle.WATER_DROP, player.getLocation().add(0, 1.6, 0), 3, 0.1, 0.2, 0.1);
            }
        }.runTaskTimerAsynchronously(seasons, 5, 100);
    }```

I do mine like this
#

Idk if its better

stoic parrot
#

oh Runnable

worthy yarrow
#

It's the same thing I'm pretty sure

eternal oxide
#

oh I see, you reset after it counts down

#

You never call the stopTimer in that code.

stoic parrot
#

I call it in a command

worthy yarrow
#

I assumed since it was a public method, that call comes from somewhere else

eternal oxide
#

then there is no reason for it to not cancel

#

unless you are calling startTimer when its already running

stoic parrot
proper cosmos
#

How can I track when someone gets item out of Brewing Stand?

eternal oxide
#

Then there is no reason your task would not stop unless its throwing an error from the scheduler

stoic parrot
eternal oxide
#

yep

stoic parrot
eternal oxide
#

What makes you think teh task is not stopping?

stoic parrot
#

While testing, when i run the /reset-timer command the timer should restart at that time correct? well it does not it just goes on how it was

eternal oxide
#

the timer will not reset on cancel as its external to the task

#

it will remain at whatever it was last at

stoic parrot
eternal oxide
#

you need to reset the timeInterval before you start your task

#

top of startTimer method

stoic parrot
worthy yarrow
#

It's a curious ask, but why do you need an exception for console command?

#

Is the system supposed to be ran through console commands?

stoic parrot
#

Automatically

worthy yarrow
#

Gotcha

stoic parrot
next kernel
#

Hi there, anyone know how to send a chat with Item hover event with BungeeChat on Spigot 1.20.5+?
I tried 3 ways to send chat:

    @Override
    public void sendNBTDebug(ItemStack stack, @NotNull CommandSender sender) {
        // test with NBTAPI
        String nbtapi = NBT.itemStackToNBT(stack).toString();
        System.out.println("NBTAPI: "+ nbtapi);
        sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
        // test with NMS
        DataComponentPatch patch = CraftItemStack.asNMSCopy(stack).getComponentsPatch();
        String nmsPatch = DataComponentPatch.CODEC.encodeStart(NbtOps.INSTANCE, patch).getOrThrow().getAsString();
        System.out.println("NMS-DataComponentPatch: "+nmsPatch);
        sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
        // test with NMS stack
        String nmsStack = net.minecraft.world.item.ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, CraftItemStack.asNMSCopy(stack)).getOrThrow().getAsString();
        System.out.println("NMS-ItemStack: "+nmsStack);
        sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
    }

    private void sendNBTDebugActually(String key, String nbt, CommandSender sender) {
        net.md_5.bungee.api.chat.HoverEvent hoverEvent = new net.md_5.bungee.api.chat.HoverEvent(net.md_5.bungee.api.chat.HoverEvent
                .Action.SHOW_ITEM,
                new Item(key, 1,
                        ItemTag.ofNbt(nbt)));
        BaseComponent component = TextComponent.fromLegacy("Hover on this");
        component.setHoverEvent(hoverEvent);
        sender.spigot().sendMessage(component);
    }

However, I didn't get any luck on them (all ways just show regular item infomations without special name and lores)

#

Console Outputs:

[15:56:14] [Server thread/INFO]: NBTAPI: {components:{"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'},count:1,id:"minecraft:piston"}
[15:56:14] [Server thread/INFO]: NMS-DataComponentPatch: {"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'}
[15:56:14] [Server thread/INFO]: NMS-ItemStack: {components:{"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'},count:1,id:"minecraft:piston"}
grim hound
#

no idea

next kernel
#

ah, alright

grim hound
#

this should work, so maybe some 1.20.5 changes

next kernel
#

yea it break since 1.20.5

sullen marlin
#

Start by figuring out the correct tellraw I guess

#

Sure you aren't after .getAsComponentString ?

#

You don't need nms for this

next kernel
stone turret
#

Hey there

Spigot version 1.20.4
Problem:
So, I am currently having an issue trying to remove all commands from the tab completions list and only showing the commands from my own plugin as well as making it where people cannot do luckperms or other commands in the chat. Its still showing the commands in the tablist completions (some of them) and as well as allowing players to do /luckperms and other commands even though in my plugin is explicitly denying that permission??

My code:
https://paste.md-5.net/moyazifore.cs

Bully all you want :( but I tried EVERYTHING lmao

#

I will be going to sleep so ping me if you have some sort of potential solution please 🙏

eternal oxide
#

?fork

undone axleBOT
#

SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.

next kernel
#

?whereami

stone turret
#

oopsie

#

It was copy paste uhh

#

I emant spigot

#

obviously :)

next kernel
#

Paper has a lot of internal changes under the API, and Spigot's solution may not be applicable to Paper.

eternal oxide
#

UnknownCommandEvent is not in Spigot

stone turret
#

😢

#

Literally any ounce of help would be appreciated even it doesnt even correlate to what i have.

orchid trout
#

you can disable all tab completions in the config

eternal oxide
#

There is an event to modify the commands sent for tab complete

#

just modify the Collection

stone turret
#

Because I dont want to hide all commands. I just want to hide all commands that arent in my own plugin. There is no need for any other plugins commands.

eternal oxide
#

^

#

PlayerCommandSendEvent

orchid trout
#

if people dont have the permission they shouldnt be able to tab complete the commands anyways

eternal oxide
#

^ also true

stone turret
orchid trout
#

you should go to the papermc discord

#

or read what elgar sent

stone turret
mellow prairie
#

how to disable fall damage tag on combat log X

stone turret
#

Thank you

inner mulch
#

does this mean custom enchants and custom paintings?

orchid trout
#

you could already have custom painting

#

s

inner mulch
#

but using maps not fun >:(

molten hearth
#

maps are such a cringe solution

orchid trout
#

texture packs

eternal night
#

with datapacks yea

inner mulch
#

will there be no api :(?

#

if its possible with datapacks its possible with plugins too, right?

tall dragon
#

in the future yea. thats pretty likely

eternal night
#

Editing the registries like that has to happen at a very very early point in time.

dawn flower
#

soo

eternal night
#

Well registries are frozen by minecraft once created. All that fun stuff happens before plugins are even loaded.

#

the reloadable stuff like enchantments you can technically edit down the line tho

#

its just a bit annoying to do so outside the normal lifecycle for the registries

inner mulch
#

ok

eternal night
#

idk, I mean, problem with an API for this kind of jazz is that, as you might be able to tell by "data version 42", the format also changes rapidly

#

an api around that might not really be able to live as long as you'd like it to

#

in terms of cross version compatibility

dawn flower
#

tf r the registries

#

commands n stuff?

eternal night
#

they are the source for pretty much any data in the game

dawn flower
#

ah

#

can u custom color (hex) concrete or wool

#

cuz that'd be hella cool

#

what's the new Wool class?

worthy yarrow
#

I've been (painfully) toying with packet events using the wrappers to try and make leaves colorful for autumn effects (my seasons plugin)

worthy yarrow
dawn flower
#

i dont think leaves can be colorful unless u make ur own leaves with block displays

worthy yarrow
#

We'll see

dawn flower
#

if concrete can be colored then display blocks can make all cartoony stuff (no textures)

#

yeah wool cant be colored

#

wait chatcolor is depricated?

stoic parrot
#

If I want save coordinates, how can i save them without putting them in a yml or json or whatever format file?

inner mulch
#

database

dawn flower
stoic parrot
#

save

inner mulch
#

database

valid burrow
#

then either files or a database

#

or

#

explain why you need to save them

stoic parrot
#

SpawnLocation

#

How does deluxehub do it?

valid burrow
#

a yml file id guess

#

nothing wrong with that lol

stoic parrot
#

They don't have a yml file or a database

valid burrow
#

They gotta have something xd

#

just use a yml file

#

nothing wrong with that

stoic parrot
#

I want to try out gson

#

That would work right?

valid burrow
#

uh sure but why

inner mulch
stoic parrot
inner mulch
#
  • you can later upgrade to a nosql database
valid burrow
#

he can always upgrade to virtually anything its 1 value

#

db would be pointless here

stoic parrot
#

I don't need a database to just save 1 spawn loc

valid burrow
#

no other api/plugin needs to know another servers spawn

valid burrow
stoic parrot
#

xd

silver robin
#

How does NamespacedKey work?
player.StoreCookie takes one but the constructor (even though its public) there is a comment saying it's for internal use only

eternal night
#

wrong constructor

#

be aware, that cookies are essentially useless unless you properly sign the content as they are 100% controlled by the client

valid burrow
#

cookies arent useless

#

i have many usecases for them

eternal night
#

They indeed are very yummy

dawn flower
#

this is like a 7 reply chain at this point

eternal night
#

I guess no one knows

tepid turret
#

How to send adventure lib supporting messages to a non player?

#

Basically what do i call to send a component message

eternal night
#

uh, against spigot api?

#

or on paper-api

tepid turret
#

on spigot

eternal night
#

ah, sorry idk

#

I think you have to create an audience from something

#

see the bukkit bridge/platform

tepid turret
#

oh that shouldnt be too hard

eternal night
slender elbow
#

Maven Gradle

dawn flower
#

my guy

#

my goddamn builder fixed it and developers cant

#

im so done

tepid turret
#

real

eternal night
buoyant viper
#

who needs adventure when u have bungee chat 😎

grim hound
#

Is there any way to have the player store a certain value, like on his pc, so that when he connects again I can ask him about that value?

tender shard
#

on his PC? no

#

why not just use PDC

grim hound
tender shard
#

or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...

grim hound
#

makes sense

grim hound
#

cuz on offline mode anybody can use any nickname

buoyant viper
#

please do not the cat

tender shard
#

not without client mods

grim hound
eternal night
#

offline mode moment

tender shard
#

also what's the purpose, if players can choose any nickname they want in offline mode, they also can just copy over every file that you want to store on their PC

grim hound
#

anyway, if not, then too bad

tepid turret
#

how to raytrace entities?

tender shard
#

the usual way to half-way secure offline servers is AuthMe or however it's called

grim hound
#

it's unideal

#

that's why I wrote AlixSystem

#

much better

tender shard
#

ofc it is unideal, the proper solution is online mode

molten hearth
#

the proper solution is supporting piracy 🙏

dawn flower
grim hound
#

and with auth me

tepid turret
grim hound
#

well, it doesn't even try

eternal oxide
#

Entity#getLocation().subtract(Entity#getLocation().getDirection())

#

it already did

eternal oxide
#

possibly set the power to zero

#

location, 0, false, false

#

why are you trying explosions?

valid burrow
#

do boats not have the normal entity atriutes?

icy beacon
#

what time is it

valid burrow
#

14:12

icy beacon
#

thx

valid burrow
#

(germany)

icy beacon
#

oh

#

no

#

i dont need germany time

#

i need the time

eternal oxide
#

13:12

icy beacon
#

thx

valid burrow
icy beacon
#

the

dawn flower
#

how do i cancel blocks from expldoing

slender elbow
#

clear the block list in the Entity/BlockExplodeEvent

eternal oxide
#

do you mean exploding or breaking due to explosion?

outer tendon
#

Hey guys, I need a bit of advice. I'm building a mini-game, but the games will have different types, like solos, doubles, fours, etc., each of which will have different numbers of teams and max team sizes. I am wondering how I should define this behavior. Should I use Game class properties like numberOfTeams and maxTeamSize, or should I use an enum? I know I could also define an enum with these properties, but that might defeat the point of the enum since Id have to grab those in order to determine what type of game it is.

dawn flower
eternal oxide
#

then as Emily said

#

the block list is mutable for removal.

#

boats have a maximum speed and explosions will not "push" them

tepid turret
#

nope lols

#

the way i've seen plugins do it is by just increasing the velocity

#

problem is you need to know when to and when not to increase the velocity

#

one plugin did this by only increasing the velocity while players were holding a special item.

#

could see it working but problem is it would get rid of blocks and cause issues for other players

#

plus during lag that breaks completelty

#

velocity is the way i'd do it.

#

Maybe give the player an item while in boats?

#

or (i know this defeats the point of a spigot server) have the players download a mod that will send specific keystrokes as a packet to the server

#

then get those packets and increase the boat speed when said keystrokes are being pressed

tepid turret
#

Only error msg im getting is "Unsupported class file major version 65" when building my maven package

#

(my maven plugin into a .jar)

plush sluice
#

how do i set attribute for entity?

valid burrow
#

entity.getAtribute.setWhatEver iirc

plush sluice
tepid turret
#

you gotta go to the specifc class

#

Example for a ghast instead of doing

#
Entity ghast = (whatever here)
ghast.getAttribute();
#

it'd be

#
Ghast ghast = (whatever here)
...
valid burrow
#

yep thats it

#

not all entities have the same atributes

#

thats why

tepid turret
#

yea

plush sluice
trim lake
#

I can't decide correctly when to use interace or abstract class. I would like to make a plugin that will manage the location as a trigger. So the player sets with a command the location as a trigger. Another player clicks on that trigger and sends it to the chat, opens the inventory... or whatever. There will the Trigger class for each type of trigger. Should I make an interface for the main Trigger class or should this abstract? I was thinking about an abstract class because each trigger will have a List of requirements. I'm trying to understand when to use an abstract class and when to use an interface.
I read some articles about that but Im still confused lol

plush sluice
#

ty

valid burrow
#

learn it with vanilla java first

#

ad then apply that logic to spigot

eternal oxide
tepid turret
#
    public String getData(OfflinePlayer player, String query) throws SQLException {
        if (!playerExists(player)) addPlayer(player);
        if (sqlContains(query) != 1) return null;
        try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT ? FROM Players WHERE uuid = ?")) {
            preparedStatement.setString(1, query);
            preparedStatement.setString(2, player.getUniqueId().toString());
            ResultSet resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) return resultSet.getString(query);
            else return null;
        }
    }

When using this code and parsing through the player and lang
it returns "No such column 'lang'

But:

#

the column literally exists

trim lake
trim lake
# eternal oxide different trigger types will have many comonalities so abstract

That was what I tought as well, tbh. I kinda dont need lot of variables or anything it will be mostly methods and they probably wont be scenerio when I will use same method in multiple triggers, that's why Im thinking about interface as well. I was working on one project with someone before when we were creating custom drinks and food and there we used interface for some reason... That what confused me

#

I kinda know how to do it and stuff but Im strugling on correct logic on thinks need some mentor/couch or smtn like that lol.

inner mulch
trim lake
inner mulch
sullen canyon
#

abstract classes, interfaces

inner mulch
#

Pizza interface

sullen canyon
#

they are all like a pizza

inner mulch
#

You can compose your Pizza with different ingeredients but it remains food so it can have the food interface with the eat method

sullen canyon
#

it follows the builder pattern to make diff pizzas

trim lake
#

I mean.. at the custom items state. I would do that with abstract class. I would create an abstract class CustomItem where it would be protected field ItemStack item and int uses with 2 methods getRemaining() (witch I would probably define in abstract class, becaouse every item will have same) and abstract void consume(Player player) method. But guy told me this is blueshit. The way how it was done was interface with getuses method and use method. Than every class had ItemStack and uses field but that why I would use abstract class to avoid that making same field for every class.

inner mulch
trim lake
#

I mean for me it make seasn make it interface bcs not only item is think what u can eat, but still... For me it seams to be pointless to have that as interface when its only for items. I cant rly find ussage for interface for what ever Im doing lol. I started feeling wrong bcs of that.

#

It was done like this:

public interface Consumable {
   int getRemaining();

   void consume(Player var1);
}

public class Juice implements Consumable {
   private ItemStack item;
   int getRemaining() {
   blabla   
  }

   void consume(Player var1) {
   blabla   
  }
}
inner mulch
#

Yeah thats good

trim lake
#

I would still use abstract class as I mentioned, lol.But I think I get it. It can be something other then ItemStack like block (Cake) or something probably thats why and thats why it was done this way.

inner mulch
#

Yes

eternal oxide
#

and to seperate API from implementation

trim lake
#

This is my fight basicly:

public interface JobTrigger {

    void handle();
    boolean meetsRequirements(Player player);

}

public class TestTrigger implements JobTrigger {

    @Override
    public void handle() {

    }

    @Override
    public boolean meetsRequirements(Player player) {
        return false;
    }
}

vs

public abstract class JobTriggerAbs {

    private List<Requirement> requirementsList = new ArrayList<>();

    abstract void handle(Player player);

    boolean meetsRequirements(Player player) {
        boolean results = true;
        for (Requirement reg : requirementsList ) {
            if (!requirementsList.meat()) {
                results = false
                break;
            }
        }
        return results;
    }

}
public class TestTrigger extends JobTriggerAbs {

    @Override
    public void handle(Player player) {
        if (!meetsRequirements(player)) return;
    }

}
#

Sure I can load requirements from config in meetsRequirements method thats why I cant decide, lol 😄 But since the requirements is same Im closely to use abstract class rather then interface. Thats probably correct?

proper cosmos
#

Can I somehow change max stack size of Material.POTION (in player's inventory)?

valid burrow
#

yeah u can set the max stack size of an itemstack i think

proper cosmos
valid burrow
#

let me check the method

#

itemmeta#setmaxstacksize

#

@proper cosmos

proper cosmos
#

Yeah, but I mean changing it globally for Material.POTION

#

not certain ItemStack

slender elbow
#

no

#

you'd have to check for every potion itemstack and run that method

trim lake
# sullen canyon it follows the builder pattern to make diff pizzas

Im trying to get it. So there will be Food interface. Than the Pizzaabstract class with will implements food interface that will be extended with HawaiPizza class (yes ananas belong on pizza lol)? I would make pizza abstract because it will have some eat method as every other pizza. I guess I get it if yes.

#

anyway thanks guys thats helped me.

trim lake
#

yeah.. that what I want to prevent as well

inner mulch
#

I dont think his idea is overabstracted

#

Its perfectly fine

icy beacon
inner mulch
#

Thats ocp

eternal oxide
#

the pizza abstraction would be pointless in that instance

slender elbow
#

"the pizza abstraction" sounds like a research paper a uni student started as a joke but actually published

icy beacon
#

look at this function signature 😍

  private suspend inline fun <reified T> downloadAndParse(
    crossinline downloadCallback: suspend BackendAPI.() -> Response<ResponseBody>,
    crossinline inputCallback: suspend (InputStream, String) -> File
  ): Pair<T, File>? = coroutineScope {
valid burrow
#

i definently understand what this does

icy beacon
#

lol

trim lake
#

Yeah, I think about it as well. Just make List of Topping and Name lol.

icy beacon
# inner mulch Kotlin >:(

look at the usage 😍

suspend fun downloadPack(id: Long): Pair<EnchantmentPack, File>? = downloadAndParse({ api.downloadPack(id) }) { input, name ->
    saveToFile(input, name).await()
  }
#

If this will work first try, I'll be extremely happy

storm crystal
#

is there any showcase of citizens plugin? is it possible to make hostile mobs with it?

#

or would I have to go into NMS to make one?

#

like the ones Hypixel has made

cinder abyss
#

Hello, how can I remove the color of a player in tab when he is in a team with color?

eternal night
#

Team#setColor iirc

cinder abyss
#

but not remove the color from the team for other usages

eternal night
#

uh

#

packets pretty much

cinder abyss
cinder abyss
eternal night
#

Yea 👍

#

player info or update teams would both technically work

mighty gazelle
#

How can I intigrade a MySQL Databank in my plugin?

eternal night
#

spigot already ships with mysql drivers

#

so like, follow any mysql java tutorial and you are good to go

mighty gazelle
#

no a 3 provider

zinc moat
#
package me.dean.aokigens.Listeners.Mines;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;


public class Mines implements Listener {
    @EventHandler
    public void OnMine(BlockBreakEvent b, Player p){
        if (b.getBlock().getType() == Material.DIAMOND_ORE){
            b.setDropItems(false);
            b.getBlock().setType(Material.BEDROCK);
            //wait 5 seconds
            b.getBlock().setType(Material.DIAMOND_ORE);
        }
    }
}

how do i wait ... seconds

stoic parrot
#

Bukkit's scheduler i think

zinc moat
#

yeah i know but it wouldnt work here right?

#

since i need to wait in the middle of the code

eternal oxide
#

Thats not how events work

zinc moat
#

wym?

eternal oxide
#

public void OnMine(BlockBreakEvent b, Player p)

#

not valid

zinc moat
#

huh?

#

how

#

ohh

#

Player p

#

but how do i get the player then

eternal oxide
#

from the event

zinc moat
#

yeah

#
public class Mines implements Listener {
    @EventHandler
    public void OnMine(BlockBreakEvent b) throws InterruptedException {
        Player player = b.getPlayer();
        if (b.getBlock().getType() == Material.DIAMOND_ORE){
            b.setDropItems(false);
            b.getBlock().setType(Material.BEDROCK);
            TimeUnit.SECONDS.sleep(5);
            b.getBlock().setType(Material.DIAMOND_ORE);
        }
    }
}

help?

chrome beacon
#

That error does not match the code

#

Recompile your jar

zinc moat
#

i did

eternal oxide
#

sleep will break the server

zinc moat
#

then how else am i suppost to wait?

eternal oxide
#

you don't

zinc moat
#

but i need to

chrome beacon
#

no

eternal oxide
#

you schedule a task for 5 seconds time

chrome beacon
#

If you want a delay schedule it later

#

?scheduling

undone axleBOT
zinc moat
#

still dont get it

eternal oxide
#

then read the linked wiki

zinc moat
#

i am

#

But in skript you can wait with no problem how do i recreate that in java?

eternal oxide
#

scheduling

#

you can NOT wait/sleep the main thread

zinc moat
#

I know but i dont know how to schedual

eternal oxide
#

read it and learn. All you need is in that wiki post

reef brook
#

Has there been any announcement or changelog about Spigot 1.20.4 (or Bukkit or Minecraft, I don't know) dropping JDK 8 support?
I know that 1.20.4 is now compiled in JDK 17 ( vs. JDK 8 before) but I can't find any information on this

blazing ocean
#

use 17

eternal oxide
#

past that you need 21+

pseudo hazel
#

I think jdk 8 was dropped singe mc 1.16 or smth

reef brook
eternal oxide
#

no its not

reef brook
reef brook
eternal oxide
#

17 has been a requirement since 1.17

pseudo hazel
#

well my point was that if such an announcement were to be made

reef brook
pseudo hazel
#

it would be for 1.16/1.17 instead

eternal oxide
#

its impossible to build spigot 1.20.3 (using Buildtools) with java 8

pseudo hazel
#

since thats when mojang decided to drop support for it

reef brook
eternal oxide
#

as a dependency is Not building it

reef brook
young knoll
#

The api itself was moved to java 17

#

It was 8 before

reef brook
young knoll
#

Not that I know of?

pseudo hazel
reef brook
young knoll
#

Because I saw the commit that changed it

reef brook
young knoll
#

yes

storm crystal
#

okay hash maps are BROKEN

eternal night
#

facts

storm crystal
#

the ability to just add an entry to your data access object without need of flipping upside down half of your project is really awesome

#

I use it to list statistics of my weapons

buoyant jasper
#

how to add lore to item to add second line

eternal night
#

idk x

#

this seems active, last commit a week ago

quaint mantle
crystal knot
#

Hey
I was wondering how can I save the inventory of a player inside an entity without saving the inventory in a file

quaint mantle
#

There’s no single mob that can store player’s inventory iirc

#

You can do with chests

chrome beacon
#

?morepdc

undone axleBOT
chrome beacon
#

can also be of use

crystal knot
#

thanks !!

nova quail
#

Hello! I need to remove player's money from Vault when he writes /auctionbet amount. When I write /auctionbet and any amount it just sends "usage" don't understand why.
https://paste.md-5.net/yebanewaza.java Can someone help please

chrome beacon
#

Is the command /auctionbet auctionbet

#

because that's what you've set it to in the code

nova quail
#

thanks

alpine swan
#

does persistentdatacontainer on items use NBT or what?
like if a client tries to combine two itemstacks which are same everything except a different persistentdatacontainer tag what happens? will it be sent to the client as nbt so not merge?

eternal night
#

It is sent to the client yea

pseudo hazel
#

pdc is nbt

eternal night
#

which is why saving secret things in there is not a vibe

shadow night
#

Yee, you can view PDC with a nbt viewer, I have a screenshot a friend sent me somewhere

alpine swan
#

is it just a wrapper over nbt?

eternal night
#

Eh, its implemented in NBT.

storm crystal
#

I cant create config on player join because of statistics for loop, how can I make it so that it creates "statistics:" that is empty and not throw null pointer exception?

eternal night
#

Don't use it to edit NBT

shadow night
#

This is a thing my friend sent me once, most of it is not pdc, but "PublicBukkitValues" is pdc iirc

eternal night
#

it is

tardy delta
#

wait explain me this, are you doing a cache lookup, and if its found, youre doing the lookup again?

pseudo hazel
#

I created a java project with maven and a single class with a public static method and I wanna use that in my plugin

#

but I cant seem to get it right

eternal night
inner mulch
#

Press install

pseudo hazel
#

the dependency looks okay and I get no errors from pom

#

I did

eternal night
#

Are you shading?

pseudo hazel
#

idk

#

no

#

but its not even seeing the class I made

eternal night
#

Oh, like in IDE?

pseudo hazel
#

I thought that would happen regardless of if I shade it

#

yeah

inner mulch
pseudo hazel
#

where is teh button for that again? xD

inner mulch
#

Im not sure top left the 3 bars and somewhere there

pseudo hazel
#

thats where everything is..

nova quail
#

How can I do get player's balance in Vault? Cause when Player has balance 10 and try to bet 20 dollars they remove and player has -10 balance.

        EconomyResponse balance = Plugin.getInstance().economy.getBalance(Player p);
        if (balance.balance <= 0 && balance.balance <= amount) {

            EconomyResponse response = Plugin.getInstance().economy.withdrawPlayer(player, amount);
            if (response.transactionSuccess()) {
                player.sendMessage("Success: " + amount);
            } else {
                player.sendMessage("Failed to place bet. Insufficient funds.");
            }
        }
            return true;
    }
}
worthy yarrow
#

Try that first

#

then do the caches

chrome beacon
storm crystal
#

how can I add an empty object in yaml

nova quail
storm crystal
#

so that I'd have statistics:

tardy delta
#

please dont use a singleton for your plugin instance

#

im thinking all people follow the same stupid tutorial

worthy yarrow
storm crystal
#

I literally

#

spent

#

like

#

5 hours

#

switching to yaml

tardy delta
#

why

worthy yarrow
#

Yeah why

storm crystal
#

because db is apparently "unnecessary"

tardy delta
#

yaml is trash

worthy yarrow
#

What all are you trying to store?

#

What do these statistics bubble down to?

storm crystal
#

nothing at this point

#

amazing

pseudo hazel
worthy yarrow
lilac dagger
#

sqlite sounds like a better place to store statistics

worthy yarrow
#

Flat file could work for this but a db would just offer you so much more

#

Idk who told you to just use flat files for this but they were kinda wrong or just not thinking in expandability / maintainability

storm crystal
#

this is trash, that is trash

#

everything is trash at this rate

#

so why even bother doing this

pliant topaz
# pseudo hazel both things didnt work

try the 'Repair IDE' button and basically do everything it suggests including the IDE restarts etc, normally fixes most of the issues if 'Invalidate Caches' doesn't work

worthy yarrow
#

...

#

Well now that's a reaction I haven't seen before

worthy yarrow
#

Oops sorry to ping ya

pliant topaz
#

haha np

pliant topaz
worthy yarrow
pliant topaz
#

idfk, it just all broke somehow, my code suddenly had over 1k+ errors inside each class like tf 😂

worthy yarrow
#

Ahaha so it literally just poofed all the lib depends?

pliant topaz
#

excactly

#

just went 'Avada Kedavra' on my libs lmfao

worthy yarrow
#

Aw thats messed up man

#

I think that's the issue with intelliJ is that it's too good, meaning there are just too many modules / features for it to run 100% all of the time

storm crystal
# worthy yarrow Well now that's a reaction I haven't seen before

I want a <String, Integer> hashmap statistics that is stored in yaml in that sequence:

statistics:
  one: 1
  two: 2
  three: 3

, but I can't seem to initialize it when the player is joining for the first time, because fetching newly made object from yaml file returns nullpointerexception, it can't create statistics: object, because it gets every element from it, and since it's not created, it has null

#

I temporarily fixed it by adding check variable into it that is set to 1 for the sake of filling it and creating the statistics object

pliant topaz
worthy yarrow
worthy yarrow
#

Ie: player joins -> add elements -> save file -> access file

worthy yarrow
storm crystal
#

setting it to 0

#

who would've thought

worthy yarrow
#

uh

kind hatch
#

Your doing it wrong somehow

worthy yarrow
#

^

eternal night
#

I mean, yea statistics isn't a configuration section

worthy yarrow
#

0 isn't null

eternal night
#

its a scalar value

#

you can do get instead

#

and instanceOf it

worthy yarrow
#

And I know you don't want to hear it buttttttt you could go back to db

eternal night
#

nah

#

stick to yaml

worthy yarrow
#

... why?

storm crystal
lilac dagger
#

mojang uses flat files

eternal night
#

there is 0 gain with moving to yaml here for them

lilac dagger
#

it isn't that big of a deal

storm crystal
#

I am not going to postpone project for 2932934923th time because someone tells me to change data saving way

#

"because X is trash"

eternal night
#

Yea

#

just use get instead of getconfigurationsection

#

and then instanceOf the object you get

kind hatch
eternal night
#

literally because of the above

eternal night
#

getConfigurationSection will yield null if you call it for a non section

worthy yarrow
eternal night
#

for all I care you can also just null check it

pseudo hazel
#

I just think maybe there is something wrong with the setup

storm crystal
eternal night
#

well you just check if that is null

#

if it is null, the player does not have any statistics

storm crystal
#

I really dont know how to make statistics: appear

#

that doesnt really do much

kind hatch
#

Try #createSection()

eternal night
#

oh, just set it to an empty hashmap I think?

storm crystal
#

okay, this works

quaint mantle
#

Hello, I am having trouble extending an entity to make a custom mob, at the moment I am trying to do

public class DesertZombie extends Husk {
however it wants me to implement like 300 methods, and doesn't have a super Cannot resolve method 'super' in 'DesertZombie'

all the tutorials I've seen use things such as EntityZombieHusk but I don't have that class somehow? can I get some support on this I can't find any good docs

inner mulch
#

Isnt Husk an interface

quaint mantle
#

import org.bukkit.entity.Husk;

#

it is

inner mulch
#

Okay so, spigot is not for making mods

quaint mantle
#

I want a mob with a custom name and a healthbar

#

and I want it to be its own class

inner mulch
#

You need to use fabric or forge or whatever the tutorial guy is using

lilac dagger
pseudo hazel
#

well you cant just implement mobs like this

#

you need some kinda wrapper

quaint mantle
lilac dagger
#

or add values to the section

inner mulch
#

No they arent

inner mulch
quaint mantle
inner mulch
#

Yes and this tutorial is not showing how to make an entity

worthy yarrow
#

Good thing we're only at 1.20.6 now

grizzled mountain
#

Say I wanna transmit data from a plugin to the world using redstone pulses. What's a reasonably efficient way to power and unpower redstone? Would switching a block's material between wire and redstone blocks quickly using Block.setType be horribly slow?

quaint mantle
worthy yarrow
#

There are plenty of changes most of which you don't have to really worry about until 1.20.5

inner mulch
#

The changes dont matter, the guy is using nms classes in the tutorial

worthy yarrow
#

Yeah uh friendly advice: learn spiogt api before delving into nms 💀

inner mulch
#

He wants pathfinding

#

So he needs to

worthy yarrow
#

Hmm

#

Welp I'm just gonna say sorry about the headaches in advance

storm crystal
#

can I apply several pdcs of same name on the item?

#

but different values?

eternal night
#

no

#

how would you get exactly one back

slender elbow
#

you ask nicely of course

worthy yarrow
#

What if you did a map<String, PDC> for each item or wtv then all your containers are cached in that map?

river oracle
#

A list allows you to store multiple things

worthy yarrow
river oracle
#

Lists don't have keys

#

Boom

worthy yarrow
#

Oh

#

I mean

#

Yeah I forgot he said they should be the same key or wtv

frosty geyser
#

Hi, I was wondering if you can silence a dispatchCommand (for example Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "give %player% minecraft:dirt 1");) to not send a message to console of CONSOLE issued server command: /give %player% minecraft:dirt 1 on 1.20.4

young knoll
#

Why are you making console run commands

frosty geyser
#

allowing configurable rewards in config and I don't want their console to spam constantly

#

and to allow the rewards to be whatever (even items from other plugins) having commands to execute it to give the user the items would be the best method for it all from what I can think of.

worthy yarrow
#

Hmmm, new project or fix the performance issues with seasons?

pseudo hazel
#

like its literally a project with a pom file and a class with a single static method in its thats just public static String test() { return "hey";}

#

but yet my intellij doesnt find it, even though it has found the repo and if I open the jar with 7zip I can see the method in the jar file

#

omg

#

im stupid

#

I forgot to add a package with teh group id into the project

#

so I guess it didnt count

#

well its fixed now xD

#

another question, how do I put it on github, because this is now in a completely different place, but I want people potentially working on the plugin to not run into build issues, how do I make sure that the dependency can be used even when downloading from github

storm crystal
#

is there a better way to check if Namedspacedkey is null?

#

I dont feel like its legit, although it works

sand spire
#

?paste

undone axleBOT
storm crystal
#
try {
                weaponDamage = Integer.parseInt(ItemPDC.getPDC(physicalElement + " Damage", weapon).toLowerCase().replace(" ", "_"));
            } catch (IllegalArgumentException e) {
                weaponDamage = 0;
            }```
glass mauve
#

you shouldnt use try catch in this case probably

storm crystal
#

great

#

I know it

#

but what else do I use

glass mauve
#

depends, where is that IllegalArgumentException coming from

#

my guess is that you use PersistentDataContainer, it has either the get method which can return nullable/throw IllegalArgumentException
so instead maybe use PersistentDataContainer#getOrDefault

#

cant provide more help without more context

river oracle
#

Try catch likely comes from the int parse

glass mauve
#

is there a better way to check if Namedspacedkey is null?

river oracle
#

Not sure why we're not just storing an int tho

glass mauve
#

also parseInt doesnt throw IllegalArgumentException

river oracle
glass mauve
#

instead it throws NumberFormatException

river oracle
#

Kek

brittle geyser
#

It is real to copy text to clipboard when player clicks a gui?

river oracle
#

Unless you use a book

#

Then you can have the player click the text inside of if

brittle geyser
#

okay thanks

tardy delta
#

why not store it as an int

river oracle
#

Literally

storm crystal
#

there is osmething wrong

#

when I call ItemPDC method it returns null when in one class

#

but returns normal value when in another class

#

I like quadruple checked and PDCs are applied correctly

tender shard
#

show stacktrace, show code

storm crystal
#

it just returns null all the time

eternal night
#

check the item in game with /data get entity @s SelectedItem while holding it

#

for a quick sanity check if the PDC applied

storm crystal
#

where is it

eternal night
#

If you don't see PublicBukkitValues in that output, the pdc did not apply

storm crystal
#

can I apply several pdcs in one item

eternal night
#

the minecraft namespace

#

well, you use different namespaced keys

#

or a list

storm crystal
#

what do you mean different namespaced keys

eternal night
#

Well you set a value with a namespaced key for a key

tender shard
#

well, you use "myplugin:firstkey" -> first value
and "myplugin:secondkey" -> second value

eternal night
#

but I mean, depends on what you need/want

tender shard
#

PDC is basically a map

storm crystal
#

how is that not different keys

tender shard
#

that are different keys but why do you use the minecraft namespace

eternal night
#

I mean, depends on what you pass for "keyName"

#

presumably because they only pass "weapon"

#

it defaults to the minecraft namespace

storm crystal
#

thats the keyname

tender shard
#

they only sent the first line but it looks like the next line continues PDC data

storm crystal
tender shard
#

oh yeah that's only one key

storm crystal
#

why

tender shard
#

because as lynx said, entry.getKey() probably is always "minecraft:weapon"

storm crystal
#

it

#

is

#

not

#

two different keys

glass mauve
#

you sure your code really works though

pseudo hazel
#

they were referring to the minecraft: bit, which can be changed if you used a string format like the namespace i.e. myplugin:weapon

#

or if you create a key using your plugin instance

kind hatch
pseudo hazel
#

yeah, its fool proof pretty much

storm crystal
#

I hate this

pseudo hazel
#

im sure you can figure it out

storm crystal
#

how merciful of you

pseudo hazel
#

i mean, can you recap what youre stuck on

storm crystal
#

how to do several pdcs

glass mauve
storm crystal
tender shard
# storm crystal

show your whole code of creating the item and how you're giving it to the player

glass mauve
#

well one message isnt proof of anything, maybe look at the other 10

storm crystal
#

you got the relevant part

glass mauve
#

not really

storm crystal
#

rest is just item meta flavor

pseudo hazel
#

okay from the part I am seeing it should work

tender shard
#

if that would be the relevant part, then why does it not work lol

#

answer: because the relevant part must be somewhere in the code you haven't sent

storm crystal
#

you literally said what doesnt work

#

something about namespaced key

#

but you decide to gatekeep it

#

you know the issue

tardy delta
#

just use different keys

storm crystal
#

look

#

for a second

#

what do you see under keyName

#

since when they are equal

#

to eachother

#

tell me

glass mauve
#

you never shared the ItemPDC implementation

storm crystal
#

"never shared"

storm crystal
#

happy?

glass mauve
#

ok thats mb, I didnt see it

storm crystal
#

I only get the last pdc tag that I put

tender shard
#

@storm crystal As I have already said, all the code you sent looks fine to me, except that you're using the minecraft namespace (which should still work).

But as you refuse to send more code, nobody can help you.

And if you repeat "I sent all the relevant code", then I now ask you: well then why doesn't it work?

storm crystal
#
    private final WeaponManager weaponManager;
    public WeaponCommandTest(WeaponManager weaponManager) {
        this.weaponManager = weaponManager;
    }
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
        if (!(commandSender instanceof Player player)) {
            return true;
        }
        if (args.length != 1) {
            player.sendMessage(ChatColor.GRAY + "Usage: " + ChatColor.RED + "/weaponspawn <weaponID>");
            return true;
        }
        WeaponDAO weaponData = weaponManager.retrieveFromDatabase(args[0]);
        if (weaponData == null) {
            player.sendMessage(ChatColor.GRAY + "Weapon with an id " + ChatColor.RED + args[0] + ChatColor.GRAY + " does not exist.");
            return true;
#
        }
        List<String> lore = new ArrayList<>();
        ItemStack weapon = new ItemStack(Material.matchMaterial(weaponData.getType()));
        ItemMeta meta = weapon.getItemMeta();
        meta.setDisplayName(weaponData.getName());
        ChatColor color;
        String value = "";
        for (Map.Entry<String, Integer> entry : weaponData.getStatistics().entrySet()) {
            if (entry.getValue() == 0) {
                continue;
            }
            color = switch (entry.getKey().split(" ")[0]) {
                case "Necrosis" -> ChatColor.DARK_GRAY;
                case "Sanity" -> ChatColor.WHITE;
                case "Otherworldly" -> ChatColor.DARK_PURPLE;
                case "Fire" -> ChatColor.GOLD;
                case "Crit" -> ChatColor.YELLOW;
                default -> ChatColor.RED;
            };
            List<String> keywords = Arrays.asList("Crit", "Multiplier", "Penetration");
            for (String keyword : keywords) {
                if (entry.getKey().contains(keyword)) {
                    value = entry.getValue().toString()  + "%";
                    break;
                } else {
                    value = entry.getValue().toString();
                }
            }
            lore.add(color + entry.getKey() + ChatColor.GRAY + ": +" + value);
            ItemPDC.setPDC((entry.getKey().toLowerCase().replace(" ", "_")), entry.getValue().toString(), weapon);
        }
        lore.add("");
        for (String descriptionElement : weaponData.getDescription()) {
            lore.add(ChatColor.DARK_AQUA + ChatColor.ITALIC.toString() + descriptionElement);
#
        lore.add("");
        color = switch (weaponData.getRarity()) {
            case "rare" -> ChatColor.BLUE;
            case "epic" -> ChatColor.DARK_PURPLE;
            case "legendary" -> ChatColor.GOLD;
            default -> ChatColor.WHITE;
        };
        lore.add(color.toString() + ChatColor.BOLD + weaponData.getRarity().toUpperCase() + " SWORD");
        meta.setLore(lore);
        weapon.setItemMeta(meta);
        ItemPDC.setPDC("weapon", args[0], weapon);
        player.getInventory().addItem(weapon);
        player.sendMessage(ChatColor.GRAY + "Weapon " + weaponData.getName() + ChatColor.GRAY + " has been added to your inventory.");
        return true;
    }
}```
tender shard
storm crystal
#

in human words?

glass mauve
#

bro ngl, learn java first

eternal night
#

getItemMeta yields you a snapshot.

#

it includes the ENTIRE state of the item's data

river oracle
#

Hi lynx

tender shard
#

quick fix: make your setPDC method take in an ItemMeta instead of ItemStack

eternal night
#

^

river oracle
#

Still helping this guy?

eternal night
#

I believe

river oracle
#

Interesting

storm crystal
#

so fucking stupid

river oracle
#

What is stupid

river oracle
#

I actually think ItemMeta is pretty nice API

glass mauve
#

lmao

river oracle
tender shard
#

You keep around different copies of ItemMeta. Then you add the PDC to another Meta copy, then set the item's meta back to the original copy.

That's why you only get one key.

As I said, the easiest fix, if you don't understand what this means, is to make setPDC take in an itemMeta. This will

  1. fix your problem
  2. be more performant as no copies of the meta have to be created all the time
glass mauve
#

bro asking for help, getting help, ignoring help

tender shard
river oracle
storm crystal
glass mauve
#

yeah whatever lmao

storm crystal
#

so whats your point

river oracle
#

🗣️

tender shard
#

you probably fixed it by moving around your setPDC calls, which is basically what I told you the problem is - keeping around different copies of the itemmeta

storm crystal
#

now tell me why this doesnt work

tender shard
#

no

river oracle
#

I fixed it. Why doesn't it work lmfao

glass mauve