#help-development

1 messages · Page 1969 of 1

sterile token
#

Oh you are using Gson to save data

quaint mantle
#

yes

#

i got the menus working

#

i am working on items in the menus now

sterile token
#

Oh allright

#

I would use Yml because it will be easier

quaint mantle
#

and i ran into this since gson cant deserialize itemstacks

sterile token
#

But it should work

quaint mantle
#

i am using json

sterile token
#

Hmn i dont think so

#

because with yml you forgot item deserialization

#

You can just save directly the item object and get it back

quaint mantle
#

i still want to use json since it took me a long time to get it working and i want it to be fast

#

yml is slow

sterile token
#

allright

#

So menus items its an array?

quaint mantle
bold flume
sterile token
#

You can see it on javadocs MountMario

quaint mantle
#

i just need a way to smash two variables in one parameter in a method

sterile token
#

Javadocs have all methods from a library or java program

quaint mantle
#

fromJson only has two

#

and i can't modify it

#

i need two variables in the second parameter somehow

sterile token
#

Two variables?

#

Explain that

#

Like having slot and item right?

quaint mantle
#

no, two arraylists

#

in that one parameter

#

one called name

#

one called postition

#

name is a string

#

position is an int

sterile token
#

Hmn

sly trout
#

guys how do we check if a player's inventory is full?

sterile token
#

?jd

vocal cloud
#

?jd

young knoll
#

Check if firstEmpty is -1

sterile token
sly trout
#

not thank you to the other ppl

wary harness
#

any one can tell me how would I run server with logger in ALL mode

#

I use to do it but forgot

#

how is that done

vocal cloud
wary harness
sterile token
vocal cloud
sly trout
#

okay but i asked

#

if you know answer

quaint mantle
#

help

sly trout
#

if not then its fine

hexed hatch
quaint mantle
#

docs are useless if you dont know how to navigate them

hexed hatch
#

Two variables in one parameter?

#

What do you mean

sterile token
quaint mantle
hexed hatch
#

What even is variableone and variabletwo

#

Like what are they

vocal cloud
# sly trout if you know answer

Most of the answers you get here are just straight from the docs which you also have access to. It's equivalent to asking someone what the definition of a word is so they read the dictionary to you.

sterile token
#

In my menu api, i use a custom object called (MenuButton) which contains the ItemStack and he Consumer<ClickEvent>. That button it saved over Map<Slot, Button>

quaint mantle
#

variable two is an int called position

hexed hatch
#

I would construct this string outside of the function call if I were you

#

For my own sanity

#

Might be a bit easier

sterile token
#

Using an object for the items?

#

Wouldnt be easier?

hexed hatch
#

Easier than what alternative?

sterile token
sterile token
#

This is one of reasons why spigot plugin development its not simple

past vapor
#

Is there any way to make ping update faster? I've seen someone do it before but I'm not sure on how

young knoll
#

You’d probably have to calculate it yourself

#

By sending the packets

storm crescent
#

Would it be possible to overwrite the Bukkit.getPlayer() method? (Make other plugins run a custom method when they call Bukkit.getPlayer())

young knoll
#

Asm

#

Probably

#

Or bytebuddy or whatever

ivory sleet
#

Bukkit::setServer would be an option

sterile token
#

I lvoe because they are really understable

#

Haha

#

?

ivory sleet
#

Isn’t there like setVisible also?

#

To my knowledge

#

Oh Idk then sorry

zealous osprey
#

How would I add a tabcomplete to a Command instance ?

sterile token
#

Hmn i love Java!!

ivory sleet
#

Oh lol

sterile token
#

Im getting StackOverflow

#

Read that its a memory problem

ivory sleet
zealous osprey
#

oh ?

ivory sleet
#

Ye

zealous osprey
#

lemme check

zealous osprey
ivory sleet
#

Assuming you don’t got yourself a PluginCommand which would allow you to set a strategy for tab completing

#

Well

#

That’s better

zealous osprey
#

Yea, I dont have a PluginCommand, I just have Command

ivory sleet
#

But it requires you to use ::setTabCompleter which is a method of PluginCommand

sterile token
#

I never used before PluginCommand

#

I only use it on my command api for registering commands

#

Then for nothing else

ivory sleet
#

Cool

sterile token
#

Because my command api uses PluginCommand and CommandMap for registering commands

#

I hate having thousands of line on pl.yml

zealous osprey
young knoll
#

Just use an existing one

#

There’s a bunch of em

ivory sleet
#

^

#

Or well take a look at one of the existing ones

#

Preferably one of the more pervasive ones

zealous osprey
ivory sleet
#

Good luck

zealous osprey
#

👍

ivory sleet
#

You’ll soon find out people handle commands similarly but not similarly if that makes sense

sterile token
young knoll
#

I’m using ACF right now

#

The Lang system is kinda annoying

ivory sleet
#

Lang systems are generally painful 🥲

young knoll
#

I just want to have every message run through my translate system

#

Why is that so complicated

sterile token
#

Overflowstack could be thrown because im trying to connect a fake player to server on main thread?

ivory sleet
#

Probably not

sterile token
#

Oh hmn

#

So i dont find the cause

ivory sleet
#

Just some method calling itself finitely

sterile token
#

I will still looking what happening

ivory sleet
#

Which overflows the stack

sterile token
#

Oh

#

Thread.sleep()

#

Prob

#

I think that the problems

ivory sleet
#

Some recursive function of yours if I’d gues

sterile token
#

I think the thread.sleep() its causing all the problems

ivory sleet
#

Lol you close the socket?

sterile token
#

No?

brave sparrow
#

Thread#sleep won’t cause a stack overflow

sterile token
#

so i will still looking what happenins

#

Im confuse

young knoll
#

What if I recursively call thread.sleep

sterile token
#

Im calling the method fron onEnable

#

I dont think onEnable method its called recursively

brave sparrow
ivory sleet
#

As said you call close on the socket

brave sparrow
#

@sterile token are you calling thread#sleep from a spigot thread?

ivory sleet
#

Unless I happen to be blind

sterile token
young knoll
#

Sleeping the server thread

#

Ohno

ivory sleet
sterile token
#

I have to sleep it if not the fake player fet disconnected

#

I used to work without thread.sleep() but them fake player get taken out from server

young knoll
#

But that’ll just

#

Freeze the server

sterile token
#

That why

#

So the fake player dont get disconnected

brave sparrow
sterile token
#

But if i dont freeze the player get disconnected

young knoll
#

Why are you connecting a fake player anyway

ivory sleet
#

Well do you have to connect and do all that login stuff on the server thread?

sterile token
ivory sleet
#

Like you could just use another thread in principle

young knoll
#

That’s

sterile token
young knoll
#

One janky way to share data

sterile token
#

And it required a player

#

So im connecting a fake one

#

:hummy:

ivory sleet
#

Creative workaround

#

Still somewhat ridiculous

young knoll
#

But you have to tell the fake player to connect

ivory sleet
#

Or well vulgar in some sense

sterile token
#

Im sending handshake and login packet

#

My issue is that it get disconnected from the bukkit server

#

idk why

#

Anyway i have taken out the socket#close and thread.sleep and getting the error

#

I will have to make an exausted checked

ivory sleet
#

Myeah try catch throwable maybe

#

Also don’t use sneaky throws

#

It’s kinda big ew, especially what it allows you as the coder to bypass

sterile token
#

I will try catching IOException

#

And i will try FixedThreadPoolExecutor

ivory sleet
#

Ok lol

sterile token
ivory sleet
#

I mean if you’re trying to fiddling something into a mediocre working state just start a Thread object and then try catch throwable and print the stack trace perhaps?

#

Don’t need to make anything fancy before it even works

sterile token
#

Lol

#

Fuck

#

Im still having the error

#

idk what happening

#

Mnns

#

I think the problem is not caused there

#

I think find the problem

wet breach
#

what are you doing o.O

sterile token
wet breach
#

that is so pointless lol

young knoll
#

I mean

#

It’s creative

sterile token
#

Redis its to much for just sending simple cross-server message

#

I dont wanna send nothing else

wet breach
#

why does everyone want to send messages on a server with no players o.O

sterile token
#

it doesnt make sense using a player for receive the message

#

Why dont use each server as receiver?

#

That my biggest question

wet breach
#

what I mean is a server with no players shouldn't be doing anything

wet breach
#

I am sure more could be added on in terms of bungee and spigot communicating, but you are free to modify both of those things as well as make PR's

#

as for making a fake player that is legit there is easier ways to do it

sterile token
#

But the ways i tried no one add it as a real connection

wet breach
#

for the purpose of plugin message channel it is pointless though since I mean servers with no players shouldn't be doing things

zealous osprey
#

Tabcompleters for generic Command

wet breach
#

basically if you want a real connection you will have to minimally have the client stuff on the bungee server

#

since the connection needs to start at bungee

quaint mantle
#

it looks sexy

#

but i could do better

sterile token
#

Its my own

sterile token
wet breach
#

there are better uses of having a fake player like you are creating though

#

other then plugin messaging stuff

#

like making a video camera

young knoll
#

Like inflating online count

#

Oh

wet breach
#

easier to record videos of your server using fake players with a minimal client 😛

sterile token
wet breach
#

inflating online count is just a matter of modifying the number lol

sterile token
#

my goal its find an simple solution for sending simple cross-server messages without extra things

#

How does Luckperms

#

It doesnt use anything

#

And it send cross server message

wet breach
#

you are not going to get anymore efficient then that

#

unless you use unix sockets I suppose

sterile token
#

Doesnt socket require extra setup?

young knoll
#

Carrier pigeon

wet breach
wet breach
#

not overly difficult

young knoll
#

Poor birb

past vapor
#

So there is a method for getting ping Player#getPing() but what about modifying that field?

young knoll
#

Why do you want to modify it

sterile token
past vapor
young knoll
#

Expose it in your own API then

#

I mean I guess you could reflect it, but why bother

past vapor
#

But I want it to interact with multiple already existing plugins

wet breach
past vapor
#

e.g tab

sterile token
wet breach
#

who cares?

young knoll
#

I mean go ahead and reflect it then

sterile token
#

Wait its possible to connect a socket from a hosting to socket server on linux vps?

grizzled briar
#

when I try to restart my server with the plugin UltimateAutoRestart it says "could not force restart because your interval argument is faulty" what does this mean?

wet breach
#

I mean software does this all the time

sterile token
#

two system?

#

Using sockets and message channel?

#

that what you mean?

wet breach
#

well your question wasn't quite clear in what you were asking

#

anyways not sure why you keep insisting on message channels

sterile token
#

Because they dont need extra setup

#

And every server has it

wet breach
#

there is no extra setup with sockets either

#

other then putting the plugin on the server

#

if you can't do that then you really shouldn't be running servers

sterile token
#

dont you require a specific port for each socket?

#

That the problem if you dont use a vps you cannot achive it

wet breach
#

you don't need multiple sockets for multiple connections

wet breach
#

this is obviously wrong

sterile token
#

Why?

#

Hosting doesnt allow opening sockets

wet breach
#

because sockets are not dependent on having a vps or not

sterile token
#

That what i was making refence

sterile token
wet breach
#

or make use of the loopback interface

sterile token
#

Oh i never listened before

#

I will give a try thanks

#

And sorry for lsoting your time

wet breach
#

not wasting my time

#

if it was a waste of my time I would have left by now 😛

sterile token
#

I said it because people said that im really hard

#

😂

wet breach
#

sure but most of your problem is the language barrier

#

in trying to convey what you are asking

sterile token
#

Yeah that i agree

#

So unix sockets was called?

#

I will save it

wet breach
#

Java 17 introduced unix sockets natively 🙂

#

before java 17 you will have to find a library or make your own in software unix socket implementation

sterile token
#

Oh i would use java 17 to compile, but them i cannot use it for plugins

#

Because you cant run java 17 plugins on old versions

wet breach
#

your other alternative is making use of the loopback device which is known as localhost or more precisely 127.0.0.1

#

opening sockets on the loopback device shouldn't trigger anything for the firewall

sterile token
#

And how you connect thems?

wet breach
#

mainly because loopback device doesn't talk to the outside world 😛

#

instead of just making a socket on all devices, specifically tell java the device/ip you want to create the socket on

sterile token
#

I know but if you are using a hosting you cannot open ports, they already assign one

wet breach
#

loopback device is an exception

sterile token
#

Oh i will read about it

wet breach
#

as I said it is a device that can't make outside connections

#

therefore, you should be able to create sockets on it

past vapor
young knoll
#

Google java reflection

sterile token
#

frost i dont still understand what its loopback device

#

I search "loopback device java examples"

#

And looks like java sockets

wet breach
#

the difference however is you will instead specify the device or ip to create the socket on

#

which is going to be localhost or 127.0.0.1

#

while the host you are on prevents creating sockets, they usually only do so for the device that communicates to the outside world or the public IP

#

which is not what you are going to be using anyways

#

the loopback device can not communicate to the outside world

#

therefore it makes no sense to attempt blocking creating sockets on it

paper zealot
#

?js

#

?java

#

okay

wet breach
#

?java

sterile token
undone axleBOT
paper zealot
wet breach
#

the loopback device however can still be used to communicate to your servers that are on the same system.

sterile token
#

right?

wet breach
#

which you most likely won't have

sterile token
#

yes i read that < 1024 are reserved for the system

past vapor
potent marten
#

How to make spigot server item translate to player local language?

sterile token
#

I love intellij

#

Sometime i wanna throw him outside my windows

wet breach
past vapor
#

22.02 00:50:22 [Server] WARN java.lang.NoSuchFieldException: ping

wet breach
#

then its a matter of grabbing the client locale which you should be able to do from the player object and display the translation to that player

sterile token
#

you send an ip address

past vapor
#

Line right above that is my ip 😟

sterile token
#

Ah no it not an ip address

young knoll
#

Ping is probably the mapped name

#

You need the obfuscated name

sterile token
potent marten
wet breach
#

well for placeholders it is dependent on the plugin or if you are creating them then the limitation is going to be it most likely doesn't support per player translations

potent marten
#

Ok so you mean I already translate it but plugin placeholder are not use spigot translate?

wet breach
#

spigot doesn't translate anything

#

you can set the language of the server which only applies to what is in the game already

#

also, the client language will translate on the client, again for stuff already in the game

#

but for stuff added by plugins, it is on the plugin authors to setup translations and most do however what most don't do is per-player translations

woeful crescent
#

anyone know if breaking a block is under PlayerInteractEvent useInteractedBlock or useItemInHand?

wet breach
#

it is an all or nothing setting in regards to language for most plugins

wet breach
sterile token
sterile token
woeful crescent
#

which thing is it

wet breach
potent marten
#

I mean like this I want translate "Wooden Pickaxe"

woeful crescent
wet breach
#

it could be both

#

multiple events for the same thing can be fired

#

use which ever one you need for whatever you are trying to do

woeful crescent
#

??????

#

i mean like

young knoll
#

?tas

undone axleBOT
woeful crescent
#

im asking bc i dont want to

#

and if someone's willing to answer they can answer

#

if you don't want to answer just dont

wet breach
#

Well I already stated both those events can fire

woeful crescent
#

both of which?

wet breach
#

the events you listed and are asking about

#

they all can fire for the same thing

woeful crescent
#

nah, im asking about the methods under PlayerInteractEvent

#

not separate events

sterile token
wet breach
woeful crescent
#

im asking which methods do what

past vapor
woeful crescent
#

like does the useItemInHand method used for breaking blocks or is it the other one

young knoll
#

CraftPlayer is the implementation

past vapor
#

aa

wet breach
#

useInteractedBlock takes whatever action with the clicked block and useIteminhand will apply durability stuff for whatever item is in hand when you were interacting with the block

woeful crescent
#

ahhhhh

#

kk

#

thx

wet breach
#

should read the javadocs

#

?jd

woeful crescent
#

not much in the docs

#

for that

wet breach
#

what I told you was from the docs, except for the itemin hand one, which is ambiguous only because it depends what item is in the hand at the time

#

if its a tool or item that can take durability damage it will apply that

woeful crescent
#

?

#

i just didn't see it huh

#

ok

past vapor
#

22.02 01:07:39 [Server] WARN java.lang.ClassNotFoundException: org.bukkit.craftbukkit.entity.CraftPlayer sad days

young knoll
#

Doesn’t craftbukkit still have the version in the package name

past vapor
#

dont think so but i'll give it a go

sterile token
#

You are using spigot-api that the problem

past vapor
#

I got it

#

I think

sterile token
#

Spigot jar its the one you get from building it with build-tools

past vapor
#

ffs

wet breach
sterile token
#

but my problem its that the player get disconnected

wet breach
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

wet breach
# sterile token but my problem its that the player get disconnected

well, the way I was telling you was you didn't need a player, you could just directly communicate with your servers via a plugin. Player connection isn't going to truly work because the loopback device can't communicate with the outside world, which means can't connect to mojang auth servers.

#

this isn't really an issue as you could just simply allow your player to connect regardless of auth

sterile token
#

No but i have worked with the fake player

#

And it still connected for 2500ms then it get auto disconnected

wet breach
#

most likely as I stated because of the auth stuff lol

sterile token
#

auth stuff?

#

Isnt just require handshake and login packet?

wet breach
#

well fake players need to be legit, unless you tell the server to let it connect regardless

wet breach
sterile token
#

oh i didnt know that part

wet breach
#

which the client needs to communicate with so that a session can be created

sterile token
#

I didnt know

#

But the client involve the mojan session?

#

or the launcher itself does it

wet breach
#

normally the launcher does it, but you can do it at the connection level. In either case however you would still need to communicate with the mojang auth servers

#

which can not be done from the loopback device

sterile token
#

Oh ok

wet breach
#

so, a way around it is you could instead allow your player to connect without fully authenticating so as long as it comes from 127.0.0.1. but I would put some kind of protection in place so you know for a fact it is your software player and not some other thing lol.

sterile token
#

ah ok

#

Thanks

#

You are one of that always help i really apreciated

wet breach
#

you would need a plugin on the bungee server to allow that to happen

past vapor
#

22.02 01:22:19 [Server] WARN java.lang.NoSuchFieldException: ping 😢

wet breach
#

because you need to tell the server yeah let the connection happen lol

wet breach
#

go to that post read it, there will be another link in said post in regards to NMS

#

and with that post combined, you should be able to resolve your problem

valid solstice
#

What event to use if i want to check if a player has a certain armor piece on?

wet breach
valid solstice
#

Because with InventoryCloseEvent, you can bypass the check by right clicking the armor

storm crescent
#

Is it possible to overwrite a bukkit method without making a subclass, if so how?

young knoll
#

Bytebuddy

storm crescent
#

Alright, thanks

wet breach
valid solstice
#

they can either put it on in their inv

#

or right click the armor, and put in on

#

and it seems to bypass the Invcloseeevent

#

is there a specific event that checks for both?

wet breach
#

just check on inventoryclick then?

valid solstice
wet breach
#

no?

valid solstice
#

the "armor put on" can also be bypassed if a dispenser gives the armor

#

how do i fix that

wet breach
#

dispenser has an event for whenever it dispenses

valid solstice
#

how about /replaceitem?

wet breach
#

that is a command, so you should be able to handle that easily

young knoll
#

There’s a library that adds an armor equip event

valid solstice
#

so i need to think of every possible way that a player can put on armor?

wet breach
wet breach
#

preventing interference

valid solstice
wet breach
#

sometimes there is, other times there isn't

#

and as Coll said above

#

you can also use libraries that add events

young knoll
wet breach
#

oh I guess we wait then lol

valid solstice
#

i hope it gets implemented

#

so i can use 1 event handler for armor instead of making a whole bunch

#

which i think maybe is inefficient

wet breach
#

it isn't that it is inefficient, just cumbersome to create all the code for the checks

valid solstice
#

exactly!

#

anyways thank you

wet breach
#

however you should become accustomed to such things though because ideally you should be preventing your plugin from working in unintended ways anyways or be used to introduce dupes 😛

cobalt tinsel
#

Hi so I need to count player hits, should I do it with EntityDamageByEntityEvent? If so, how could I count them?

wet breach
#

player hits of any kind?

#

or player hits in regards to specific combat?

drowsy helm
#

player on player hits, entity hitting players? wdym

cobalt tinsel
#

Combat*

#

lmao

#

Yea (player) e.getEntity()

cobalt tinsel
wet breach
#

Then the event you listed will work, just check if they are players and just make a method that counts the hits to each of them

#

you are going to have to create some kind of grace period where it is determined they are no longer in combat or whatever else

cobalt tinsel
#

yeah like int hits;

wet breach
#

well going to need a list or hashmap

drowsy helm
#

use a map

cobalt tinsel
#

Oh

#

Right

#

And then set hits to 0 after the Match ends

wet breach
#

but you are going to have to determine for yourself when combat is dictated as being over

#

so you know when to clear out that list/map

cobalt tinsel
wet breach
#

even so, the server doesn't have a mechanism in place that keeps track if a player is in combat or not

#

or when said combat is over

#

so you will have to create your own rules on that

cobalt tinsel
#

Yeah I have an event for that

#

MatchEndEvent

wet breach
#

most people use a time limit from the last hit

#

to determine when combat is over

sterile token
#

AnY HELP?

wet breach
#

or if the other player dies

sterile token
#

Someone tag me

cobalt tinsel
cobalt tinsel
sterile token
cobalt tinsel
sterile token
#

here its for plugin development

wet breach
sterile token
#

ah sorry

cobalt tinsel
sterile token
#

I got confused btw

cobalt tinsel
wet breach
#

and now confusion is gone hopefully

sterile token
carmine urchin
#

When making like an onjoin event where you need to give player certain items and also prevent those items from being dropped, should you create a separate class for every event? Like a class for onjoin, ondrop, and also a class that handles the items? or should you just stuff it all together

sterile token
#

Depend

#

On the context

#

for example i done a core

#

That contains multiple things

#

And i have one listener for data loading/unloading (onJoin, onQuit and onKick), the for managing the items i have another class called ItemListener

carmine urchin
#

Ahh

sterile token
#

Do ihave explained

carmine urchin
#

Ty yes that makes sense

sterile token
#

Allright no problem

#

have a lovely day/night

carmine urchin
#

u too!

cobalt tinsel
cobalt tinsel
sterile token
#

Who needing help?

#

I see another tag

hybrid spoke
tranquil viper
#

I am a little curious about hypixel skyblocks pets... anyone have any guides/links that can teach me about them (or floating heads in general?)

SS:

hybrid spoke
tranquil viper
#

ah it's an armor stand

#

I was just trying to think in my head what it could even be I don't know why I didn't think about that

#

xD

#

thank you, gonna go do some research >:)

hybrid spoke
#

np, hf

green spire
#

hey just wondering if i were to make an economy plugin but i want it to work across servers is there anything i have to do for it to work on servers in a bungee setup or do i just connect it to a mongodb and that should be good?

lost matrix
tranquil viper
#

If implemented properly mongodb should be good

#

for private ^

green spire
#

private use atm, possibly public but right now its only for my server network

tranquil viper
#

If you wanted it to work across servers just store the uuid and the balance of the player

#

boom

lost matrix
green spire
#

thats what i had a feeling of but i just wanted to confirm i wouldnt need to do anything special

green spire
#

and using plugins that depend on vault

lost matrix
#

You need to do some special stuff if you dont want your servers performance to tank

green spire
#

oh alright like?

lost matrix
#

Let me look into the src of vault to see if they have any async support by now.

young knoll
#

Vault doesn’t support async balance retrieval does it

#

Last I checked anyway

lost matrix
# green spire oh alright like?

This is probably what you should do: Use a cache like Redis or Hazelcast between your network and the DB.
There are 2 approaches.

  1. Have only the cache hold the data. Every data received should be considered stale instantly. You should use redis locks to make sure your data is eventually consistent.
  2. Every server has its own cache and you use Redis Topics to notify when a value needs to be changed. This could yield an even better performance but is also
    infinitely more complex.
vague oracle
#

Is there a way to get an entity from its int ID?

green spire
#

so i want it connected to redis instead of directly to the db?

#

i think i can do that

lost matrix
green spire
#

alright ill play around with that and see if i can figure that out, thanks for the tip 👍

lost matrix
vague oracle
#

I'm listening to outgoing packets for entity equipment to hide equipment it if they crouch, but I need to get the player object from the id (could also be a mob)

lost matrix
#

Hm i can only think of expensive ways at the moment

vague oracle
#

I found a protocol lib utility for it

lost matrix
vague oracle
#

But I can't tell if its more expensive than just looping though all mobs in world

lost matrix
#

Make sure it uses mapping internally and not loop over every entitiy XD

vague oracle
#

Another way is to maybe just put all crouched players in a map

lost matrix
#

Is it only for players?

vague oracle
#

ye but if the packet could also be a mob

young knoll
#

Isn’t there an easy way to get the entity from its id

lost matrix
#

Player starts crouching -> Add his id to a Set<Integer>
Player stops crouching -> Remove him from the set

young knoll
#

I thought there was

hybrid spoke
#

well

#

you would have to loop

#

otherwise you wont get every entity

young knoll
#

I thought it was just a map lookup

tranquil viper
#

Anyone have a good tutorial on StringLists in yaml files?

#

tried: plugin.enabledpvp.getStringList("enabled-pvp").add(player.getUniqueId().toString()); but it doesn't seem to want to add it to the string list

lost matrix
tranquil viper
#

maybe you can help me solve my problem then xD

desert loom
#

getStringList returns a copy.

lost matrix
tranquil viper
#

I saved it

#

When I try to access it later or manually look at the file it's not there

lost matrix
#

Dont use configs during runtime.
Load all your data when the server starts. From then on you use properly named variables and data structures/classes.
Then save everything when the server stops. You can also regularly save everything every few minutes if you like.

desert loom
#

you need to get the string list, modify it, and then set it back into the configuration using the set method or do what 7smile7 said.

waxen plinth
#

Do you need to do set afterwards?

desert loom
#

it returns a copy

waxen plinth
#

Okay then you would need to call set

#

But you should really just use pdc for this

#

Much easier

lost matrix
#

Actually just adding a Scoreboard tag would be super simple here.

#
  public boolean hasPvPEnabled(Player player) {
    return player.getScoreboardTags().contains("_pvp_");
  }

  public void enablePvP(Player player) {
    player.getScoreboardTags().add("_pvp_");
  }

  public void disablePvP(Player player) {
    player.getScoreboardTags().remove("_pvp_");
  }

  public void togglePvP(Player player) {
    if (this.hasPvPEnabled(player)) {
      this.disablePvP(player);
    } else {
      this.enablePvP(player);
    }
  }
#

XDD just came up with this idea

  public void togglePvP(Player player) {
    ((this.hasPvPEnabled(player) ? (Consumer<Player>) this::disablePvP : (Consumer<Player>) this::enablePvP)).accept(player);
  }
olive lance
#

can someone send a basic maven config with just spigot as dependency

lost matrix
olive lance
#

i do

lost matrix
desert loom
lost matrix
# olive lance i do

With this you can create a clean maven or gradle project for all the minecraft platforms

olive lance
#

does it require maven to generate the maven project

#

i need to install that too prob

lost matrix
#

Intellij has maven bundled but you should def install maven.
You just need to download the maven folder and then add the maven/bin directory to your PATH

olive lance
#

i am literally so clueless about maven

#

can the plugin generate maven project for an exiting project?

lost matrix
olive lance
#

it only depends on spigot if that matters

lost matrix
#

It will lead to inconsistencies because there is more to a clean maven project than just the pom.xml

olive lance
#

Also you say IJ has maven bundled, so can I create a maven project with that? or do i need to install it

#

happy tuesday

lost matrix
#

You dont need to install it but you should. *Its been tuesday for 6 hours for me already XD

olive lance
#

Lol

#

Whats an achetype

#

archetype

young knoll
#

Yugioh?

olive lance
#

maven project

lost matrix
#

Basically a template

olive lance
#

Ok i think i got it

#

made a new maven project

#

So does the pom.xml get automatically generated?

olive lance
#

its generated an src/main/java directory should i just overwrite the main/java with whatever my src folder has?

lost matrix
#

Click on your old src folder in IJ. Press ctrl + C. Click on your new src folder. Press ctrl + V.

olive lance
#

ok. should i move my config.yml to resources or does that matter?

lost matrix
#

Yes everything that is not part of your source code is now put in the resources folder. Like you plugin.yml and other files like configs.

olive lance
#

so its ok that the java folder is empty?

#

And how do you trigger the pom.xml to update the dependencies?

lost matrix
olive lance
#

ah ok i see

olive lance
#

Wheres that maven window

lost matrix
#

Top right corner for me

olive lance
#

goit it

#

view>tool windows>maven

#

hm

#

clicked that and my pom.xml is still missing spigot api

lost matrix
#

Did you generate a maven project or a minecraft project?

olive lance
#

maven project

#

guess it was supposed to be minecraft lol

#

im gonna go though getting late. ill do this later in the week

storm crescent
#

How do you update a player's uuid in the playerList? (for Bukkit.getPlayer())

young knoll
#

Probably reflection

lost matrix
#

Better disconnect him and change the UUID early in the handshake.

storm crescent
#

I tried setting the entity uuid and gameprofile but they dont seem to change the Bukkit.getPlayer() method

storm crescent
#

in an on join event

lost matrix
storm crescent
#

I see so would I just listen to the handshake packets and change the uuid there?

lost matrix
storm crescent
#

Alright thanks

wet breach
#

Login Success

#

is where the UUID gets set

#

but if you are trying to change the UUID you might break the session though

vagrant steppe
#

I would do PreLoginEvent

#

since there’s nothing else that logs in besides a player really xd

wet breach
#

you could put this under a PlayerEvents class

#

So (plugin namePlayerEvents)

#

Classes generally are capitialized

#

I wouldn't do per-event per class

#

I mean you can if you want

#

just you are going to have a lot of classes that contain probably just 5 or 10 lines of code and that is it

#

and you are going to have to register all those classes too

desert loom
#

might be better to name it PlayerListeners

wet breach
#

I didn't say it wasn't easy

#

Well there is a balance

#

I think 3-4 events in a class is fine

#

as long as they are related to each other in some fashion

#

like player events spanned across 3-4 classes would be perfectly fine

#

everyone has their preference. There really is no right way of doing something as long as it compiles and runs 😛

#

I don't like having super long classes myself

#

but I also don't like needlessly creating classes either that doesn't contain much lol

#

Anyways do what you think is right. Most projects it really doesn't matter unless you intend to have a bunch of people contribute to it

desert loom
#

yea that's a fine way of doing it.

humble heath
#

.

wet breach
#

?DI

#

!DI

#

?DependencyInjection

#

?di

undone axleBOT
golden kelp
#

Which event should I use if I want to cancel the event when player tries to fix a item In a anvil

desert loom
#

the code you posted earlier is in package private.

#

the constructor has to be public not the variable.

#

the variable can be whatever visibility you want it to but it's likely better to keep it private.

#

encapsulation is nice

#

if you change that to private you couldn't instantiate it outside of that class.

ivory sleet
#

Encapsulation doesn’t mean declare everything private

golden kelp
#

what event is fired when a player tries to fix/enchant something in an anvil

ivory sleet
#

It means that instance variables are only directly changed within the class itself, any dependency that interacts with the instance outside must use its methods it exposes by the type

desert loom
#

I meant the main field. It's up to you if you want to keep it private or not, I was just saying it might be better since I doubt you want anyone having access to that field.

#

the public Main pl; field

ivory sleet
#

^

#

Yeah to some extent if you use the preprocess event

#

but else not really unless you do some really intricate stuff which you probably shouldn’t do anyway

desert loom
#

that won't work to block /plugins and /pl that well.

#

since you can type /bukkit:plugins or even /plugins <any string beyond here> to bypass what you put.

wet breach
#

could just use permissions

#

bukkit.commands.plugins

#

sure

#

stops them from using the command lol

#

there is other commands you can block too from the server, they all have permissions

#

most of which are just under bukkit.commands node

#

most people don't realize there is permissions attached to the commands bukkit/spigot provides even the vanilla ones too

#

hence you get all these plugins trying to block commands that already are blockable with just a permission plugin 😂

#

you can, depends what it needs to do

#

but in general you should make your plugin handle server reloads as well

#

not just a reload command for your plugin 😉

#

the reason people say not to do this

#

is because most devs don't code their plugin to handle it like they are supposed to

#

the more people that learn to handle such things, the better 🙂

#

server reload nulls out objects

#

like player stuff etc

#

so you need to recreate your objects or check to ensure they are not null

#

and basically have a way to correct a null object

#

most plugins listen for onplayerjoin to add them to a list

#

but on a server reload you won't have player join event

#

because the players are already connected 😛

valid solstice
#

Hi,
What is the best way to implement a shared damage system? Something like if Player1 gets damaged, 50% of that damage would be negated and transfered to Player2

mental zodiac
#

didnt tested it

wet breach
#

I wouldn't. You can end up with too many classes trying to be organized lol

#

but it is up to you, as long as it is easy to understand and intuitive you are generally fine

#

anything that might be questionable to someone, add some comments before/during/after the method where it seems feasible to document something

#

main key is documentation and comments. Those help just as much as having organized classes and intuitive naming schemes

#

this is how I do my commands

#

just need to handle when the sender is the console and not just check for a player lol

#

you should only check if the sender is a player if the command being ran is dependent on such things

desert loom
#

I think most permission plugins allow you to prefix a permission with - to negate it

#

so like -<permission>

wet breach
#

or the adopted one that permission plugins have taken to using

#

always nice to have something work on the first try

#

returning false gives them the message automatically that they don't have permission

#

I generally return true in all the methods for the if's the last outer return false if nothing matched

#

exactly

#

hmm wonder if that got changed

#

or maybe its dependent on the permission plugin being used

#

I don't use luckperms

#

I use groupmanager which many here will despise you of using 😛

#

well I have a customized version of groupmanager

#

it is open source after all

#

I use GM because it works and does what I need it to without much fuss

#

yeah that is really what it comes down to

#

I just don't have a need for such a feature

#

some people like that which is understandable

#

and all the more reason to go use something like luckperms

#

but, I don't need all the frills 😛

#

basically GM is what you would think of Debian

#

and luckperms ubuntu the go to Debian distro

#

There are people that like Debian vanilla because it doesn't have all the frills that they don't use or care about anyways

#

where as ubuntu adds quite a lot of useful things out of the box

#

well, was just an analogy anyways 😛

valid solstice
#

what is the difference of getvalue() and getdefaultvalue()?

#

whoWasHit.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()

whoWasHit.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()

#

entity damage by entity event

#

yup

#

no im not getting the damage

#

im getting the current health

#

of who was hit

#

sorry if it confused you

wet breach
valid solstice
#

so getdefaultvalue will always be 20 right?

#

why do more work when i can just get the value directly from getAttribute xD

wet breach
valid solstice
#

alright thanks

wet breach
#

could do that, but you shouldn't worry what the default is either

#

default just implies that is what the server is configured for

#

and you should always respect the default regardless of the number 😛

#

just have to ensure you don't encounter negative numbers unexpectedly is all

#

otherwise your players die 🙂

valid solstice
#

Player#getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() is the same as Player#getHealth?

wet breach
#

getHealth() should return what the players health currently is

valid solstice
#

wait

#

wtf

#

ok im confused

#

getValue() gets whatever the value is even if its not the default one since it can be changed

valid solstice
#

so isnt that the same as getValue()?

wet breach
#

you can change the max health number

valid solstice
#

oh i see what you mean

wet breach
#

getValue() returns whatever that number is, it can be the default number

#

or a different number that it was changed to

valid solstice
#

mhm yup, thanks

sharp flare
#

getValue gets the max health the player has if he has bonus hearts, etc, getDefault always returns 20 which is the default vanilla

zealous osprey
#

I have a question which I cant seem to find an answer anywhere for:
I am registering commands via the commandmap, they work, but then trying to get an instance of PluginCommand from them doesnt want to work, I went trough the map, the commands are in there, but just not as PluginCommands, just as regular Command type. Tried to convert it, but that doesnt seem to work either.
Looked into other plugins that do something like this, but most I looked at do it in very different ways to each other and for me not very understandably.
Just for the sake of completion, cause this might be easier, idk, I want to register a tabcomplete to the command, if that helps, this is my final goal anyways.

blazing rune
#

Is it possible to runtasktimer once?

lost matrix
lost matrix
wet breach
#

these days vault isn't really needed for permissions

#

query the permissions plugin being used

tall dragon
#

whats even the difference to just using Player#hasPermission?

wet breach
#

luckperms and pex are the common permission plugins in use they have API's

tall dragon
#

ah i see

wet breach
#

they have a wiki

#

and documentation

lost matrix
#

Permissions are used to verify immediate action of a Player. Why do you need to check the permission of an offline player?

#

Elaborate pls

wet breach
#

if it is your voting plugin, why not just keep your own list of players that have been given permission?

tall dragon
#

or you could proccess the vote when they log on

wet breach
#

if every user that has ever joined has been given permission

lost matrix
#

Still not enough information. Its probably better to store the players name and wait for his next login.

wet breach
#

then why would you need to check if they still have permission if they are offline?

tall dragon
#

why would you need to

wet breach
#

you just said this

tall dragon
#

just wait for them to log on

wet breach
#

isn't it pointless to check perms if everyone has perms?

#

then query their rank

#

should be fairly easier to do that then to worry about permissions

lost matrix
#

What if someone doesnt use luckperms?

wet breach
#

this is for their own personal needs

lost matrix
#

Ah i see

wet breach
#

if you are using luckperms just use mysql DB option with it

#

then with your vote plugin, query the DB

#

for their rank

#

no need to hook into anything at that point except just use some SQL stuff 😛

lost matrix
wet breach
#

that is what DB's are for

#

why would I go through middleware

lost matrix
#

You joking, right?

wet breach
#

no? Not hard to query a DB, acting like as if its some big risky thing o.O

#

I am not going to use some large API to just query a DB with a simple sql connection

#

nor would I recommend for someone to do so either

lost matrix
#

It fking is. What if the scheme gets migrated to a new one?
Do you then look into the db and write your quries new instead of doing nothing because the API abstracted that away from you?

wet breach
#

you know when the scheme changes

#

you shouldn't be allowing something to change the DB freely without your knowledge

lost matrix
#

Yes. And its better if you dont have to react on changes because you use an abstract API anyways.

wet breach
lost matrix
#

Its like measuring the currencies of your calculator instead of using the lcd display...

wet breach
#

If you like to let software change your DB without your knowledge that is on you and poor security practices

#

anyways you can even setup a function on the DB too

#

so you don't actually have to query anything

#

you could just invoke the function instead

lost matrix
wet breach
lost matrix
#

I really hope you dont work in the backend...

wet breach
#

just because it is a microservice doesn't mean it is better

#

I do

lost matrix
wet breach
#

ok what are the several reasons

#

other then DB scheme

#

which isn't really a big concern since no writing is happening

blazing scarab
#

I agree. Database should be an implementation detail

tall dragon
#

its a variable

wet breach
#

its probably at the top

lost matrix
#

Consistency. Metrics. Not breaking SOLID principles. Modularity.
Basically everything that makes out micro service architecture.
If everyone uses this services abstract API then you just have to swap out the implementation
if you want to change something on the data structure. But if 20 other services access this DB
by hand then 20 more services need to be updated.

tall dragon
#
wet breach
#

someone elses metrics is not a valid reason to use someones api

#

consistency sure, but again we just checking for two things combined, user to get their rank

#

solid principles? not sure which you infer

#

Modularity? What modularity? This isn't some large project where we got tons of moving parts

lost matrix
tall dragon
#

thats pretty likely ye

wet breach
#

metrics is not a fact of anything in why you should use it

lost matrix
#

Anyways this is not a fruitful conversation. Lets just move on. 👍

wet breach
#

Basically you are advocating that this large API should be used to query two small data pieces and I would argue bypassing it would be far more efficient in the long run then using said API

#

I am sure you could probably setup a test to prove that bypassing it would be more efficient even scaling wise

#

simply because we cut out the middle man

ivory sleet
#

Depends on what your concerns are imho

lost matrix
#

Yes you can cut out all your middlemen if you like that.
But lets just move on.

wet breach
#

a microservice is only as good as the service it provides, if it isn't good enough then you simply don't use it.

#

in this case it is just too much

#

in my opinion and I wouldn't use it

ivory sleet
#

If it’s about speed then maybe, but in the long run having layers (such as an api) which separates concerns makes it simpler and more robust against changes

lost matrix
lost matrix
#

I dont care anymore

wet breach
#

of course you don't but I don't tell businesses to buy something they don't need either. Not that luckperms costs anything. but still same principle

ivory sleet
#

An api allows for the actual concretion to scale and change whilst still supporting consumers

lost matrix
#

pls just stop your rant and lets move on

ivory sleet
#

Very nice

cold field
#

Hi guys, I'm trying to use a scoreboard to save player data for a minigame but I've some questions. First of all is it a good practice?

ivory sleet
#

Cant understand how you don’t want robustness in design

lost matrix
#

Its an observer of data

cold field
#

So, if I use it to count player kills is ok, right?

lost matrix
#

Its ok if you use it to display player kills.

cold field
#

Hum, ok. Can I ask why it's not recommended to use it?

#

Slow?

lost matrix
# cold field Slow?

Not as slow that it would matter. Do you want the data to persist over server restarts?

cold field
#

Nope

blazing scarab
#

It is harder to manage and wiping data, comparing to relational database

#

Use pdc ftw

cold field
#

Uh, you are right XD

lost matrix
#

You should use a centralised way of storing your data. Maybe a PlayerKillManager singleton that
hosts a Map<UUID, Integer>. Or if you want to store statistics then a PlayerStatsManager.

cold field
#

OK , what if that manager uses PDC?

lost matrix
#

This way sorting and doing a top list is possible. PDC doesnt provide that luxus.

cold field
#

Like a facade to easily access stats

#

OK ty all of you guys

lost matrix
#

Or just set it to 0 at the start of whatever you are tracking

#

The client does that sorting. You just send it a bunch of Strings.

ivory sleet
#

Client does

wet breach
#

you could either use OfflinePlayer to get the UUID or you could query mojang servers to get UUID. Generally better to use OfflinePlayer since it already has mechanisms in place if the user doesn't exist to query mojang servers as well as built in rate limits since mojang servers only allow so many requests every so often.

#

Bukkit.getOfflinePlayer(string).getUniqueId();

#

players name

ivory sleet
#

Yes

#

It’s not deprecated for removal

#

Because it might make a request to mojang

#

To lookup uuid based on name

wet breach
#

because generally you should use UUID to get a offlineplayer object or player object, however sometimes that isn't feasible. It is basically warning you that a players name can change

#

when a player is offline, they can change their user name via mojang account settings

#

this is what the deprecation is warning you about

#

however this doesn't really apply to you

#

because you want the UUID anyways

#

not that you are using player names only to store info etc lol

#

the method that is deprecated is getOfflinePlayer(String) even if you are using methods provided by offline player, that specific method is deprecated and instead should use getOfflinePlayer(UUID) but you are getting their UUID anyways, therefore the deprecation doesn't apply in how you are making use of the method. Also the reason why that method isn't marked for removal because it is needed otherwise how would we lookup UUID's of players 😛

lost matrix
#

Its not deprecated because it gets removed or is draft but simply to make sure people use UUID for retrieval whenever possible. So dont be worried.

#

getOfflinePlayer will automatically check for online players first

wet breach
#

Player player = Bukkit.getPlayer(username); probably should change this too

#

for a voting plugin you should always assume players are offline

#

you can easily check if they are online and convert to a Player Object from offlineplayer

#

as it provides a method to do so as well as you can cast

#

you can cast

#

but if the player isn't on the server though

#

you are not going to get a valid player object regardless

#

not without some hacks

#

doesn't luck perms allow you to query users regardless?

#

don't think it requires an online player to use its api to query permissions

eternal oxide
#

all permission plugins allow you to query an offline players perms, IF you use their API

lost matrix
eternal oxide
#

eww, you need shooting

wet breach
#

but it seems they are having more troubles using the api then making a simple sql query though lol

lost matrix
#

Dont bother getting an online player directly

wet breach
#

its what I said above

#

should be using OfflinePlayer until you check and know they are actually on the server

#

then you could cast it to Player, but I don't really see where they would really need to do that though

#

OfflinePlayer is all that is needed

lost matrix
#

I mean if he wants to give him immediate feedback then he can call isOnline() and then getPlayer()

#

But other than that its not really needed, right

visual tide
#

Us vault

#

Use

#

perms.has()

#

But

#

U gotta run that async

#

Or luckperms will complain

wet breach
#

using vault isn't needed and just adds another api into the mix, since all vault is going to do is query the permission plugins api anyways

visual tide
wet breach
#

means creating a thread

#

the spigot api has methods for this to make it easier to do things async

lost matrix
visual tide
wet breach
#

without another thread, it is just sync o.O

lost matrix
thick tundra
#

Hello, im currently making a plugin and im wondering if anyone can help me with the following issue:
I have an instance of an entity in my class, but once the server unloads that entity i cant use that instance of the entity anymore. anyone here knows how to either keep the chunks at the entity loaded, or how to make it so the refrenced entity doesnt change so i can keep using the object?

lost matrix
#

Async does not mean multi threaded

lost matrix
#

Best example is FAWE. Its async but everything is happening on the main thread.

thick tundra
#

yes but im updating the entity every tick, (armorstand animation).

wet breach
thick tundra