#help-development

1 messages · Page 1010 of 1

eternal oxide
#

But its way simpler to use teh API if you can over packets

eager turtle
#

okay i think i solved my issue. for whatever reason canceling EntityExplodeEvent does the mobs from taking damage

#

so i just set a dumby NPC i have on my server to be the cause of the explosion

#

then in EntityDamageByEntityEvent i check if its that entity and cancel

eternal oxide
#

you could just set a flag on teh exploding entity itself

eager turtle
#

problem is, that NPC might despawn if i go to a diff world

eternal oxide
#

?PDC

eager turtle
eternal oxide
#

wake up CafeBabe

pseudo hazel
#

?pdc

blazing ocean
pseudo hazel
#

case sensitive

eternal oxide
#

lol case sensitive

eager turtle
#

for most cases that would work, but i have a very specific case where the player themself causes the explosion. they jump in the air and when they land it creates an explosion

eternal oxide
#

doesn;t matter

#

the explosion you spawn IS an entity

#

you set a flag on IT not on the cause

eager turtle
#

yes but i need to set the source entity

pseudo hazel
#

so

#

that entity will have a uuid

eternal oxide
#

for blame yes, but not for the damage logic you wan tto apply

spice burrow
#

hmmm this works sort of. it's the effect i was looking for but unfortunately like you said at range it becomes inaccurate because the players location stays static

i think i may essentially do this exact same thing just using packets and adding the item manually

eager turtle
pseudo hazel
#

well yes, but if its not loaded, how does it take damage

#

or am i misunderstanding

#

but it shouldnt really matter

#

all info you need can be saved in the explosion

#

then it doesnt matter who done it

eternal oxide
#

teh getEntity in teh EntityExplodeEvent will always return the exploding Entity

#

set a pdc flag on that when you create it

#

detect it in teh explode event

#

the source you set will be available in the damage event

eager turtle
#

heres the whole thing. a trident can be thrown and cause an explosion. a throwing tnt can be thrown and cause an explosion using createExplosion and passing in the trident and tnt entity as the damage sources. I have metadata attached to those two entities so i can ignore the damage in EntityDamageByEntityEvent and apply my own damage. I do this because these weapons can be upgraded and I want to increase or decrease damage. The problem is the player themself can cause the explosion by jumping in the air and landing. So if i set the player as the damage source entity then i run into issues. Because I can check if the damaging cause is an explosion then check if its the trident or tnt with my meta data were the damaging entities and cancel. But if I do damage cause Explosion and get the damager and its a player, well i dont think i can cancel that because a player setting off TNT normally in survival would be linked to the damager and i dont want to also cancel that. but maybe the damager would be the TNT that was set off

eager turtle
#

at least better than using my dumby npc

#

now that i think about it more, does a player setting off a standard TNT in survival and it killing someone even count as their kill? should it

eternal oxide
#

normally no

eager turtle
#

i guess i gotta test it

#

if they throw a fireball they wouldnt normally be the damaging entity either i assume

#

i guess that could maybe work

eternal oxide
#

Normally no, as thats not vanilla mechanics

#

you can via teh API though by setting the source

eager turtle
#

ah okay, well id probably just use metadata on the fireball to circumvent that anyways

eternal oxide
#

Note setting teh source is setting the damage source not the explosion source

eager turtle
#

so as it stands i will do damageCause = explosion, then check if its my trident, tnt, or player. Then cancel

eternal oxide
#

with thrown fireballs, it's usually a launched projection so it has a shooter

eager turtle
#

damn yeah

#

but a projectile right? or still explosion i guess if its not a direct hit

#

regardless, in EntityDamageByEntityEvent the damager() would still just be the fireball

#

it should never be the player if its an explosion

eternal oxide
#

with launch you use a disguised projectile, then cause the explosion on hit

eager turtle
#

as far as i understand

#

gonna try this

#

wow that sent terribly

chrome beacon
#

If the trident is what explodes then it would make more sense to put that as the entity

#

also it's preferable that you send text as text

#

instead of in an image

#

?paste

undone axleBOT
dusty nexus
#

Hi, how can I change the size of the armorstand (the hitbox)

chrome beacon
#

For what purpose are you trying to change it

eager turtle
#

but the player themself can do a special move where they jump in the air and land on ground causing an explosion

dusty nexus
eager turtle
#

so if i pass them in ill be checking for the player anyways with that part. so i just set the player as the damager for all types

eternal oxide
dusty nexus
#

Just the hitbox

chrome beacon
eternal oxide
#

change how? Bigger, smaller?

dusty nexus
#

smaller

eager turtle
#

as far as im concerned there will never be a case where theres an explosion and the player is the direct damager entity. except for where i explicity say to in my code

#

so i cancel that

#

and it works great now

chrome beacon
dusty nexus
#

Without using marker and small

eternal oxide
#

then no

chrome beacon
#

^^ can't help you further without any information

pliant topaz
dusty nexus
#

To place the armorstand above player head exactly

eternal oxide
#

You are still not properly explaining. What is your end goal?

chrome beacon
#

so xy problem

pliant topaz
#

?xy

undone axleBOT
eternal oxide
#

We know an AS as a passenger will be offset. We also know about collisions for clicking. So stop beating around the bush and tell us EXACTLY what you want to achieve

#

We might be able to help and by being precise we might avoid 10 hours of back and forth with questions

valid basin
#

Why does it take so long for a premium resource to be verified?

#

And how can I speed up the process? Can I send src to some staff member?

chrome beacon
#

Verification is done by volunteers in their free time

#

all you can do is have patience

valid basin
#

I wanna become volunteer

#

How do I become? I'm an OG on spigot since 2014

#

lmk

echo basalt
#

Well

#

I don't think you'll make it with a windows 11 activation script in your git

fair rock
#

Bro wants to become a volunteer just for speed up his own resource 💀 Thats not really what that word means xd

grim hound
eager turtle
eager turtle
#

If you really wanted to use an armor stand without a hitbox, then your answer is nms (sending packets)

grim hound
#

You'd need to override the internal hitbox (probably each time it's refreshed)

eager turtle
#

I think using the scoreboard you can at least get one under

grim hound
#

And send refresh hitbox packets (dunno what that is)

dusty nexus
#

Thats why I'm trying this way

eager turtle
#

Yeah i think you gotta go with nms, unless you can attach a TextDisplay to a player

#

But i dont think those are entities they cant be mounted you would have to update the location basically on playermovement which can be slow to do for every player

#

TextDisplays are 1.20.6

#

Havent used them yet they might be easily attached to an entity dunno

dusty nexus
#

The addPassenger is smooth asf and I need a same result to place the armorstand above the player

eager turtle
#

And now that i think about it, with nms youd still have to teleport the armor stand to the players head on movement probably

pseudo hazel
#

arent text displays 1.19.4 or whatever?

eager turtle
#

I doubt theres an easy way to use addPassenger but there might be

#

I thought they were brand new ive been out of the loop for a year

eternal oxide
#

with current version syou can use a TextDisplay as a passenger

blazing ocean
eager turtle
#

Ayo there you go

dusty nexus
eternal oxide
#

you can apply translations to align it however you want and it has no ditbox

blazing ocean
#

easy on the server too

pseudo hazel
#

what version are you coding for

eager turtle
#

Bruh

eager turtle
#

Use text display lol

eternal oxide
#

nms AS has teh same issues of collision boxes or stuttering if its not a passenger

blazing ocean
eager turtle
#

Yeah ur good alot of people typing lol

eternal oxide
#

TextDisplay is the way to go

valid basin
blazing ocean
eager turtle
#

Exactly why no textdisplay lol

blazing ocean
#

they're my fav entity

eager turtle
#

If you can add it as passenger thats clutch

#

0 hitbox

dusty nexus
#

oh

blazing ocean
fair rock
dusty nexus
#

lm see

eager turtle
#

I gotta try them still havent lol

#

Im using nms armor stands still

blazing ocean
#

you might have issues with teleportation, not sure how spigot handles that, paper doesn't directly allow you to without a flag that's all i know

eager turtle
#

True if its a passenger. But he said he wants to use passenger anyways

#

So hes prob accounting for that or should at least

blazing ocean
#

yea

#

spigot doesn't have that flag but it should tp i think

blazing ocean
eager turtle
#

What about on death?

#

Does it stay as passenger

blazing ocean
blazing ocean
eager turtle
#

Yeah figured

#

Honestly worth it cause teleporting on player movement would be slowww if you get alot of player online

blazing ocean
#

wouldn't necessarily be slow but looks shit

#

as it's slightly delayed

eager turtle
#

So @dusty nexus think of these edge cases when you do passenger

#

Death, teleport, leave, join, etc

#

All gonna need to be listened for

eager turtle
dusty nexus
#

ye

blazing ocean
#

the nice thing is that you can just do Player#hideEntity

#

oh also gamemode switching!!

#

important

eager turtle
#

My server never got big enough to notice a delay i just read to never use playermovement if theres another way

#

I have one check for it and its to raise the void height

#

Actually wait

#

I changed it to a runnable

blazing ocean
eager turtle
#

No no no

#

Im talking about something else

blazing ocean
#

ah

eager turtle
#

Every tick i check their Z value and if its like below 40 i kill them

blazing ocean
eager turtle
#

Cause i made a skylands map and dont want to put the islands close to the void and have it look all shitty and dark

#

Yeah i was just saying i avoid playermovent at all costs if theres a better way

#

And right now text display as passenger is the way

blazing ocean
eager turtle
#

I mean if it works it works

blazing ocean
#

as it doesn't check every tick

eager turtle
#

Idk about that haha. Could be

#

Its not every tick i do every 10 or so

blazing ocean
eager turtle
#

Probably more actually like 20

blazing ocean
#

as it's 5x/second if not moving

eager turtle
#

Death barrier doesnt need to be super fast

#

Yeah and at most how many?

blazing ocean
eager turtle
#

Yeah

blazing ocean
#

only if the player is moving

eager turtle
#

It could maybe send an event multiple times per tick

#

If they are sporadically moving

eager turtle
#

At least for my case its not necessary

#

Ah okay i dont really know what constitutes as an event for that

pliant topaz
#

This might not be an ideal solution for my problem (certainly a bad solution xd) but it's been the only thing preventing me from finishing for around a month now, and it's really unmotivating i gotta say, so I've come up with another solution.
As the data needed to be stored isn't much, it's possible to store it in localizedName. Ik this is a bad thing to do, but as I already have ways of identifying items which would use that, I could grab the real localizedName, as I would seperate the data with another character I won't use otherwise. The data could then be split by, for example double underscores so I get all seperate pieces of data.
The actual problem I had with PD I'll leave for future me to solve, maybe when I'm more experienced with PDCs as this was the first real time working with them

blazing ocean
eager turtle
#

Huh insteresting never seen this. And now that i think about it more itd be impossible to send an event multiple times per tick that doesnt even make sense logically. Im tired lol

#

Well basically i use runnable cause i only need to check every 1-2 seconds. For something more involved like a second nametage obviously playermovent is the best itll get

#

But of course we got text displays now

#

So add that thing as a passenger and go wild

eager turtle
#

Often the solution you are already implementing could be flawed and there might be a better way to do it overall

#

So if you just give a general statement with some examples of edgecases im sure we can come up with a solution here

pliant topaz
#

So I basically have 'Tool' items which can have up to 3 upgrades and theoretically unlimited abilities. Upgrades and abilities are stored in enums, which hold all the data (identifying name). These names get converted to integers acccording to what value I gave them, and from that I store it in an integer array for storing in PDC

#

My end goal is that this works flawlessly and would work for every item

#

But somehow even when I overwrite this data, It still shows the already modified one, which is from a different item

#

lmk if u need any other information (I'll be away now bc RL's calling lmao)

#

important code pieces are found in replies from the messages if u go through the replys

eager turtle
#

Heres an idea for what I think you are trying to do. You want special items on your server? Create a java class called Weapon and use that to store an item and any special attributes about it such as material, damage amount, name, methods that do special abilities, upgrade values in arrays, etc. Then create an Enum class which will store the WeaponType, like THORS_HAMMER for example. Add this enum as another field inside of your Weapon class. Now when you want to give a player a special item, you simply create an insance of your Weapon class (which will create the item) and then give that item to the player. When you create the actual item inside of the Weapon class, attach a PDC to it that stores the WeaponType Enum you made earlier. Then whenever a player uses that item such as for a BlockBreakEvent, you can do item=e.getItemInMainHand() or whatever it is and then simply retrieve the PDC from that item. Then you get the WeaponType from the PDC you stored earlier. And now you know the exact Weapon they are using. Keep in mind you will only know the type at this point. But if you are being a smart programmer and storing your Weapon instance you made earlier to give to the player, you can simply say okay I know hes using THORS_HAMMER so im going to go retrive that Weapon instance I made earlier so I can get values from it I need.

#

I just read your last messages what i wrote should apply

#

You are going at it like a caveman, you need to use a wrapper like i suggested. The Weapon class will be your wrapper

#

If you need any help with direct implementation @ me

hollow vessel
#

is it possible to get chunk id? if not would it be very burdensome for the server to loop all chunks and put to the hashmap id per chunk when plugin start?

eager turtle
hollow vessel
#

why I need chunk id?

eternal oxide
#

Why all of it?

hollow vessel
#

i have an idea to make somethink like postal system, postal would be chunks, then i will get nearest chunk (postal) to the player and shows chunk id

hollow vessel
eternal oxide
#

I've no clue what a "postal system" is sorry

drowsy helm
#

Yeah just stringify the position

#

A chubk is a 2d map, it cant be flatmapped to one integer because it’s effectively infinite

pliant topaz
hollow vessel
#

okay thanks

#

so use cordinates as chunk id?

drowsy helm
#

Yes

hollow vessel
#

okay thanks

drowsy helm
#

X:Z is enough

eager turtle
pliant topaz
#

Ik haha

eager turtle
#

There are alot of specifics I left out. Im not sure how familiar you are with java or object oriented programming in general

fair rock
#

Refractoring code is necessary sometimes c:

eager turtle
#

But mostly everything in your Weapon class should not be static either

#

From one fellow cat profile pic to another you got this

acoustic pendant
#

https://paste.md-5.net/uconekageg.sql

Could someone tell me why am i getting this error? doesn't make sense to me

My line 83 :

        List<String> worlds = data.getConfig().getStringList("created-worlds");
        for (String world : worlds) {
            System.out.println(world);
            Utils.createWorld(world);
        }
        loadGames();```
#

(line 83 is the list)

drowsy helm
#

Whats in Utils.createWorlx

acoustic pendant
#

But i don't think the error is there

#

maybe

fair rock
#

so line 83 is:
List<String> worlds = data.getConfig().getStringList("created-worlds");

#

?

eager turtle
#

That should give you a pretty good jumping off point

fair rock
acoustic pendant
#

but i'm not using it there i believe

#

let me check lol

fair rock
#

Your stacktrace says NexusCore 83 calling a method -> DataFile 42 calling -> DataFile 30

acoustic pendant
#

just here

fair rock
#

so

eternal oxide
#

You tried to access a Yaml file with a Location in a world which is not loaded

acoustic pendant
#

With a location?

#

i don't think so

#

ooh

#

could be

#

wait

acoustic pendant
eternal oxide
#

all objects in a config are deserialized the instant you access the file

acoustic pendant
eternal oxide
#

So if it uses a world thats nto loaded it blows up

acoustic pendant
#

hmm

#

Is there some way to wait until the world is loaded?

orchid trout
#

just load the world

acoustic pendant
#

I'm doing that, but getting the error because it is not loaded

lilac dagger
#

have mvcore and others as dependencies

#

i think i have a list of what people use atm

acoustic pendant
#

I have just read that the server "stops" until world is loaded

orchid trout
acoustic pendant
eternal oxide
#

On Spigot

acoustic pendant
#

I'm on spigot

#

The method that is calling the location from the file is loadGames();

#

It shouldn't be null right?

fair rock
#

I try to explain:
The code:

dataConfig = YamlConfiguration.loadConfiguration(configFile)

or

YamlConfiguration defaultCOnfig = YamlConfiguration.loadConfiguration(...)

Tries to deserialize the location to a world thats not loaded

eternal oxide
#

yes, you access the config before loading the worlds

acoustic pendant
eternal oxide
#

teh INSTANT you TOUCH a config its object are deserialized. Worlds must all be loaded before you touch it

#

keep your world names in a different config

acoustic pendant
#

but it is a string

eternal oxide
#

elsewhere in that config is a serialized Location

acoustic pendant
#

oh yea

#

oooh

fair rock
acoustic pendant
#

i understood now

eternal oxide
#

teh whole file is parsed at once

acoustic pendant
#

okay, didn't know that

#

I'll change it from file i guess

#

thanks

valid basin
#

Is there a way to send data and messages from one server to another without relying on Redis? Since most of my customers don't know how to use redis

#

ik there's pubsub on redis, but looking for easier to setup alternatives for customers

#

So I want to send data from lets say KitPvP to Hub

fair rock
eternal oxide
#

so long as there is a player on each server

#

?pmc

quiet ice
#

the other alternative is that you consider the ips to be static and do a direct plain old TCP/UDP connection which is negotiated using a plugin message or via the configurations - but that isn't ideal compared to more stable solutions and also means that TCP/UDP port needs to be exposed in the first place

ivory sleet
#

yea tho letting customer just setup a very simple server socket thingy isn’t that bad, but yea you run into some issues if you wanna scale on it

drowsy helm
#

Can always use upnp

#

Though they have to ensure their host provides it

young knoll
#

You can use my new java library pigeonlib

#

For sending and receiving data through carrier pigeon

#

* pigeon not included

drowsy helm
young knoll
#

Yes but don’t touch it

young knoll
#

No

unique grove
#

help me pls "Invalid signature for profile public key"

pseudo hazel
#

in regards to what

eternal oxide
unique grove
#

okay thanks

#

My server uses bungecoords, I can join the lobby, but when I enter the survival server I get kicked "Invalid signature for profile public key"

eternal oxide
#

all servers behind bungee shoudl be set to offline but in spigot.yml bungeecord: true

unique grove
#

I've done that, but still can't

eternal oxide
#

You did it on your lobby server but probably not on your survival

unique grove
#

Only a few experienced "Invalid signature for profile public key".

#

my friend can join to survival, but i cant

eternal oxide
#

different clients?

unique grove
#

The same

eternal oxide
#

one pirate, one not?

unique grove
#

mm yes

#

i used premium but my friend use tlauncher

eternal oxide
#

Then you must have bungee set to offline

#

and you are using some auth plugin

#

I can't help with offline though

hushed spindle
#

Why is Trident#getItem() marked as experimental?

sharp heart
#

Hello i'm trying to send an Entity Metadata packet but I'm getting an error when the client is receiving the packet

**My code : **

            final Player player = Bukkit.getPlayer("Hokib");
            if (player == null) return;

            PacketContainer packet = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);

            packet.getIntegers().write(0, player.getEntityId());

            WrappedDataWatcher watcher = new WrappedDataWatcher();

            // Index 0: Byte flags (e.g., is on fire, crouched, etc.)
            byte flags = 0x01; // 0x01 for on fire
            WrappedDataWatcher.WrappedDataWatcherObject object0 = new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
            watcher.setObject(object0, flags);

            // Index 8: Indicates the player is interacting with the item in hand
            byte handFlags = 0x01; // Assuming 0x01 means interacting with the main hand item
            WrappedDataWatcher.WrappedDataWatcherObject object8 = new WrappedDataWatcher.WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Byte.class));
            watcher.setObject(object8, handFlags);

            // Convert the WrappedDataWatcher to a list of watchable objects
            List<WrappedWatchableObject> watchableObjects = new ArrayList<>(watcher.getWatchableObjects());

            // Set the metadata in the packet
            packet.getWatchableCollectionModifier().write(0, watchableObjects);

            // sending...

Error :
Packet encoding of packet ClientboundSetEntityDataPacket (ID: 86) threw (skippable? false)
java.lang.ClassCastException: class net.minecraft.network.syncher.DataWatcher$Item cannot be cast to class net.minecraft.network.syncher.DataWatcher$b (net.minecraft.network.syncher.DataWatcher$Item and net.minecraft.network.syncher.DataWatcher$b are in unnamed module of loader java.net.URLClassLoader @3b764bce)

eternal oxide
hushed spindle
#

in 1.20.5+

#

wasnt the case before that

#

so im wondering what changed and if i can still use it

eternal oxide
#

I'm looking at 1.20.6 javadocs

hushed spindle
#

its under AbstractArrow

eternal oxide
#

I'm guessing you are looking at Paper

hushed spindle
#

which trident implements

#

oh possible, let me check

#

part of the plugin is only enabled if paper is also there

eternal oxide
#

ah I see

hushed spindle
#

nope definitely spigot

eternal oxide
#

nope, its experimental on Spigot too

hushed spindle
#

my guess is that it was previously a trident exclusive method and it instead got moved to abstractarrow so that regular arrows get it too

torn badge
#

Anyone have an idea why Chunk#unload would return false?

eternal oxide
#

You need someone in teh know then, Col, Choco or...

hushed spindle
#

so its experimental for regular arrows but for tridents nothing changed

#

implementation the same

torn badge
#

I'm trying to load chunks, create snapshots of them, then unload them again, but somehow unload() always returns false and they stay loaded

eternal oxide
royal heath
#

Can someone help me as to why the player can still see server broadcast messages and player joins / leaves?

I'm new to protocollib. I tried the player info packet, but it still doesn't work.

drowsy helm
royal heath
#

Because I'm trying to cancel messages from being recieved by a player in a list

#

It's in general, not just from my plugin

drowsy helm
#

Is it printing “packet cancelled”?

royal heath
#

yes

#

it works fine with player messages, but when it comes to anything else like player join / leave messages it does not work

drowsy helm
#

Theres also system chat messages pretty sure it’s another packet

royal heath
#

Ah okay I'll look further, thanks

drowsy helm
#

Keep in mind protocol lib isnt updated for 1.20 so it might be missing some packet types

clear elm
#

how can i disable join, death and quit messages

drowsy helm
clear elm
#

what config

#

and whats the gamerule command

royal heath
#

You can also pick up on the join/leave/death event and use event.set{event}Message("");

drowsy helm
#

This is a simple google search

clear elm
#

if i do the message to an empty string will it work?

royal heath
#

It should, try it

#

Doesn't hurt to try

marsh crest
#

oh what did i do wrong here?

drowsy helm
marsh crest
#

different listener class

#

Oh wait i have an idea

#

i set maxHealth to 1.0 earlier

#

would it break if i set the health to a number higher than the maxHealth?

young knoll
#

Yes

marsh crest
#

ah okay

pseudo hazel
#

seems unrelated to this event

marsh crest
#

ik i was actually trying to fix this bug earlier

shadow night
#

Ij even shows you where it's going wrong lol

marsh crest
#

oh i remember having that earlier but it wasn't an issue

slender elbow
#

getItemInUse doesn't return what you think it returns

#

you're looking for getInventory().getItemInMainHand()

#

Gets the item that the player is using (eating food, drawing back a bow, blocking, etc.)
this is what the item in use is

marsh crest
#

ohhh

#

tyy

orchid hinge
#

so i use this function to give a player a name prefix, how bad of an idea is it to just call it everytime that prefix changes? ```java
public static void setNametags(Player player) { // create scoreboard & teams
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());

for (Map.Entry<String, Rank> entry : Ranks.getInstance().getRanks().entrySet()) {
Rank rank = entry.getValue();

Team team = player.getScoreboard().registerNewTeam(rank.getName());
team.setPrefix(ChatColor.translateAlternateColorCodes('&', rank.getPrefix()));

}

}

royal heath
#

So you refresh the scoreboard when the prefix changes?

orchid hinge
#

no i was wondering if i could just call the function again when it changes?

royal heath
#

it looks like it just makes a new scoreboard that could be bad

orchid hinge
#

so extra function for refreshing?

marsh crest
#

oh wait i have idea

#

lemme test something first

royal heath
#

I'm not 100% on scoreboards its been over 3 years since I touched them, but can't you get the player scoreboard and modify the value instead of making a new one?

orchid hinge
#

ill see later imma eat

#

thanks for the answers

marsh crest
#

is there a way i could not drop the average drop of the block and also play the sound of the block breaking

#

oh wait the particles also aren't there

dawn flower
#

is it possible to listen for right click on air with no item in hand?

young knoll
#

No

dawn flower
#

uh

#

then how does hypixel let u shoot the cannons in kuudra without an item in hand

royal heath
#

You should be able to

eternal oxide
#

no packet is sent

dawn flower
#

md_5 said no packet gets sent

royal heath
#

PlayerInteractEvent and check if the action is left_click_air

dawn flower
#

so i'm hella confused

royal heath
#

but right click might not work

dawn flower
#

i want right click as well

#

ima just force give the player an item

#

wait...

#

what if i trick the client that he has an item in his hand with a fake packet

royal heath
#

You could put something in their left hand

young knoll
#

You could also just place an entity in front of them so they interact with that

remote swallow
#

theres most likely an entity in their face

dawn flower
#

it works if there's an invisible entity?

remote swallow
#

sure iirc

dawn flower
#

does that mean the client knows about invisible entities 😳

remote swallow
#

yeah

dawn flower
#

wild stuff

remote swallow
#

in tweakaroo you can see invisable players with 1 tweak last time i played mc

zealous osprey
dawn flower
#

why does minecraft give so much to clients

remote swallow
#

discord tells all users about channels, even ones they have no permission to se e

dawn flower
#

in the early days u could even modify ur own inventory while in survival, thank god they made it serverside

zealous osprey
#

Because it's very hard to know exactly what the client should and shouldn't have. Most of the reasons also just boil down to make the server run more efficiently and not let players, blocks and entities in general appear out of thin air

fair rock
dawn flower
#

companies trust their clients alot

dawn flower
fair rock
dawn flower
#

is conorsmine writing an essay

zealous osprey
dawn flower
#

did u just spend like 5 minutes writing yes

zealous osprey
zealous osprey
# dawn flower is conorsmine writing an essay

companies trust their clients alot

yesn't.
Let's view the following example:
Two players are sperated by a stone wall, neither of the players can see each other. With your logic, the server shouldn't send the players any data about the other player. Well... that makes sense, but there are two issues:

  1. The server would need to do multiple checks to make sure that players that should be able to see each other actually do so. This issue gets worse the more players you have. 2 players is fine, the server checks if Player A can see Player B and Player B checks if they can see Player A. But you rarely are only 2 players. Now lets assume you are something like 16 players. That would be 16 checks per Player for a total of 256 checks. Depending how this check is performed, this might take a while.
  2. Player A walks a bit to the side, so far that Player B should be able to see them. Since the server will most likely check every tick if players can see each other, it'll take at worst 50ms before the server checks if the players can see each other. But don't forget that it will also take some time for the data to be sent to both players, maybe 20ms. At thins point a grand total of 70+ms have passed before players could see each other. On your screen it would seem like the player just appeared out of thin air. That's... shit.

Reasons like these just make it impractical to sanitize every bit of information that gets send to every client. It's far easier to just estimate that every player within X blocks should be informed about the player. Then the client does the calculations, therefore a lot of load is removed from the server.

dawn flower
#

ah

#

so latency > hackers

zealous osprey
# dawn flower so latency > hackers

hackers can use latency to their advantage. There was an issue where hackers just didn't send movement packets to the server for a while and then spammed a bunch when they wanted to "teleport". Since the server was naive and trusted the players, it execute the "movements" one after another, effectively teleporting them to a destination.
I think paper and spigot might still have this issue, but in a very, very small amount. While you can't "teleport", you can move a very small amount, iirc

dawn flower
#

i believe spigot stops that

#

with the "moved too quickly" thingi

quaint mantle
zealous osprey
# dawn flower with the "moved too quickly" thingi

yeah, but there's also the opposite. If you sit in a minecart and still send movement packets, you get moved a very tiny amount. So you could just ride a minecart without tracks. This was once used to ignore protection rules for some protection plugins

worthy yarrow
dawn flower
#

can u remove the fire effect from a fireball

worthy yarrow
#

If only I knew about them however 😦

quaint mantle
#

No error message in console either

zealous osprey
worthy yarrow
dawn flower
#

how do i make non persistent block displays?

#

i made one but when i left and rejoined they still existed

quaint mantle
worthy yarrow
dawn flower
#

it wasnt me

dawn flower
worthy yarrow
#

#setPersistence is a thing I think

#

For display entities

dawn flower
dawn flower
#

nvm the chunk has a ticket

worthy yarrow
#

Haha

quaint mantle
#

I'm pretty confident it's an error from my plugin

quaint mantle
dawn flower
quaint mantle
#

Indeed

dawn flower
#

try disabling ur plugin

worthy yarrow
#

My queue to dip

quaint mantle
#

It's only during a boss fight

dawn flower
#

what does ur plugin do with entities or bosses

quaint mantle
#

There is a hit phase, once the hit phase is 0, the boss summons some kind of beacons around it

#

Instantly killing the player if the player touches the beam

dawn flower
#

beams are client side

#

how r u checking if they touch the beam

quaint mantle
#

Wait, that's the wrong one

#

?paste

undone axleBOT
quaint mantle
pseudo hazel
#

wtf is exampleclass.entitybeam

quaint mantle
#
public static void entityBeam(final ArmorStand stand, Location location1, final Player p, final Entity e) {
        final Beam beam = new Beam(stand.getLocation().clone().add(stand.getLocation().getDirection().normalize().multiply(20)), stand.getLocation().clone().add(stand.getLocation().getDirection().normalize().multiply(-20)));
        stand.setGravity(false);
        beam.start();
        new BukkitRunnable(){

            public void run() {
                if (stand.isDead()) {
                    if (beam.isActive()) {
                        beam.stop();
                    }
                    this.cancel();
                    return;
                }
                Location location = stand.getLocation();
                location.setYaw(stand.getLocation().getYaw() + 2.25f);
                stand.teleport(location);
                Sputnik.getEntity(stand.getLocation().add(stand.getLocation().getDirection().multiply(20)), stand.getLocation().add(stand.getLocation().getDirection().multiply(-20)), p, e);
                beam.setEndingPosition(stand.getLocation().add(stand.getLocation().getDirection().multiply(0 - Sputnik.findArgo(p.getLocation(), stand.getLocation()))));
                beam.setStartingPosition(stand.getLocation().add(stand.getLocation().getDirection().normalize().multiply(Sputnik.findArgo(p.getLocation(), stand.getLocation()))));
                if (!beam.isActive() && !stand.isDead()) {
                    beam.update();
                }
            }
        }.runTaskTimer((Plugin)ExamplePlugin.getPlugin(), 0L, 1L);
    }```
pseudo hazel
#

whats Beam

quaint mantle
#

    public Beam(Location startingPosition, Location endingPosition, double viewingRadius, long updateDelay) {
        Preconditions.checkNotNull((Object)startingPosition, (Object)"startingPosition cannot be null");
        Preconditions.checkNotNull((Object)endingPosition, (Object)"endingPosition cannot be null");
        Preconditions.checkState((boolean)startingPosition.getWorld().equals(endingPosition.getWorld()), (Object)"startingPosition and endingPosition must be in the same world");
        Preconditions.checkArgument((viewingRadius > 0.0 ? 1 : 0) != 0, (Object)"viewingRadius must be positive");
        Preconditions.checkArgument((updateDelay >= 1L ? 1 : 0) != 0, (Object)"viewingRadius must be a natural number");
        this.worldname = startingPosition.getWorld().getName();
        this.viewingRadiusSquared = viewingRadius * viewingRadius;
        this.updateDelay = updateDelay;
        this.isActive = false;
        this.beam = new LocationTargetBeam(startingPosition, endingPosition);
        this.startingPosition = startingPosition;
        this.endingPosition = endingPosition;
        this.viewers = new HashSet<UUID>();
    }```
pseudo hazel
#

so which part uses nms?

lilac dagger
#

normalized means the length is 1 block

marsh crest
#

i think i was trying to figure this out but

#

i wanna make a system that doesn't save worlds when they are unloaded?

#

my idea was by simply just making a copy of the world and taking people there, then when the world isn't being used anymore just deleting the copy

pseudo hazel
#

you have to remove them from the disk

#

creating a world creates a folder on the server with the world in it

marsh crest
#

oh

pseudo hazel
#

i dont know of a way to only create a world in runtime memory

remote swallow
#

anyone here ever used discordkt

blazing ocean
#

no

quaint mantle
marsh crest
#

how do i check if you took damage from lava

fair rock
#

Isnt DamageSource an enum?

marsh crest
#

i dont know that is why i am asking

pseudo hazel
#

you can figure it out

#

by clicking on it

#

ctrl click on getdamagesource

eternal oxide
#

getCause() not getDamageSource

marsh crest
#

ima try this

eternal oxide
#

remove the ! if you want to cancel lava damage

marsh crest
#

no im cancelling everything except lava damage

eternal oxide
#

ok

remote swallow
quaint mantle
#

I thought kord ex was the main one

remote swallow
#

it adds loads of kotlin dsl stuff

quaint mantle
tardy delta
#

ig thats enough awful code for today

worthy yarrow
#

We love awful code

tardy delta
#

im wondering how many people would be fired if they shipped things i saw here into production

pseudo hazel
#

none

#

cuz ceo only care about code working

worthy yarrow
#

Truth

tardy delta
#

ceo which is a dev himself

#

that changes things

worthy yarrow
#

Well that’s another issue

eternal oxide
#

ceo is always about profit

worthy yarrow
#

Which is why it only matters if it works kek

orchid trout
#

Sorry, I encountered an error while processing your message.

worthy yarrow
#

That’s not to say as a dev you shouldn’t care for proper writing techniques and what not

tardy delta
#

but having non maintainable code slows things down 😳😳

pliant topaz
#

but it doesn't matter for profit ad ceo doesn't know shit about code

fair rock
lilac dagger
#

you can milk old code for so long before it all comes crashing down

orchid hinge
#

im literally reusing old code rn xD

lilac dagger
#

when a competitive project comes along yours is dead

#

you can't restructure

#

you just become skype

orchid hinge
#

who the hell uses skype

lilac dagger
#

it's funny, everyone was using skype

#

it died because poor decisions

lilac dagger
#

i remember when i was added to 1k people groups

#

and there's no option to turn it down

#

so every day i was spammed by these groups

orchid hinge
#

sounds like a real shitshow grandpa

lilac dagger
#

we'll be grandpas together in 5 years don't worry

orchid hinge
#

true

icy beacon
lilac dagger
worthy yarrow
#

Elgarl is a Chad grandpapa

tardy delta
#

lol

icy beacon
#

Granddaddy

ivory sleet
#

what the sigma

orchid hinge
worthy yarrow
#

Not the cat

pliant topaz
#

bruh, i rlly gotta make a spigot account lmfao

orchid hinge
#

woops

#

too late

ivory sleet
#

Im doomed

ivory sleet
#

😔

ivory sleet
#

Alright but lets try to keep this channel a bit clean when it comes to gif and meme shitposting

orchid hinge
#

fine

ivory sleet
#

I mean you caught me lacking w my brainrot soo :(

remote swallow
#

what do you mean

tardy delta
#

smh

pliant topaz
valid burrow
#
private void reloadPlanetFundAmount() {
    planetFund = BigInteger.ZERO;
    for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
        double balance = econ.getBalance(player);
        BigInteger balanceBigInt = BigInteger.valueOf((long) balance);
        planetFund = planetFund.add(balanceBigInt);
    }
}

could yall imagine a better way to get the total money on the server

orchid hinge
#

seems pretty good already

valid burrow
#

not good enough

#

i need speeeed

orchid hinge
#

bukkit runnable, start a task for every player and run it async

valid burrow
#

mhm

ivory sleet
#

I mean you could technically parallelize it

orchid hinge
#

i give advice not good advice so take it with a grain of salt

ivory sleet
#

but I think it'd be pretty diminishing

pliant topaz
#

I'm vewifiied now :3

#

Await me for the next gif storm...

valid burrow
#

do yall think it would be faster

#

to load it once on boot

#

and then track transactions myself

ivory sleet
#

whats option B?

valid burrow
tardy delta
#

i dont see a reason to optimize it if you dont have 20 thousand people

valid burrow
#

not sure when though

remote swallow
#

if you run it once a minute async it should be fine

ivory sleet
tardy delta
#

ig when someones balance change, change the total too?

#

if you really want to optimize it

valid burrow
#

yh thats what i mean with track transactions myself

ivory sleet
# valid burrow mhm

well I mean usually a total is calculated just like that, you poll an update every so often, ofc given that the data availability of the total isn't needed to be realtime-high

tardy delta
#

british people really are a troll

quaint mantle
#

is it possible to completely freeze the player's camera/head from moving?

zealous osprey
#

Is this allowed? Can I add a "_" inbetween without issues? The IDE isn't complaining, so ig it's ok

chrome beacon
#

yes you can

zealous osprey
#

neat

chrome beacon
zealous osprey
#

But I find it's more understandable that I want the last 12 bits of an int this way. Tbh I almost never use hex for masks, I find bits just convey more of an intent

chrome beacon
#

bits for masks make sense

tardy delta
#

~0 >> (32 - 12) or smth lol

remote swallow
#

im gonna jump infront of a truck on the m42

tardy delta
#

what are you doing

remote swallow
#

trying to get data from a companion object ona class specified in an enum value

tardy delta
#

¯_(ツ)_/¯

tidal kettle
#

i can't delete a value from an List<String> while in a BukkitRunnable?

hazy parrot
#

Why

#

Show code and error

tidal kettle
#

?paste

undone axleBOT
tidal kettle
tidal kettle
hazy parrot
#

Like how do you set map value

tidal kettle
#

?paste

undone axleBOT
tidal kettle
tardy delta
#

immutable collection?

tidal kettle
#

the code wortk i know

tardy delta
#

Collections.singletonList is immutable if thats the issue

hazy parrot
#

^

tardy delta
#

also youre doing three map operations to waste two

tidal kettle
#

but when i wan't to delete for the list inside of the map I just can't do it

hazy parrot
#

You are putting an immutable list as a value

tardy delta
hazy parrot
#

You can't mutate that list

tidal kettle
#

but i can't add thing in that list so it's mutable

#

(i think)

hazy parrot
#

?

tidal kettle
tardy delta
#
public void addPlayerInvitation(String playerName, String Inviter) {
  invitations.computeIfAbsent(playerName, k -> new ArrayList<>()).add(inviter)
}

probably

#

you cant call any methods that modify it internally

hazy parrot
tardy delta
#

cuz they didnt learn liskov

tidal kettle
tardy delta
#

no its about the list

tidal kettle
tardy delta
#

look at the impelemntation of Collections.singletonList

hazy parrot
tardy delta
#

look at the methods of thr returned type

#

all throw unsupported oop

tidal kettle
#

it work bruuh

#

but good to know that collection.singleton = can't mutate

ivory sleet
#

Goofy Java

tardy delta
#

reminds me of our discussion about liskov

ivory sleet
#

yep, in conclusion goofy java

royal heath
tardy delta
#

the shit i see at college

royal heath
#

Well yeah, it's college, they're learning

#

It's why code reviews exist, they'll phase out of it

tardy delta
#

they taking a long time to learn

royal heath
#

Some people learn at their own pace. When I was in college some people took the entire course to get a grip, some people got it right away

#

However there are a lot of ppl in college doing programming who just shouldn't do it

marsh crest
#

has anyone made a tutorial for compiling and using vsc as a ide instead of intellij

royal heath
#

Just use IntelliJ, you'll thank yourself later

#

Not worth the pain lol

marsh crest
#

i jus wanna liveshare wit my besties lmao i didn't think it would cause any issues

royal heath
marsh crest
#

OH !

royal heath
#

That's cool though I didn't know this kind of thing existed

tardy delta
#

or gradle or whatever

scarlet gate
#

Is it possible to get a list of possible equipment slots for an entity?

glass mauve
#

ah well that one supports cross ide

pseudo hazel
#

omg im triggered, I am trying to use the translated texts for statistics for minigame purposes, but for some reason, while all other languages have 2 arguments for the player killed "entity" "2" times, some languages like french and spanish only have one argument

#

cuz the translator was lazy or something

#

so it doesnt read well since the actual mob you killed isnt in the translation in that case

#

but its only for about 13 json files

#

all the other languages have double arguments, like you would expect..

fair rock
#

Sure he was lazy? Not he was like: Do it on purpose to fuck someone up, that would be hilarious xd

pseudo hazel
#

but I dont think there is any way to treat those languages differently when translating, since its done in the client

#

yeah well they did it I guess

#

it is kinda funny

#

but its also kind of an unsolvable problem for me

fair rock
#

True, sadge

pseudo hazel
#

I can cheese it a bit

#

it would just be You killed 2 " " (mob_name) which works for most languages, where " " is an empty placeholder and (mob_name) is after the translated part

#

works well enoug I guess

eager pier
#

Hello, i'm trying to use EntityType enum and my IDE (IntelliJ) tells me it does not exists and so it does not compile ... I'm using Spigot 1.20.6-R0.1-SNAPSHOT and EntityType exists in the documentation. Any other class like Player, Bukkit, CommandExecutor, etc are available so I don't understand. If anyone has an idea. (Yes I tried to add EntityType import line)

remote swallow
#

Update ij

eager pier
#

Update IJ did not work. EntityType seems to be a problem in version 1.20.6 because it is working in 1.20.5

eager pier
swift sable
#

I desperately need help adding nms to my plugin; ive tried like 100 times and guides and none of them work and i have nfi why. Just getting 😦 now

peak depot
# swift sable I desperately need help adding nms to my plugin; ive tried like 100 times and gu...

If you need to access NMS classes from inside your Spigot plugin, it is a very good idea to use the so called Mojang mappings. Disclaimer: This post is written for 1.20.4. If you use another version, you of course have to replace every occurance of “1.20.4” with the version you actually use. What are...

swift sable
#

im using paper not spigot

peak depot
#

?whereami

nova notch
#

why was my message deleted

remote swallow
#

?whereami

nova notch
#

ok so i guess i cant help people thats awesome

#

ill just dm them

remote swallow
#

you are in spigot

river oracle
#

Why are we deleting references to paper now

#

That's just lame it exists

#

Cope

nova notch
marsh crest
#

includes isn't a thing but is there something kinda like what i'm going for

young knoll
#

Not sure if there is for arrays

#

But you can make it into a set or a list and use contains

marsh crest
#

oo yea

#

is there no way to just

dawn flower
#

u need to use streams to check in an array

marsh crest
#

new ArrayList<String>("A", "B");

dawn flower
#

u cant do that

young knoll
#

List.of

marsh crest
#

aw

dawn flower
#

List.of(...)

young knoll
#

Or Arrays.asList

dawn flower
#

actually it'd be nice if arraylist had a constructor like that

#

since List.of is immutable iirc

young knoll
#

So is arrays.asList

#

But you can just wrap that in a new arraylist, kek

slender elbow
#

Arrays.asList isn't immutable

#

it's just not resizeable

marsh crest
#

okay cool

dawn flower
#

im in immutable is a not

young knoll
#

That’s wacky

#

But fair enough

marsh crest
#

i am hella brainfarting

#

can i do this

dawn flower
#

yes

#

but dont cast it as player

#

also u can just do if (sender instanceof Player player)

slender elbow
dawn flower
marsh crest
dawn flower
#

return true not false

#

the console would be hella confused if it just sends the usage message

marsh crest
#

what does the bool do actually

dawn flower
#

false = sends usage message

marsh crest
#

ah

#

also do these enhanced switch cases need breaks

#

(ima change how this is coded later i'm just curious)

slender elbow
#

nope

marsh crest
#

cool

glad prawn
#

fancy

dawn flower
#

fence

marsh crest
#

farce

buoyant jasper
#

Why player gets send message twice

private void processUpgrade(Player player, int upgradeCost, int upgradeLevel) {
    String uuid = player.getUniqueId().toString();
    try {
        int balance = plugin.getDatabase().getBalanceFromDatabase(uuid);

        if (balance >= upgradeCost) {
            plugin.getDatabase().updatePlayerBalance(uuid, balance - upgradeCost);
            plugin.getDatabase().setPhantom(uuid, upgradeLevel);
            player.sendMessage(ChatColor.GOLD + "You bought Upgrade " + upgradeLevel + " for the Phantom Kit!");
            player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f);
        } else {
            player.sendMessage(ChatColor.RED + "You don't have enough coins to purchase this upgrade!");
            player.playSound(player.getLocation(), Sound.ENTITY_SHEEP_AMBIENT, 1.0f, 1.0f);
        }
        player.closeInventory();
    } catch (SQLException ex) {
        ex.printStackTrace();
        player.sendMessage(ChatColor.RED + "Error processing database transaction.");
    }
}
remote swallow
#

what message are they getting twice

buoyant jasper
#

player.sendMessage(ChatColor.RED + "You don't have enough coins to purchase this upgrade!");

#

this is sending twice

remote swallow
#

where are you calling the method

buoyant jasper
#

@EventHandler
public void onInventoryClickPhantom(InventoryClickEvent event) {
if (event.getView().getTitle().equals(ChatColor.YELLOW + "Phantom Kit")) {
Player player = (Player) event.getWhoClicked();
ItemStack clickedItem = event.getCurrentItem();
String displayName = clickedItem != null && clickedItem.hasItemMeta()
? clickedItem.getItemMeta().getDisplayName()
: "";

        if (displayName.equals(ChatColor.YELLOW + "Upgrade 2")) {
            processUpgrade(player, 1000, 2);
        } else if (displayName.equals(ChatColor.YELLOW + "Upgrade 3")) {
            processUpgrade(player, 1500, 3);
        }

        event.setCancelled(true);
    }
}
wraith delta
marsh crest
#

i'm getting a null error but i literally have a null check i'm not sure what's up

#

also the "okay ima do that" does get sent to the player so the code is good up to that part

young knoll
#

You check if it’s null

#

But then in the else you call toLowerCase on it

#

Nvm I’m dumb

marsh crest
#

yea it wouldnt be null in the else

#

i feel like i'm missing something directly jingled in front of me oufhh

young knoll
#

Wait you are accessing the 3rd element in args

#

But the command in the other screenshot only has 1 argument

marsh crest
#

the crash happens before these two messages are sent

young knoll
#

Yeh it’ll brick as soon as you do args[2] == null

#

Because 2 is outside the bounds of the array

marsh crest
#

how do i check for how many parameters are given

#

and like properly deal wit it yk

young knoll
#

args.length

buoyant jasper
#

fixed thank you

night gorge
#

Anyone know an event for when primed TNT explodes, affecting (usually moving) other primed TNT?

I checked EntityDamageByEntityEvent, but it isn't called since the primed TNT doesn't deal damage to other primed TNT. I can't find anything else in the Spigot javadocs that may be fired in this situation.

Currently my solution is to check nearby entities for primed TNT on EntityExplodeEvent and manage them that way. But I'm wondering if there's a better way. If not, that's chill

young knoll
#

Does it call EntityKnockbackEvent

night gorge
#

Oh thanks, I'll try that

#

Doesn't seem to unfortunately

#

Wait

#

Nope

carmine mica
#

is TNTPrimeEvent not called?

young knoll
#

Should be, but that’s basically the same as the explode event

#

Just allows you to stop the explosion from happening

night gorge
#

Not for my situation. I'm looking for when primed TNT affects other primed TNT rather than priming blocks

#

Tbf I think the solution I have atm is sufficient. Thanks for the help though c:

wooden thicket
#

Not sure if this is the correct channel or server but I am currenting using spigot 1.16.5 and I am using mavern and vsc to make plugins and currently I am having issues with connecting a plugin to postgreSQL if anyone could help me.. that would be great..

drowsy helm
#

and what isnt working

wooden thicket
#

so I don't flood the server chat

drowsy helm
#

no

#

post it here

wooden thicket
#

alr

#

I've been following this youtube video for connecting spigot to postgreSQL and current my code looks like this:

package com.pixelite.easylogin;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;

import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.JavaPlugin;
import org.postgresql.Driver;

/*
 * easylogin java plugin
 */
public class Plugin extends JavaPlugin {
  public static Logger LOGGER = Logger.getLogger("easylogin");
  private CommandHandler commandHandler;
  public Connection connection;
  public Configuration config;

  public void onEnable() {
    loadConfig();
    LOGGER.info("easylogin enabled");
    try {
      DriverManager.registerDriver(new Driver());
      connection = DriverManager.getConnection(
          "jdbc:postgresql://" + config.getString("database.ip") + ":" + config.getInt("database.port") + "/"
              + config.getString("database.database") + "?stringtype=unspecified",
          config.getString("database.username"), config.getString("database.password"));
      commandHandler = new CommandHandler(connection);
      getCommand("register").setExecutor(commandHandler);
    } catch (SQLException e) {
      LOGGER.severe("failed to register");
      e.printStackTrace();
    }
  }

  public void onDisable() {
    LOGGER.info("easylogin disabled");
  }

  public void loadConfig() {
    getConfig().options().copyDefaults(true);
    saveConfig();
    config = getConfig();
  }
}
#
package com.pixelite.easylogin;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class SQLHelper {
    private Connection connection;
    
    public SQLHelper(Connection connection) {
        this.connection = connection;
    }
    public ResultSet query(String query, Object... args) throws SQLException{
        PreparedStatement preparedStatement = connection.prepareStatement(query);
        for(int i =0; i < args.length; i++){
            preparedStatement.setObject(i + 1, args[1]);
        }
        preparedStatement.executeQuery();
        return preparedStatement.getResultSet();
    }
    public void update(String query, Object... args) throws SQLException{
        PreparedStatement preparedStatement = connection.prepareStatement(query);
        for(int i =0; i < args.length; i++){
            preparedStatement.setObject(i + 1, args[1]);
        }
        preparedStatement.executeUpdate();
    }
}
#

I am not recieving any errors

#

like syntax

#

errors or anything

#

then I have a config file

#

like this

#
database:
  ip: localhost # host of your database
  port: 5432 # default port for MariaDB and MySQL
  database: postgres # name of your database. A database server can contain multiple databases
  username: postgres
  password: 12345
regal scaffold
#

What java are people using to compile for latest mc plugins? 21?

wooden thicket
#

ill show you the server error now when I run the server

wooden thicket
# wooden thicket ill show you the server error now when I run the server
java.lang.NoClassDefFoundError: org/postgresql/Driver
        at com.pixelite.easylogin.Plugin.onEnable(Plugin.java:25) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:492) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:406) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:554) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:257) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_411]
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:140) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot.jar:3096a-Spigot-9fb885e-af1a232]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_411]
        ... 11 more
drowsy helm
#

show your pom.xml

wooden thicket
regal scaffold
drowsy helm
#

yeah it's not being shaded

#

so basically during runtime, the library isnt available. Shading it puts the needed library (in your case postgres) inside your jar so it can use it

wooden thicket
#

is shading a depenency

#

needed?

young knoll
#

Yes

drowsy helm
#

if it's not in the spigot runtime, yes

#

but there is an alternative with spigot

#

sec

fluid cypress
#

what is the easiest way to serialize an item stack into json? im using kotlinx.serialization btw

drowsy helm
#

look at the libraries section

#

basically spigot will load your library at runtime, rather than it being shaded in your jar

wooden thicket
#

is this the section

#

you're referring too

drowsy helm
drowsy helm
wooden thicket
#

would it just go inside the pom file

drowsy helm
#

no thats inside your plugin.yml

#

if you don't want to shade it

#

If you do want to go the shading option, look into maven shade plugin

wooden thicket
#

what would you recommend

#

for my case shade it or use an alternative

drowsy helm
#

for such a large lib like postgres i would use the plugin.yml alternative as it might be shared by other plugins

drowsy helm
fluid cypress
#

if not, at least, if i want to be able to not lose any information, what do i have to serialize? material, amount, enchantments, lore, idk what else

fluid cypress
drowsy helm
fluid cypress
#

i just dont want to do it myself

#

but it has to be json

drowsy helm
fluid cypress
#

i mean, unless i can convert Map<String, Object> to a json string somehow

fluid cypress
#

so it doesnt have to be readable

#

but it has to be json

drowsy helm
#

i mean you can still serialise it but it wouldnt be ideal

#

just make an adapter and manually store the variables, theres not that many

#

NBT, name, desc, stack size, material

#

thats about it

fluid cypress
#

for example if i do itemStack.toString(), its almost like what i want, just that its not json, its some other weird format

drowsy helm
#

are you using SQL or a no sql db

#

because if you use an ORM on your javascript side it will automatically get converted to json

fluid cypress
#

sql

drowsy helm
#

storing it as json in the db is just adding an extra layer of complexity

fluid cypress
#

you mean using ItemStack#serialize

#

and storing it as blob

#

and then an orm will magically convert it back to json?

drowsy helm
#

no

#

store it in a table as you would any other sql object
{
name: varcar(256),
desc: varchar(256),
etc..
}

fluid cypress
#

right

drowsy helm
#

then your ORM on the javascript side will convert it to json

fluid cypress
#

well, the thing is

#

i have to think about each column

#

and i wanted to avoid that

drowsy helm
#

why..?

fluid cypress
#

so i dont forget stuff

drowsy helm
#

you're using a proprietary method to consume the data, expect there to be some manual work to get it working

fluid cypress
#

and bc i plan to use items adder and idk how does all that work

young knoll
#

Probably all in pdc

fluid cypress
drowsy helm
#

itemsadder doesnt add ontop of anything that spigot doesnt use

fluid cypress
#

you can even store that directly in a yaml iirc

drowsy helm
#

if oyu cover everything spigot does, it will work with items adder

fluid cypress
young knoll
#

Spigot has methods to convert it to yml

fluid cypress
#

and thats why i wanted to use an already existing serializer and not my own

young knoll
#

Which is a subset of json iirc

fluid cypress
young knoll
#

Yes

fluid cypress
#

which one exactly, i guess i can serialize it to yaml and then json

young knoll
#

ItemStack#serialize converts it to a map<string, object>

#

From there that gets converted to yml

fluid cypress
#

but how exactly

#

what do i do with the Map<String, Object>

drowsy helm
#

map it to a json object

fluid cypress
#

but what is Object?

#

i should mention that i barely use java

young knoll
#

Various types

drowsy helm
#

can be anything

young knoll
#

Should be all primitives in this case though

#

and collections of primitives

#

(And string which technically isnt a primitive)

fluid cypress
#

ok but how do i create a string in yaml format from the Map<String, Object>

#

how does spigot do it

#

iirc you can do config.set("something", x)

drowsy helm
#

string is just the item path

fluid cypress
#

x being the Map<String, Object> serialized thing

drowsy helm
#

x is just the value which is always a primitive

#

all it does is iterate over the map and put the value where the path is

young knoll
#

Yeah you can stick the entire map into spigots yaml objects

#

It handles the rest from there

fluid cypress
#

ok, good to know, but how do i use that information to create a yaml string

fluid cypress
#

is there an easy way to go from those paths with their primitives

#

to a yaml string

drowsy helm
#

past that point, is where it uses snakeyaml

#

String.valueOf(x)

#

if its a primitive, valueOf will work

young knoll
#

You should be able to just String.valueOf anything that isn’t a collection or another map

fluid cypress
#

ok so the snakeyaml library is what can convert a Map<String, Object> into a yaml string?

young knoll
#

Yes

#

Gson might be able to deal with that map too actually

#

Assuming the meta in that map is already serialized, it should be all types gson is able to handle natively

fluid cypress
#

ok, didnt know that

#

let me try that

wooden thicket
drowsy helm
wooden thicket
#

which was already provided to me

#

with mavern

drowsy helm
#

okay add

libraries:
   - com.squareup.okhttp3:okhttp:4.9.0```
but with the lib you need
#

in your plugin.yml

drowsy helm
#

dont get it confused

wooden thicket
#

I used a mavern plugin

#

to create it

#

it generated it

#

is what I meant

#
name: easylogin
main: com.pixelite.easylogin.Plugin
version: 0.0.1
api-version: 1.15
author: ("Rose")
commands:
  register:
    description: Creates an account
    usage: /<command> <password>
    aliases: [r]
libraries:
   - com.squareup.okhttp3:okhttp:4.9.0
#

do I got red of the "-"

drowsy helm
#

no

#

jus replace it with the lib you need

wooden thicket
#

okay thank you

#

I am not sure what I need though

#

I cannot find any tutorials on youtube

#

nor does it mention it

#

in the series

drowsy helm
#

the postgres library

wooden thicket
#

I've been following

drowsy helm
#

that you import in maven

drowsy helm
wooden thicket
drowsy helm
#

dependencies

#

is another word for it

wooden thicket
#

yes

#

well the tutorial I followed just assumed the watcher

#

already had it

#

and didn't provide any context

#

¯_(ツ)_/¯

fluid cypress
drowsy helm
#

just use the default postgres dependency

#

you dont need anything spigot specific

marsh crest
#

this doesn't seem to clear the drops from stuff

carmine mica
#

It’s just potential drops as if it ran the loot table once.

glad prawn
#

p-paper

carmine mica
#

Well spigots javadocs aren’t helpful for that method

quaint mantle
#

?whereami

quaint mantle
#

I've got a strange error with gson & itemstacks...

com.google.gson.JsonIOException: Failed making field 'java.util.Optional#value' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.
... rest of stacktrace is just repeated gson reflection bs
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.Object java.util.Optional.value accessible: module java.base does not "opens java.util" to unnamed module @22c8d07d
        at java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391) ~[?:?]
        at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367) ~[?:?]
        at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315) ~[?:?]
        at java.lang.reflect.Field.checkCanSetAccessible(Field.java:183) ~[?:?]
        at java.lang.reflect.Field.setAccessible(Field.java:177) ~[?:?]
        at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:35) ~[gson-2.10.1.jar:?]
        ... 72 more
public class ItemSerializer extends TypeAdapter<ItemStack> {

    private static final ItemSerializer INSTANCE = new ItemSerializer();
    public static final Gson GSON = new GsonBuilder()
            .setPrettyPrinting()
            .serializeNulls()
            .registerTypeAdapter(ItemStack.class, INSTANCE)
            .create();

    @Override
    public void write(JsonWriter jsonWriter, ItemStack itemStack) throws IOException {
        for (int i = 0; i < 50; i++) {
            System.out.println();
        }
        jsonWriter.jsonValue(ItemUtils.itemStackToBase64(itemStack));
        jsonWriter.close();
    }

    @Override
    public ItemStack read(JsonReader jsonReader) throws IOException {
        return ItemUtils.itemStackFromBase64(jsonReader.nextString());
    }
}

This is my item serializer and I am attempting to serialize a

#

List<Kit>

carmine mica
#

probably want registerTypeHierarchyAdapter

quaint mantle
#

preciate it gangy

tranquil stump
#

In IntelliJ there is a feature where when there's a color in the name of something (like a class or method) it will show that color on the side of the line. Anyone know of a vscode extension that does something simmilar to this?

#

I'm remembering to when I used IntelliJ and it would show a color preview whenever I would use a Bukkit Color or something like that

delicate lynx
#

that might of been from the minecraft development plugin on intellij? dunno if that adds it

#

not sure if someone made it for vsc

pseudo hazel
#

yeah thats the intellij minecraft plugin

stoic summit
#

@pseudo hazel