#help-development

1 messages Β· Page 959 of 1

quiet ice
#

Use something like ManagementFactory. OperatingSystemMXBean would allow you to get the CPU load

brittle geyser
#

just use spark

#

if u want advanced memory info, u need to use JDK mission control, mat or visualVM

echo basalt
#

Yourkit

brittle geyser
#

with spark u can get info about plugins processer usage

quiet ice
#

what exactly is the problem anyways

brittle geyser
#

Why reinvent the bicycle? Use existing programs

echo basalt
#

We're using lossy hashing for culling

quiet ice
#

so basically - rounding?

echo basalt
#

Yeah but encoding a whole location in a long

quiet ice
#

So not something like Objects.hash((long) x * c, (long) y * c, (long) z * c)?

echo basalt
#

Nope

#

Because we want to fine tune exactly the losses

#

So we can define how many "steps" are in each axis

#

And keep the pos xyz the same

#

The whole point isn't to avoid collisions

#

But to use them in our favor

#

Force a collision if it's within a certain range

quiet ice
#

so something like

fun hash(x, y, z, c) {
  xi : int = x * c
  yi : int = y * c
  zi : int = z * c
  ret xi & ((1 << 26) - 1) << 0
      | yi & ((1 << 12) - 1) << 26
      | zi & ((1 << 26) - 1) << (26 + 12)
}
proven musk
#

ok, for some reason I can't save persistent data using my setup
so while the server runs im saving it into a hashmap, and then onDisable I save all of that to each players pdc
however when i restart the server it doesn't load the data

anything wrong with this on first blush?

echo basalt
#

Yeah but xyz are encoded too

quiet ice
#

I mean surely the MSBs aren't required?

hollow vessel
#

still doesnt working

echo basalt
#

They're nice to haves

#

We just store a Map<UUID, Set<Long>>

#

And check directly

quiet ice
#
  • even your algo culls them at 0x3F_FF_FF_FF (= (1 << 30) - 1) for x and z and 0xFF (= (1 << 16) - 1) for y
#

Oops, forgot the bitshifts before OR'ing them together in my pseudocode

ocean hollow
#
private static final AttributeModifier attackSpeed = new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 0, AttributeModifier.Operation.ADD_SCALAR);
```  if I want to add attribute item, will it set attackSpeed to 0?
#

and than that:

quiet ice
young knoll
#

I think it will

#

?tas

undone axleBOT
quiet ice
#

Really? It's ADD_SCALAR?

#

?jd-s

undone axleBOT
quiet ice
young knoll
#

As soon as you add a modifier the base modifiers are gone

#

So adding 0 to 0 should result in 0

#

Althought now that I think about it that'll be apllied to the players base attack speed

#

Which is 4

#

So you probably want -4

quiet ice
#

I mean multiplication with 0 will defo get you to 0 so you'll completely avoid everything else

young knoll
#

True

#

Depends if you want to cancel our attributes on armor ig

#

And attributes on the player itself

#

Also note that at 0 attack speed the player will never raise the item when switching to it

old cloud
ivory gale
#

Hello !

I'm designing a plugin to "freeze" the state of blocks, i.e. prevent them from growing, and I'm trying to cancel the growth of cactus, sugar cane and other plants.

These trigger BlockGrowEvent events, which offer two methods:

  • getBlock(), which returns the block before the growth.
  • getNewState(), which returns the new block

The problem is that these two methods concern the block that has just appeared, i.e. just above the block I've frozen, so I can't carry out my check on the stored blocks, which shouldn't be growing. For example, in the case of the cactus, getBlock() will return air, and getNewState() will return a cactus. And there are no other methods. Of course I could use the getRelative(0, -1, 0) method to retrieve the block below and that would work for the cactus and the sugar cane, but that would cause problems for the wheat, which stays on the same block and calls the same event.

It's a shame, because the BlockSpreadEvent, which works in the same way, offers a getSource() method... Why isn't this the case with the BlockGrowEvent, or why don't the cactus trigger the BlockSpreadEvent instead? So, does anyone know how to efficiently retrieve the event's origin block, the one from which the extension is added, without having to check the item's previous type and add conditions?

Thank you very much!

chrome beacon
#

You can always add a getSource method yourself with a PR

#

?contribute

ivory gale
#

I guess it's a good challenge

hybrid spoke
#

not sure how its handled serverside, but my first thought would be that it could be a challenge to get the source of melons f.e.

#

maybe its clearer than i think it is

ivory gale
#

I'm not sure I have the required level, but I can always try πŸ™ƒ
But as you said, it might be complicated to find the origin of plants that can spread horizontally like melons, especially if there are several side by side

azure vault
#

i need to use com.github.koca2000:NoteBlockAPI:1.6.2, it's not in mvncentral, only in jitpack. is there any way to use the libraries plugin.yml feature to do this?

#

like can i add an additional repository somewhere?

hybrid spoke
#

you'll have to see

young knoll
#

You could also just jank it with the physics event

#

But that event is a bit Oof

ivory gale
#

From what I've read, it's a good way to make your server explode πŸ˜‚

young knoll
#

I mean it’s not actually that bad

#

But it’s not ideal

hybrid spoke
ivory gale
#

Oh wow, to contribute to Spigot I really have to give my physical address and phone number? That's pretty intimidating 😳

hybrid spoke
#

yeah because you have to sign a contract

ivory gale
#

I'll add that to my CV

hybrid spoke
#

could be the beginning of something great πŸ€·β€β™‚οΈ

quiet ice
#

I mean to contribute to libGDX you have to print out a text file, sign it, scan it, send it as a PDF inside an email and then send the piece of paper via snail mail.
So spigot certainly is not the worst one out there

chrome beacon
#

πŸ‘€

#

wait really

quiet ice
#

yeah, I was like "okay?" when I first read it. Seems like it is only for larger contributions though

chrome beacon
#

hm I don't see the snail mail part

#

just email

tardy delta
#

oh libgdx is java, i thought we were talking about some niche c library

quiet ice
tardy delta
#

ye sure lets send a document to austria, piece of cake

#

hopefully it would arrive

quiet ice
#

there's a different CLA for corporate entities, which is something I haven't seen before either

proven musk
#

???? why does the actual folder disappear?

#

im trying to upgrade from ecplise to intellj

#

and the folder shows up for a sec and then goes woop bye bye

tardy delta
#

id say remove that eclipse nonsense

quiet ice
#

which folder?

tardy delta
#

src

quiet ice
#

they seem to not be using maven or gradle from the looks of it

proven musk
#

this shows up for a split second

tardy delta
#

nope, go use maven or gradle

proven musk
#

im trying to follow this tutorial

quiet ice
#

Using either maven or gradle might be best practice. I'd say you have your visibility options wrongly set up

#

But since I am a hardcore eclipse enthusiast, I cannot help you beyond that

tardy delta
#

id say just create a pom.xml

#

good luck with gradle

proven musk
#

what even is maven

quiet ice
#

I mean at the end of the day it usually boils down to whether you hate having lots of lines or not

proven musk
#

this tutorail that says "create a blank spigot file with maven" doesn't rly say much about it

tardy delta
#

whether you want to have an awful lot of gradle files

proven musk
#

unless im missing something

quiet ice
proven musk
#

nope

#

im mostly concerned on how do I "go use maven"

quiet ice
proven musk
#

literally the exact one im using

quiet ice
#

it's not

#

scroll down

tardy delta
#

just copy the pom.xml, change it and call it a day

proven musk
#

idk what to tell u

#

I added the pom.xml but nothing changed

tardy delta
#

gotta re open it

#

intellij isnt gonna magically refresh it

quiet ice
proven musk
#

tbf idk what any of this is

quiet ice
#

In that case you are all set!

proven musk
#

but thanks

tardy delta
#

its just a build system, like for dependencies and stuff

proven musk
#

it worked

#

kinda

#

is there a way to generate a proper pom.xml file

#

cuz idk what to put as the headers

quiet ice
#

headers?

tardy delta
#

what did you get?

#

well just create something along the lines of

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>project</artifactId>
    <version>1.0.1</version>
</project>
proven musk
#

it needs like a project thing which I could add but I assume theres a better way than manually adding that and making sure its all right

tardy delta
#

just copy my project tag, never seems to change

proven musk
#

alr

#

ty

#

I think it works

tardy delta
#

lovely bunch of chickanery, but if it works

#

please also use a gitignore, well if you put it on github atleast

quiet ice
#

meh, it's only required if one does version control

tardy delta
#

true

#

i just make a template once and use gh repo create name --template=path", github cli for the win

proven musk
#

how do I make it so that it outputs the jar directly into my plugins folder

quiet ice
#

I only create a repo once a month or so so I never bothered to streamline the process - but I also have enough repos that I can copy & paste what I need and know where to find what I need

#

I think mfnalex might have a guide for that somewhere

quiet ice
#

see

proven musk
#

ty!

#

yayy got it working

lilac dagger
#

did any of you guys tried to get the generic type of a list in this context?

tardy delta
#

impossible

#

or what do you mean

lilac dagger
#

fields carry generic info assuming nothing deletes the attribute from the class

tardy delta
#

theres type erasure

lilac dagger
#

i'm upgrading my config system

rotund ravine
#

ArrayListMultiMap 🫢🏻

lilac dagger
proven musk
#

wheres my intellj code highlighting?

rotund ravine
lilac dagger
#

nope

rotund ravine
#

Empty like it has string but no values

lilac dagger
#

there is value

tardy delta
#

could call getClass() on an element if you're lucky

lost matrix
lilac dagger
#

actually it's not true for Field

rotund ravine
#

Just do nothing if empty otherwise pretend it’s a List<Object> and save individual keys as their respective types

lilac dagger
#

field.getgenerictype returns the class type

lilac dagger
tardy delta
#

isnt Field::getGenericType() for the field type itself

lilac dagger
#

yup

rotund ravine
#

Whatever it is querying with getGenericType is probably slow too

tardy delta
#

you cannot ask a Map what its generic type parameters are

lilac dagger
#

i guess it doesn't matter hmm

tardy delta
#

could write a code generator if you're feeling fancy

#

Γ  la annotation processor

lilac dagger
#

so close

#

this is the final issue

lilac dagger
#

i mean this works

young knoll
#

πŸ˜‰

lilac dagger
#

hmm

#

thanks col

rotund ravine
#

Or use kotlin, it probably has something for this

tardy delta
#

you know something we dont know?

lilac dagger
#

this is uh, over engineered i think

#

i have this already

proven musk
#

is my dependency not setup right? I dont get autocomplete or anything

tardy delta
#

:o ParameterizedType is a thing? ig it just asks the jvm

lilac dagger
#

yup

#

found in gson types class

rotund ravine
proven musk
#

thats what it said to do

young knoll
#

Idk I just used what redlib had :p

proven musk
#

if I know switching would be such a pain in the ass I woulda just stayed with ecilpse 😭

tardy delta
#

its a good thing to get rid of eclipse

quiet ice
tardy delta
#

people will probably start throwing stuff at me now

tardy delta
#

especially geol

quiet ice
proven musk
#

Ive done all that

lilac dagger
#

eclipse is good, otherwise our intellij overlords would think that community edition shouldn't exists

rotund ravine
proven musk
#

dude I know

tardy delta
#

dunno how good eclipse is now, ive only used it in the very beginning like 3-4 years ago

proven musk
#

its just not doing that

rotund ravine
#

Take a picture of ur full IJ window

quiet ice
#

Is your classpath even set up correctly?

proven musk
#

i have no idea what that is

quiet ice
rotund ravine
#

maven uses src/java too right?

quiet ice
#

src/main/java yes

proven musk
#

πŸ€·β€β™€οΈ

quiet ice
#

This is an issue with using the wrong source directory as JanTuck detected

proven musk
#

do I have to change the folder

tardy delta
#

create a proper package structure

quiet ice
#

Yeah, just dump everything in your "src" directory in "src/main/java"

quiet ice
proven musk
#

ok that worked

#

ty guys

#

why does intellj not like when I use var

#

eclipse was totally chill with it

rotund ravine
#

Check ur java version in project settings

brittle geyser
rotund ravine
proven musk
#

yeah ik I can change it but I dont wanna

brittle geyser
#

wait a moment

rotund ravine
young knoll
#

Booo var

quiet ice
proven musk
#

I will not tolerate codeshaming

#

it works for me

young knoll
#

Maybe java 8 was better

tardy delta
#

ew

rotund ravine
#

U need jdk 10 or newer for var

brittle geyser
#

var is big problem

quiet ice
tardy delta
#

or switch to kotlin and get var and val for free πŸŽ‰

proven musk
quiet ice
proven musk
#

idk if you considered that

tardy delta
proven musk
rotund ravine
#

Better than

tardy delta
#

uh ye..

proven musk
#

whats val

quiet ice
tardy delta
#

final var in kotlin

rotund ravine
proven musk
#

i already had that tho

tardy delta
#

i believe lombok also has val but that would work with a compiler plugin

brittle geyser
#

gif not working

rotund ravine
#

She wants to use var πŸ€·πŸ½β€β™‚οΈ

#

Just let her

proven musk
#

she

brittle geyser
sullen marlin
#

real developers use real variables

brittle geyser
#

U can write getter and press ALT + ENTER + ENTER

brittle geyser
#

Option + Enter for Mac

proven musk
#

im above the average programmer

tardy delta
sullen marlin
proven musk
#

real developers dont need to use good principles

tardy delta
#

nah go or c++

young knoll
#

Be C# and do it backwards

quiet ice
#

real developers don't spend their entire day on the spigot discord

brittle geyser
#

Real developers use keyboard shortcuts

young knoll
#

MyObject object = new();

tardy delta
#

real developers go touch grass once in a while

proven musk
brittle geyser
#

new MyObject() ALT + ENTER + ENTER

tardy delta
proven musk
#

yes I know

tardy delta
#

c++ just be like MyObject object, i love it

#

i believe i scared everyone away by mentioning

young knoll
tardy delta
#

i use it on fields, quite reasonable

young knoll
#

Ig

#

Idk C# wacky sometimes

tardy delta
#

i'm starting to like it over java

vast ledge
#

YOU SAY WHAT

tardy delta
#

wouldnt ever touch c# if i didnt have too but i just like it

vast ledge
#

I was boutta say...

young knoll
#

Some things do be kinda nice

tardy delta
#

it has structs

#

i can sleep happily if i know i didnt waste time on a heap allocation

young knoll
#

Getting those fancy $”” strings up in here

tardy delta
#

meanwhile we getting weird ass string templates

vast ledge
#

'Fancy String'

#

or js

#

its cursed

tardy delta
#

cuz they cant alter the lang too much

vast ledge
#

("%s - %d" % (1, 2))

#

Like tf is that

tardy delta
#

string and double and something?

vast ledge
#

no like placeholders in text

proven musk
#

whadda hell

tardy delta
#

be glad you dont have to use printf

proven musk
#

now my plugin wont load

#

after switching to intellj

vast ledge
#

Cool

vast ledge
#

it fun

young knoll
#

$”My name is {name}” > whatever java is getting

tardy delta
#

STR."""hello"""

#

tf

proven musk
#

i have no idea what the problem is

vast ledge
#

Just do str.replace("{name}", name)

#

why the new fancy shit

young knoll
#

That’s slow

#

Smh

proven musk
#

since it wont even have the common decency to give me an error

young knoll
#

Muh cpu cycles

tardy delta
#

string processor would still have to do it at runtime

#

wouldnt be surprised if it generates the code for it at runtime

vast ledge
#

Maybe

#

god knows

tardy delta
#

lambdas do that too but anyways

vast ledge
#

but lambda

#

is nice

#

:D

tardy delta
#

string concantenations do that too

#

"a" + "b" could turn into StringConcatFactory.concatSomethingSomething

young knoll
#

~~ C# operator overloading also kinda nice~~

vast ledge
# vast ledge but lambda
AtomicInteger largest = new AtomicInteger(0);
json.keySet().forEach(key -> {
  String str = stripKey(key);
  if(!str.equalsIgnoreCase(p1.getWorld().getUID().toString())) return;
  largest.set(Math.max(largest.get(), Integer.parseInt(key.split("\\.")[1].split("\\.")[0])));
});
return largest.get();
#

look at it

#

it so lovely

tardy delta
vast ledge
#

it saves so much space

ivory sleet
#

apart from that u use atomic integer

#

but yea

vast ledge
#

Yea

brittle geyser
#

largest

vast ledge
#

the Atomic stuff is annoying af

tardy delta
#

in kotlin, it works fine with Int but wraps your int in the background πŸ’€

young knoll
#

It stills feels weird doing += on a list tho

#

Ngl

brittle geyser
#

new AtmoicInreger() is equal to new AtmoicInreger(0)
Congradulations u save 0.0001 seconds

ivory sleet
#

singleton array or effective final w var

vast ledge
brittle geyser
#

Ok

ivory sleet
#
int[] o = new int[1];

//or
var b = new Object() {
  int ref = 0;
};
b.ref //access
young knoll
#

Cursed

#

Both of them

ivory sleet
#

fr

vast ledge
#

brother

#

the actual

#

fck

#

is that

#

abomination

tardy delta
#

wondering what rust does

ivory sleet
#

ayo

#

why the hate

proven musk
vast ledge
#

explodes

proven musk
#

huhhh

young knoll
#

Wait can’t you just use Integer

vast ledge
#

no

#

who lieks integers

#

just use int

brittle geyser
tardy delta
#

is that effective final?

vast ledge
#

stop using not not not not

#

it hurts

young knoll
#

Ah right because it’s immutable

proven musk
young knoll
#

MutableInt when

vast ledge
#

never

proven musk
#

(this is supposed to be HELP development right?)

young knoll
#

Actually that’s probably a thing

ivory sleet
#

buuut

vast ledge
brittle geyser
rotund ravine
#

No one really cares unless someone is asking for help

ivory sleet
#

ask away yk :P

proven musk
#

im the one asking for help

rotund ravine
#

Then click alt enter

#

Select implement methods

proven musk
#

but it worked before

vast ledge
#

"But it worked before"

#

thats the same statment

#

sa

#

"It works on my PC"

proven musk
#

it literally worked before i moved to intellj

#

the code cant be the issue

vast ledge
#

No shit

#

Did you import it with intellij?

proven musk
brittle geyser
#

intellij is smarter

vast ledge
#

or did you just pull the folder over?

#

Show code

#

?paste

undone axleBOT
proven musk
#

alright uhh

#

I hit implement methods and I just created a copy of what I had

#

I deleted that and now it works

#

very smart intellj

vast ledge
#

Cool, so problem solved

brittle geyser
#

maybe u have mistake on name

#

or method parametres

rotund ravine
#

Or indentation

vast ledge
#

Anyways @ivory sleet , Completeable futures, yay or ney?

proven musk
#

idk

brittle geyser
#

so intellij just fixed it

vast ledge
#

I abuse the shit out of them

#

Worse then my static abuse

rotund ravine
#

Well that’s less yay

hybrid spoke
#

cf everything

ivory sleet
#

i mean structured concurrency api is gonna be neat also

rotund ravine
#

I still remember the guy who thought he could use CFs whenComplete or whatever to have it run on the main thread

tardy delta
proven musk
#

if im saving data using onDisable theres a chance that it wont save in the event of a crash right? Or do I not have to worry about that

vast ledge
#

I mean look at this, its epic, lambda + completablfuture is epic

rotund ravine
proven musk
#

I just wasn't sure if usually it gets called anyway

vast ledge
#

I mean...

#

a crash is a crash

rotund ravine
proven musk
#

alr

young knoll
#

I wish there was a CompletableFuture#join that also deal with exceptions

vast ledge
#

You wish

young knoll
#

Yes ik try catch but blah

vast ledge
#

But thats

#

like

#

3 more lines

#

wayyy

#

to many

tardy delta
#

add an .exceptionally first before joining? or doesnt that work?

young knoll
#

Exactly!

brittle geyser
#

Is completable future equal function?

young knoll
#

Idk I just made a janky wrapper that adds a join(BiConsumer<Exception, T>)

tardy delta
#

makes him deal with an interrupted ex

young knoll
ivory sleet
#

yea

tardy delta
#

ive never found that exception to be useful

ivory sleet
#

its useful

vast ledge
#

The only reason i used completable future was cus i wanted it async ☠️

ivory sleet
#

because it allows for async things to cancel appropriately

young knoll
#

SonarLint just tells me to dethrone it

#

rethrow

ivory sleet
#

anyway

tardy delta
#

hmmye..

ivory sleet
#

get() throws ExecutionException

tardy delta
#

anyways good night

vast ledge
#

Everything throws an exception

#

event good night

#

Exception in main thread: Couldnt sleep

ivory sleet
#

and then join() throws completion error right?

#

or sth

young knoll
#

I believe so

rotund ravine
ivory sleet
#

yea thats fine

#

the actual exception is just the cause in those ones

#

iirc

brittle geyser
#

use else

vast ledge
#

ewww

#

!else

#

idk

#

i just have a personal issue with else

hybrid spoke
#

boilerplate ftw

vast ledge
hybrid spoke
rotund ravine
#

Smh

rotund ravine
vast ledge
#

Ya know

#

i could

#

but then it wouldnt be nearly as fun to torture myself :D

brittle geyser
#

How i can do it initialize on plugin start and only one instance

private static ScheduleManager instance;
    public static ScheduleManager getInstance() {
        if (ScheduleManager.instance == null) {
            ScheduleManager.instance = new ScheduleManager();
        }
        return ScheduleManager.instance;
    }

    private ScheduleManager() {

    }
rotund ravine
#

A plugin will only be initialized once

#

Hint hint onEnable

brittle geyser
#

i can split getInstance to 2 another methods

#

initialize and get?

vast ledge
#

????

rotund ravine
#

I mean if ur lazy

#

Just getInstance in onEnable

#

U could also

vast ledge
#

or just init it in ur onEnable?

brittle geyser
vast ledge
#

yea

rotund ravine
vast ledge
#

then call initialize in your plugin onEnable()

rough ibex
#

what a font

#

lmao

proven musk
#

How would i keep a specific item in a specific slot? (basically a menu item)

brittle geyser
#

It`s for classes without parametres ?

proven musk
#

what event would be best to actually put the item there

vast ledge
#

Theres a bunch

#

InventoryMoveEvent

#

i forogr the other ones

#

refer to docs

brittle geyser
hybrid spoke
#

you want to cancel the inventoryclickevent

#

and inventorydragevent

brittle geyser
#

write class which contain inventory

rotund ravine
vast ledge
brittle geyser
proven musk
brittle geyser
#

You need to put things in your inventory once?

rotund ravine
proven musk
#

I just need to make sure its always there

brittle geyser
proven musk
#

ig i could just do it on player join

vast ledge
#

Heres all the inveory events

#

Future Reference

https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/package-summary.html
brittle geyser
vast ledge
#

Oh no

#

dont start this

vast ledge
#

i got grilled for using em to

young knoll
#

Click and drag are generally all you need

#

That said I never use drag and things work fine

inner mulch
#

read it i will help you design proper gui

rotund ravine
ancient plank
#

holy embed

vast ledge
#

😒

#

Jan

#

stab the embed

#

please

#

its my entire fucking screen

brittle geyser
rotund ravine
brittle geyser
#

Oh

hybrid spoke
#

i mean to drop if you already cancelled the other events

rotund ravine
brittle geyser
#

I need to rewrite my code xd

hybrid spoke
#

hotbar yes, but the topic was menu items

rotund ravine
#

No

#

The topic was keeping an item in one slot

rotund ravine
#

Yes

#

A slot can be in the hotbar

#

And can be clicked as a menu item if setup as such

vast ledge
#

oh god

#

i have to pay

#

fck

#

man

#

why didnt i go to bed

#

i wouldnt have thought avout the server bill

proven musk
#

is there an nbt data library

vast ledge
#

why?

#

for what reason?

chrome beacon
rotund ravine
proven musk
rotund ravine
#

Yes

proven musk
#

not just store data

chrome beacon
rotund ravine
vast ledge
#

Everybody be askin the same question

proven musk
#

in this instance the player of a player head

#

but id like to know how to do it in general

chrome beacon
#

in general you don't touch the nbt directly at all

proven musk
#

whats the api method

chrome beacon
#

block or item?

proven musk
#

ohh is it like

#

itemmeta

chrome beacon
#

Yeah

#

SkullMeta for skulls

proven musk
#

hmm

#

how do I get the skullmeta

chrome beacon
proven musk
#

ah

chrome beacon
#

Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...

#

^^ this is what you should send for custom skulls

#

it's also what the thread above links to

vast ledge
#

I c

proven musk
#

alr I got it

#

ty

young knoll
#

Man Alex should be paying us for all this advertising

sullen marlin
#

Alex to make official docs when

ivory sleet
#

fr

worldly ingot
#

mfw wiki pages Sad

#

Also, wow, really? A rainbow skull as an example. Even Alex has gone woke. Unacceptable

quiet ice
worldly ingot
#

Can't be having none of them wokies around these parts

#

/s

remote swallow
#

alex is the wokie

#

ban him

quiet ice
#

I haven't seen him in a while, is he already banned?

proven musk
#
var data = PlayerData.getPlayerData(player);
var stack = new ItemStack(Material.PLAYER_HEAD, data.soulPoints);

var skullMeta = (SkullMeta)stack.getItemMeta();
skullMeta.setOwnerProfile(player.getPlayerProfile());
player.getInventory().setItem(44,stack);
player.sendMessage("Updated player menu");

I know this code is running on the right player, but its not doing anything. Do i misunderstand what the .setitem command does

#

im pretty sure soulPoints is not 0 but could that be it?

worldly ingot
#

Nope. Should work fine. Though a couple things to note:

  1. Is data.soulPoints > 0?
  2. You didn't call stack.setItemMeta(skullMeta) before you set it in the inventory
proven musk
#

ah

#

why might it not be working other than the soulpoints

worldly ingot
#

That's probably the only thing I can think of tbh

#

Aside from just that code not getting invoked at all

proven musk
#

I changed it to 1 but its still not working

#

but im getting the message in chat

worthy yarrow
#

Time for debug statements

worldly ingot
#

Actually, wait, what is slot 44? If you're trying to set the head slot there's a setHelmet()

proven musk
#

the last hotbarslot

#

but idk if thats right

worldly ingot
#

Definitely not

proven musk
#

idk what the slot ids are tbh i just looked up it for vanilla

worthy yarrow
#

You might also want to check that the slot isn't already filled with something

worldly ingot
#

Yeah Bukkit's slot ids differ from the protocol ones

#

Slot 0 would be the first hotbar slot

proven musk
#

so it would be 9

worldly ingot
#

0 - 8 from left to right, then 9 - 35 for the inventory slots, top left to bottom right

proven musk
#

er

#

9

worldly ingot
#

Oh, sorry, last slot, yes. 8

proven musk
#

8

#

ok it worked with that

#

where are the real slot ids

proven musk
#

how would I uhhh

#

set stuff like bold and italics

young knoll
#

Smh bad wiki

proven musk
#

strangley theres nothing on google

worldly ingot
#

ChatColor has constants for those

proven musk
#

is it just chatcolor.italic?

worldly ingot
#

Yes

proven musk
#

weeird it didn't show up when I first tried it

#

how do I ensure its NOT italic
bc usually custom item names are italic by default

#

is there no way to just use the datapack json method then id know what im doing

worthy yarrow
#

You can do the generic chatColor.(color), I prefer the translateAlternateColorCodes, as to make the messages easier to configure (when it comes to color and what not)

worthy yarrow
proven musk
#

huh

worthy yarrow
#

Just make a new string objext

worldly ingot
#

ChatColor.WHITE would work fine

#

It will strip the italics

worthy yarrow
#

Or do what choco said

#

Cuz I'm cooked

proven musk
#

oh so any color would work

#

how would you add two things

worthy yarrow
#

Technically yes

proven musk
#

like color and italics

worldly ingot
#

Colour first, then format I think

worthy yarrow
#

translateAlternateColorCodes

proven musk
#

thanks!

worthy yarrow
proven musk
#

is swapping hands (swapping with offhand) just a item drag event?

worthy yarrow
#

I thought there was a playerSwapHandItemsEvent

proven musk
#

alr

#

how would I stop a player from moving an item from the inventory? Im cancelling the drag and click event

#

but it like

#

lets me pick it up with the item staying in the same place

#

it duplicates it basically

worthy yarrow
#

EntityPickupItemEvent and playerDropItemEvent

proven musk
#

I dont think thats it

worthy yarrow
#

Wdym by moving an item from the inventory?

proven musk
#

thats when you pick it up and throw it on the ground

#

sorry I meant in the inventory

worthy yarrow
#

send your listener code

proven musk
#
@EventHandler
    public void onItemClick(InventoryClickEvent event) {
        if(event.getSlot() == 8) event.setCancelled(true);
    }

    @EventHandler
    public void onItemDrag(InventoryDragEvent event) {
        if(event.getRawSlots().contains(8)) event.setCancelled(true);
    }```
young knoll
#

Creative mode is jank

worthy yarrow
#

Oh

young knoll
#

Replicate in survival first

worthy yarrow
#

That's why haha

proven musk
#

OH

#

it works in survival

#

how would I get it to work in creative? is it not possible

worthy yarrow
#

Creative likes to mess with inventory events

proven musk
#

its ok if I doesn't but id rather it worked

worldly ingot
#

Yeah, you're a bit shit out of luck when it comes to creative mode inventory handling

young knoll
#

Mojaaaaaang

proven musk
#

nw

worthy yarrow
#

tbf

proven musk
#

ok so

worthy yarrow
#

You could prolly detect what gamemode the player is in and not allow them to do whatever it is you want whilst in creative

proven musk
#

when I hit a number key it moves the item still, what event is that

worthy yarrow
#

but that's like your best fix tbf

fluid river
#

can somebody explain

#

how does server know that entity should be in this exact position and state next tick

worthy yarrow
fluid river
#

like server doesn't know what blocks are and that entities are stepping on them

#

why can't entities drop through the blocks then

young knoll
#

The server knows what the collision shape of a block is

fluid river
#

so server stores collision shape of all blocks in all loaded chunks at runtime?

proven musk
fluid river
#

since server is more about packets, not like spawning stuff

young knoll
#

It knows what state is at what position

#

And each state has a collision state

fluid river
#

server doesn't like "see" what's going on

proven musk
#

I mean the blocks are all on the server I assume

fluid river
#

it just receives and sends packets

proven musk
#

where else would they be

young knoll
#

It also stores all the data, lol

#

Main thing the server doesn’t have is textures

fluid river
#

yeah, true

#

entire rendering is client-side

#

but like on server each tick each entity updates it's position, right?

proven musk
#

hmmmm

fluid river
#

players are not taking part in it at all

#

like in force-loaded chunks entities should still exist like around spawn?

#

and do smth like fight against each other

young knoll
#

They won’t spawn

#

Nor will they be active

#

But yes they will still β€œexist”

proven musk
#

so the item drop event doesn't know what slot its from

fluid river
#

but it's not possible yet afair

fluid river
fluid river
#

at least entities which are near players

young knoll
#

Yes

fluid river
#

and some kind of code does the ground check for that each tick

#

and if there is no ground, entities are pulled down by simulated gravity

#

am i thinking in right direction?

worthy yarrow
young knoll
proven musk
#

im jsut gonna do this the right way and store the fact that the item can't be moved in its pdc

fluid river
#

isn't there some kind of playerdecidedtothrowstuff event?

brittle geyser
#

It is crazy code?

worthy yarrow
fluid river
fluid river
young knoll
#

Correct

fluid river
#

cuz i mean some games which have a host-clients multiplayer model, host player does the physics

#

and just sends packets to all connected guys

fluid river
#

i'm doing a multiplayer shit for like 4 players in total for lobby

young knoll
#

What

fluid river
#

and using the minecraft system where everything is counted as a multiplayer(even a singleplayer world)

fluid river
#

with npcs which are gonna walk around

#

i only need them walking(no dialogues or actions yet)

worthy yarrow
#

Have you considered using mythic mobs?

fluid river
#

if that's to me, then i'm not coding minigame

young knoll
#

I think they are making a stand-alone game

fluid river
#

im coding a game from scratch

worthy yarrow
#

Ah

#

Thought you meant a minigame

slender elbow
#

Craftmine?

fluid river
#

more of a

#

RimSky

young knoll
#

Minetest

#

Wait no that’s already a thing

fluid river
#

yeah

fluid river
#

I guess you all got the joke, i'm a bit frustrated right now

#

sorry for that

worthy yarrow
young knoll
#

Minecraft runs on a server in both single player and multiplayer

young knoll
#

The single player server is internal where the multiplayer one is dedicated

fluid river
#

well, in my game server just stops, saving data if possible when anybody is not responding for too long

#

it's kinda like not letting game progress when you lose second player

#

in splitscreen games

worthy yarrow
#

Intentional? Seems a bit unorthodox

fluid river
worthy yarrow
#

Why would the server stop when players stop responding / interacting or wtv

fluid river
#

i mean it's like a hard coop for not more than 4 players

#

you ever played for the king?

worthy yarrow
#

Ohh gotcha so it is intentional then

#

I have not, but I get the idea

fluid river
#

i just had a dream for a long time to create some kind of RPG but also with coop

#

like imagine playing DnD or Munchkin, but players are in open world and meet each other like randomly

#

one of 4 players can, for example, never meet other 3

worthy yarrow
#

Dont get me wrong rpg is fun, but I'd like to see a sandbox / rpg style come out... as in something where the story doesnt actually end, just keeps building from player input

fluid river
#

rpgs are mostly freeplayed

#

with no end

#

i mean sure you can beat all questlines

worthy yarrow
#

"end" in the sense of the storyline for most games

fluid river
#

but that doesn't stop random fun encounters

#

Or like random activities

#

and the bangerest banger -- game can have mods

#

with new quests and location

worthy yarrow
#

Yeah but imo those activities/objectives will never be as fun as the "main" goal of completing the storyline as it were

fluid river
#

I mean i'm almost 600hrs in skyrim

#

and when guys released their first multiplayer mod like 6-8 years ago, this idea came to my mind

worthy yarrow
fluid river
#

yeah like some random town decides to start a war because of circumstances which are not fully controlled by the player

worthy yarrow
#

Exactly

#

Things that seem external from the players current obj

fluid river
#

well now you get what i wanna do

worthy yarrow
#

Yes I believe I am understanding the goal

#

Be sure to include me in the alpha

#

and beta for that matter

fluid river
#

yeah i'm currently adding devkit and mod support

worthy yarrow
#

How much of the foundation is done?

fluid river
#

so well, i guess this week i would have working map for multiplayer

fluid river
worthy yarrow
#

Not bad

fluid river
#

i need to make devkit extra powerful

worthy yarrow
#

How's the world generation?

fluid river
#

basically when you get to play, game spawns grid of 5x5 cells around you with events happening

worthy yarrow
#

So essentially you're using mc framework for the I guess what you could call backbone?

fluid river
#

nah, it's independant of mc

#

and not blocky

worthy yarrow
#

I know that, just in the idea of their multiplayer impl / world generation / etc?

#

Not that cell system isn't common

fluid river
#

rn the multiplayer impl is just udp and tcp for establishing the connection

#

so when host hits Play, he and his lobby-mates are getting loaded into the game

proven musk
#

hold on

fluid river
#

for new save at least

#

i haven't made fine save system yet

proven musk
#

is the Player object only for the spawned player? Does it go away when they leave and go back?

fluid river
worthy yarrow
fluid river
#

or you mean in my game

proven musk
#

so I should store data in playerprofile

proven musk
#

in mine

fluid river
#

like in for the king

#

you create base lobby settings like difficulty and other stuff

proven musk
#

er

#

that doesn't work

fluid river
#

then you call your friends on discord

#

and invite to lobby

proven musk
#

how do I store data for a specific player

worthy yarrow
#

Uh

fluid river
#

it's moved to playerdat now tho

proven musk
#

sounds overcomplicated

fluid river
proven musk
#

PDC is supposed to save it when the server restarts... right?

worthy yarrow
#

pdc is saved when pdc is applied iirc

fluid river
proven musk
#

damn

#

how would I do that

fluid river
#

what are you trying to do

proven musk
#

I just want to store a few stats

#

honestly

#

nothing crazy here

fluid river
#

but it was long ago

worthy yarrow
proven musk
#

that also seems overcomplicated

fluid river
proven musk
#

like I might as well jsut store it in scoreboard

fluid river
#

which stats are you counting?

worthy yarrow
#

Store/save can mean a lot of things

proven musk
#

players have a certain number of soul points

#

I just wanna store how many they have

fluid river
#

and when all guys are ready, game starts and lets them walk and do stuff

worthy yarrow
fluid river
#

rn no

#

they all do spawn in a small room

#

this part is not done yet

worthy yarrow
#

Well if you're doing a square shaped map, would the best approach be 4 corner spawnpoints?

fluid river
#

sure why not

#

i can also probably have predefined spawn locations

#

like in some beautiful places

#

scattered across the map

worthy yarrow
#

I'd assume so in the sense the map is squared, however you could do randomized spawnpoints based on a quandrant as it were

fluid river
#

also base spawnpoint on race player picked

worthy yarrow
fluid river
#

tho races are pure text rn

#

they don't do anything

#

don't even change appearance since players rn are just capsules

worthy yarrow
#

Right

#

In the theme of races, are they primarily humanoid types?

fluid river
#

If i'm allowed to steal, i can probably have the lizard, catman and smth similar

#

as well as humans like black and white since one race is from desert and second from mountains

worthy yarrow
#

Or perhaps og star trek races :p

fluid river
#

when devkit is done of course

worthy yarrow
#

Oh so that's how powerful you want the kit to be

#

that's nice

fluid river
#

well, base game is literally empty with tons of scripts attached

worthy yarrow
#

Sure sure, but that's where it starts eh?

fluid river
#

yeah

#

base game assets are all packaged until game starts up

#

so firstly i unpack default "records" which are like object datas

#

model records, texture records, worldspaces and cells records and so on

#

then modloader comes in play overriding records or adding new ones depending on installed mods

#

and then you get to main menu

worthy yarrow
#

Whats the primary language?

fluid river
#

c#, with tons of reflection in order to provide an api

#

since it's c#, i use .dlls

#

not jars

#

and well, i got rid of plugin.yml for plugin manager

worthy yarrow
#

Man if there's one thing I never want to get into... its c#

fluid river
#

myclass.DoShit()

#

i swear class.getDeclaredFields is doing the same thing

#

tho in c# it's type.getFields()

worthy yarrow
#

Yeah but imo java is more modern in the fact of I suppose "sctrictness"

#

Easier to manage as well since in the case of being so sctrict, it's almost hard to mess things up that bad

fluid river
#

And also c# is more into event handling

worthy yarrow
#

Well that's probably better for a game from scratch for sure

fluid river
worthy yarrow
#

I think that's just good practice tbf

fluid river
#

so well, along with mods which are just records-based shit

#

which is higly data-oriented

#

i also provide the plugin system

#

for runtime stuff on the server

#

here is where reflection comes to play

#
public class MyShitPlugin : DoTPlugin {

    public override string Name = "MyShitMod";
    // author
    // description
    // api-version
    // mod-version

    public override void OnEnable() {

    }

}```
worthy yarrow
#

I mean I understand why reflection is a thing buttttttt.... it just shouldn't be imo

ivory sleet
#

why not

ivory sleet
#

its a tool, good in the right scenario

drowsy helm
#

most serialization librarie would not exist if not for reflection

#

it's there for a reason

worthy yarrow
fluid river
worthy yarrow
#

It's only ever used for niche purposes (in most cases) and I feel like there should be better or rather cleaner methods of doing so

fluid river
#
DoTPlugin plugin = assembly.CreateInstance("MainClass") as DoTPlugin;```
worthy yarrow
#

Maybe I just dont use reflection enough then

fluid river
drowsy helm
#

and what other 'cleaner' methods would there be?

fluid river
#

since bukkit guys created api for you

fluid river
#

but if there is no api, some random modder would spend a year messing with reflection, to bring it to you

worthy yarrow
#

I say niche in the fact most modern plugins have public api's

#

Hence the cleaner method of just using their api

drowsy helm
#

are you just talking in the case of spigot

worthy yarrow
#

Yes

fluid river
worthy yarrow
#

Reflection is very powerful and useful, I just don't think it's very useful for spigot dev

fluid river
#

yeah same actually

#

well, afair for mobs stuff you need it

drowsy helm
#

if you mean that, yeah I thought oyu meant reflection is a bad thing as a whole

fluid river
#

like ai

drowsy helm
#

but either way even in plugin dev, theres still some cases where its needed

worthy yarrow
fluid river
worthy yarrow
#

Well I think the proccess of making a good api just comes with time of that application being released

#

Ie: user input for better optimization

fluid river
#

well, i decided to start with modding(devkit), api and multiplayer and only after finishing these topics, move to creating locations, quests and npcs

#

Also using a devkit i made

#

alr good night guys

worthy yarrow
#

Take care!

proven musk
#

so what is the best way to store player data

#

people keep saying a config file

#

but idk what that means exactly

#

can you edit config files

worthy yarrow
#

Yes

#

Config file just means flat file unless specified as a config, ie: .yml file would be fine for storing that sort of data

#

config.yml (config) is just the name more or less a descriptor of whats contained within that .yml file

proven musk
#

I think imma just serialize it

worthy yarrow
#

serialize the data, then store it in a flat file. When needed, deserialize and take whatever data you need

proven musk
#

how would I get the filepath of the plugin folder

#

Plugin.getDataFolder().getPath() ?

worthy yarrow
#
 public static void saveKits(Map<String, Kit> kits, JavaPlugin plugin) {
        config = plugin.getConfig();

        config.createSection("kits");
        ConfigurationSection kitsSection = config.getConfigurationSection("kits");

        for (Map.Entry<String, Kit> entry : kits.entrySet()) {
            Kit kit = entry.getValue();
            String path = entry.getKey();

            kitsSection.set(path + ".name", kit.getKitName());
            kitsSection.set(path + ".cooldown", kit.getKitCooldown());
            kitsSection.set(path + ".cost", kit.getKitCost());
            kitsSection.set(path + ".permission", kit.getKitPermission());

            List<Map<String, Object>> serializedContents = kit.getKitContents().stream()
                    .map(ItemStack::serialize)
                    .collect(Collectors.toList());
            kitsSection.set(path + ".contents", serializedContents);

        }
        plugin.saveConfig();
    }```
worthy yarrow
#

But iirc that will return the path of the file not the path within the file

#

I may just be cooked

proven musk
#

hmm

#

well

#

it does say get data folder

worthy yarrow
#

Oh wait

proven musk
#

so if its not the data folder im gonna have a talk with whoever made that api

worthy yarrow
#

No I think I'm just cooked man

#

that should be fine

inner mulch
#

In hibernate, is it possible to somehow make the setters of an entity auto write to the db? (All the changes should be sent to the database automatically) Preferably asnyc? Maybe even just certain methods if possible?

worthy yarrow
inner mulch
#

Im not using transactions currently only to save the objecg fully not while using its setters

#

Is there a different way?

worthy yarrow
#

mmm not that I am aware of unfortunately... might have to ask illusion or someone like that haha

inner mulch
#

some APIs have attached objects which are attached to the db and save auto

#

I wonder if hibernate has tjat

worthy yarrow
#

I'm pretty sure hibernate only process through main thread

#

So they probably wrote that logic out seperately?

inner mulch
#

Okay

worthy yarrow
#

I'd keep in mind the load you're trying to work with async as well... I've seen a couple of operations that absolutely cook the server

inner mulch
#

Yeah i usually dont write instantly to the db but there is some crucial stuff that should be saved instantly

worthy yarrow
#

Yeah just gotta be cautious with your session management, otherwise it's probably fine

inner mulch
#

You mean opening and closing?

worthy yarrow
#

Yes

inner mulch
#

I keep a singleton for every entity

worthy yarrow
#

Ah then you're good

inner mulch
#

So open on start close on stop

worthy yarrow
#

I'd certainly test it, but that sounds fine

inner mulch
#

Okay, thanks for you help

worthy yarrow
#

For sure! I hope it helped more than it didnt haha

proven musk
#

how do i get a uuid thats persistent for a specific player

#

I tried just using the profile as a key but that didn't work so i dont think getting the uuid from that will