#help-development

1 messages · Page 1956 of 1

quiet ice
#

Memory is cheap \s

brave sparrow
#

Storage is cheap

#

Memory is pricey

#

But getting cheaper

grim ice
brave sparrow
# grim ice

That’s VSCode, you have to install a bunch of extra stuff if you want a “create project” type thing

quiet ice
#

Honestly, I always found vscode more like a generic text editor than anything usefull for development

grim ice
#

how do i do that then

brave sparrow
quiet ice
#

At that point you might as well use vim or emacs

brave sparrow
#

It’s a slightly more powerful text editor more than an IDE

#

Realistically

native bluff
#

Anyone knows if there's a way to color the players names above head with hex colors?
Team.setColor doesn't support Hex unfortunately

#

I even tried looking up some packets but nothing seems to do the trick

sacred mountain
#

is anyone here good at art and can make me a pfp

#

i made mine in ms paint

tall crystal
#

who can help me with a plugin

sacred mountain
#

wrong channel sorry lol

brave sparrow
grim ice
#

so uh what do i do

brave sparrow
sacred mountain
#

just create a hologram

#

with rgb

grim ice
#

didnt work out

sacred mountain
#

above the player

native bluff
native bluff
quiet ice
#

I personally use Geany for C dev, but that is another pretty generic text editor

sacred mountain
#

welp then im not sure

brave sparrow
sacred mountain
#

i dont know if you can do it in player names/tags

grim ice
#

i was googling vscode

#

i didnt know visual studio even existed

brave sparrow
quiet ice
#

Do you have the C++ extension installed?

grim ice
#

yes

#

C/C++ thing?

quiet ice
#

Well, then you are on-par with my knowledge

ivory sleet
#

iirc yes

sacred mountain
#

listen to the orange guy

grim ice
#

thats why i hate anything other than jetbrains

ivory sleet
#

like you can probably pass an int

grim ice
#

too confusing

#

but CLion is moni

#

and i dont have that student shit they want

tardy delta
#

orange guy :kekw:

sacred mountain
ivory sleet
#

might be byte even

native bluff
#

Tried running the /team command and it didn't work with HEX

brave sparrow
tardy delta
#

amplifier is int

ivory sleet
#

yes but in minecraft you cant have any higher than 255

mortal hare
#

have anyone used NIO V2 before?? hello??

ivory sleet
#

additionally its interesting since 129-255 iirc uses negative integers (when stored in nbt)

#

yes in api

#

tho thats not how game treats it

quiet ice
quiet ice
#

Though what is NIO v2?

ivory sleet
#

well yeah they're capped to the limit of shorts also in modern versions

#

used to be 35k or 36k or sth

quiet ice
#

35k

brave sparrow
#

@native bluff doesn’t appear to be supported

mortal hare
#

there were some packages of nio before that

native bluff
ivory sleet
#

I mean there's just nio and nio channels?

#

not sth like nio revamp afaik

quiet ice
#

Why would be use pre-java7 java?

mortal hare
#

Im not

#

im just calling that

#

ffs

#

Java I/O, NIO, and NIO.2

#

its a standard name

ivory sleet
#

interesting

quiet ice
#

yes, but specifing this is a bit strange, given that nowadays we all understand the same thing

mortal hare
#

i have such a question

#

lets say i want to serialize some data to files

#

ingame

#

should i use AsynchronoushFileChannel

quiet ice
#

At least in the progressive java world

mortal hare
#

to do operations async

#

and not to block main thread

ivory sleet
#

depends

mortal hare
#

also does Files interface blocks

ivory sleet
#

usually a ReentrantReadWriteLock is enough

#

myes

mortal hare
#

lets say i want to serialize data per player

#

not the init data

quiet ice
#

I'd use a simple FileOutputStream (you can dump the data off-thread and I do not think that there is a global FIO lock)

mortal hare
#

its binary type of data

#

i need to create binary file per player

brave sparrow
#

That’s fine

sacred mountain
#

I have 2 listeners, one is EntityDamageByEntityEvent (for the fireball hitting the player and setting the damage) and one is the PlayerInteractEvent (for throwing a fireball)
both of them currently work as intended, but im trying to add a message like this :

"Your fireball hit %count% entities for %damage% damage."
and
"You were hit by %playername% for %damage% damage with fireball"

How would i get the shooter and the player hit and use the message like that? i have a few options that i thought of:
i could put them both in the same class, but then i would need to let the damage event know who threw the fireball if multiple different players were throwing them at once

#

i feel like im overcomplicatnig my thought process

#

and its really simple

mortal hare
#

i don't want to use java.io specifically, since we have new apis since java7 to handle that

#

but im not sure about that actually

ivory sleet
#

well

#

not everything in java.io is straight up trash

mortal hare
#

ik

#

Streams aren't for example

#

?paste

undone axleBOT
ivory sleet
#

myes

mortal hare
#

if i dont specify ExecutorService inside AsynchronousFileChannel

#

what thread pool will it use

ivory sleet
#

I mean I'd say its the exception rather than the rule that sth is obsolete and should not be used when its contained in that package

#

iirc fjp common

mortal hare
#

i mean my binary files are quite small (1-5KB) uncompressed

#

so im thinking if i could use separate thread pool

ivory sleet
#

yes

#

calculate the blocking coefficient (if you have one) and maybe a fjp

sacred mountain
#

i like it neater

ivory sleet
#

actually dovidas, it might not be the common pool

#

wouldnt make sense

blazing scarab
sacred mountain
#

to have different evnthandlers in differnet classes

mortal hare
#

?paste

undone axleBOT
tardy delta
mortal hare
#

this is my current method of saving data

tardy delta
#

i like to put them per category

mortal hare
#

any ideas how to improve this

ivory sleet
#

depends on what you want to improve

ivory sleet
#

but maybe write a unittest for it dovidas

brave sparrow
ivory sleet
#

to check that it works fine asynchronously

blazing scarab
#

Idk

mortal hare
#

well it does write it just fine

#

what should i test

ivory sleet
#

yeah file writer or buffered writer both cool stuff

blazing scarab
#

I havent worked with io by myself too much

mortal hare
#

same

quiet ice
#

does it have advantages over FileOutputStream?

ivory sleet
#

well

quiet ice
#

(other than the fact that you can write raw strings with it)

mortal hare
#

Writer is usually meant for text based streams

blazing scarab
#

At least it worked

ivory sleet
#

I mean FileOutputStream and FileWriter are kinda for different things

blazing scarab
#

oh

ivory sleet
#

(not entirely)

blazing scarab
#

I used writer for gson

mortal hare
#

Yea one's for byte transport

ivory sleet
#

^

mortal hare
#

and another for text based transport

blazing scarab
#

I wanted to use outpur streams, but that didnt work

quiet ice
#

okay, so I am not misusing it

midnight shore
#

Guys how can i get a random entry in an enum?

#

this is my method rn, and it is a little broekn

young knoll
#

Enum.values[random.nextInt(Enum.values.size)]

ivory sleet
#

I mean most common approach is to cache the enum values by Enum::values and then access a random index with sth like RandomGenerator::nextInt where you pass the length of the collection

young knoll
#

Except yknow, less ugly

manic furnace
#

I want to make my plugin use MySQL. It has to save a lot of data several times. How should i do that?

quiet ice
#

Just beware that .values() clones the returned array

midnight shore
#

omg i forgot that arrays have that option of getting an entry by [entry]

lavish hemlock
lavish hemlock
#
Enum[] values = Enum.values();
Enum value = values[random.nextInt(values.length)];
blazing scarab
#

yes

young knoll
#

Looks too clean

#

To the void with it

quiet ice
#

I mean, the issue with this is that the .values() call is not fully cached

midnight shore
#

I already fixed it! ty

blazing scarab
#

i cant sleep if i know that my code does unnecessary computations

midnight shore
#

finally this is what i'm using

quiet ice
#

JIT might solve a few concerns but nothign is 100% sure

midnight shore
#

is it ok for you ProDevs?

ivory sleet
#

but ye for enums like material

#

better cache it

young knoll
#

If your code isn't held together by toothpicks then it isn't worthy of spigot

#

:p

ivory sleet
#

🥲

quiet ice
#

I think it just calls Enum[].clone() (so it could be using jvm internals shenanigans to reduce ops)

manic furnace
quiet ice
young knoll
#

Yeah why do you convert the enum entry to a string and then back to an enum entry

blazing scarab
manic furnace
#

OK. I create something, store the data. Later on i would delete/change the data. This Data has do bei persistant.

blazing scarab
#

ok

#

Whats the problem

manic furnace
#

I don't know how to make that with dbs. Should i keep the connection live? How should i do that?

blazing scarab
#

Go and learn sql and jdbc

quiet ice
#

(i. e. just yolo it)

#

There is nothing better than jumping head-first into the cold waters and then to come out screaming in pain

manic furnace
#

Ok i come when i am screaming 🤣

tardy delta
#

hikaricp uwu

midnight shore
#

So i need it as a string

quiet ice
#

but can't you just invoke .toString() later on?

midnight shore
#

Just wanted to make it simpler after

#

Because I’m actually using it like 10 times

quaint mantle
#

hey, so this is my first time making a plugin, and i have used gson to make a json file to store a class's contents in an array list, but when this function runs, it doesnt update the json

#

(it does create the file, though)

hybrid spoke
# quaint mantle

do you really want to create a new GSON and File object everytime the method runs?

quaint mantle
#

basically i want to know why the file stays blank even when the method runs

#

and the arraylist does have contents

hybrid spoke
#

boilerplate should be avoided

blazing scarab
#

what boilerplate

drifting bridge
hybrid spoke
# quaint mantle

but seems like there is nothing wrong. what if you use the writer to actually send the data, instead of gson?

drifting bridge
#

I testing it but i get this error

[22:36:07 ERROR]: Could not pass event PlayerInteractEvent to wiktorm v1.0.0
java.lang.UnsupportedOperationException: null
at com.google.common.collect.ImmutableMap.clear(ImmutableMap.java:877) ~[guava-31.0.1-jre.jar:?]
hybrid spoke
hybrid spoke
mortal hare
#

is there any way to declare generic type inside the class like this?

public class Foo<Bar[]> {}
tardy delta
#

record 👀

mortal hare
blazing scarab
#

aaand?

mortal hare
#

and i need to have array as a generic type

blazing scarab
#

what's the problem

mortal hare
#

this doesnt work

blazing scarab
#

What

hybrid spoke
#

just use a list or any other collection

#

java doesn't support array generics

mortal hare
#

But its an Object

#

Array is technically an object

hybrid spoke
#

array generics

#

as you say, technically

blazing scarab
hybrid spoke
#

internally its just a fixed order of objects, or primitives

blazing scarab
#

I dont understand your issue dovidas

mortal hare
#

lets say i want to create a class which already declares a generic type

#

with primitive type array

#

as a generic type

#

what you don't understand

blazing scarab
#

Thst doesnt make any sense

hybrid spoke
#

it do. java doesn't allow it.

#

you literally can't do that

mortal hare
#

it does make sense

blazing scarab
#

Why do yoy need a class wirh defined generic

#

it doesnt

mortal hare
#

because i have class implementation which doesnt need generic type anymore externally

quaint mantle
#

use c+

blazing scarab
#

please provide a context

hybrid spoke
#

doesn't matter. just use a list or any other collection impl you might need

mortal hare
#

ok this is weird

#

if it doesnt support primitive types as generic types

#

then why Class<byte[]> is legal

hybrid spoke
#

java.lang.Class<**T**>

blazing scarab
#

cuz arrays are objects

mortal hare
#

You can provide byte[] as an object generic type inside variable declarations while you cant declare them inside the classes

#

weird.

#
Foo<byte[]> foo = new Foo<>(); // Legal
class Bar implements Baz<byte[]> {} // legal
class Foo<T> implements Baz<T> {} // legal
class Foo<Integer> {} // legal
class Foo<byte[]> {} // not legal
blazing scarab
#

Because the last doesnt make sense

mortal hare
#

so does Integer

hybrid spoke
#

why doesn't Integer make sense?

blazing scarab
#

class Foo<UUID> {} woudlnt work i'm pretty sure

#

wtf

hybrid spoke
mortal hare
#

it does

hybrid spoke
#

since its a class

mortal hare
#

byte[].class is also a class

#

its just weird handling

hybrid spoke
#

not explicit

mortal hare
#

im gonna just close this thought for myself

#

as weird syntax

blazing scarab
#

okay

#

Can you explain to me why do you need to define generics in classes

mortal hare
#

that was just me experimenting

blazing scarab
#

Liks, not the actual java.util.UUID

#

or Integer

mortal hare
#

Could be

blazing scarab
#

And you cant have arrays since []

mortal hare
#

yea

#

its true

blazing scarab
#

That's it

mortal hare
#

solved

#

case closed 😄

hybrid spoke
#

welcome to generics

mortal hare
#

How evil would that be if someone named generic type as an existing class name

#

great for obfuscation i guess ( not much, but harder to read i guess)

ivory sleet
#

yeah, its an easy refactor

neon minnow
#

How to get an offline player in bukkit from an uuid?

ivory sleet
#

Bukkit::getOfflinePlayer

neon minnow
#

you can't get an offline player if they haven't joined yet

young knoll
#

Sure you can

#

getOfflinePlayer(uuid) always returns an OfflinePlayer

neon minnow
#

Bukkit.getPlayer(UUID.fromString); im going to use this?

young knoll
#

No

#

That’s for online players

neon minnow
#

Explain

young knoll
#

And has to use their name

neon minnow
#

Oh

young knoll
#

Explain what

neon minnow
#

Wait

young knoll
#

GetPlayer requires the player to be online

#

GetOfflinePlayer does not

neon minnow
#

getOfflinePlayer is unresolved reference

young knoll
#

Bukkit#getOfflinePlayer

#

Oh wait you use stupid outdated versions

#

No idea if it existed then

neon minnow
#

Gets the player by the given name, regardless if they are offline or online.
This method may involve a blocking web request to get the UUID for the given name.
This will return an object even if the player does not exist. To this method, all players will exist.

#

'getOfflinePlayer(String!): OfflinePlayer!' is deprecated. Deprecated in Java

young knoll
#

Yes there are two methods

neon minnow
young knoll
#

One for uuid one for string

#

Only the string one can be blocking

neon minnow
#

So, in that case, wouldn't an async function made by me be better that way that gets their uuid

young knoll
#

I mean

#

You’d just be doing exactly what the function does

neon minnow
young knoll
#

Yes

neon minnow
#

and slow the entire server, but if you do it asyncly?

young knoll
#

So do it async

neon minnow
#

Okay

#

was gonna us ethis

#

but ill just do the already existing bukkit one u said

#

Bukkit.getOfflinePlayer()

mortal hare
young knoll
#

Sure

neon minnow
# young knoll Sure

java.lang.ClassCastException: class java.lang.String cannot be cast to class org.bukkit.entity.Player (java.lang.String is in module java.base of loader 'bootstrap'; org.bukkit.entity.Player is in unnamed module of loader 'app')

var playerfromargs = args[0]
playerfromargs = Bukkit.getOfflinePlayer(playerfromargs).toString()
playerfromargs as Player

ivory sleet
#

its probs thread safe, but not atomically safe (just a guess)

neon minnow
#

what am i doing wrong ?

young knoll
#

Trying to cast a string to a player

mortal hare
#

doesnt getOfflinePlayer() cache data?

neon minnow
#

my ide is telling me to

#

Bukkit.getOfflinePlayer(playerfromargs)

#

Type mismatch.
Required:
String
Found:
OfflinePlayer!

ivory sleet
mortal hare
#

meh, i'd probably would've made http request by myself just to be sure im not screwing up something

ivory sleet
#

yeah, the entire disadvantage of abstraction is mainly concurrency

mortal hare
#

cache boolean or separate method would be enough for me to not to

ivory sleet
#

since its an "implementation detail"

#

but still needs to be concrete in apis (since hiding implementation causes concurrency update oblivion)

neon minnow
#

I got the uuid as string

#

now what

mortal hare
young knoll
#

You already have a uuid?

neon minnow
young knoll
#

Then just do getOfflinePlayer(uuid)

#

That one isn’t even blocking

mortal hare
#

but what if that player haven't played on the server

ivory sleet
#

still instantiates an object

#

tho name is null (along other things iirc)

young knoll
#

Mhm

spare patio
#
@Override
    public OfflinePlayer getOfflinePlayer(UUID id) {
        Validate.notNull(id, "UUID cannot be null");

        OfflinePlayer result = getPlayer(id);
        if (result == null) {
            result = offlinePlayers.get(id);
            if (result == null) {
                result = new CraftOfflinePlayer(this, new GameProfile(id, null));
                offlinePlayers.put(id, result);
            }
        } else {
            offlinePlayers.remove(id);
        }

        return result;
    }

1.8.4 implementation

neon minnow
#

java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_8_R3.CraftOfflinePlayer cannot be cast to class org.bukkit.entity.Player (org.bukkit.craftbukkit.v1_8_R3.CraftOfflinePlayer and org.bukkit.entity.Player are in unnamed module of loader 'app')
myFunction.initializestuffs(sender as Player, finalOfflinePlayer as Player)

Dont get it

mortal hare
#

what version of minecraft do you use

neon minnow
#

1_8_R3

ivory sleet
neon minnow
mortal hare
#

I havent been using 1.8 for ages

#

sorry

young knoll
#

You can cast an OfflinePlayer to a player

ivory sleet
#

the other way around?

lavish hemlock
#

Nah

#

Player extends OfflinePlayer

young knoll
#

Player is always an OfflinePlayer

lavish hemlock
#

So, chances are, an OfflinePlayer could be a Player

ivory sleet
#

You cant cast OfflinePlayer to Player

lavish hemlock
#

Best to instanceof first

ivory sleet
#

yes exactly

young knoll
#

Or use isOnline

lavish hemlock
#

Ye

lavish hemlock
#

That's just untrue of the language

neon minnow
#

i did OfflinePlayer

#

instead

ivory sleet
#

Well, you know what I meant, anyhow point is as said there's no guarantee an instance of OfflinePlayer is an instance of Player

lavish hemlock
#

I didn't know what you meant until you said "yes exactly."

#

Say "You can't just cast"

neon minnow
#

How many requests can be sent to the mojang api

young knoll
#

Shh

lavish hemlock
young knoll
#

This is why you use the built in method

#

It caches and such for you

ivory sleet
#

well usually you get your hands on a OfflinePlayer object so then it will objectively yield a ClassCastException if you cast it to Player

#

or

#

wwait

#

what am I even saying

#

its the reverse

#

I just said what you said before

neon minnow
#

can u get offline player name

#

like

#

.name.toString()

ivory sleet
#

myes

neon minnow
#

Thanks

ivory sleet
#

well using Bukkit::getOfflinePlayer by passing a uuid would yield an instance where the name might be null

young knoll
#

Don’t need the toString

ivory sleet
#

but else, sure if its cached

lavish hemlock
#

when you .toString().toString()

neon minnow
#

xD

#

lol

ivory sleet
#

might be using sth like components shrug

neon minnow
#

I got

#

e.getRightClicked() as Player as a player

#

but how can i get their uuid

#

from this

ivory sleet
#

.uniqueId

neon minnow
#

thanks

ivory sleet
#

?jd-s btw

undone axleBOT
ivory sleet
#

getters and setters become properties

summer scroll
#

Is this the same?

if(player.isFlying()){
  // code here
} else {
  if(player.isInWater()){
    // code here
  }
}

if(player.isFlying()){
  // code here
} else if(player.isInWater()){
  // code here
}
lavish hemlock
#

Yeah

summer scroll
#

Ah, intereseting

lavish hemlock
#

I mean they are effectively the same

opal juniper
#

elif 🤩🤩🤩

lavish hemlock
#

But there is one difference

#

You can put some code after that if in the else

#

And it will only run on else, no matter if the if was triggered

summer scroll
#

I want to do something If player is flying and in the water in this case.

neon minnow
#

sender.name.toString() returns uuid???
sender = OfflinePlayer

summer scroll
#

I always thought you need to put !player.isFlying() in the else if statement.

lavish hemlock
#

Well if the player is both flying and in water

#

Then use a logical and

#

&&

summer scroll
#

else if(player.isInWater()){ this mean the condition will be success if the player is not flying and is in water right?

young knoll
#

Yes

summer scroll
#

Alright, thanks guys

golden turret
quaint mantle
#

how do i save an arraylist to a .json, i have literally been trying to do this all day and the file stays blank

#

so can someone give me a snippet or something

golden turret
waxen plinth
#

Depending on what's in there you might not need a json library at all

quaint mantle
willow stream
waxen plinth
#

Like do you literally mean it is a List<Class<?>>?

quaint mantle
#

the class is called menu

#

which opens the inventory and handles the customizations

waxen plinth
#

Okay then that's really important information that you left out

#

You're gonna need a way to serialize the Menu instances

quaint mantle
waxen plinth
#

You need some way to convert it to a string, basically

waxen plinth
#

And then back

quaint mantle
#

String menu = new Menu(name, size, new Menu.OptionClickEventHandler() {

        public void onOptionClick(Menu.OptionClickEvent event) {
            event.setWillClose(true);
        }
    }, this).toString();
#

right now i am just saving it

#

so i will worry about destringing it later

waxen plinth
#

You can't just call toString() and expect something deserializable to come out

#

The standard toString() implementation just gives the name of the class and its location in memory

#

Which is useless for persistence

#

You need a way to actually convert all of the relevant data to a string

#

And you have an anonymous class definition in there so that's gonna be quite hard

quaint mantle
#

just the variables that need to be read

waxen plinth
#

Why are you trying to save this to a json file exactly?

quaint mantle
waxen plinth
#

It does matter

#

Why are you trying to save this

#

It's very strange to try to save something like this to a file

quaint mantle
#

not why

waxen plinth
#

That's not what I'm asking

#

Why are you trying to save this

quaint mantle
#

they need to be stored somewhere

#

as well as the name, items, etc.

waxen plinth
#

And how are the menus created?

#

How does a player create a Menu?

quaint mantle
#

/menu create

waxen plinth
#

In the code

lost matrix
waxen plinth
#

What variations are there

worldly ingot
#

Just a random aside I wanted to throw in there

waxen plinth
#

They can overlap considerably

#

My serialization methods tend to be human-readable

#

But yeah it often does make sense to separate them

worldly ingot
#

It's rare. Few cases for that are things like enums

waxen plinth
#

A Menu takes an event handler of some kind

#

That's what's going to make serialization difficult here

#

If there are a preset number of possible values then you can just assign names to them and be done with it

#

Otherwise it's going to be a lot more complicated

lost matrix
#

He would need to define a fixed set of actions with serializable context.

waxen plinth
#

Yeah I guess "assign names to them and be done with it" is a bit simplistic

#

But it really is much much simpler if that's how this works

quaint mantle
# waxen plinth In the code

when a player runs /menu create {size} {name} it is SUPPOSED to add the size and name, items, and commands items do when clicked to an array, which would be stored in either a yml or json depending on which works

waxen plinth
#

But what other properties does a menu have?

#

Size and name are clearly not the only ones

#

It's probably the items in there, right?

#

The behavior of the menu - can each item have a different handler that is run when it's clicked?

waxen plinth
#

Right, that's where it gets complicated

#

So does each item have only one command attached to it?

#

Are there any other things an item can do when it's clicked other than just run a command?

quaint mantle
waxen plinth
#

Okay

#

Then that's doable

#

Now you have a few choices

#

You could do all of this yourself

#

Handle serialization of everything, including the items, which is gonna be very annoying

#

Or you can use a pre-existing library that will handle the serialization for you as long as you tell it how

waxen plinth
#

I've made one that you could use for serialization to yaml

#

For json there's gson which I believe works similarly

quaint mantle
#

i tried gson earlier but it did not work

waxen plinth
#

You can also use ConfigurationSerializable which is built into bukkit

quaint mantle
#

file would create but not update

waxen plinth
#

Yeah most likely you were using it wrong

#

is

grand venture
#

This does not make sens right?

`@EventHandler
public void onPlayerRespawn (PlayerRespawnEvent event) {
Player player = event.getPlayer();
player.teleport(new Location(player.getWorld(),97, 242, -143));
if(!player.isOnGround()) player.setGliding(true);

}`
waxen plinth
#

Make sense how

#

It's valid code

#

I don't know why you would do such a thing but it would work

grand venture
#

But it doesnt work 🥲

low temple
#

Hey, does ```
FileOutputStream output = new FileOutputStream(file);
ObjectOutputStream stream = new ObjectOutputStream(output);
stream.writeObject(object);

Allocate the same amount of memory as 

new ObjectOutputStream(new FileOutputStream(targetFile)).writeObject(object);

?
waxen plinth
#

Why would it not

#

It will take the same amount of heap space

#

It will use very slightly less stack space, but that barely matters at all

#

Take readability over that micro-optimization

low temple
#

So no reason to use one or the other? Just impacts readability?

waxen plinth
#

Readability is more important here

#

The stack allocations of a few variables uses such a negligible amount of memory that doesn't even need to be garbage collected

low temple
#

gotcha thanks

grand venture
worldly ingot
#

because the teleported location will be overridden by the actual respawn

grand venture
#

ty

quaint mantle
#

I'm querying db "mysql/SQLite" for each online player every 5 min. Would I just use a for each loop on online players and inject playerdata into db ? Or do something like hashmaps ? Im not sure if db can handle a loop like this or what is most commonly used to do this.

muted sand
#

how do i change a large area of blocks?
I use a for loop, and theres just a small visual lag of the for loop working, and it just bothers me :}

sharp flare
#

loop

muted sand
#

oh

#

okay!

#

i go learn more java

lost matrix
quaint mantle
#

Makes more sense thanks!

muted sand
#

Additionally you can also backup the data every 5minutes. But this should not be done with a loop but a single query that delivers all data.
so it'll cause less strain on the database?

drowsy helm
#

yeah one single data dump every so often is better than constant r+w

#

but also runs the risk of data loss if the server goes off line, the cache of data will be lost

muted sand
drowsy helm
#

well personally i used to cache to redis then dump that every so often

muted sand
#

oh that sounds smarter

drowsy helm
#

but if you are only using 1 db just have a db manager that stores objects then writes later on

muted sand
#

wdym by a db manager-?

drowsy helm
#

just a class that manages the db IO

muted sand
#

oh

drowsy helm
#

or just create your statement, save it to some sort of array

#

or queue

#

then dump all those statements

muted sand
#

ooh okay!

#

and would redis be better opposed to using variables for a caching? (or does this just matter on usage cases?)

drowsy helm
#

yeah depends on usecase tbh. Only reason i used redis is for redundancy

#

if your mc server goes offline, redis will still have the data

#

whereas if you didn't have redis you would just lose the data

young knoll
#

I just write every change :p

muted sand
#

unless your entire host were to magically poof 🤡

young knoll
#

Reads are heavily cached though

drowsy helm
#

separate servers pog

#

yeah depends on what you are read/writing

hybrid spoke
muted sand
#

aight

hybrid spoke
#

with many backups

drowsy helm
#

if its not super taxing i wouldn't bother even caching it

hybrid spoke
#

at different locations

muted sand
drowsy helm
#

theres some nms methods that are far faster

sullen marlin
#

World#setType or whatever will be very slightly faster (on 1.18.1 anyway)

#

the 'fast' nms methods are a scam

#

setType without physics is as fast as you'll get without breaking things

neon minnow
#

Is it possible to have an on click that would then open the player's chat and write a command in for them, for example when they click their inventory item it would open the chat and write "/help" but not actually execute it (just show it)

young knoll
#

No

#

Only chat components can do that

worldly ingot
#

I mean, kind of

#

Could reflect into the CommandMap, #get() the command and invoke its execute() method

#

That's ugly and hacky as hell, and I seriously don't advise it

#

but you can do it lol

young knoll
#

But that doesn’t just show it

#

Besides, why not just performCommand

worldly ingot
#

but not actually execute it
led me to believe they want to avoid that lol

young knoll
#

Isn’t that what the execute method does

worldly ingot
#

afaik it does still perform and log the command

neon minnow
#

I want it to be like how JSON does it, it sends a player a reccomended command.

worldly ingot
#

oh you want command suggestions

#

yeah that's only done with components. You can't do that any other way

#

I misunderstood the original question I guess lol

neon minnow
#

No you understood right first time

#

Not a suggestion where it shows possible commands in a black box in chat, but actually write it in the player's chat box so then they can finish it by writing the arguments in

#

but i guess that cant be done.

worldly ingot
#

Yeah that's a command suggestion done with components

neon minnow
#

Only with the json chat component

#

Ok thanks

low temple
#

Does anyone know the proper way of getting a player’s DisplayName as a String in 1.18.1? The Player#getDisplayName() is deprecated. Still works but is there a better way to get someone’s display name?

eternal night
#

You are developing against paper's api if that method is deprecated

neon minnow
#

How can I send a centered message in chat

neon minnow
#

yep

#

just found that

#

pretty cool!

neon minnow
#

I have a question guys, so I have two plugins that I am working on and I want to incorporate the first one into the second one without having to always update it back and fourth, how can I manage these two plugins with IntelliJ and build and compile them in a way where the first plugin goes into the second one easily, and I can manage what different files classes are in the second plugin? Thank you

lost matrix
neon minnow
#

How can i set it up?

lost matrix
#

A dependency manager

lost matrix
neon minnow
#

Thanks

#

I searched but cant find anything on why maven would be used

#

oh lol

tranquil viper
#
[21:53:52 INFO]: §x§2§0§B§2§A§APig §x§7§7§9§9§9§9(9)
[21:53:53 INFO]: 9
[21:53:53 INFO]: §x§2§0§B§2§A§APig §x§7§7§10§10§10§10(10)

I am trying to only replace the 9 in the (), but when I replace 9 it replaces all the hex. How can I only replace the 9 in the ()?

neon minnow
#

try going on this guys

drowsy helm
#

no

#

lol

neon minnow
#

lol

silk mirage
#

\(9\)

#

.replaceAll uses a regex parameter at first

tranquil viper
#

oh dope

#

thanks

neon minnow
#

Im working with EntityPlayers right now to create NPC's, how can I make an Entity sit on another one? Do i have to use packets for this? Im in 1.8

storm crescent
#

How would I update a player's gameprofile to have a different uuid? I'm trying to make a custom profile plugin where players can have different profiles. When I change the gameprofile uuid, the getUniqueId method still returns the original uuid.

lost matrix
neon minnow
#

because i cant find much about that

#

like

lost matrix
neon minnow
#

riding a pig

#

how would you code that

lost matrix
neon minnow
lost matrix
neon minnow
storm crescent
young knoll
#

EntityPlayer

lost matrix
neon minnow
#

oh yea nvm

lost matrix
#

So you will have to hook early into the handshake.

lost matrix
hardy swan
#

you mean you wanna regenerate the entire world?

lost matrix
#

Talking about just setting the block type at a location. Dont bother with nms.
If you want to change huge areas of blocks then you should do it async.

#

Async does not mean from a different thread. If you split the task over several ticks then thats an async action.

#

Example: You have a million blocks that need regeneration.
Doing this in one tick will crash the server. But placing 20k blocks every tick for 50 ticks will probably be fine.
It wont lag and only take about 3 seconds.

#

You can also just place 1k and wait for 30 seconds and dont even lose 0,1 TPS. Shouldnt really matter.

ancient jackal
#

I'm trying to navigate to latest.log in the logs folder but getting the parent file beyond /plugins is returning null
earlier it was said spigot doesn't prevent it but... does it?

#
        // f = plugin.getDataFolder();
        System.out.println("--------------------");
        System.out.println(f.getAbsolutePath());
        System.out.println(f.getParentFile().getAbsolutePath());
        System.out.println(f.getParentFile().getParentFile().getAbsolutePath());
        System.out.println("--------------------");```
the logs
```[00:39:20] [Server thread/INFO]: --------------------
[00:39:20] [Server thread/INFO]: C:\Users\name\Documents\Minecraft Server\plugins\ConDump
[00:39:20] [Server thread/INFO]: C:\Users\name\Documents\Minecraft Server\plugins
[00:39:20] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'condump' in plugin ConDump v1.0-SNAPSHOT```
lost matrix
ancient jackal
#

is there a way for me to reach latest.log?

lost matrix
#

Sure. You have java at your disposal. You can do anything. As long as the os allows it.

ancient jackal
#

Thank you, I will try that

lost matrix
# ancient jackal Thank you, I will try that
  public File getLogsFolder() throws URISyntaxException {
    File spigotFolder = new File(Bukkit.class.getProtectionDomain().getCodeSource().getLocation().toURI());
    return new File(spigotFolder + File.separator + "logs");
  }

In most cases this will also work:

  public File getLogsFolder() {
    File spigotFolder = Bukkit.getWorldContainer();
    return new File(spigotFolder + File.separator + "logs");
  }
ancient jackal
#

oh shoot I just raw dogged it, didn't know those methods existed

#
        LinkedList<String> oldPath = (LinkedList<String>) Arrays.asList(f.getAbsolutePath().split("\\"));
        oldPath.removeLast();
        oldPath.removeLast();
        oldPath.addLast("logs");
        oldPath.addLast("latest.log");

        String newPath = oldPath.getFirst();
        for (int i = 1; i < oldPath.size(); i++) {
            String s = oldPath.get(i);
            newPath = newPath + "/" + s;
        }```
lost matrix
#

oof...

ancient jackal
#

quite a big one indeed

#

I just need to resolve this illegal escape sequence in the split regex...

lost matrix
#

Use the second method. Im not 100% if the first points to the jar or the folder.

ancient jackal
#

I will, thank you for showing me that method

neon minnow
#

Hi all im using NMS but when im compiling i get an error because it cant find the classes, how do i tell gradle to compileOnly with it? i typed in compileOnly(org.bukkit:bukkit:spigot-1.8.8.jar) but i dont think it can find it? where do i put spigot jar . my IDE can recognize it because i added it in Settings Global Libraries

chrome beacon
#

You do not add your spigot jar anywhere

neon minnow
#

*/
compileOnly("org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT")

#

BUILD FAILED in 4s

chrome beacon
#

Anyways that is the wrong compileOnly information

neon minnow
#

how

#

unresolved reference nms

chrome beacon
#

org.spigotmcspigot1.8.8-R0.1-SNAPSHOT

#

...

#

It replaced it to an emoji

#

Either way I think you get it

neon minnow
#

org.spigotmcspigot1.8.8-R0.1-SNAPSHOT

#

but that doesnt have nms

chrome beacon
#

It does

chrome beacon
#

Don't include the emoji >.<

neon minnow
#

i didnt

chrome beacon
#

Ah so you didn't run BuildTools

neon minnow
#
  • What went wrong:
    Execution failed for task ':compileKotlin'.

Could not resolve all files for configuration ':compileClasspath'.
Could not find org.spigotmc:1.8.8-R0.1-SNAPSHOT:.
Required by:
project :

neon minnow
chrome beacon
#

?bt

undone axleBOT
neon minnow
#

Yes i have it but how do i include it in my IDE

#

and gradle

chrome beacon
#

Never download Spigot from anywhere else

neon minnow
#

Yes i know that!!

#

i built my spigot and put it in resources folder

#

but dont know how to link it up to gradle

chrome beacon
neon minnow
#

run what

#

im so confused.

chrome beacon
#

BuildTools

neon minnow
#

how do you run buildtools in ide

chrome beacon
#

You don't

neon minnow
#

so what are you talking about

chrome beacon
#

?bt

undone axleBOT
neon minnow
#

i already have that and i built spigot jar with it !

chrome beacon
#

Just follow these instructions

neon minnow
#

???

#

That literally just says how to build spigot jar

#

and i did

#

but gradle doesnt know anything

#

how do i link it

chrome beacon
#

So you didn't download your jar

neon minnow
#

I have the jar in my resources folder

#

i built it in a cmd in my downloads folder

chrome beacon
#

It shouldn't be there

neon minnow
#

Ok, so how does gradle know build tools then

#

youre telling me to build a spigot jar with buildtools which i already did.

quasi flint
#

i ma justmd_5

neon minnow
#

But this gradle shit doesnt work

quasi flint
#

it works

#

if u use it right

neon minnow
#

Thats what im literally asking how to use it and how to compile

chrome beacon
quasi flint
#

dead versions yey

chrome beacon
#

If it doesn't work you will need to add it manually

neon minnow
neon minnow
#

but thats shouldnt be where it is

chrome beacon
#

You can run that anywhere

neon minnow
#

oh

#

i see now

#

do i have to add my own

#

?

#

so that it can find

chrome beacon
#

Try mavenLocal()

#

Not sure if you need it

neon minnow
#

org.spigotmc:1.8.8-R0.1-SNAPSHOT

#

this is the right one?

#

my jar is named spigot-1.8.8.jar the built one

neon minnow
#
  • What went wrong:
    Execution failed for task ':compileKotlin'.

Could not resolve all files for configuration ':compileClasspath'.
Could not find org.spigotmc:1.8.8-R0.1-SNAPSHOT:.
Required by:

chrome beacon
#

You forgot the spigot part?

neon minnow
#

Okay thank you it worked

quasi flint
#

kotlin?

neon minnow
#

but what is mavenLocal() and how can I make sure that it can access spigot jar file ?

wet breach
neon minnow
wet breach
#

yep

neon minnow
#

ohh

#

Now i understand!

#

Thanks everyone

chrome beacon
#

So it works now?

neon minnow
#

im still learning everything

#

but yes

#

thank you

chrome beacon
#

Aight

quasi flint
#

more 1.8 plugins ;7

neon minnow
#

Im not releasing shit

#

Its my own plugin

quasi flint
#

wellthen #1.17

#

or 1.18.1

chrome beacon
#

Eh let them choose what they want for a private project

#

Just do understand that working with 1.8 will be harder than newer versions

gritty urchin
#

if anything its easier

#

cuz it doesnt have the extra shit

eternal night
#

👀👀 a wild take

#

1.8 is missing a lot of API that can be pretty helpful even outside of the API that represents gameplay additions

neon minnow
neon minnow
# gritty urchin cuz it doesnt have the extra shit

1.18 is so bloated + servers require like 2Gig ram each, now tell me, how are you supposed to launch a big network based on 1.18? You can't, each instance of a lobby / minigame will be like 2 gig each, with 1.8, what? its like 400mb. usage, or smaller plus, its so simple, and the fact that i have to learn packets and shit, just better for me as i can get even more understanding and learn more

neon minnow
# lost matrix bollocks

haha, youre funny, i went onto the papermc server, got laughed at for using 1.8, so i tried out 1.18, my entire pc nearly crashed, 100% cpu usage, and i had to put at least 1 gig ram. whilst 1.8 can easily just fine with 400mb using 200mb currently, on my server

#

1.8 is simple, yes old, but simple

eternal night
#

You are still using outdated software. If neither spigot nor paper were kind enough to supply you with a fix for log4j, you'd be stranded.

neon minnow
#

for most people new versions are recommended -- yes. but let people choose what they want to play with

neon minnow
eternal night
#

In terms of API, PDC, NoAI, MaterialTags, all that good stuff

lost matrix
#
  1. You dont need to support thousands of concurrent users. You are not Mineplex.
  2. 1.18 is more than capable to handle a metric ton of users if you know what you are doing
  3. Its all a matter of setup. If you know what you are doing then 1.18 is as capable as 1.8 when it comes to minimalist setups
eternal night
#

idk where people get the "a lot of people are using 1.8" from

#

bstats screams otherwise

neon minnow
#

most 1.8 users turn bstats off anyways

#

lmao

lost matrix
eternal night
#

Ah yes, to stay hidden from the bstats overlords

#

but only the 1.8 servers

neon minnow
#

I literally dont care

eternal night
#

But I guess your point stands yes, 1.8 does require less resources

neon minnow
#

Please stop talking about versions

#

How can i set set players tablist name ?

#

I cant really find anything about it

eternal night
#

in what API version ? :>

neon minnow
#

lol

woven phoenix
#

Does anyone know how to make mobs not hostile and not moveable on there own?

eternal night
#

NoAI ?

#

e.g. no movement at all ?

lost matrix
neon minnow
eternal night
#

tho like, one google search got me an answer to change the players tabname/over head name

#

even for 1.8.8 lol

woven phoenix
#

Lynx I want them to not be able to move on there own but I can move them with my body or with water etc

eternal night
#

Ohh, hmmm probably less easy for you and might require NMS

#

you'd have to wipe their mob goals

neon minnow
eternal night
#

no that breaks the "move around and in water" afaik

lost matrix
eternal night
#

Eeeh IIRC

#

might be wrong

woven phoenix
#

So is there no simple way?

eternal night
#

I might be thinking of no gravity

#

Well try the NoAI flag

lost matrix
#

^

#

Might work. If not then you need to clear their AI goals.

woven phoenix
#

Alright ima try

#

How do I even do that NaAi flag 💀shi look confusing

eternal night
#

Well with that method o.O

lost matrix
eternal night
#
final LivingEntity e = world.spawn(loc, Zombie.class);
e.setAI(false);
woven phoenix
#

No idea what a Boolean is

lost matrix
eternal night
#

you are in help-development o.O

woven phoenix
#

Oh

eternal night
#

you are coding a plugin right ?

woven phoenix
#

Oh this is for coding plugins 💀

eternal night
#

yeeaaa

lost matrix
#

...

woven phoenix
#

🤣🤣

#

Whooops

eternal night
#

if you just want to spawn one in game you do

#

/summon sheep ~ ~ ~ {NoAI:1b}

#

as a very basic example

woven phoenix
#

But is that permanent

eternal night
#

yea

#

that is persisted through restarts

#

however, again, you'll have to see if that is actually what you want to happen

woven phoenix
#

Say like I have blaze spawners and I do that with blazes will they still spawn fall flow in water and not attack me

eternal night
#

?tryandsee

undone axleBOT
woven phoenix
#

Alright

eternal night
#

tho for blaze spawners to all spawn blazes with that tag

lost matrix
eternal night
#

you'd either need a plugin or some active command blocks

#

or yea, custom spawners

lost matrix
#

Cant you specify a nbt String for custom spawner? Or did he mean naturally generated ones.

woven phoenix
#

I have silkspawners

#

I think it works

#

So they don’t attack me but they can still walk

eternal night
#

Are you talking about a connection pool ?

#

like hikaricp

blazing scarab
#

You always should

lost matrix
#

f it makes sense with sqlite

#

Probably good practice still

blazing scarab
#

supporting Sqlite only is meh

neon minnow
#

Postgres?

#

Is it good?

drowsy helm
#

yep

neon minnow
#

nice

tender shard
#

why do people always confuse this channel with help-server

dusk flicker
#

no idea

#

It happened so often

mortal hare
#

i never realised that you can do something like this:

for (ItemStack itemStack : player.getInventory()) {
                
}
#

Inventory interface extends Iterable

#

you don't need .getContents() to iterate through the items

#

but sadly InventoryView doesnt implement iterable interface

lost matrix
#

Would be a bit weird because it doesnt contain ItemStacks itself. It just represents the view of 2 inventories.

mortal hare
#

it could still be iterable

#

it could iterate all of the items (including player's)

dire marsh
neon minnow
#

Guys, anyone know how to send a title with subtitle? Thanks

opal juniper
#

does changing an enum that other plugins have already compiled with cause issues? like do they rely on the ordinal under the hood

chrome beacon
neon minnow
lost matrix
neon minnow
#

im using NMS

lost matrix
#

You can even specify fade in fade out time

neon minnow
eternal night
#

Damn I never knew newer API has those cool feaures smile!

#

But yeah, Google once and you should find the respective Packets

lost matrix
#

Astounding, right? Its like people improved the API in the last half decade.

neon minnow
#

lol

dire marsh
#

No complex API additions like that dum PDC!

lost matrix
#

Sometimes i which that old versions would have been left out from CVE-2021-44228 patches.
Was an opportunity for a big cleansing.

dire marsh
#

people would have just downloaded a plugin to fix it

lost matrix
#

I guess with some regex...

#

Still

dire marsh
#

there were plugins made that intercepted it using packets

neon minnow
#

Whilst having the efficiency and speed of the server with only 200mb memory usage

#

something a 1.18 server will never be able to achieve.

opal juniper
#

you could fix it with packet catching like Sam said

#

but eh, i mean whatever

#

200mb ram, zero features

lost matrix
#

You are making the wrong design choices, but ok...
Do you even have a playerbase worth sacrificing that much API and features for?

#

Increasing your development time by years just to have 20 players on an outdated piece of software

dire marsh
#

@neon minnow what server type

lost matrix
blazing scarab
#

Or factions with laggy cannons

young knoll
#

You gotta use a cannon fork 🤡

buoyant viper
warped panther
#

Config get differnt value in a while loop

buoyant viper
#

the regex filter

willow stream
#

can someone please check out #942934911432687656 ? I'm trying to make it so the cube goes behind the player if it goes over his head

elfin atlas
#

Does someone know what this effects are?

chrome beacon
#

Guardian rays

elfin atlas
chrome beacon
#

Probably

drowsy helm
#

2nd is just a bunch of music notes

#

3rd is guardian ray

chrome beacon
#

Ah

drowsy helm
#

No clue what 1st is

elfin atlas
#

Okay

#

Hmm still thinking about what the 1st is

chrome beacon
#

Looks like the ender dragon death beam

#

But this one is fully white

neon minnow
#

This ^

elfin atlas
chrome beacon
#

Try killing an ender dragon in the overworld

#

See if it's white

#

I'll check back later

elfin atlas
#

Okay

#

But how would I’ll spawn effects like this?

gritty mist
#

hello I missed the method for creating a formated text like "&1H&2E&3Y" instead of doing ChatColor.BLUE + "H" + etc...

quaint mantle
#

does this db query cause heavy load to db ?

blazing scarab
#

Use batches

#

Also object oriented programming is a thing

buoyant viper
#

or something like that

quaint mantle
#

instead of copying the codes over

#

just call the method with 5 mins

#

prob more readable code?

#

phwwww just realized they are two different codes

#

ah yea 😄 np

neon minnow
#

I got player.location, how can i add +5 to it at Y coords?

#

Thanks

hollow bluff
#

player.location.getY

#

create a new location and add thst for the y

#

Location location = new Location();

neon minnow
#

ty

spiral light
#

or just location.setY(location.getY + 5) ? thats simple stuff you should know

neon minnow
#

just a question, how can i do async in a function?

#

trying to do object : BukkitRunnable() { } but it doesnt let me

spiral light
#

?schedular

#

?schedule

#

?scheduling

undone axleBOT
spiral light
#

^^

neon minnow
#

Yep

#

i read

#

it says to do new BukkitRunnable() {
/* the usual code */
}.runTask(plugin);

#

but i cant do that in function

spiral light
#

what do you want to do and show code of what you want to do

tardy delta
#

just use lambda expression instead of new BukkitRunnable

neon minnow
#

I have a function. I want to thread sleep inside of it, but to do that i need to make it async. I cant make it async inside of the function, because bukkitrunabble turns into object: BukkitRunnable in Kotlin, and object cant be used inside function.

neon minnow
undone axleBOT
tardy delta
#

stupid kotlin

spiral light
#

i believe he is doing it wrong anyway

tardy delta
#

there should be a way, shouldnt make sense otherwise

neon minnow
#

Do you understand what i am trying to say

tardy delta
#

yes

tender shard
#

although I don't like kotlin, I gotta add that this statement is not true

neon minnow
#

its not letting me for some reason

tender shard
#

show your code pls

neon minnow
#

nvm fixed

#

So its safe to do

#

thread.sleep

#

in an async bukkit ?

tender shard
#

yes

tardy delta
#

uhm kinda but why would youN

young knoll
#

I mean

#

I guess you could easily delay stuff further inside an already delayed task

neon minnow
#

delaying

#

in for loop

young knoll
#

Afaik async tasks use a thread pool

#

So sleeping them may still be a bad idea

tender shard
#

as long as you don't have thousand threads, I don't see any problems in putting one of them to sleep

#

just be sure to include a nice catchy lullaby before doing so

vocal cloud
#

Just schedule the task instead of sleeping the thread