#help-development

1 messages · Page 757 of 1

umbral ridge
#

I know even essentialsX is horrible

#

I'm making my own

floral drum
#

mhmmmm

#

I have my own made for 1.8, approx 3 billion blocks per second it can reset

#

All async

umbral ridge
floral drum
#

No MSPT increases

remote swallow
floral drum
#

(from testing)

remote swallow
#

im debating on implementing my own reset system but idk if i can be arsed for that

floral drum
remote swallow
#

normal worldedit cannot handle 3 billion a second without lag mr purple

#

fawe or awe can

floral drum
#

not 3 billion

floral drum
#

Asynchronously, not effecting MSPT at all, all smooth

remote swallow
#

smh

floral drum
#

lol

umbral ridge
#

With this, I should be able to create a subdirectory in my plugin root folder right?

Eg.

PluginName/ - root
PluginName/data - subdirectory

File tempDir = new File(fileFolder);
if (!tempDir.exists() && !tempDir.mkdir())
  throw new IOException("Cannot create a directory!");
#

If I pass in the usual stuff getDataFolder().getPath() + "/data" ?

#

it should work?

#

Nvm works now

solar sparrow
#

How can I add a hex color in my msg string below?

private final Pattern pattern = Pattern.compile("[a-fA-F0-9]{6}");

public static String sem_perm = "You don't have permission";
rough drift
#

At this point

#

sun.misc.Unsafe

#

Be looking real sexy

floral drum
rough drift
#

What did you use for block setting? Only thing I can think of is NMS and directly editing the pallette

floral drum
#

This is honestly for 1.8.8, the one that I made.

rough drift
#

Ah

floral drum
#

The way it works it creating a "Fake" world. I manage the chunks, I manage the blocks.

#

All packet based

sullen iris
#

Dang, my whole Discord changed on my phone😂

warped basin
#

does cancelling a task nullify any references to it? like if I had a variable like BukkitTask task = new TaskClass(); and then ran Bukkit.getServer().getScheduler().cancelTask(task.getTaskId()); would that task variable become null or would that variable still be populated but not scheduled?

sullen marlin
#

It would still be populated

warped basin
#

okay cool that's what I thought

rough drift
rough drift
#

Long-press for like 5 to 10s until you get a pop-up

#

Then restart discord completely

#

Un-fucks the UI

wet breach
#

really weird way to fix the UI

dry hazel
#

you can do it via settings as well, appearance -> show new layout

signal tiger
#

how remove tpo for Admin's

#

?

#

code need

rough drift
undone axleBOT
signal tiger
#

and i ask

#

a day later for

#

line code

#

/searchitem <player> <itemgamemode1>

#

for <player> -gamemode1

wet breach
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

signal tiger
#

2s i search line code

rough drift
#

Brother just learn

frank kettle
#

Is there a way to make blocks only visible with nms?

my idea is make chests across the map that people can pick up once, so they can only be visible until u click on them and then they never appear again, and the player gets rewards for clicking on them

echo basalt
#

Uhh yeah

#

Player#sendBlockChange is a start

#

But you'll need to work with packets to detect clicks

frank kettle
#

i tried searching on google for it but all i found was thing for falling blocks and nothing else useful

frank kettle
echo basalt
#

well yeah but no

frank kettle
#

cause i just need the chest to be an illusion

echo basalt
#

The client will send a packet for whatever block it clicked on

frank kettle
#

i know the server will see it as a air block

frank kettle
echo basalt
#

Yeah

rough drift
#

yes

echo basalt
#

I've worked with fake blocks

#

like a lot

frank kettle
#

thats useful then, just need to check if its a chest

echo basalt
#

I'd make something like a

rough drift
#

That's how me and my friend made fake worlds

frank kettle
#

btw a different question, do fake entities lag as much as real entities to the players fps?

rough drift
#

because real entites are the exact same as fake entities

echo basalt
#

Map<String, FakeBlockContainer> worldMap

and the FakeBlockContainer just being like a

String worldName
Map<Long, FakeBlockChunk> thing

and the FakeBlockChunk just being a

int chunkX
int chunkZ
Map<Integer, FakeBlock> where the int is the index within the chunk

frank kettle
#

just curious

rough drift
#

the client just handles them the exact same way

frank kettle
#

thank you

#

is there a way for this to not happen? 🤔

#

@echo basalt @rough drift

rough drift
#

Nope

#

not that I know of

echo basalt
#

you can just disable the flying thing on config

#

and impl a proper anticheat with fake block checks

frank kettle
#

i kinda dont want to disable the flying thing 🤔

#

will see how this goes, it takes a few seconds, hope nobody does it

#

even if they do it, they can just reconnect, the world where this happens it's 100% safe anyways

#

i rather keep the flying thing turned on for now

echo basalt
#

just render a fake barrier above as well

rough drift
frank kettle
#

and if the chest is in the open, they could fly or jump from a mountain or smth and bug it

#

so for now i will just ignore it and see how it goes, if people want to mess up with it for their own disconnects, fine with me

#

is there a way for players to click on block AIR without hack clients?

#

with the PlayerInteractEvent

#

cause im noticing if there's nothing, the clickedBlock is null, but if it's a fake block, it returns as a AIR block, not null.

#

so i can check if they are clicking on air in this world for the chests, dont need to work around with nms packets.

rough drift
frank kettle
#

which item?

#

im using different ones and clicking on air does nothing

rough drift
#

I mean the event is fired

#

but the actual block is still null

frank kettle
#

yes but the clickBlock is null

#

but if it's a fake block

#

it returns as AIR block

rough drift
#

I mean yeah

frank kettle
#

so i was asking if there's a way for them to click without returning null

rough drift
#

no

frank kettle
#

cause if there isn't, then i can use this for the chests interaction

rough drift
#

shouldn't afaik

#

but any fake block does that

#

even ghost blocks

frank kettle
#

i just need then to check if it's a location of a chest just to make sure

frank kettle
onyx fjord
#

Can I somehow read/find properties file with the API?

#

Because it can be in a different folder

rough drift
#

no I don't think so

sullen marlin
#

Can it?

#

Also isn't the setting in the API

onyx fjord
#

Someone reported to me that it can be moved with an argument

#

--config

#

I wonder if it's a spigot, vanilla or paper thing

tranquil dome
#

What is recommend to use for a database connectivity? JDBC? Or is there a better alternative?

rough drift
#

For SQL?

#

I'd use JDBC

#

for NoSQL? Use a lib for the specific db

tranquil dome
#

Planning to use postgres for personal projects but I'd like to support multiple databases for other users.

rough drift
#

Postgres has an API iirc

#

for SQL use JDBC and call it a day

tranquil dome
#

But postgres would also work with jdbc correct?

eternal oxide
#

yes

#

I added a few DB types to GroupManager (via Hikari) a short while back, Postgresql was one of them

eternal oxide
#

jdbc:postgresql://%HostName%:%Port%/%DatabaseName%?characterEncoding=utf8

tranquil dome
#

And for people that don't know how to set up databases, should I use H2 or SQLite?

#

And would it be easy to export from those to an SQL database and vice versa?

lilac dagger
#

is this overengineered?

eternal oxide
#

H2 or SQLite makes no difference, other than SQLite driver is included in Spigot

tranquil dome
#

Alright, I'll probably go with SQLite then

lilac dagger
#

it's for the best

ivory sleet
lilac dagger
#

awesome

rough drift
#

I have a slightly more engineered one

quaint mantle
#

Basically, in file

jagged thicket
#

its the most commonly used one

young knoll
#

H2 is good too

quaint mantle
#

i don't like sql and everything that is nosql is better than any sql thing

young knoll
#

Okay

jagged thicket
quaint mantle
#

yeah

jagged thicket
#

will give you nightmares

jagged thicket
quaint mantle
#

thats why i dont like sql becuz people cant even write sql also you are using java so use java for everything lol

jagged thicket
#

it gets the job donee

#

if you use sql

#

one code for both sql and sqlite

#

just a single method for choosing which one

young knoll
#

Not quite

jagged thicket
#

for my project atleast

young knoll
#

Sadly MySQL and SQLite have different syntax

jagged thicket
#

i use ormlite

young knoll
#

So you gotta be careful

warm mica
young knoll
#

Mhm

#

But they still have different syntax

orchid trout
#

my secret query language

#

is that what it stands for

#

no

#

ok

warm mica
eternal oxide
#

not quite teh same syntax

warm mica
eternal oxide
#

depending on the driver ytou may need to wrap '

#

and differing words in teh syntax

warm mica
pastel axle
#

is there a way to hide worlds from getServer().getWorlds()?

eternal oxide
#

eg
Mysql has boolean where SQLite you have to use int

#

depending on driver of course

young knoll
#

Whatever you want to call it, syntax or feature, the point is

jagged thicket
#

i just use string for everything 💀

young knoll
#

Ya gotta write different queries for each

eternal oxide
#

yep ^

keen star
#

hey how to extends EntityCreature in nms 1.20 remapped?

young knoll
#

?mappings

undone axleBOT
keen star
#

how to get Nms world in nms 1.20.1?

young knoll
#

?mappings

undone axleBOT
slate tinsel
#

How do particles work, so you can't see them from a certain distance or is it some sort of y level?

lost cosmos
#

hello

lost matrix
#

Collections are not thread safe on default. Meaning you cant just concurrently access them from async threads/tasks.

quaint mantle
#

Pro’s use arrays

lost matrix
ivory sleet
storm crystal
#

How can I make a code that would make cases depending on how much of them Id put in method?

#

As in, if my method took argument of 5, it would make five cases from 1 to 5

lost matrix
quaint mantle
storm crystal
ivory sleet
#

Well not reflection that shits not the right thing

storm crystal
#

method(int amount);

ivory sleet
#

But VarHandle

storm crystal
#

I give amount 5

slate tinsel
quaint mantle
#

I love reflection😭😭

young knoll
#

I don't think you can make a switch case dynimically

storm crystal
#

It makes switch for 5 cases

young knoll
quaint mantle
ivory sleet
young knoll
#

But you can't choose the distance

#

You either get 16 blocks or infinite

lost matrix
quaint mantle
storm crystal
#

How can I make randomizer that would take into consideration weight value

young knoll
#

MAke a weighted random class

#

I have one you are welcome to use

slate tinsel
ivory sleet
storm crystal
#

I dont think that making array of 100 values is a good idea for that

quaint mantle
ivory sleet
#

Lol

young knoll
keen star
#

how to register MeleeAttackGoal in nms 1.20.1 remapped? i from 1.16.5 nms and now up to 1.20 but everythings look new and i can't register MeleeAttackGoal it has error The constructor MeleeAttackGoal(CustomZombie, double, boolean) is undefined also with RandomStrollLandGoal pls help 😭

storm crystal
#

Im on my phone

lost matrix
quaint mantle
young knoll
#

?mappings

undone axleBOT
young knoll
#

Should tell you the proper names for stuff

quaint mantle
slate tinsel
ivory sleet
quaint mantle
ivory sleet
storm crystal
#

I want to make lootbox plugin that would be more universal, takes amount of drops available and their odds to randomly pick one of them

young knoll
#

The last arg is a boolean called force

ivory sleet
#

Mojang is gonna remove the goal api sooner or later

#

Since its not as data drivable

quaint mantle
storm crystal
#

And im stuck on a point where the code could tell apart how many items in pool there is

ivory sleet
#

and they wanna make everything data driven in principle it looks like

ivory sleet
quaint mantle
#

What do you think all these api’s are based off

storm crystal
#

Only thing that comes to mind is arraylist

young knoll
keen star
#

brrr

#

it don't say how to use, requirements, covert,etc

quaint mantle
lost matrix
ivory sleet
quaint mantle
#

Nms code

young knoll
slate tinsel
ivory sleet
lost matrix
ivory sleet
#

the goalselector and target selector are gonna get yeeted off soon

quaint mantle
ivory sleet
#

Since brain replaces it totally

lost matrix
young knoll
#

Fancy

quaint mantle
ivory sleet
#

But yes lol

storm crystal
ivory sleet
#

Just look at all newer mobs

#

They use the brain instead

young knoll
#

wdym independant code?

ivory sleet
#

Because its superior

quaint mantle
#

They aint gon rewrite their whole ai system

ivory sleet
lost matrix
ivory sleet
#

Everything could in principle just be replaced with the brain api

storm crystal
#

So do I just copy it into code?

quaint mantle
young knoll
#

It would make sense for them to replace it

ivory sleet
#

Just need to create a few more activity types and stuff, but in theory its plausible

young knoll
#

But brain has been artound for years now and they haven't done anything yet

#

so hrmm

ivory sleet
#

Yes

#

Camels use them, sniffers do, iirc warden as well

young knoll
#

See I want to tackle the pathfinding api in spigot again

#

But if Mojang has plans to yeet the old system it would be a waste of time

ivory sleet
#

More and more mobs use them because its just a better way to support mob memories, mob activities and so on

storm crystal
#

Can I dynamically change how big array is?

#

As in

#

I make empty array

young knoll
#

That's called a list

storm crystal
#

Well whatever semantics

quaint mantle
young knoll
#

ArrayList is basically a dynamic array

storm crystal
#

I make a thing and add things to it dynamically

ivory sleet
quaint mantle
#

Java5👍

young knoll
#

Do all new mobs use brains?

quaint mantle
#

Brrraaaan

ivory sleet
storm crystal
#

Okay I think I could work with that

young knoll
#

hmm

#

Do froge brain

ivory sleet
#

I think yea

#

Idr exacrlt

#

But I was gonna code my dragon mob

lost matrix
young knoll
#

I mean a brain api for spigot is also possible

ivory sleet
#

And it turned out its pretty much implementable with brain only

young knoll
#

But then that exludes all the old mobs

#

Dangit mojang have some consistency

ivory sleet
young knoll
#

A lot of things are data driven

ivory sleet
#

As all activities and memories are type based

lost cosmos
#

i can run this task without async
but what should i do if i need to run task async?

ivory sleet
#

yeaaa coll

young knoll
#

Doesn't make an API for them easy 😩

ivory sleet
#

morweww enums? :>

#

(/s)

#

But yea true

young knoll
#

No more of me screaming

#

The big hurdle atm

#

Is that datapacks load super fuck off early

#

And then the regestries all get frozen

ivory sleet
#

Ah

quaint mantle
ivory sleet
#

Then its about time we get rid of these enums

ivory sleet
young knoll
#

That's been worked on

quaint mantle
#

Hey cube, bff?

ivory sleet
#

Nice

young knoll
#

PotionType and Particle are already registry backed on prod

lost cosmos
#

okay

lost matrix
quaint mantle
ivory sleet
#

Coll, is the api gonna provide functionality to see original vs changed data

lost cosmos
#

i have ConcurrentModificationException without async

storm crystal
#

Ill make code that would add as many values as stated to represent weight and then Id make random int from 1 to length of this arraylist, so if I want to make 25/75 odds of diamond and dirt Id just make [0,1,1,1], where 0 and 1 represent giving a specific item depending on that variable

#

Does that sound any optimal?

ivory sleet
#

You know how we can change tags w/ datapacks

young knoll
#

Changed as in modifyed by a datapack?

quaint mantle
ivory sleet
#

yeah, such that the api have a method to get the original tag, and the changed one’s state

ivory sleet
young knoll
#

Maybe one day

#

Atm it only sees the changed stuff

ivory sleet
#

ah

quaint mantle
ivory sleet
lost cosmos
#

ConcurrentModificationException isn't depend on is void .runTaskTimer or .runTaskTimerAsynchrously

young knoll
#

Well

lost matrix
#

Conclure does his code look like it should throw a concurrent mod for modification while iterating?
I dont see the problem there.

quaint mantle
young knoll
#

Only one of those runs in a different thread

quaint mantle
#

I hate you now😭

lost matrix
#

The iterator should support .remove() while iterating

young knoll
#

Yeah that looks alright to me

#

Which line is the CME coming from

lost cosmos
#

and what shouild i do, after all?

eternal oxide
#

nothign in that code could CME, unless you insert elsewhere

ivory sleet
slate tinsel
lost cosmos
#

i can send extra code

young knoll
#

It should

ivory sleet
young knoll
#

Be aware thought that passing true is mostly a suggestion

#

It doesn't force the client to render it further

slate tinsel
lost matrix
#

I mean. Nothing really forces the client to do anything. 🙂
It does what it wants

young knoll
young knoll
#

Or it gets the boot

lost matrix
slate tinsel
# young knoll yes

So this should work or:

          world.spawnParticle(Particle.CLOUD, location, 25, 1, 1, 1, 0.1, true);

          world.spawnParticle(Particle.EXPLOSION_LARGE, location, 10, 0.5, 0.5, 0.5, 0.1, true);

          world.spawnParticle(Particle.LAVA, location, 2, 0.5, 0.5, 0.5, 0.1, true);
#

Therefore I get null when I test

storm crystal
#

Can I just make methods and classes inside plugin java file?

lost matrix
young knoll
#

Did someone say ASM

storm crystal
#

Can I just make a method in here?

#

Or is it only for event handlers and listeners

lost cosmos
#

well i think that the one right way is to add try/catch in my code

#

because idk what to do

lost matrix
lost matrix
young knoll
#

^ the full exception

#

You can paste it

#

?paste

undone axleBOT
keen star
#

Hi do someone know how to register AttributeInstance?
i tried using this code (worked in 1.16.5) but to 1.20 it got an error:
the code: AttributeInstance AttributeInstance = new AttributeInstance(attributeBase, AttributeInstance::getAttribute);
error: The type AttributeInstance does not define getAttribute(AttributeInstance) that is applicable here

young knoll
#

Which line is CombatChecker line 14

lost cosmos
#

public void run() {

young knoll
#

Ah wait I see it

#
public void disable() {
        player.sendMessage(TextUtils.hex(UltimateCombats.getInstance().lang().getString("combat_ended")));
        bossBar.removePlayer(player);
        UltimateCombats.getInstance().getCombats().remove(this); <-- CME HERE
    }
lost matrix
#

Thats what i was looking for

#

But in the setDuration method...

#

To clarify this: You cant modify a collection while iterating over it

lost cosmos
young knoll
#

Since you already remove it with the iterator.remove

#

You should be fine to just delete that line

#

Unless you are calling disable from somewhere else as well

lost matrix
# lost cosmos do i have to remove this line?

Another fix would be to change

Iterator<Combat> iterator = UltimateCombats.getInstance().getCombats().iterator();

to

Iterator<Combat> iterator = List.copyOf(UltimateCombats.getInstance().getCombats()).iterator();
#

Lets say you have an average of 20 players on your server, then this wont cause any problems.
Copying 20 references is done in a hearbeat

lost matrix
lost cosmos
#

but what if i have 80 players average online?

lost matrix
#

And the outcome would be pretty much the same

shadow night
#

Is 80 players really that much these days

young knoll
#

Yeah

ivory sleet
#

yep

young knoll
#

Most servers either have thousands or like

#

10

shadow night
#

I once had a server

#

3 at peak

#

Including myself

lost cosmos
#

why do i have a developer

#

when i already have developer

#

and this developer is me

shadow night
#

Because there are developers better than you that can do stuff better and faster

#

There is always somebody better

lost cosmos
#

why do i have to waste my money

#

when i can waste my time and get some skills

ancient plank
#

dat is swo twue, weaw as fwick

shadow night
#

Does that say real

ancient plank
#

ya

lost cosmos
#

i get this exception yet

#

    public CombatChecker() {

        new BukkitRunnable() {
            @Override
            public void run() {
                
                Iterator<Combat> iterator = new HashSet<>(UltimateCombats.getInstance().getCombats()).iterator();
                while (iterator.hasNext()) {
                    Combat combat = iterator.next();
                    if (combat.getDuration() != 1)
                        combat.setDuration(combat.getDuration() - 1);
                    else {
                        iterator.remove();
                        //combat.disable();
                    }
                }
            }
        }.runTaskTimer(UltimateCombats.getInstance(), 0, 20);
    }
echo basalt
#

guard clauses ftw

lost cosmos
#

can someone help?

chrome beacon
#

Don't remove while iterating or iterate a copy and remove from the original

keen star
keen star
chrome beacon
#

Is that NMS?

#

or where is AttributeInstance from? because it doesn't match the Spigot API

worldly ingot
#

:p He's right though

#

Some people genuinely think that Java is just for Minecraft

shadow night
#

The bukkit api does a lot behind the scenes

#

Events seem like magic

ancient plank
#

Da onwy mwagic in da bwukkit API is dat fish dwown when dey awe out of watew

shadow night
#

Fish drown when they are out the water BUKKIT

#

Best pun

keen star
#

i use it to registerAttribute attack for Pig

chrome beacon
#

Take a look at how vanilla does it

shadow night
young knoll
#

I mean

#

It usually works

chrome beacon
#

Yeah that is how you make mods

#

Takea look at how vanilla does things

#

and then use that

ancient plank
#

yub

shadow night
#

But the other 50% or rather 15% of the time vanilla doesn't have a solution. 35% are "learn java mf"

lost matrix
storm crystal
worldly ingot
#

You can

#

Bukkit only cares about methods annotated with @EventHandler

shadow night
#

How does @EventHandler, or rather, how do annotations even work

#

I never understood how annotations do stuff

lost matrix
shadow night
#

Server-side mc client

river oracle
worldly ingot
lost matrix
shadow night
#

Annotations always confused me

lost matrix
#

Annotations are just a tag you can add to elements so that they can be read on runtime.
They have really no functionality outside of being readable in reflections.

#

*Putting aside annotation processors

worldly ingot
#

Beat me to it

shadow night
#

When making an annotation, what does all that code meam

lost matrix
#

Was seeing you writing something and just threw it in quickly 😛

quaint mantle
#

Reflection

river oracle
worldly ingot
#

Annotating annotations do be weird tho

shadow night
young knoll
#

annotationception?

quaint mantle
shadow night
#

Annotations can annotate

river oracle
shadow night
dry hazel
lost matrix
#

And there is @FunctionalInterface as well

shadow night
#

Not null and nullable are just decorations for future readers of code, right?

lost matrix
#

Which is just an information for the dev reading code

lost matrix
shadow night
dry hazel
#

yes

#

and kotlin interop also makes nullability assumptions based on them

slate tinsel
#

Is this correct to set force to true for particles

          world.spawnParticle(Particle.CLOUD, location, 25, 1, 1, 1, 0.1, true);

          world.spawnParticle(Particle.EXPLOSION_LARGE, location, 10, 0.5, 0.5, 0.5, 0.1, true);

          world.spawnParticle(Particle.LAVA, location, 2, 0.5, 0.5, 0.5, 0.1, true);

therefore I only get null.

#
[16:29:06 WARN]: [HubTeleport] Task #6 for HubTeleport v1.0-SNAPSHOT generated an exception
java.lang.IllegalArgumentException: data (class java.lang.Boolean) should be class java.lang.Void
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:435) ~[guava-31.1-jre.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.spawnParticle(CraftWorld.java:2114) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.spawnParticle(CraftWorld.java:2109) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.spawnParticle(CraftWorld.java:2098) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.spawnParticle(CraftWorld.java:2093) ~[paper-1.20.1.jar:git-Paper-169]
        at wilmer.hubteleport.Utils.ActionUtils.rocket_particle(ActionUtils.java:62) ~[HubTeleport.jar:?]        at wilmer.hubteleport.Action.Rocket.RocketTask.run(RocketTask.java:59) ~[HubTeleport.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.1.jar:git-Paper-169]
        at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1479) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1393) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1170) ~[paper-1.20.1.jar:git-Paper-169]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.20.1.jar:git-Paper-169]
        at java.lang.Thread.run(Thread.java:1623) ~[?:?]```
quaint mantle
young knoll
#

You need to add another argument

#

Add a null before the true

slate tinsel
young knoll
#

Ope you need another arg

#

Add a 0 before the null

slate tinsel
young knoll
#

mhm

slate tinsel
#

Thanks! 🙂

quaint mantle
#

Guys, is there a method for making custom portals?

lost matrix
lost matrix
storm crystal
#

What do they do

quaint mantle
shadow night
lost matrix
lost matrix
quaint mantle
icy beacon
#

Thanks! I'll try that now

storm crystal
#

Why

#

Guy in tutorial just said to put it didnt explain what it does

#

Didnt know its called annotation as well

shadow night
#

Basically

icy beacon
# storm crystal Guy in tutorial just said to put it didnt explain what it does

So from what I know, the event system in Spigot is done with reflection, which basically means that you can call code using only the names of something, e.g.

MyClass instance = new MyClass();
Method method = MyClass.getClass().getDeclaredMethod("someCoolMethod");
method.invoke(instance, parameters);

And the system that Spigot uses basically scans methods that are annotated with @EventHandler inside every registered listener (because you obviously wouldn't want to treat every function inside a class as an event, what if it's an utility or something totally unrelated).

#

Look up annotations in Java to learn more about their general premise

remote swallow
#

it probably loops annotations, checks the method params and then handles it

slate tinsel
#

Can I check if a block is not a complete block, for example if it is a slab or a trapdoor, etc. in some simple way

young knoll
#

Material#isOccluding will handle most of it

#

However some full blocks are also not occluding

#

Like glass

slate tinsel
#

can you otherwise use solid or check solid for other blocks as well?

grand flint
young knoll
#

Or you can mess about with its collision shape

grand flint
#

isnt that unnecessary effort

storm crystal
young knoll
#

# is used to note that it's an instance method

#

Material.isOccluding cound be confused as a static method

storm crystal
#

ah

#

so you need to do like

#

Material mat = idk how material is syntaxed;
and then you can do mat.isOccluding?

glad prawn
#

Material mat = Material.DIAMOND; ?

wooden hearth
#

Hey, should I make it when they reload the server it loads the PlayerData onEnable or just say in red PlayerData won't load on Reload as I'm thinking to load player data on Join

icy beacon
#

Discourage people from reloading the server

#

Restarting it should always be the way

#

And if you want your plugin to be reloadable, make a command for your plugin specifically

#

Like /myplugin reload

#

And treat it as you wish

wooden hearth
#

I want them to restart the server instead of reloading because I'm making a server core which provides alot of Data and player data

#

or even kick all the players on reload

river oracle
orchid trout
#

is this normal

lilac dagger
#

the red?

remote swallow
#

ye

lilac dagger
#

yes

remote swallow
#

you havent added it to git

orchid trout
#

ok

#

thans

river oracle
lilac dagger
#

it means those classes aren't on git

wooden hearth
river oracle
#

lol nice picture

#

xD

#

what was that

lost matrix
orchid trout
#

is this normal

lost matrix
#

Wanted to post this...

river oracle
#

that's more boring

#

whats the other thing!

icy beacon
lost matrix
orchid trout
icy beacon
#

Yeah generally

storm crystal
orchid trout
#

wdym what

lost matrix
storm crystal
#

I was asking if I understood # symbol correctly

#

Since its present often

wooden hearth
#

Hey, would it be wrong to store a hashmap inside of Value of a hashmap?

lilac dagger
#

no

lost matrix
shadow night
#

How much data are you storing if you got a hashmap in a hashmap

wooden hearth
lost matrix
#

Sure, do that. But create manager classes and dont let it dangle in random HashMaps

lilac dagger
#

you're losing variable names which is why you don't see maps inside other maps that much

shadow night
shadow night
#

that's why mojang has a pair class

lost matrix
#

Using Pair is a sign of failure imo

shadow night
#

what even is pair lmao

#

I've only seen it in packets

lost matrix
#

Just an object with two objects in it

shadow night
lost matrix
#

Write a proper class with a meaningful name for that

shadow night
#

Map 2.0?

lilac dagger
#

writing clean code's not easy

valid burrow
#

does anyone know an decent api for nicknames

#

or is it simpler in newer versions

#

all i find is 10 year old resources

lilac dagger
#

they should work i think

valid burrow
#

well is it worth it or do i just use an api?

#

alr

grand flint
#

What's the updated version of registerPacket?

slender elbow
#

no it doesn't?

grand flint
#

Yes it does

quiet ice
#

6.5 Mb isn't that large

grand flint
#

Anyways what is the newer version of registerPacket?

quiet ice
#

If it were to exceed a Gb then yeah, perhaps. But 6.5 Mb is peanuts

lost matrix
#

What are you loading there?

slender elbow
#

yeah it definitely doesn't exceed any "length limit"

#

that'd be around 2 GB anyway

quiet ice
#

I'd more worry about the tokenizer/parser running out of memory than String length being a concern.

lost matrix
#

I mean for 6.4M chars it would have to be a pretty small server to run out of memory

quiet ice
#

Yeah, it's still a nonissue worry

smoky oak
#

was it deploy or install to get your code's API into .m2

quiet ice
#

deploy is a superset of install

smoky oak
#

lright

quiet ice
#

However deploy also pushes it to all other repos that you may or may not have

smoky oak
#

how do i put that dependency into the xml?

#

like i dont think i need the repo but the other part?

lost matrix
quiet ice
smoky oak
#

like

#

its a api

grand flint
#

nvm it was my own thing 😭

smoky oak
#

of course i want to use it in another plugin

quiet ice
#

Just register the dependency like any other dependency?

#

I am a little bit confused as you should already know that...

smoky oak
#

the gears arent turning here

#

i had 5 hours of sleep and been awake for over 14 horus

sullen iris
quiet ice
#

Like

        <dependency>
            <groupId>{group}</groupId>
            <artifactId>{artifact}</artifactId>
            <version>{version}</version>
        </dependency>

whereas those correspond to those declared in your API's pom.

#

Like, uh I don't know how to explain it to you

quiet ice
smoky oak
sullen iris
quiet ice
#

What trail after the numbers?

smoky oak
#

I'm saying <version>-dev to prevent it generating 100 different entries

#

<version>0.1-dev</version>

quiet ice
#

0.1-dev is your version string

smoky oak
#

lright

#

btw dont i need to say it's provided as well?

quiet ice
#

You could also use [0,1) or other ranges - however 0.1 wouldn't work as it ONLY* matches 0.1

#

You may need provided but you could also used compile or test - depending on your needs

smoky oak
#

k

umbral ridge
#

hey
what's better?
use WatchService to detect config.yml changes or
use a scheduler that periodically checks for changes
(I tried to use WatchService but I don't understand why it fires 2 times)
I listened for StandardWatchEventKinds.ENTRY_MODIFY

young knoll
#

Generally just

dry hazel
#

the watchservice javadoc outlines this, a file modification may result in several events being fired; you'll have to deduplicate them, i.e. process only one within a given timeframe

young knoll
#

add a reload command

#

Automatically reloading on change sounds a bit risky

slender elbow
#

i wish WatchService allowed to watch for file closing :/

umbral ridge
#

It doesn't specify what "more" is and why

#

Got it. So I gotta code like a workaround

#

play with some booleans?

#

ints?

dry hazel
umbral ridge
#

I'll take a look thanks!

slender elbow
#

/chatgpt translate this go code to java

#

:trollface:

dry hazel
umbral ridge
slender elbow
#

I'm sorry to hear that

dry hazel
#

EMILY

umbral ridge
#

It wasn't very pleasant

slender elbow
#

only 50% of that is true

#

I wouldn't call it great, it's alright but eh

lost matrix
#

It has decent coroutines. And thats where my compliments end for the language.

slender elbow
#

@dry hazel never

dry hazel
#

I know you are secretly a rust fan

slender elbow
#

your knowledge is deeply flawed

dry hazel
#

😴

lost matrix
#

VHDL isnt really programming. (Same goes for Verilog if you are american)

quiet ice
#

Should I use Float#floatToIntBits or Float#floatToRawIntBits? What is the difference outside of different handling of NaN values, if any? Is one method faster?

#

I'm using them for a #hashcode method btw

young knoll
#

You could try a benchmark

valid burrow
#

if i do .add(0, "afawga"); in a stringlist will that remove the previous 1st string or will it just move everything up a int

quiet ice
#

I'll go with floatToRawIntBits then as the non-intrinsic impl uses it either way

slender elbow
#

insert and shift everything else

valid burrow
#

arl th

#

alr thx

paper viper
#
int i = 0;
        for(SkyBlockMaterial material : farmingMaterials.keySet())
        {
            int actualSlot = FarmingHelper.slots[i];
            menu.getSlot(actualSlot).setItemTemplate(p -> {
                ItemBuilder farmingMaterial = new ItemBuilder(material.getItemStack());
                farmingMaterial.setName("§a" + material.getName() + " "+ CollectionHelper.getCurrentTier(p, material));
                farmingMaterial.setLore(CollectionHelper.generateLore(material, p));
                p.getInventory().addItem(farmingMaterial.toItemStack());
                LoggerModule.getInstance().log(actualSlot + " " + material.name());
                return farmingMaterial.toItemStack();
            });
            LoggerModule.getInstance().log(actualSlot + " " + material.name());
            i++;
        }

Why are some slots not showing up?

lost matrix
#

Looks to me like everything is showing up?
What do you expect to be different?

paper viper
#

the three missing items

#
private static LinkedHashMap<SkyBlockMaterial, GUIMenu> farmingMaterials = new LinkedHashMap<>()
    {{
        put(SkyBlockMaterial.Farming_Wheat, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Seeds, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Cactus, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Cocoa_Beans, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Carrot, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Melon, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Mushroom, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Nether_Wart, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Potato, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Pumpkin, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Sugar_Cane, new PlaceHolderPage());
    }};
storm crystal
#

I learnt basic syntax, OOP, polymorphism, inheritance, arrays and arraylists (yeah I can tell them apart lol), what else could I learn that would help me in plugin development out of java basics?

lost matrix
river oracle
lost matrix
storm crystal
river oracle
paper viper
#

i switched the order of the list

private static LinkedHashMap<SkyBlockMaterial, GUIMenu> farmingMaterials = new LinkedHashMap<>()
    {{
        put(SkyBlockMaterial.Farming_Cocoa_Beans, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Carrot, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Melon, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Mushroom, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Nether_Wart, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Potato, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Pumpkin, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Sugar_Cane, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Wheat, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Seeds, new PlaceHolderPage());
        put(SkyBlockMaterial.Farming_Cactus, new PlaceHolderPage());
    }};
``` now three other slots arent showing
#
public class FarmingHelper
{
    public static int[] slots = {10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30 ,31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43};
}
low marlin
#

does anybody know how to stop arrows from pushing buttons?

wet breach
storm crystal
#

how does Hypixel do their enemies that look and behave like players?

wet breach
#

if you don't expect NaN or there isn't a possibility of it, then go with the normal one

#

otherwise use the raw

storm crystal
#

such as goblins in mines

wet breach
#

or which ever way it is

#

lol

wet breach
#

but if you look in the source code for this method, literally there is almost no difference except the return

quiet ice
#

Yeah, though you can never be sure with intrinsic method - but I'd guess I am being a little bit too suspicius

wet breach
#

lol

#

if only NaN had a standard

#

in what it was supposed to be

#

s111 1111 1a00 0000 0000 0000 0000 0000 NaN (this is the proper way according to IEEE 754)
0111 1111 1100 0000 0000 0000 0000 0000 FloatToIntBits NaN

pulsar parcel
#

Hi, I was just wondering, is there any way, to send player like packet with fake info about his position, so any client side mod would show this fake position? Or something like that?

wet breach
#

sending such a packet would also show the player physically at that fake position as well. And then you will start encountering issues when they start moving, where the client realizes that isn't their real position tells the server or vice versa so you will get a lot of teleporting issues with it lol

#

ultimately will either result in crashing the players client or kicking them from the server

pulsar parcel
#

Hmm, I see.

#

Ok, thanks for your response

wet breach
#

not sure if there is some other thing you can do except hide the player from the others

#

until they are in view

#

in doing this, the server will keep track of the players movements but won't send such info to the players they are hidden from

dry patrol
#

do any of you know how to make TextDisplay background transparent? 😮

lost matrix
dry patrol
#

How do I do it? 😅

lost matrix
#

This is a bit freestyled

TextDisplay display = ...;
Color color = Color.fromARGB(0, 0, 0, 0);
display.setBackgroundColor(color);

Its deprecated because its still draft API

dry patrol
#

Thank you 🫶

uncut needle
#
@EventHandler
    public void OnPlayerJoinGame(PlayerJoinEvent event) {
        World world = player.getWorld();
        
        Bukkit.broadcastMessage(String.valueOf(world.getPlayers().size()));
        if (world.getPlayers().size() == 1) {
            //THIS PART
        }
    }```
#

Why this gets called only 1/3 of the time

#

the if statement

#

the 1/3 chance is choosen when server reloads or restarts

#

I want to check if the player is the first person to join the world

rough drift
#

<= 1

uncut needle
#

doesnt work

lost matrix
#

Why do you check the amount of players in a world instead of the whole server?

uncut needle
#

because the world is the only world in the server

lost matrix
#

Then check using the player count server wide

uncut needle
#

ok I will try it

#

still doesnt work 1/3 of the time

#

I have multiverse installed

#

does that cause issues?

lost matrix
#

What do you mean it doesnt work 1/3 of the time? Is that an exaggeration or an actual measurement?

uncut needle
#

about

#

sometimes doesnt sometimes does

lost matrix
#

Ok let me replicate this real quick

uncut needle
#

I have been trying to fix it for 3h

lost matrix
#
  @EventHandler
  public void onJoin(PlayerJoinEvent event) {
    int playersOnline = Bukkit.getOnlinePlayers().size();
    if (playersOnline == 1) {
      System.out.println("First player joined");
    }
  }

Ok so this worked 100% of the time for me so far.

#

Send your full code again pls

uncut needle
#
@EventHandler
    public void OnPlayerJoinGame(PlayerJoinEvent event) {
        World world = player.getWorld();
        
        Bukkit.broadcastMessage(String.valueOf(world.getPlayers().size()));
        if (world.getPlayers().size() == 1) {
            //THIS PART
        }
    }```
#

I will tell you more about my code

#

this is in abstract class

uncut needle
lost matrix
#

You are still not testing against all online players

uncut needle
#

I didnt want to show my actual code because its messy

#
@EventHandler
    public void OnPlayerJoinGame(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        World world = player.getWorld();

        if (!world.getName().equals(name)) {
            return;
        }
        Bukkit.broadcastMessage(String.valueOf(world.getPlayers().size()));
        if (Bukkit.getOnlinePlayers().size() == 1) {
            this.world = world;
            points = new Points(player.getWorld().getPlayers(), maxPlayers);
            //StartGame();
            WaitForPlayers();
            /*
            if (!devMode){
                StartCountDown();
            } else {
                GameStart();
            }
             */
        }

        points.addPlayer(player);

        player.sendTitle("Waiting for players", "", 10, 100, 10);
        player.setLevel(gameLength);
        player.setExp(1f);
        /*
        player.getInventory().setItemInOffHand(gps);
        points.addPlayer(player);
         */
    }```
#

here it is

lost matrix
#

Add a sysout in your if clause and check if its called

uncut needle
#

WaitForPlayers() does a thing that is noticible

quaint mantle
#

how can we help someone without them showing their code

lost matrix
#

Add a sysout in your if clause and check if its called

uncut needle
#

ok

#

Bukkit.broadcastMessage("test")

#

can I use that

uncut needle
#

no im happy with my naming

#

first try

#

I realised its something else

lost matrix
#

Yeah, i suspected that

uncut needle
#

the way I checked before is I make a task output something

#

so its still something with tasks

#

urgh

#

I was trying to fix my tasks and then I tought its still in the if statement

#

I will go back to fixing my tasks

heady grove
#

Hi, I am having an issue with my command, it is both in the plugin.yml (below) and registered in the onEnable() (also below) method, however, when I run the command in game I am simply given the usage instructions from the plugin.yml. The command previously worked but perhaps I have changed something that has broken it, any ideas would be appreciated. I have verified the onCommand method in ClaimListener is not called using a breakpoint and jdwp

plugin.yml

name: conceptc-claiming
version: "1.0-SNAPSHOT"
author: Dinoosawruss
main: com.github.dinoosawruss.ConceptCClaiming
api-version: '1.20'

depend: [conceptc-core]

commands:
  claim:
    description: Commands used to control claims
    usage: /<command> <trust|untrust|info> [args]

  ignoreclaims:
    description: Admin command to ignore any claims
    usage: /ignoreclaims
    permission: conceptc.admin.ignoreclaims

onEnable() method

@Override
public void onEnable() {
    logger = getLogger();

    dbUtils = getPlugin(ConceptCCore.class).getDbUtils();
    
    logger.log(Level.INFO, "{0}.onEnable()", this.getClass().getName());

    this.getServer().getPluginManager().registerEvents(new BlockListener(), this);
    this.getServer().getPluginManager().registerEvents(new ClaimBlockInteractListener(), this);
    this.getServer().getPluginManager().registerEvents(new ViolationEventListener(), this);

    this.getCommand("claim").setExecutor(new ClaimListener());
    this.getCommand("ignoreclaims").setExecutor(new IgnoreClaims());
}

Neither the claim or ignoreclaims commands work and both just give the usage information in response when run in-game

lost matrix
#

^

uncut needle
#

everyone do a posture check

heady grove
#

onCommand is not being called when the command is run

#

Although onCommand in this case would only return false when a message is also issued to the player which is also not happening

uncut needle
#

ur welcome

heady grove
#
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    ConceptCClaiming.logger.info("Reached");
    if (sender instanceof Player) {
        Player player = (Player) sender;

        if (args.length == 0) {
            player.sendMessage("Insufficient args");
            return false;
        }

        switch(args[0]) {
        case "trust":
            new ClaimTrust(player, args);
            break;

        case "untrust":
            new ClaimUntrust(player, args);
            break;

        case "info":
            new ClaimInfo(player);
            break;

        default:
            player.sendMessage("Unknown argument");
            return false;
        }
    }
    
    return true;
}

"Reached" is never issued in the log when run - I have also verified with jdwp that the onCommand method is not being run

lost matrix
#

case "default": lmao

heady grove
#

oh yeah oops...

#

although that isn't causing it

#

thats better lol

young knoll
#

There’s a Player#getAddress

lost matrix
#

^
And then you can get the GeoLocation from his IP

#

Just download the GeoLite2 database. Its not too big i think.

heady grove
#

23.10 21:04:50 [Server] [INFO] Dinoosawruss issued server command: /claim trust conceptc is the only log line given when the command is executed

lost matrix
#

The GeoIP2 api reads this file in with their reider. Cant quite remember how it went.

#

Let me just check real quick

heady grove
#

It is definitely ClaimListener

package com.github.dinoosawruss.commands.listeners;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.github.dinoosawruss.ConceptCClaiming;
import com.github.dinoosawruss.commands.executors.ClaimInfo;
import com.github.dinoosawruss.commands.executors.ClaimTrust;
import com.github.dinoosawruss.commands.executors.ClaimUntrust;

public class ClaimListener implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        ConceptCClaiming.logger.info("Reached");
        if (sender instanceof Player) {
            Player player = (Player) sender;

            if (args.length == 0) {
                player.sendMessage("Insufficient args");
                return false;
            }

            switch(args[0]) {
            case "trust":
                new ClaimTrust(player, args);
                break;

            case "untrust":
                new ClaimUntrust(player, args);
                break;

            case "info":
                new ClaimInfo(player);
                break;

            default:
                player.sendMessage("Unknown argument");
                return false;
            }
        }
        
        return true;
    }
    
}

Imported to main class via import com.github.dinoosawruss.commands.listeners.ClaimListener;

#

jdwp shows ClaimListener being initialised as expected also

lost matrix
#
    String ip = "your-ip-address";
    String dbLocation = "your-path-to-mmdb";
        
    File database = new File(dbLocation);
    DatabaseReader dbReader = new DatabaseReader.Builder(database).build();
        
    InetAddress ipAddress = InetAddress.getByName(ip);
    CityResponse response = dbReader.city(ipAddress);
        
    String countryName = response.getCountry().getName();
    String cityName = response.getCity().getName();
    String postal = response.getPostal().getCode();
    String state = response.getLeastSpecificSubdivision().getName();

I would also reuse the DatabaseReader

young knoll
#

You can do that with a static database?

#

Magic

lost matrix
#

Feeling a bit stalky today, are we?

#

You could probably scrap GeoIP then and query an external provider for that information

glad prawn
storm crystal
#

is using database an optimal way to store information about player? as in lets say that on player join I would assign them in database base custom statstics such as attack, crit chance etc. and do it only once after they join to add them to database

young knoll
#

Yeah that’s fine

#

You can also store data in their pdc

#

Advantage of a database is querying and all that fancy relational stuff

#

Also pdc isn’t available if they are offline

wet breach
lost matrix
storm crystal
wet breach
#

they just use a different kind of DB that suits their needs

#

that is really the only thing to consider

#

is the DB that suits what you need it for

lost matrix
#

Probably a paid one.

storm crystal
lost matrix
# storm crystal whats the difference in storing things in files or databases?

There are quite a few differences. When it comes to pure persistence, then Files and Databases are pretty equal until you reach a
bigger number of entries. The file system can be slower if it has to deal with thousands of files while Databases are optimized to
search for properties and even more optimized for primary keys and indices.
The file system also does not support queries. For example: "Collect all players with more than 100 kills"
Databases have the drawback of added complexity as they often come with their own API and SQL even
with its own turing complete language that needs to be learned first.

So if you are explicitly looking for only persisting data, then Files can be a very viable tool.

storm crystal
#

especially could be extra useful on my programming classes

#

I want to universalize a few things in my server

#

such as adding custom enemies, lootboxes, statistics and such

lost matrix
#

Then write against interfaces. This lets you swap out different implementations whenever you want, without breaking your code.
But this is quite the task because designing for abstraction can be complicated.

storm crystal
#

I dont really catch it

lost matrix
#

Yes, already writing an example

#

[Part I]
Given the interface

public interface PlayerDataAccess {
  PlayerData load(UUID playerId);
  void save(PlayerData data);
}

You can already write against this interface, without knowing how the implementation looks like.
You just define the input and output of your methods and trust that the impl will achieve what you expect:

public class PlayerListener implements Listener {

  private final PlayerDataAccess access;
  
  public PlayerListener(PlayerDataAccess access) {
    this.access = access;
  }

  @EventHandler
  public void onJoin(PlayerJoinEvent event) {
    PlayerData data = this.access.load(event.getPlayer().getUniqueId());
  }

}
#

[Part II]
Now if you want an impl which saves your data to Files, you simply implement this interface in a concrete class:

public class PlayerFileAccess implements PlayerDataAccess {

  private final JavaPlugin plugin;

  @Override
  public PlayerData load(UUID playerId) {
    File playerFile = new File(plugin.getDataFolder(),  playerId.toString() + ".yml");
    // Some loading from file
    PlayerData data = ...;
    return data;
  }

  @Override
  public void save(PlayerData data) {
    UUID playerId = data.getPlayerId();
    File playerFile = new File(plugin.getDataFolder(),  playerId.toString() + ".yml");
    // Some saving to file
  }
}

This impl can be used when creating an instance of the Listener:

  @Override
  public void onEnable() {
    PlayerDataAccess access = new PlayerFileAccess();
    PlayerListener listener = new PlayerListener(access);
    Bukkit.getPluginManager().registerEvents(listener, this);
  }
#

[Part III]
If you want to change your impl at any point later in time, you can simply write a completely different impl which uses a DB for example:

public class PlayerDBAccess implements PlayerDataAccess {

  @Override
  public PlayerData load(UUID playerId) {
    Connection connection = DriverManager.getConnection(...);
    PreparedStatement statement = connection.prepareStatement(...);
    // Load PlayerData from DB
    PlayerData data = ...;
    return data;
  }

  @Override
  public void save(PlayerData data) {
    Connection connection = DriverManager.getConnection(...);
    PreparedStatement statement = connection.prepareStatement(...);
    // Save PlayerData to DB
  }
}

And then change the impl you provide:

  @Override
  public void onEnable() {
    PlayerDataAccess access = new PlayerDBAccess(); // This is now another impl
    PlayerListener listener = new PlayerListener(access);
    Bukkit.getPluginManager().registerEvents(listener, this);
  }

The listener doesnt care what class he gets, as long as it implements PlayerDataAccess.
This makes it easy to swap out different implementations without changing anything in your code.
All you need to do is change this single line:

  PlayerDataAccess access = new SomeCoolImpl();
#

A lot of big words. Not sure if it makes interfaces clear...

#

It is really important to actually write something like this for yourself and test it out. Otherwise the whole concept is quite abstract.

storm crystal
#

idk I feel like databases would be better

lost matrix
# storm crystal idk I feel like databases would be better

Well, you could just use an interface as a placeholder for now.
But if you think that learning Databases right away doesnt mess with the learning curve of your primary code then go for it.
Usually i ask for a justification from the person who decides to use a Database. Do you really need it, and what is your argument for using it.

storm crystal
#

do you have any resources about SQL database management in spigot?

#

cuz in Kody's video its more of a showcase rather than tutorial, basically saying "here you can do this and that" without any in depth explanation

lost matrix
#

You can apply any modern Java SQL tutorial

#

Baeldung probably has a decent one

storm crystal
#

😭

valid burrow
#

?paste

undone axleBOT
valid burrow
#

but

#

printing it out works just fine

#

it just stops after that line

somber night
#

how do i play custom sounds from a resource pack from my plugin?

valid burrow
kind hatch
valid burrow
#

how is line 54 and "unsupported operation"

#

im adding a string to a string list

echo basalt
#

probably because it's an immutable list

#

as in Collections.EMPTY_LIST type deal

#

also mutable lists are.. mutable

valid burrow
#

i cant add stuff to an empty list?

echo basalt
#

You aren't working on a copy

#

so your setter is useless

valid burrow
#

i want to change one value then put it back into the database

echo basalt
#

so don't call setUnlocked

#

even then, you shouldn't expose mutable collections

#

I'd make an addUnlocked method on the TitleData class

valid burrow
#

okay ill change that but i still dont understand why i get that error

#

like

echo basalt
#

Your main problem is how you're initializing the list

#

List.of() and Collections.EMPTY_LIST return an immutable list

valid burrow
#

so i cant edit it cause its empty?

echo basalt
#

because it's immutable

valid burrow
#

and its immutable cause its empty?

echo basalt
#

No

valid burrow
#

why then

slender elbow
#

it's immutable because it's immutable

#

you can have an empty list that is mutable

echo basalt
#

They're meant to always be empty by design so adding elements would never be a good idea

slender elbow
#

you can have a non empty list that is immutable

echo basalt
#

think of immutable as a final but for elements in a collection

valid burrow
#

okay well how else should i do it then

echo basalt
#

I'd make the getters always expose immutable lists and just making methods to add data to the class itself

#
/**
 * The TitleData class represents data belonging to a {@link Title}.
 * @author Illusion  
 */
public class TitleData { // TODO: Make this an interface, enterprisify the entire code structure

  private final List<Whatever> list = ...; // Make sure you don't use List.of or whatever, but rather initialize a list object with the "new" keyword

  /**
    * Returns an immutable copy of the backing list
    * @return an unmodifiable list.
   */
  public List<Whatever> getMyList() {
    return List.copyOf(list);
  }

  /**
    * Adds an element to the internal list.
    * @param whatever - The element to add to the internal list
    */
  public void addWhateverToList(Whatever whatever) {
    this.list.add(whatever);
  }
}
#

You have full control over what gets added to your list because you never expose it directly

kind hatch
#

Should probably also add a comment about it returning a immutable copy. For the documentation and what not. :3

echo basalt
#

fuck you

kind hatch
#

.-.

#

no u

glad prawn
#

gay moment

valid burrow
#

somone gotta reach me how to really handle data

#

cause i just do whate ever with it

river oracle
#

Wdym by handle data

valid burrow
#

scroll up

echo basalt
#

there you go

wet breach
slender elbow
#

Lost.copyOf :woeisme:

echo basalt
#

done in discord so fuck indentation

echo basalt
slender elbow
#

ly2

valid burrow
kind hatch
#

What does yh mean?

echo basalt
#

yeah

valid burrow
#

yeah

kind hatch
#

Seriously?

echo basalt
#

yeah

valid burrow
#

yeah

river oracle
kind hatch
#

ight

wet breach
noble flume
#

Anyone know how to get started with server sharding?

river oracle
#

Especially when it comes yo editing data

echo basalt
#

"what does idk mean"

river oracle
#

I don't know 😕

#

I wish I knew

echo basalt
valid burrow
echo basalt
#

now all of my code looks unreadable unless you have exact context of what you're looking at

#

because it's all just interfaces and generics

kind hatch
#

I feel that

echo basalt
#

just grab betonquest's codebase, pull up a random class and tell me what it does

echo basalt
wet breach
# noble flume ^

you will basically have to create a whole new implementation unless you are trying to do this concept without doing so

echo basalt
#

and want like.. general tips

wet breach
#

in which case good luck because there is no easy way to do that

river oracle
kind hatch
#

🤔

noble flume
echo basalt
#

Yeah so you know about packets and stuff

noble flume
#

I was thinking about forking multipaper

echo basalt
#

that's like having a minigame as your first project

#

slow down

wet breach
#

sharding works under the principle of there being a master server and many slave servers. Difference here is that if a slave goes down, the whole system doesn't go down just whatever that slave controlled. If slave doesn't come back you either just ignore whatever it had for the time being or you move the work from it to the rest of the shards

echo basalt
#

I'd rather do meshing where there's no master server and all the slaves gaslight each other

wet breach
#

lol

echo basalt
#

or well, your "master" database is more of a redis cluster

echo basalt
#

Where you have, for example, a messaging queue of some sort (Redis pubsub for example, let's skip its caching functionality for now just to make it a little harder)

#

And each server you have, has an internal id, for example

valid burrow
#

how do i clear my database

kind hatch
#

Drop it. lmao

echo basalt
#

You can have, for example, a Map<UUID, Integer> playerCounts

#

Where the uuid is the server id and the int is the player count for that server

wet breach
#

just be careful to not drop the table or db

#

unless you just want everything to be gone

valid burrow
#

thats what i want

#

i wanna rese tit

wet breach
#

well this won't reset it

#

it will just erase it

valid burrow
#

goo enough

#

good enough

#

just need it to be empty

wet breach
#

drop database "dbname";

echo basalt
#

Now the idea is to have it so every single server has the map synchronized, so let's also add a long lastUpdateMS

#

When the server starts, ask "the network" for the latest data, which can just involve every single server sending its data and last update ms and we just filter it all

#

When a player joins, you add 1 to your own id, update your lastUpdateMS and send a packet to "the network" indicating new data

#

When a player leaves, you remove 1 etc

#

And when your server stops, you try to tell everyone to remove your data

#

Now, what if the server crashes? You can implement a heartbeat system where if I don't hear from you in ~5 seconds I just assume you collapsed and died

noble flume
#

Developing a sharding/meshing system

echo basalt
#

If this is advanced then multipaper is hell

#

But yeah you also want to make sure that every single server like

#

only contains its own data and minimizes the amount of data it knows about everyone else

#

Otherwise as you scale in server count, every instance gets more and more bloated

noble flume
echo basalt
#

No clue what you're trying to do

noble flume
#

Trying to figure out how to cram as many players onto a world as possible

echo basalt
#

multipaper is a start

#

didn't mrbeast's minecraft team make a plugin where you saw holograms of other players on clone servers?

#

that needs a ton of packet magic

subtle folio
#

would you do this to sync ping?

noble flume
#

Mr Beast can hire like the best networking professionals on the planet

echo basalt
#

kennytv and egg82

#

doesn't need to be networking professionals