#help-development

1 messages · Page 2286 of 1

brave sparrow
#

setDisplayName

glossy scroll
#

i think the whole player/uuid debate is pretty pretentious lol

#

if youre lazy use uuid

#

you can get away with player

brave sparrow
#

It’s a case of best practices to minimize the fallout if you slip up

dim palm
ember estuary
#

isnt player for if ur lazy

dim palm
#

just chat name

ember estuary
#

cuz with uuid u need to do extra work to get the player object

brave sparrow
#

If you want to change their name tag that’s a whole other ordeal

lost matrix
#

If you want to be extra then use a
Map<WeakReference<Player>, V>

quaint mantle
#

Ok thanks

ember estuary
#

does that delete the player when he leaves?

#

like remove from map

drowsy harness
#

is it possible to add a pathfinder goal to a existing entity? (without creating your own)

lost matrix
lost matrix
#

it will get collected by the gc

glossy scroll
#

the whole idea of soft references is that theyre collected

ember estuary
#

ah, so can take some time

glossy scroll
#

whereas if it was a hard reference your map instance would keep it in memory

dry forum
ember estuary
#

isnt each player always in memory anyway?

glossy scroll
#

well i mean

ember estuary
#

o.O

glossy scroll
#

if you keep the player object loaded once theyre no longer online

#

the player is still in memory

ember estuary
#

well, i said remove on disconnect

glossy scroll
#

you need to nullify it for it to get collected

ember estuary
#

if u remove on disconnect i dont see a problem

glossy scroll
#

also smile i apologize for the spam but you never really got back to me on this

tall dragon
#

if you dont want to rely on disconnect event

#

you can also use a WeakHashmap

lost matrix
brave sparrow
glossy scroll
#

ya ok thats what i figured

#

still confused why it behaves differently than my example

#

whatever

lost matrix
glossy scroll
#

mmmm yes that would make sense

#

it also doesnt help that my example was compiled in a different environment

solid jungle
glossy scroll
#

compared to the plugin

brave sparrow
brave sparrow
worldly ingot
#

Players have a display name as well and will be used in chat

brave sparrow
#

^

worldly ingot
#

The tab list as well iirc

brave sparrow
#

¯_(ツ)_/¯

solid jungle
dry forum
brave sparrow
#

Ok so it’s your velocity application that doesn’t work

#

Oh

#

You never set the item’s velocity lol

dry forum
#

oh my god im dumb ty

tall dragon
#

coming back to this. you can actually do it but you have to be really certain you remove the reference

lost matrix
#

But as soon as you have to serialize your data you will be glad that you dont have a Player variable somewhere.

tall dragon
#

the non-usage of player objects comes from the fact that if you fail to remove a reference the garbage collector will not gc the player object. and anything it relies on this can include whole worlds

brave sparrow
#

It’s a matter of good practice more so than anything else

ember estuary
#

i see

tall dragon
#

you could approach the problem by using a WeakReference

ember estuary
#

so you're basically expecting human error

brave sparrow
#

You avoid the risk if you don’t store player objects

glossy scroll
#

yea i absolutely agree with making sure your player references are removed and that you dont serialize them

glossy scroll
#

just takes up less memory

brave sparrow
#

That’s the point

#

Lol

glossy scroll
#

right but memory leak either way

brave sparrow
#

You avoid the risk of dragging around the huge amount of data a player object drags around

glossy scroll
#

id prefer no memory leak at all

ember estuary
#

nah, no memory leak with uuid

#

cuz a string more doesnt matter

glossy scroll
#

uuids arent strings

ember estuary
#

but with player objects, the whole object will stay in memory

#

they arent? oh

glossy scroll
#

nope

glossy scroll
#

theyre two longs

ember estuary
#

always thought they're just strings

lost matrix
#

uuids are just 2 longs. So 128 bit

ember estuary
#

well, basically the same then

#

no memory leak

glossy scroll
#

well no

brave sparrow
#

It’s still a memory leak

glossy scroll
#

a memory leak will eventually happen

#

and it does happen

ember estuary
#

how is it

brave sparrow
#

It’s just of a much more negligible size

glossy scroll
#

just less memory being leaked

ember estuary
#

well yea

brave sparrow
#

You’re leaking 128 bits

ember estuary
#

but that doesnt matter

glossy scroll
#

im of the opinion you shouldnt have memory leaks to begin with

brave sparrow
#

The goal is to avoid memory leaks but you should also write code such that if a leak occurs it’s not massive

ember estuary
#

ok yeah

lost matrix
#

You guys are missing the serialisation aspect

glossy scroll
#

using a bigger object will let you fix it faster though 😛

ember estuary
#

i never needed to serialize anything

glossy scroll
#

when i need to have an object serialized, i do use uuid, yes

brave sparrow
#

Same

glossy scroll
#

that is how its intended

ember estuary
#

when do you need an object serialized?

glossy scroll
#

store in DB

#

config

#

etc

ember estuary
#

ah

glossy scroll
#

serialized just means bringing it out of the code

ember estuary
#

well yeah, not gonna store a player reference in the db LOL

#

xDD

brave sparrow
#

Whenever you’re saving it or serving it

glossy scroll
#

well yea but typically serializing in this case refers to using osmething like gson

#

you want to avoid using a player reference in an object you serialize with gson

brave sparrow
#

Player is ConfigurationSerializable

#

So you can

glossy scroll
#

unless you denote it as transient

ember estuary
#

But you're weird if you do

#

xD

glossy scroll
#

unsure if ConfigurationSerializable respects transient

#

yet again i dont really use it

ivory sleet
#

I mean you choose what to serialize with it

#

(Like you manually have to put stuff into a map)

lost matrix
#

garbage

ivory sleet
thorn crypt
#

Hi, when my server load I got 6 times the same error in my console but I don't know why it says "unkonwn world" since I don't load location

https://pastebin.com/hFgZiqRz

quaint mantle
#

?whereami

lost matrix
#

lol

brave sparrow
#

Speak of the devil lol

lost matrix
thorn crypt
#

if (this.getConfig().contains("data")) {

quaint mantle
#

Send main class

brave sparrow
#

^

quaint mantle
#

Why are you dming me it

delicate lynx
#

bruh

thorn crypt
#

Cause I can't send it

#

here

lost matrix
delicate lynx
#

?paste

undone axleBOT
delicate lynx
#

copy and paste it there

glossy scroll
#

?verify

quaint mantle
#

#verify

brave sparrow
#

They sent pastebin links so they clearly can send links

#

That must not be the issue if there is one

thorn crypt
delicate lynx
#

were they trying to attach the fucking java file or something

quaint mantle
#

yes

smoky oak
#

no it now recognizes language

#

and makes that the ending

quaint mantle
smoky oak
#

looks java to me

quaint mantle
delicate lynx
#

oh no

#

what is with the casting

quaint mantle
#

Looks like you need a dataclass

brave sparrow
#

My guess is that the issue is the spawn

tall dragon
#

storing players as string?

ember estuary
#

UUID? nah
Player Object? nah
String? Hell yeah

#

xD

tall dragon
#

lmao

#

that's detrimental to performance

lost matrix
#

Lets just use Map<Object, Object> from now on

tall dragon
#

uuid's hashcode & equals check are so much faster

delicate lynx
#

my brother in christ please use proper logging and not the ConsoleSender

quaint mantle
#

@thorn crypt you should completely restart your project and let us walk you through it

brave sparrow
#

This sounds like a job for

#

?learnjava

undone axleBOT
delicate lynx
#

wait can you do contains() to check if a section of a config exists?

#

I never tried that

lost matrix
delicate lynx
#

even better

tall dragon
smoky oak
#

considering HashMaps and StringBuffer (and other stuff with an initial capacity), how much time does it cost to increase the object's capacity compared to initializing it with a smaller capacity?

#

in other words

#

is it advisable to overshoot the initial capacity

ivory sleet
#

R u doing multithreaded stuff? Else use StringBuilder

smoky oak
#

logger

ivory sleet
#

and if you are, you might wanna go with ConcurrentHashMap

brave sparrow
#

Hashmap increases by a power of 2 each time it resizes

smoky oak
#

code example used StringBuffer

ivory sleet
#

Yes but it is synchronized wth the traditional way by the means of thread safety

smoky oak
#

ah

smoky oak
brave sparrow
#

A concurrent hashmap

#

The name kinda gives it away

ivory sleet
#

^

#

But since you seem to be doing stuff non async, you probably dont need StringBuffer neither ConcurrentHashMap

#

Anyway both use System::copyarray iirc

#

Which is a native call under the hood I believe

#

Thus is quite fast with little overhead

smoky oak
#

sounds like a complicated way of not having to lock a code snippet

lost matrix
smoky oak
#

im more a red kinda guy

quaint mantle
smoky oak
#

also my memory is atrocious

#

so i cant remember if i asked this before

lost matrix
#

PS: Thats a möbius strip

quaint mantle
#

Morbius

ivory sleet
#

But well moterius if you can predict the rezise and average size specify the load factor as well as the initial capacity

smoky oak
#

oh for fucks sake

brave sparrow
#

It’s designed for multiple threads to be reading and writing concurrently

smoky oak
brave sparrow
#

For high throughput in a highly concurrent application

quaint mantle
lost matrix
ember estuary
#

What is the difference between
Map<WeakReference<Player>, V>
and
WeakHashMap<Player, V>
?

quaint mantle
#

Does that even work

ember estuary
#

which

quaint mantle
#

First

#

I dont even think you would be able to access it

ember estuary
#

idk, @lost matrix sent it

#

i always use the second

lost matrix
#

You should use WeakHashMap.

smoky oak
ember estuary
#

ok xD

lost matrix
#

The one ive sent makes no sense

ember estuary
#

haha

#

alright

smoky oak
#

I'm trying to do something to the effect of this and am a bit curious why they used StringBuffer instead of String

public class LogFormatter extends Formatter {
    @Override
    public String format(LogRecord record) {
        StringBuffer buffer = new StringBuffer(256);

        return null;
    }```
#

i have to format my log output for the log file

ivory sleet
#

Because many Java devs were and still are oblivious to the fact that StringBuffer is synchronized

#

So they use it cause well, it does appear to function the same as StringBuilder

#

(Which is true, just a bit slower)

#

Because every append method on it is synchronized

#

Thus you need to flush local registries

smoky oak
#

should i just throw back an append chain then?

ivory sleet
#

And contraint jit and compiler from reordering and optimization

smoky oak
#

uh what?

ivory sleet
#

Well, using synchronized ensures a memory order

ember estuary
#

How can I use colors in player.sendTitle() ?
Do i have to do it with §3 etc. or is there a cleaner way?

ivory sleet
#

Which decreases the amount of optimizations java can apply

#

Thus you shouldnt be using StringBuffer unless necessary

ivory sleet
ember estuary
#

Thats what I use for messages, and then use the Components to build them

#

But dont see any sendTitle there

ivory sleet
#

Yeah

#

hmm maybe with ChatMessageType?

ember estuary
#

ah

ivory sleet
#

(:

smoky oak
#

wait, would that even matter here? I mean, could there even be issues with just throwing back a String consisting of log level, message and time?
Considering how you talked, im guessing that compiler optimizations might readjust the order in which those are extracted from the record, but would that even affect the return value in any way

ember estuary
#

Looks like theres only those 3 :(

ivory sleet
#

It doesnt matter here, but synchronized will still end up locking the damn buffer, and it will force local registries to flush

#

so it is gonna affect you performance wise

smoky oak
#

when should i use synchronized objects then, aside from objects accessible to multiple threads

ivory sleet
ember estuary
#

I thought spigot added Title support there in the new versions, but looks like a no :/

#

sad

ivory sleet
#

when you only want one thread to safely mutate some variables

smoky oak
#

its that racing thing right

brave sparrow
#

A thread race?

#

Lol

smoky oak
#

if two things try to read or write to the same variable issues might occur

#

like add one

brave sparrow
#

Yeah a race condition

ivory sleet
#

I mean you can use synchronized to avoid indeterminacy when threads race

ember estuary
#

Is there any Feature Suggestions kind of thing for spigot?

smoky oak
#

they grab both the number and both return that number to the variable

ivory sleet
#

But usually you wanna go with a ReentrantLock or do the operation atomically

smoky oak
#

however since they got the number before the other thread returned it the number was added to once not twice

#

hence synchronized blocks

#

'only one thread may enter'

brave sparrow
#

Which is not always what you want

#

There are more complex locking patterns

#

Like the ReentrantReadWriteLock

gentle quail
#

How could I get a players balance from their username, using the getBalance method in the Vault API?

ivory sleet
#

Yea, but assume you do change some variables’ value based on its old value, we can often perform a release/acquire compare and swap operation instead of synchronized (You’d end up using AtomicReference or AtomicFieldUpdater)

#

Since synchronized is more performance demanding

dry forum
#

how can i get the block in front of an entity? (not a player so i cant use eyelocation or anything) i cant just add to x or z since it could be eather going x or z

smoky oak
#

call the raytrace method

brave sparrow
#

Most entities have eye locations

smoky oak
#

^

dry forum
eternal oxide
#

Entity#getLocation().add(entity.getLocation().getDirection()).getBlock()

smoky oak
#

that should still have a direction

brave sparrow
#

Then what does “in front” mean?

#

And yeah it should still have a direction of some kind

dry forum
#

the block in front of the dropped item like if a player dropped it or smthn for example

gleaming grove
#

Hi I have an issue with clearning queue inside runTaskTimerAsynchronously the error
i'm getting is ConcurrentModificationException. Any idea how can I deal with it? Bascially task are comming from Websocket thread and need to be handle in Spigot thread

#
{
    private final Queue<Consumer<WebSocket>> tasks;

    public ExampleHandler()
    {
        tasks = new LinkedList<>();
        Bukkit.getScheduler().runTaskTimerAsynchronously(FluentPlugin.getPlugin(), () ->
        {
            try
            {
                for (final var task : tasks) {
                    task.accept(null);
                }
                tasks.clear();
            }
            catch (Exception e)
            {
                FluentLogger.error("FluentTask error",e);
            }
        }, 0, 1);
    }

    public void addSpigotTaskAsync(Consumer<WebSocket> task)
    {
        tasks.add(task);
    }
}```
dry forum
#

the direction its facing

brave sparrow
#

If the item just spawns in, what does “in front” mean?

ivory sleet
brave sparrow
#

getLocation().getDirection() will get you the direction the item is “facing” but that won’t necessarily mean anything

dry forum
#

ill try it to see if it works

smoky oak
ivory sleet
#

You probably wanna go with a data structure that supports concurrent operations

brave sparrow
#

Or synchronize it

ivory sleet
#

Yeah that too is an option

gleaming grove
brave sparrow
#

That’s not going to slow your server no

gleaming grove
brave sparrow
#

Unless you have a deadlock

ivory sleet
#

Yes but concurrency is expensive sometimes at the cost of providing higher throughput

ivory sleet
#

You have to remember runAsync on the bukkit scheduler pushes a task to a cached thread pool

gleaming grove
#

So ConcurecyQueue would be good in case there will be about 50-60 tasks every second?

ivory sleet
#

You do have some options, like LinkedBlockingQueue, SynchronousQueue and some other implementations

#

Its worth looking at the javadocs

#

To see which one will fit your needs more pertinently

gleaming grove
#

ye I've never been much into this topic

dry forum
visual tide
#

you can raytrace on any entity iirc

eternal oxide
#

How are you deciding what is "front"?

dry forum
eternal oxide
#

Stairs has a direction

dry forum
#

yes?

eternal oxide
#

get teh BlockData, cast to Directional

dry forum
#

uh

eternal oxide
#

it then has a getFacing() method

dry forum
#

but then how could i detect if the item is at the stairs/collides with it so it goes up

eternal oxide
#

if its on teh stairs (the block below it is a stair)

#

push it in teh direction of the stairs

#

or the opposite, depending on up or down

dry forum
#

yeah ik but

#

how can i check if the item is at the stairs

eternal oxide
#

at teh stairs?

#

its either on the stairs or its not

dry forum
#

yeah but items cant go up stairs on their own so i need to check if the item is in front of the stairs

eternal oxide
#

why in front? If you are doing a conveyor it should be ON the stairs to be moved, not in front of

dry forum
#

items cant go up stairs on their own it acts like a normal block it will stop right before the stairs

eternal oxide
#

unless you want stairs to pick up items that are dropped in front of them

#

If an item is dropped ON a stair you can push it in any direction you want. I've no idea what you keep refering to in front of

#

are you sliding items along the floor?

dry forum
#

they go along a conveyer so yeah sort of im applying a velocity

#

and items wouldnt be dropped on stairs

eternal oxide
#

ok, so you already have a direction from teh applied velocity on the conveyor

dry forum
#

yes

eternal oxide
#

Velocity being a vector...

#

if (Tag.STAIRS.isTagged(entity#getLocation().add(velocity.normalize()).getBlock().getType))

#

then you are in front of a stair

dry forum
#

i dont have the stairs as a variable though? or do i not need it?

#

oh nvm

eternal oxide
#

you can store teh block in a variable if you want to use it for its direction later

dry forum
#
                                Bukkit.broadcastMessage("wr");
                            }``` says its a boolean but i need a material to see if its a stairs
#
  • purpur stairs
eternal oxide
#

Tag is all stair blocks

#

if you only want a specific type, then remove the Tag

#
if (entity#getLocation().add(velocity.normalize()).getBlock().getType() == Material...))```
dry forum
#
                                Bukkit.broadcastMessage("wr");
                            }``` doesnt work 😢  same issue as before it only works like 1/5 of the time
#

no errors

eternal oxide
#

That code will detect a stair block in front of the items you are applying velocity to.

#

You then need to adjust your velocity to take it up the stairs

dry forum
#

uh alright ill try it thanks

eternal oxide
#

just increate teh Y component of the vector

#

after you detect the stairs

dry forum
#

ok tysm

echo basalt
#

Hey, what's the NMS method that does mob movement collision?

twilit roost
#

Is there Fly To Pathfinder goal?

frozen thorn
#

Hello, I don't understand the deep search of ConfigurationSection#getKeys

eternal oxide
#

getKeys(false) gets JUST the top level keys.
If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc). These will be in a valid path notation for you to use.

frozen thorn
#

oh okay ty

#

is it possible to get directly a Map<Material, Integer> from this or I need to loop every Materials and get their Integer?

#
    blocks:
      - OBSIDIAN: 20
      - DIAMOND_BLOCK: 20
valid folio
#

Some one help

#

I was working on that for whole 4 hours

#

$this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);

#

That line

#

and

#

yeah idk

eternal oxide
ornate mantle
#

how do i get the contents inside a configurationsection as a string

river oracle
ornate mantle
#

no i dont want a specific path

#

i wanna print the entire thing

river oracle
#

ConfigurationSection#getKeys(false) gets a full list of keys

ornate mantle
#

not the keys 💀

#

is there a way

#

to print the entire section as it is

#
deaths:
  1:
    - effect: speed
      multiplier: 12

    - effect: haste
      multiplier: 10``` 

i have `deaths.1` as the configurationsection
#

is there a way to print everything inside it

river oracle
#

🤷‍♂️ loop through the keys

#

the docs are here couldn't find anything else useful other than keys

ornate mantle
#

mate ive looked through the docs

river oracle
#

then why bother asking you should have your answer

#

getKeys is your best bet looping through it will end up working pretty decently

#

if you have a specific format to be followed you can filter for that to ensure errorless execution

tranquil dome
#

Currently I am cancelling the ProjectileLaunchEvent when a snowball is thrown, but the snowball is still consumed. How can I cancel the item from being consumed?

eternal oxide
#

No item should be consumed if you cancel the event. It runs before teh snowball is removed

tranquil dome
#

Well, it does consume the snowball for me. In EntityShootBowEvent I can cancel it, update inventory and no item is removed. For ProjectileLaunchEvent this is not the case. Should I perhaps check in PlayerInteractEvent if the player is right clicking a snowball, then cancel it?

eternal oxide
#

One sec. opening IDE to terst

wet breach
eternal oxide
#

ok I just tested it and cancelling works. It stops a snowball being consumed

tranquil dome
wet breach
#

you don't need to know the slot

#

there is api methods to find the stacks of snowballs 🙂

eternal oxide
#

Literally this stops the snowball being consumed```java
@EventHandler
public void event(ProjectileLaunchEvent event){

    Bukkit.broadcastMessage("Cancelled");
    event.setCancelled(true);
}```
wet breach
#

anyways it seems though it should stop it from being consumed, I also assume that only applies to newer versions and not older versions either

eternal oxide
#

It flashes to 15 for a second and is instantly back to 16

tranquil dome
tranquil dome
eternal oxide
#

Interesting. Changing a players skin also causes their permissions to be wiped

wet breach
#

yeah older versions like 1.8 you have to put the item back into the inventory

wet breach
eternal oxide
#

Tested with 1 snowball. Not consumed

wet breach
eternal oxide
#

Glad I use current builds 😉

wet breach
#

well, at least they got an answer to their problem 🙂

eternal oxide
#

That was nice. That caused me to find a bug with my skin changer code

wet breach
#

nice

eternal oxide
#

Seems when you apply a new texture on teh player you have to send a respawn packet so their client updates. Turns out it also breaks their permissions and the clien no longer knows they are op

#

[Debug] Unable to open game mode switcher; no permission

#

updating perms doesn;t clear it either

#

have to deop and re op the player

tranquil dome
wet breach
#

if there isn't an api method available to add the item to the appropriate stack, then you might just have to deal with it placing it in another slot

#

not too big of a deal, just probably a bit inconvenient for your players lol

ornate patio
#

how are UIs like this possible

#

using just a resource pack

#

the apps are clickable

dusk flicker
#

might be in a chest or smth

eternal oxide
#

Thats a shame. You can;t send a ClientboundGameProfilePacket after teh player has joined 😦

granite burrow
#

Is it possible to give a player access to a recipe whenever the plugin is loaded? I tried to loop through all online players and give them the recipe, however, that doesn't seem to work

river oracle
#

why not just register the recipe with bukkit

#

Bukkit#addRecipe

granite burrow
#

I've already registered it with bukkit :/

eternal oxide
granite burrow
#

ah okay, then its probably an issue where I need to remove the recipe from then when the plugin starts to shut down and add it back when the plugin is done restarting. Because /reload breaks it.

I know /reload isn't good but I know that users will complain that it breaks crafting lmao

eternal oxide
#

you can test if they know it first

granite burrow
#

yeah I have a check for that, but since its a server reload and not a restart the recipe gets removed from the book but the plugin still thinks they know it

gleaming finch
#

Hi,I want to prevent item change in specific slots in inventory.
It means a player can change item stack in some slots, but not in all slots.
Is it possible?
So far, I'm checking InventoryClickEvent::getRawSlot(), but it won't be work well when user drag items or trigger shift click (selected item will be stacked that in blocked slots)

noble lantern
#

You would just getSlot() == mySlotIDontWantUserToEdit

And InventoryClickEvent::setCancelled(true)

If you don't want them to my able to move it whatsoever you just cancel any interactions with it in that event

#

forgot what getRawSlot does, ive always used the ladder method uhmmm

#

get getSlot is the name i normally use

Doubt it matters tho

#

ah

#

it actually does slightly

gleaming finch
#

Even if I use getSlot(), the result is same. Because the slot id will be origin slot and not destination slot.

upper vale
#

i dont think thats what drag event does

noble lantern
#

looks like it is

gleaming finch
#

InventoryDragEvent does not cover shift stacking case 😿

noble lantern
#

You would cancel both InventoryClickEvent and the drag event

#

not just one

#

shift clicking can be cancelled in click event

gleaming finch
#

I mean a player can change item stack in some slots, but not in all slots.

#

I can not get a destination slot in InventoryClickEvent(shift stacking case)

noble lantern
#

Soo

#

for that

#

its a little complicated

#

You might need packets

Or setup some oddly complex PDT system to retrieve the item

ornate patio
#

how do i start developing a plugin with paper

gleaming finch
#

Hmm.. I got it, so there is no easy way to handle it..

inland axle
noble lantern
ornate patio
#

vscode dont attack me pls

noble lantern
#

would of assumed this would be a standard api feature

inland axle
ornate patio
#

I'm using maven

#

do I just use a different repository

noble lantern
#

you just import paper in maven

#

yes

inland axle
#

If you use idea there is a plugin that does all of the config for you

noble lantern
#

^^

ornate patio
#

like whats the repo name and the source

inland axle
#

For most things the spigot api will be good enough

noble lantern
#

ask in theyre discord

#

this is spigot

#

^

#

plus

#

paper breaks on spigot servers

ornate patio
noble lantern
#

if you use paper methods

ornate patio
ornate patio
glossy scroll
#

?whereami

glossy scroll
#

Oops that was meant for someone else

lusty cipher
#

e.g. event.getClickedItem().getType() == Material.CHEST

inland axle
mighty aurora
#

Ok. I'm relatively new to plugin development and I am working on(for now) a simple GUI that will open from a command. I have defined the command and it appears to work but then it doesn't open my GUI I have created. I think its that I haven't properly called the segment to open the GUI but I'm not sure.
I have 2 class files one defines the GUI and the other defines the command. inside the class file that defines the GUI I created a method that would open the GUI(I think it works anyway) it is this:
public void openInventory(final HumanEntity ent) { ent.openInventory(inv); }
I then tried to call that from the class file with the command but upon execution it doesn't do anything.

granite burrow
#

Alright so I learned that when attempting to give the player access to a craft recipe after a server reload it is not very possible.

Trying to re added it after the server loaded wont give the player anything. (Only relogging will give the recipe back to the book)
Trying to remove the recipe from all players when the plugin is disabled and re adding it to that player when the plugin is loaded also does nothing.

Just putting that out there for anyone else who has this issue.

lavish robin
#

how do I access net.minecraft.server classes? They don't appear to be on the class path.

sullen marlin
#

alternatively Server#reloadData might do the trick though its a bit blunt

granite burrow
sullen marlin
#

I'd open a bug report with a minimal example plugin... may be the case that addRecipe can be changed to resend all recipes

eternal oxide
#

I'll check it but I had zero issues with recipes and reload

granite burrow
#

everything about the recipe still works, just doesn't show in the book

eternal oxide
#

yep not in book anymore after a reload

granite burrow
#

I just finished testing the Server#reloadData as well and that didn't seem to do anything

coral oyster
sullen marlin
#

I guess part 5 is all it goes to

#

if youre just trying to learn java theres probably better articles

#

?learnjava

undone axleBOT
coral oyster
#

huh ok. I went through the W3schools guide but its not very detailed on the tools like Maven, Intellij, etc.

noble lantern
#

IMO Learning about intelliJ is just a trial and error type thing

You just keep using it and eventually things become easier, google is your best friend eg "How to invalidate caches in intellij", i dont think anyone in here ever sat through a 6 hours long how to use an IDE tutorial

Reguarding maven idk any good tutorials for that

eternal oxide
#

Yep, nothing displays the recipes after a restart.

#

I tried discoverRecipe on all logged in players

granite burrow
#

Yeah I just finished making my basic plugin to send as a test, lets hope it gets fixed 😄

eternal oxide
#

I could have given you a single class

granite burrow
#

thats basically what I made. I just wanted to also provide them with a simple plugin that they can use for a quick test

eternal oxide
#

yep

granite burrow
#

That's alot, I just wrote a basic program that will teach the player when they join and create a recipe when the plugin is enabled.

eternal oxide
#

That was just something I was messing about with when someone in here wanted to learn about recipes.

mighty aurora
eternal oxide
#

we'd need to see some code

mighty aurora
#

More than I gave/

eternal oxide
#

yes as nothing you posted sounds wrong

#

you get no console errors?

#

?paste for any code you want to show

undone axleBOT
mighty aurora
#

That is the code for the command and the gui

eternal oxide
#

um, how does this compile PwarpsGui openInventory(player);

mighty aurora
#

It doesnt give any errors

#

and console literally shows nothing

#

other than the fact that I ran the command

eternal oxide
#

yeah, that line isn't valid java

mighty aurora
#

How would I reference the openInventory method or would I not be able to?

eternal oxide
#

You can, but you have to pass an instance of it to your command class.

#

add a constructor to your command class, which accepts PwarpsGui as an arg

mighty aurora
#

When I do that(I've been looking but i'm a bit confused and want to understand how this works) I would define ```public void openGui(PwarpsGui args) {

}``` And then exactly what. From what I see online I would do something along the lines of PwarpsGui open = new PwarpsGui(openInventory) but I dont think thats right.

eternal oxide
#
PwarpsGui gui;
public CommandPwarps(PwarpsGui gui) {
    this.gui = gui;
}```
#

then in your onEnable of your plugin...

#

you register the command and you also create an instance of PwarpsGui to register it as it is a listener?

#

although it has no events yet

#

something like this in your onEnable...java PwarpsGui gui = new PwarpsGui(); getServer().getPluginManager().registerEvents(gui, this); getCommand("blahblah").setExecutor(new CommandPwarps(gui));

#

that first code was supposed to be a constructor in yrou command class. I just fixed it

mighty aurora
#

I know I may sound stupid asking this but would I then use gui(); to open/call the gui inside my command?

eternal oxide
#

just gui.openInventory(player)

subtle folio
#

Can scoreboard teams have the same name?

mighty aurora
subtle folio
#

A team..

#

from the scoreboard ?

mighty aurora
#

So the builtin minecraft teams system?

#

but most likely for anything the answer would be no

noble lantern
#

im pretty sure those teams are stored in some type of map so yeah ^

#

since maps cant have duplicate keys

#

you would just overwrite the previous team when doing that

glossy scroll
#

you need two separate scoreboard instances

#

but no they cannot have same team name on same scoreboard

granite burrow
#

I'm not too well versed in scoreboards and stuff but couldn't you use color codes to have it display the same name but in a different color making it a different name?

noble lantern
#

yes

#

in fact

#

its better to add at the end

#

that way no colors get displayed

granite burrow
#

loop holes 😄

noble lantern
#

Should i be calling join() on futures when running them like this?

#

im getting a weird result, after running this about the same size as my executor (96) the entire program freezes (Using Executors.newFixedThreadPool(threads);)

Not sure if maybe this future isnt getting closed or something?

#

also get this, always runs to thread 48, and restarts to 1 Thonk

gentle quail
#

How can I get a players balance from their username using the getBalance method from the Vault API?

noble lantern
#

iirc Bukkit#getOfflinePlayer

Cache these results this method contacts mojang API iirc

gentle quail
noble lantern
#

that way your not contantly getting the player

gentle quail
#

Ok cool

#

Stupid question but how would I go about getting a player UUID from their username

noble lantern
mighty aurora
#

So I am trying to follow this tutorial so that I can learn to use databases with my plugin. When I add the dependency for the mysql driver though it gives me an error in my IDE that the dependency is not found... I did go to the link but I am utterly confused because no matter how deep I go through the links looking for how to install it just gives me more files to download and despite attempts at installing nothing happens

noble lantern
#

Did you import its repository? (If not from maven central)

#

i know theres a driver thats on a different repo, so do send pom.xml

#

?paste

undone axleBOT
mighty aurora
#

and I literally just copy pasted the extra dependency line in but I'll send the whole file in a sec

noble lantern
#

just curious

#

cause your missing opening tagline there

mighty aurora
#

oops

#

I did accidenty cut it off

noble lantern
#

thats fine

#

its in the actual file though right

#

thats all that matters

mighty aurora
#

yeah

noble lantern
#

just though you accidentally cut it from project

#

Did you refresh maven?

mighty aurora
#

yeh

#

it was giving me the error but after refreshing and waiting a few minutes it now stopped giving the error

noble lantern
#

ohhh your running this on a server rn huh

#

add

#

scope compile

mighty aurora
#

I havent compiled it yet

#

Im still putting the plugin together lol

noble lantern
#

well youll need to add that too when you do compile so add that

#

without it its just provided scope by default

noble lantern
#

yes theres error no theres no error?

mighty aurora
#

Their is no longer any error displayed within the file by my IDE

noble lantern
#

Alrighty, also the reason it took a few minutes is likely cause intellij was downloading it

You can see the running maven tasks on the bottom bar

#

so that way you know if mavens running something or not

mighty aurora
#

ah ok

noble lantern
#

ik that mysql lib is rather beefy

mighty aurora
#

So do I need to add a <scope> segment?

#

and if so what would I place their

noble lantern
#

yeah inside the depenency

#

<scope>compile</scope>

#

that way it gets shaded into your jar

#

and you need a shading plugin

#

unless you have one and it was just cut off from that past

mighty aurora
#

I dont know what that is(im quite new to a lot of this)

noble lantern
#

sec

#

?paste

undone axleBOT
noble lantern
#

Those plugins can be pasted anywhere

They just allowed dependencies to get shaded into your jar when compiling, which is what youll need for mysql

#

You can actually replace the java.version variable in my paste to maven.compiler.source if you dont wanna make a new property

mighty aurora
#

so I copy that into my pom.xml?

#

or do I need another file?

noble lantern
#

yeh it goes anywhere i typically put it under my properties tags

#

just note groupid artifact id name and version

#

and java version in that files 1.8 make it 16 if you do copy/paste it

#

if you use intellij

#

theres a plugin that handles making this pom for you

#

with all those plugins automatically added

mighty aurora
#

what it called/

noble lantern
#

note you use it when you make new projects

#

when you create new project there will be a Minecraft option

echo basalt
#

I always wonder if there's a way to edit the default templates

noble lantern
#

You might be able to

#

hmmm

#

sec

echo basalt
#

found it

#

but it's like hardcoded or something

noble lantern
#

was it in intellij's /plugins file?

#

You can always make your own templates too

noble lantern
#

intellij has built in feature for it

#

ahhh you found it on source code

#

i cant find the plugin folder in intellijs directory

#

weird

echo basalt
#

Feel like it's hardcoded

#

there is a way

#

%appdata%/Roaming/Jetbrains/IdealC<version>/plugins/Minecraft Development/lib

#

then open MinecraftDev-<version> with winrar and edit the files

noble lantern
#

ohhh its in appdata

#

makes sense

echo basalt
#

issa pain

noble lantern
#

i was looking in C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3\plugins

echo basalt
#

yeah it's not there

#

I checked

#

I'll edit mine to bring paperweight by default

noble lantern
#

oh you need to edit the jar

#

ewwww

gleaming grove
#

IDK if its proper development question but it is dangerous if I send real server address to Html client app? My plugin generates Hashed JSON that contains server IP and websocket Port and that Hash will be past by user in client app

noble lantern
#

seems all for velocity tho

#

i think it would be easier to just fork it then manually install

echo basalt
#

the .html ones are worthles

#

the .ft ones work

echo basalt
#

but not everything is there

noble lantern
#

But you need to authenticate who is who and if x user has permission to get the ip from that server

noble lantern
#

idk where main classes are

gleaming grove
#

In worst case some guy could use IP adress to ddos, right?

noble lantern
#

Yeah your find just having an endpoint that returns the IP then just add a rate limiter

noble lantern
#

cause the users gonna have to use it someway no?

#

all IP's are public

echo basalt
#

shit's hardcoded

noble lantern
#

ewwww

#

yeah gotta fork from github then

#

unless you only want pom changed

#

then i think it will work

#

but when it updates it will break it and revert to defaults

gleaming grove
noble lantern
echo basalt
#

ip-restricted firewalls 👀

noble lantern
#

If your rly concerned about protecting the main IP of the server build a proxy for it that way no user ever directly connects to the server

echo basalt
#

then just pull an ethernet cable from the datacenter to your house

noble lantern
echo basalt
#

and tell everyone to not step or cut it

noble lantern
#

i wanna cut the undersea atlantic cables

#

just for shits and giggles

echo basalt
#

#pranked

noble lantern
#

toooo ezz

echo basalt
#

ezz

noble lantern
#

you ever see the pic of a shark biting those cables?

echo basalt
#

what if

#

you buy a datacenter

#

and make like 200 dummy servers

#

and only 1 is the real one

noble lantern
echo basalt
#

chonker!

noble lantern
#

and rely on dns to hopefully connect you to the right one

#

funny thing is thats a makeshift load balancer

sage merlin
#
            if (cooldown.get(entity.getUniqueId()) >= 10 + (System.currentTimeMillis() / 1000)) {
                EntitySet.clear();
                e.setCancelled(false);
            }``` does anyone know why this is not working
noble lantern
#

its not a perfectly even load balancer, but its a load balancer none the less

gleaming grove
#

ok guys, thanks for answer

noble lantern
#

Also Whats EntitySet? Why is it static?

noble lantern
echo basalt
#

it might just be c# naming scheme

sage merlin
#

its a hashset

noble lantern
#

im doing a lot of stuff with websockets myself rn

noble lantern
noble lantern
echo basalt
#

I've been doing lots of stuff with nms and pathfinders lately

noble lantern
#

ooo

echo basalt
#

websockets are interesting but ehh

noble lantern
#

always wanted to get into that

#

i made a rly badass socket implementation

#

it parses data to java objets

echo basalt
#

I might make a proprietary messaging system using sockets

noble lantern
#

and you can make handlers for the actions like:

echo basalt
#

because people don't like setting up redis 90% of the time

quaint mantle
compact haven
noble lantern
noble lantern
#

my websocket infrastructure is superior

#

i just need to change my actual networking from strings to bytes

sage merlin
echo basalt
noble lantern
#

cause data is sent in string format which rly isnt safe

echo basalt
#

redis is like 60%

noble lantern
#

Did you register it?

sage merlin
#

it does

echo basalt
#

the other 30% are people who don't have either because they use a frEe hOsT

noble lantern
#

What exact line of code isnt running?

sage merlin
#

but the only thing is that it always stays cancelled

noble lantern
#

Did you debug?

compact haven
#

but redis pubsub is shit

sage merlin
#

so the if statement is not running

echo basalt
#

man's putting and checking the cooldown on the same event

echo basalt
#

and I can add more types of "processors" like rabbitmq

noble lantern
sage merlin
#

nope

echo basalt
#

it's basically TCP running on top of TCP

gleaming grove
noble lantern
#

so then you need to debug your if statements

#

log the values

noble lantern
#

converting mine to byte arrays will be simple

#

i just need to toBytes() my strings im sending

#

then stringify them on receive

#

actuallly gson might handle parsing bytes directly

echo basalt
#

mine's an nms ripoff :(

gleaming grove
#

well in my case JSON is pretty bad format to exchande date because there will be about 100 msg per secound

noble lantern
#

mine handles 100+ reconnects easily

#

with sending a message

#

my packets parse in about .03 seconds iirc

#

unless its the first request bc json schema caching

#

first request using a new schema instance is like 300ms

echo basalt
#

this sounds like a weird IT dick measuring contest

noble lantern
#

it is

#

100% is

echo basalt
#

I studied networking in school and the teacher was always like that

noble lantern
#

also helps i run all my requests in async too

#

might help your too woln

gleaming grove
echo basalt
#

my packet system doesn't run on json or anything fancy like that

#

I just happen to use byte arrays

noble lantern
#

i run the actual socket on a new Thread, and handle the quests in a CompletableFuture

noble lantern
noble lantern
#

use what MC uses for protocols

#

i forgot its name

#

does anyone remember it?

echo basalt
#

netty

noble lantern
#

no

#

its something else

echo basalt
#

well they use netty

noble lantern
#

its like the actual data format

#

for packets

gleaming grove
echo basalt
#

like I do

noble lantern
#

fuuuck

echo basalt
#

then they zip the packet bytes

#

and send it over

noble lantern
#

@ivory sleet are you around

#

ik you know the name of that protocol

echo basalt
#

I wrote a proprietary server jar

#

they do that shit

#

They also use fancy stuff like VarInts to lower integer byte-sizes

noble lantern
#

Yeah but theres a name for it i cant find it

#

gimme a bit

gleaming grove
noble lantern
gleaming grove
#

i use org.java_websocket.server

noble lantern
#

that one

#

you call

#

new Thread(yourSocketClassExtendingWebSocketServer).start()

#

i use a logger with my thread displayed so i know what thread my stuff runs on

echo basalt
#

man made a fancy proxy

noble lantern
#

Its needed sadly

#

my auth server is whack

echo basalt
#

why make your own when you can fork a shitty one or make a plugin that changes half the logic

noble lantern
#

This isnt minecraft haha

echo basalt
#

oh

noble lantern
#

its for my own game

echo basalt
#

flashbacks to rewriting half of nms to make entities recognize fake blocks

noble lantern
#

100 rpm json should be fine

river oracle
#

Gross your making a game in java

noble lantern
#

esp if your parsing the stuff async

echo basalt
#

by overriding like 19 classes and changing methods

noble lantern
echo basalt
#

via a plugin

noble lantern
#

i would 100% write back end in java

#

but not front end but...

#

im forced to use java for front end too

river oracle
#

Why

noble lantern
#

android :/

river oracle
#

Ooof

noble lantern
#

yeeeah sucks

#

i hate the front end part

river oracle
#

Is kotlin and better for that

gleaming grove
echo basalt
#

make a phone OS that runs your game

#

how about that

noble lantern
#

yeah kotlin definatly better for it

noble lantern
river oracle
noble lantern
#

ide have to learn it

echo basalt
#

I can see myself getting bored in like 3 years

noble lantern
#

Civ-OS

echo basalt
#

and writing an OS that runs a custom minecraft server

noble lantern
#

OS wouldnt even be too hard

#

you just need to write it in native C

river oracle
noble lantern
gleaming grove
#

IMO the best feature of kotlin is ASYNC AWAIT

echo basalt
noble lantern
#

anyone wanna try and crash my socket server by spam reconnecting to it kek

echo basalt
#

I saw a dude writing a tetris OS and it was very specific

noble lantern
#

Only reason why i wouldnt write a OS is the I/O system

#

would hate to write that

noble lantern
echo basalt
#

oh that sounds fun

#

I'll be reading this tonight

noble lantern
#

im not

#

that page took like

#

10 seconds to load

#

shits huge i bet

#

lmao it is

#

77 pdfs

deft shell
#

anyone have experience in making an mc server bc i need help

noble lantern
#

Like

#

from scratch?

deft shell
#

ye

noble lantern
#

You would need a TCP Socket and use of MC protocol

#

Bedrock uses UDP if your going bedrock

echo basalt
deft shell
#

well m just trying to figure out what i should for the map because i either pay someone to do it or do it myself which would take forever

echo basalt
#

You can look into the .schem format

#

it's an nbt format that's quite simple to parse

noble lantern
#

Why are you wanting to re-develop minecraft-server for a map

#

and ^

deft shell
#

and i just need people besides me and my friend to help setup

#

its hard to find help now a days

echo basalt
noble lantern
echo basalt
#

I think he's talking about making a spigot server

noble lantern
#

Not sure

echo basalt
#

and I think we're all too used to network development to even think of it

noble lantern
#

@deft shell ? ^ is it?

deft shell
#

well im just trying to make an mc server

#

plain and simple

noble lantern
#

Ah, this is a channel for java development

echo basalt
#

mans don't even know what spigot is

deft shell
#

o

noble lantern
#

#help-server would be your cause

And you can just google this tbh

#

its first page google results

echo basalt
#

So yeah we're all hardcore developers here and you're basically asking the pope if god is real

noble lantern
#

"How to make a spigot server"

deft shell
#

lol sorry im new here

noble lantern
#

all good

deft shell
#

but thanks

gleaming grove
#

there is only one god md_5

echo basalt
#

mm interesting apparently cpus run in 16-bit mode initially for backwards compatibility

#

thank you intel

noble lantern
#

there a fly in my room

#

and i cant see my code cause of it

#

do i kill him?

echo basalt
#

yesterday I was coding and a cockroach dropped into my fancy logitech keyboard

noble lantern
#

oh hell naw

echo basalt
#

I've also had a spider dangle in my third monitor

#

I was about to punch the living shit out of it

gleaming grove
#

it seems that you are from Australia

echo basalt
#

couldn't be further

chilly fox
#

Hello i learned java basic can anyone guide my building my first project (i want to create a custom item and a cosmetic plugin)

gleaming grove
chilly fox
#

Not that model and all stuff

noble lantern
#

by java basics what exactly does that mean

chilly fox
#

Haven't practiced much...

#

I know classes arrays methods and all that stuffs

#

Constructors method overloading overwriting...

#

Its was not that hard for me to learn cus i am pretty expert in python...

noble lantern
#

oh fair enough

#

in that case if you rly just wanna get started

#

Youll need to know maven at bare minimum

However there is an intellij plugin that will generate a maven pom.xml for you with a base main class file with onEnable and onDisable methods

gleaming grove
noble lantern
#

lmfao what

chilly fox
noble lantern
#

Volkswagon minecraft server

noble lantern
#

intellij bundles it all

#

sec

chilly fox
#

O.o

noble lantern
#

Do you know how to add plugins to intellij?

chilly fox
#

Ya it was in Minecraft package that i installed in intellij

gleaming grove
chilly fox
#

Wait actually i still don't know how to import plugin from other's source code...

noble lantern
chilly fox
noble lantern
noble lantern
#

what plugin?

vocal cloud
#

inb4 random 1.8.8 jar abandoned 6 years ago

noble lantern
#

?1.8

undone axleBOT
noble lantern
#

OHdskhklasd

#

Didnt know he actually added that command today

#

hilarious

final star
#

Hey guys, so I wanted to get some playerdata values ​​from the player, but it just returns a 0, I'm doing it like this:
someone help?

sullen marlin
#

?pdc

cursive kite
#

async?

river oracle
#

No curly braces on the if statement?

#

Also you print your debug before your if statements

gleaming grove
#

try sync and better print Bukkit.broadcastMessage("PARTICE"); under If statement

cursive kite
#

So it turns out in Eclipse ive been pushing my username/password typed in one of my classes (was suppose to test and delete it) to GitHub, can I just delete the file and its history from GitHub

river oracle
cursive kite
river oracle
#

If you've changed it and pushed an update it's not a huge deal unless you use the same password fir multiple things under that case shame on you

noble lantern
#

if (stuff) return;

#

also

river oracle
noble lantern
#

You cant spawn particles asyn

noble lantern
river oracle
noble lantern
#

does it for me, but i use github desktop

cursive kite
river oracle
#

Though that's preference I suppose

noble lantern
#

yee

chilly fox
#

Hmm how can i make a projectile have a particle trail?

noble lantern
#

you need to follow the arrow traveling (Gets its flight path) and while its moving spawn a particle at its location every x ticks

#

projectile* not arrow

zenith gate
#
new BukkitRunnable(){
                @Override
                public void run(){
                    if(event.getPlayer().isFlying()){
                        Mana.removeMana(p, 1);
                        if(Mana.getPlayerMana(p) <= 1){
                            p.setFlying(false);
                            p.setAllowFlight(false);
                            p.sendMessage(ChatColor.RED + "You are out of mana!");
                        }
                    }
                }
            }.runTaskLater(Wired.getPlugin(), 20);

can someone explain why this mana loses like 4 every seconed instead of the 1 its suppose to?

sullen marlin
#

did you run the task 4 times

zenith gate
#

umm... wait

#

this is on a PlayerMoveEvent now that im think fo it

noble lantern
#

bukkit runnables in player move event?

#

bold move

#

Chaotic Neutral

flat leaf
#

is there any way to set the nbt of a block in the generate methods of ChunkGenerator?

noble lantern
#

like block data?

flat leaf
#

doesn't really seem to be a good way to even do this with NMS since the way in which you set blocks during this method is very abstracted

#

no, NBT