#help-development

1 messages · Page 2088 of 1

ivory sleet
#

well

#

its always up to date

granite owl
#

its funny those questions may seem simple and dumb at first but in the end the detail is in their exact implementation

#

and can thus change its ultimate usage

#

xD

ivory sleet
#

ye lol, disadvantage of abstraction

granite owl
#

ppl always ask me

#

why i write so much low level in java

#

simply cause u have more control xD

#

and im too used to it anyway

#

in for example my ini parser, which is written using primitives

grim ice
ivory sleet
#

mye I mean its a dilemma, writing too coupled code and it becomes deplorably suffering to work with

granite owl
#

and iterating strings with low level methods

ivory sleet
#

spigot abstracts over the storage implementation

granite owl
#

the problem is that an api is supposed to help you

grim ice
#

Good

ivory sleet
#

yes but its a disadvantage as well

granite owl
#

but if its not doing what you need and ur bound to it

grim ice
#

I dont see any disadventage though

lean gull
#

does anyone know why PlayerInteractEvent runs twice?

grim ice
granite owl
#

like hasPlayedBefore works for anyone EXCEPT first time joiners

#

and when do you actually figure that

#

only very rarely

ivory sleet
#

I mean just look at timinators case, we do not know for sure how hasPlayedBefore works from a high level abstraction point of view

lean gull
grim ice
ivory sleet
#

nah

granite owl
#

checks if a player has played before

#

yay

ivory sleet
#

the docs must not talk about the low level implementation

granite owl
#

already know that from .hasPlayedBefore

#

xD

#

the name is program

ivory sleet
#

the documentation of an interface should only define the abstract contract of said methods

grim ice
#

in this case, this is functionality

ivory sleet
#

I mean to some degree

grim ice
#

it should mention unexpected results in certain cases

granite owl
#

the low level doc would be like "checks if a player profile has been serialized, returns null if no file was found"

#

and thats what id need

grim ice
#

This isnt abstraction fault

#

documentation instead

ivory sleet
#

you miss the point

#

lets take Map for instance

grim ice
#

in this very case, this isnt a disadventage

#

of abstraction

ivory sleet
#

it cannot talk about how IdentityHashMap disobeys the general Map contract

#

it cannot talk about the concurrency impl of ConcurrentHashMap or ConcurrentSkipListMap

granite owl
#

the problem is that i misinterpreted it as its also a check for online players and thus coded in an oversight which i only found by chance by testing the plugin with a friend who didnt connect to the server ever before

grim ice
#

Mhm

ivory sleet
#

that would be a leaky documentation

#

same applies here

grim ice
#

Well IdentityHashMap should talk about it

granite owl
#

and quickly realized where the error is coming from

ivory sleet
#

it should define the contract of the method

#

not the implementation details

tardy delta
#

yes

ivory sleet
#

or well any particular concretions

#

we can even look at Object::equals

grim ice
ivory sleet
#

it defines contract such as transitivity, symmetry etc

ivory sleet
#

sometimes they're too coupled with the concretion

granite owl
#

oh and btw

#

im using this to set the players scoreboard data

grim ice
#

In this case it isnt though

granite owl
#

thats why i work with offline player

ivory sleet
#

yes it is

grim ice
#

Oh

#

How?

ivory sleet
#

because it'd have to define whether the check of hasPlayedBefore is using a cached value of if it uses a direct IO check as those would be the main error sources

#

which is definitively too coupled with the implementation

lean gull
grim ice
granite owl
#

funfact did u know that by setting an offlineplayer op who is actually offline u can jank the vanilla command system

#

xD

grim ice
#

jank?

ivory sleet
#

are we talking about CraftOfflinePlayer or CraftPlayer merely?

granite owl
#

cause its then missing the name value, and that causes the system to always throw nullptr errors when that players name is being retrieved for say auto completing the deop list

#

OfflinePlayer.setOp(true);

#

and it breaks vanilla commands

eternal oxide
#

My guess is you got an invalid OfflinePlayer which would hav no name

granite owl
#

nope

#

ive compared it

#

the uuid was correct

#

used my own to test it

#

but the name field wasnt existing

#

and that causes the other vanilla commands to break

grim ice
#

OfflinePlayer? it has the name value though

granite owl
#

as well as its version in memory

eternal oxide
#

if you get an OfflinePlayer (by name) which does not exist, an OfflinePlayer object will still be returned but it will have a null name

granite owl
#

i used my own name

#

its valid

#

i used the name of my friend

#

its valid

#

it is because OfflinePlayer seems to be missing methods

grim ice
granite owl
#

to actually set a player

grim ice
#

thats kinda weird

granite owl
#

op

grim ice
#

doesnt it take the name from Mojjang servers

#

nah tf it should have a name

granite owl
#

like ive said

#

if i use it on the player

#

and hes actually online

#

the server has no problem to set op for an OfflinePlayer instance

#

but if that player logs off

#

and is then set op

#

it breaks

grim ice
#

How wtf

granite owl
#

test it for urself if u cant believe it 😛

tardy delta
#

working with valid player objects after they logged out?

granite owl
#

and then check the ops.json

grim ice
#

thats a bug then @granite owl

tardy delta
#

that explenation isnt makign sense then

sterile token
#

Dont tell me he is still trying to do what you told was not recommend?

#

🤔

granite owl
#

ive already written a system that works

#

xD

sterile token
#

So what the issue so

#

....

eternal oxide
#

are you getting the same error using the console op command?

granite owl
#

no issue

granite owl
#

only using the .setOp member from the bukkit api

sterile token
#

So what are you discussing if no issue

eternal oxide
#

one sec and I'll test it

granite owl
grim ice
#

I barely can believe this

granite owl
#

me too

#

until it broke

#

xD

#

then ive written a system that checks if that player is actually online

#

and if hes not

#

his op will be updated

#

the next time he logs in

grim ice
#

then just make console say

#

op offlinePlayer.getName()

granite owl
#

ive overriden the vanilla /op and /deop with my own one

#

using reflection

#

xD

grim ice
#

Why

crisp steeple
#

is your usercache.json corrupted or something?

granite owl
#

because i needed different behavior

grim ice
#

which is

lean gull
#

are there vectors with x, y, z, yaw & pitch in spigot?

granite owl
# grim ice which is

which is what i receive alot of hate for. binding permissions to scoreboard teams

grim ice
#

Whaaaaat

#

why ru doing that

ivory sleet
#

yaw and pitch would be with a location, but then you get the world as well

grim ice
#

why not use PermissionAttachment

eternal oxide
#

I just tested Bukkit.getOfflinePlayer("ElgarL").setOp(true); and it works just fine

crisp steeple
lean gull
#

how do i set the yaw and pitch tho

worldly ingot
eternal oxide
#

yes, just started server. Never logged in

noble lantern
#

Location technically could be a vector

eternal oxide
#

also had an empty usercache

granite owl
grim ice
#

@granite owl lol?

granite owl
#

try to deop urself

#

being ingame

eternal oxide
#

why?

granite owl
#

and see if autocomplete still works

noble lantern
granite owl
#

because thats where i got the nullptr error from

grim ice
#

ofc it works since ops.json is correct

noble lantern
#

Same with pitch

eternal oxide
#

You said your issue was with OfflinePlayer setting op had no name in teh ops.json

noble lantern
#

Ide should show all methods they'll be named relative to what they are

granite owl
#

ye

#

does it now?

eternal oxide
#

it worked perfectly with .setOp

grim ice
#

knew it

eternal oxide
#
    "uuid": "2643e076-2434-4994-bd91-cb076d57f941",
    "name": "ElgarL",
    "level": 4,
    "bypassesPlayerLimit": false```
lean gull
#

v.toLocation(world).setYaw(10)?

granite owl
#

well i mean i can try to delete the usercache but it did happen to me on 2 different server installations

worldly ingot
#

Well, no, you would use a Location instead of a Vector ;p

grim ice
#

u did it incorrectly then

noble lantern
#

Choco****

#

Stupid autocirrecy

ivory sleet
#

lol

worldly ingot
noble lantern
#

OH BUT DONT CORRECT THAT OKAY

granite owl
lean gull
#

i don't understand

eternal oxide
noble lantern
#

"Autocirrecy"

grim ice
noble lantern
#

Or create your own vector class with these values

worldly ingot
eternal oxide
#

I can test using UUID

lean gull
#

lets say i want to make a ray of particles with vectors, so i set the yaw and the pitch for the direction, then i set the location of where i want to shoot it from, and then i play a particle at the tip of the vector, add 1 to the length, and repeat

#

that's how we do it in skript lol

noble lantern
#

Iirc there is a racist method somewhere

#

Forgot what object its located in

grim ice
#

racist method

#

LOL

noble lantern
#

OMFG

#

Im done

hasty prawn
grim ice
#

BROOO

#

LMFAO

noble lantern
#

This is why I dont help from my phone lmfao

tardy delta
#

ahahah

granite owl
noble lantern
granite owl
#

xD

eternal oxide
#

@granite owl Getting the Offline Player by UUID fails with no name Bukkit.getOfflinePlayer(UUID.fromString("2643e076-2434-4994-bd91-cb076d57f941")).setOp(true);

#

as they have never been on the server

granite owl
#

and it retrieved the username?

eternal oxide
#

No, they have never been on the server and getting by UUID does not perform a Mojang lookup

granite owl
#

then use it on urself

eternal oxide
#

so if you get by UUID, you MUST check the name is not null to ensure its a valid object

granite owl
#

yea but like

#

did u use it on urself

#

with a known user profile

eternal oxide
#

You seem to be confused

#

get an OfflinePlayer by UUID ONLY checks the local server cache of players

granite owl
#

ya

#

ik

#

u told me that before

eternal oxide
#

it will not get a name if the player has never logged into your server

granite owl
#

did u try to op urself with a known user profile on ur local server installation

#

targeting by uuid

eternal oxide
#

op from a valid OfflinePlayer object always works

crisp steeple
noble lantern
#

I feel more ppl would of brought this issue up if it was the api

eternal oxide
#

will take me a minute. I have to update my MC as I've not logged in for over a year 🙂

granite owl
#

sure xD

eternal oxide
#

OK, odd. I can confirm fetching by UUID from Usercache does fail to set the name field in ops.json

#

afk 10, then I'll check soime more

crude loom
#

?paste

undone axleBOT
viral crag
#

what does your shrink say?

ancient plank
#

I am

crude loom
#

I'm having this weird bug, I'm trying to set it so every time the player click a green dye then it will vanish him and convert the green to a gray dye and the other way around
But when its on the green dye i have to click twice and when I had the if statements in order to try and debug it doesnt work at all
here is my code: https://paste.md-5.net/orizinipuf.cs

viral crag
#

mmmm, this is a great place to use a switch case jyk

crude loom
#

I will try and do that

noble lantern
#

Also when you change a material in a gui try calling p.updateInventory()

#

(If the item you edited in the gui doesn't update that is)

crude loom
#

Ah, didn't know this was a thing

viral crag
#

so you set it to grey dye and then you run the code for the grey dye 😛 - yeah a switch would avoid that

#

and speed up the time you are in that code a bit

#

the other alternative is to reduce your code and make the dye swap a generic function and call it by itself and swap colors - rather than separate tests

#

however that is a logic call and style thing on your part

crude loom
#

Also, what am I doing wrong here?

 Material m = p.getInventory().getItemInMainHand().getType();

            switch(m){
                case XMaterial.GREEN_DYE.parseMaterial():

                    break;
            }

Error : Constant expression required

hasty prawn
#

Your case statements have to be constants

#

parseMaterial is not

crude loom
#

A constant variable?

hasty prawn
#

No, not a variable.

#

Something like 5, "hello", Enum.VALUE

crude loom
#

Oh

#
String m = p.getInventory().getItemInMainHand().getType().toString();

            switch(m){
                case XMaterial.GREEN_DYE.parseMaterial().toString():
                    p.sendMessage();
                    break;
            }

Shouldnt this work then?

hasty prawn
#

No because you need a string constant not just a string

eternal oxide
# granite owl so im not insane?

ok finished testing. If the player data (from their last login) is too old/expired it will fail to fetch their data as an OfflinePlayer. As such the name will be null.

viral crag
#

it doesnt need to be a string, your sort of complicating your test

#

just use XMaterial and GREEN_DYE

hasty prawn
#

what's confusing about that

#

It wants a String literal

grim ice
#

it always did?

#

waa

hasty prawn
#

Huh

#

I don't get what you're saying lol

crude loom
#

But I need to give it a value from XMaterial because of the version compatabillity, is it not possible like that?

ivory sleet
#

I mean

#

u have version compat w/o xmaterial

hasty prawn
viral crag
glossy venture
#

is XMaterial an enum

hasty prawn
glossy venture
#

because then you can convert the type to an XMaterial and switch that

viral crag
#

thinks its a good thing I didnt suggest Swtch Case-L

crude loom
glossy venture
#

like

switch (XMaterial.of(m)) {
    case XMaterial.GRAY_DYE:
        // ...
        break;
    // ...
}
crude loom
#

Ah, then why will this work and doing this with normal Material won't?

viral crag
#

it will but its harder if you keep trying to cast it to other types

#

switch is like if, while, etc. it does not care what the types are, but they need to match to be valid

glossy venture
#

which is required for switch cases

crude loom
#

I'm confused😅

viral crag
#

switch is a fairly new method to java

crude loom
#

Oh, so it works the other way around because I convert it before the switch

#

And in the switch I need variables the are not a result of methods?

viral crag
#

they need to be constant, yes

crude loom
#

I see, thanks for the help!

viral crag
#

a switch is (normally) a hard coded state machine

ivory sleet
#

hence sometimes desugared to something completely else

lavish hemlock
#

Uhh

viral crag
#

yeah... it was painful not having it when I first tried to learn java

lavish hemlock
#

I wouldn't exactly call switch new to Java.

viral crag
#

Switch Case-L is actually only available java 16+

#

true. the general switch was added in java 5 or 7 - says the internet

lavish hemlock
#

You're referring to switch expressions

#

...no

#

Absolutely not

noble lantern
#

Wtf

lavish hemlock
#

Okay actually so

#

Strings were added to switch cases in 7

#

BUT

viral crag
#

anyway, its moot and just shows when i first tried to learn java

lavish hemlock
#

switch has likely been around since JDK 1.0

viral crag
#

nope

#

it was one of the things java intially refused to adopt from C

#

that could be, I abandoned trying to learn java for quite a while

lavish hemlock
#

I found the very first language specification for Java

#

JLS, First Edition

#

There's a section for the switch statement :p

granite owl
muted sand
#

if I were to change my server hardware, would I use bungeecord or iptables to route the traffic while the dns changes propagate?

dire marsh
#
Could not find spigot-api-1.18.2-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220318.230433-21).
Searched in the following locations:
    https://hub.spigotmc.org/nexus/content/groups/public/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/spigot-api-1.18.2-R0.1-20220318.230433-21.jar```
#

anyone know how to fix this?

#

tried clearing .m2, invalidating caches, etc

noble lantern
lavish hemlock
fervent gate
#

How would I check if the inv click event is in the actual player inv?

muted sand
dire marsh
lavish hemlock
#

I would also like to mention how

dire marsh
#

it just randomly started doing this yesterday

viral crag
dire marsh
#

has been working fine for months

muted sand
dire marsh
#

same happens across multiple projects as well :/

viral crag
#

it will probably only take an hour anyway, unless your DNS is in a very slow part of the world

viral crag
muted sand
#

i suppose. but if i were to do that, which would be the best option?

||cloudflare now lol?||

muted sand
#

oh, faster dns changes

viral crag
#

it will propigate in teh cloudflare network the fastest and spread out

#

then you can keep your iptables /UFW locked down

muted sand
#

ah okay, thanks!

dire marsh
#

Well, what's the issue?

#

I haven't changed anything in those projects build.gradles for ages

#

and i've tried clearing all kinds of caches

viral crag
muted sand
ivory sleet
#

sam

#

can be a broken push from spigots side

#

or sth

dire marsh
#

I mean it clearly doesn't exist when I go to it, so where would it get that from

#

if I just leave it for a month it will probably fix itself lol

ivory sleet
#

you might have another version still cached

#

lol

viral crag
ivory sleet
#

he has the newest one?

dire marsh
#

unless the repo url has changed

ivory sleet
#

yes

dire marsh
#

year/month/day?

ivory sleet
#

oh yeah

#

well sam you could declare which snapshot version to use specifically

#

or well, just clear the caches and everything

#

.gradle specifically

cyan compass
#

Is there a way of checking if a ChatColor exists before trying to use it?

#

Like i have a config file that you put a colour in. But if that is say something like DARK_CYAN which doesn't exist then the plugin just kind of crashes, so i wish to check if a colour exists before trying to use it

viral crag
cyan compass
#

wdm

dire marsh
#

it's still searching for 20220318 after I specified 20220408, why must I always get problems like this

#

guess I'll just wait for it to fix itself

cyan compass
#

You mean translate the dark_cyan to be dark_aqua and do that for every colour? No that really isn't an option cause what if someone put something stupid in like banana and expected it to work? That would just crash again

viral crag
#

pretty sure they mean id

cyan compass
#

id?

ivory sleet
viral crag
#

you could check against valid ID for the version rather that whatever the color is called

dire marsh
#

I tried .gradle, will try .idea now

ivory sleet
#

mye

cyan compass
#

chatcolor#?

undone axleBOT
dire marsh
#

same thing

ivory sleet
#

hmm

dire marsh
#

dum computers not doing what i tell them to

ivory sleet
#

idk if u tried the m2 folder

#

lol

#

alr

dire marsh
#

yes definitely deleted that

#

I wonder if it'll work from gradlew cmd line

viral crag
#

this is gradle not pulling the correct snapshot?

ivory sleet
#

yes

#

cached an outdated snapshot version

dire marsh
#

It works from gradlew cmd line, intellij is on drugs

viral crag
#

yes, yes it is

cyan compass
#

This doesn't help me

viral crag
#

i generally only use gradlew in teh terminal

dire marsh
#

Where?

cyan compass
#

Well your wrong cause i've tried finding what # means and i cannot find anything expect basic operators which i already know

dire marsh
#

don't think that's doing anything

viral crag
#

intellij may just be dumb and set it in your tasks

dire marsh
#

alright time to try repair ide lol

ivory sleet
#

lol

viral crag
#

I abandoned using intellij's tasks a long time ago

dire marsh
#

yes

viral crag
#

i am not energetic enough to implement vi in windows for programming java

dire marsh
#

alright repair ide didn't work with all 7 steps, good job intellij

#

build.gradle? or the .gradle folder

cyan compass
#

Then could you explain it? Cause all i know is python comments and google isn't finding anything

coarse finch
#

i hate plugin.yml!!!!!

cyan compass
#

Got it

ivory sleet
#

clash of code ?

#

or clash of clans

hasty prawn
#

thats very random

sterile token
#

I think its dead compared with class royale

coarse finch
#

can spigot unblock tor

#

like damn

#

i cant access the forums

#

and stackoverflow is no help here

viral crag
quaint mantle
#

Is there any good developer able to contact me? (Able to create games)
It's agains't rules ask for that?

undone axleBOT
viral crag
#

which no?

quaint mantle
ivory sleet
#

since we don't have a dedicated channel for services and collabs

#

but ye

#

Ig its fine to ask in general every once in a while

coarse finch
#

how can i have a command parameter tab completion for all online players

sterile token
#

Oh lmao 2 weeks with claim and doesnt work its amzimg

#

😂 😂

coarse finch
#

how do i do that

sterile token
#

Im really secure because im not doing correct the Listener

dire marsh
viral crag
#

you reinventing the wheel @sterile token ?

sterile token
#

Console has tab complete

ivory sleet
#

or return null

coarse finch
#

i cant access the docs for it though cause im at school

sterile token
#

Who execute the tab complete class

ivory sleet
sterile token
#

Oh ok

#

Jsut random like me can underdtanf

ivory sleet
#

since TabCompleter, CommandExecutor and the combiner interfaces are just strategies

sterile token
#

So to register command throw Command Map I should use plugin command or command executor?

ivory sleet
#

Uh well

#

any Command derivative works fine

#

so like PluginCommand ye

sterile token
#

But in using reflections 2 times

#

🤔

#

Imsome minutes I will send my code again because the claims are not being created

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

dire marsh
#

intellij has to be caching it somewhere, I just can't figure out where

sterile token
#

But when I said not working really I dont find the reason

#

ME NO

#

I hate kotlin, its like really oddy to understand

lethal knoll
#

Anyone who has experience with integrating with the new mythic mobs?

viral crag
dire marsh
#

yes

lethal knoll
#

For development 🙂

viral crag
dire marsh
#

no just build.gradle.kts

#

it looks better and is faster (apparently)

dire marsh
viral crag
#

when you look in your libraries what did the plugin set?

lethal knoll
#

Maven is giving me the following error when I try to compile:

I'm not a maven expert and don't understand what I'm missing

viral crag
#

its F4 to open module settings btw - intellij has stupid names for settings and preferences

tardy delta
#

is intellij available on linux?

viral crag
ivory sleet
#

of mythic mobs

lethal knoll
#

the latest

dire marsh
sterile token
#

Why the heck the operator "||" cannot be applied to a boolean?

dire marsh
#

it was using my user's .gradle folder

#

so I deleted that, which was massive as well

tardy delta
#

i downloaded it for windows and and i have access to that disk but i probably have to reinstall it for linux then

ivory sleet
dire marsh
#

I didn't even know it used that

viral crag
#

yeah ...

dire marsh
#

i thought that was just where it downloaded gradle and those jdk's to

ivory sleet
#

well .gradle is used to determine the underlying snapshot version

#

since else it'd have to make a request to the repo every time

coarse finch
#

shouldnt return stop the code from executing further? or is my previous python experience fooling me?

maiden thicket
#

yes it should

maiden thicket
#

show code

#

yeah it depends where return is

sterile token
#

Can u assert if what i code its correct because im still having the issue that the claim its not being created

ivory sleet
coarse finch
sterile token
maiden thicket
#

u do if claim is null then create a claim

#

but u never set the claim var again

echo basalt
#

you can easily mitigate that by doing this.claims.create(claim = new Claim(...)

sterile token
#

So what i have to change

#

Because im so depressed with this sh**

#

Hahaha

echo basalt
#

r e a d

tardy delta
#

what is event.setBuild(true) btw

sterile token
#

I will remake the listener for 900 times

#

Already exists, that why im calling getClaim()

viral crag
#

wonders why you dont use an api from an existing claim library

tardy delta
#

claims.getOrCreate(id, SUpplier<Claim>)

sterile token
#

Because my issue is the next im not using normal cuboid

#

Im using radius cuboid

#

oh ok

#

oh ok

maiden thicket
#

oh ok

sterile token
#

why id?

#

Im dont have a map

tardy delta
#

ahah get ninja'd

sterile token
#

Doesnt exists that method on set

tardy delta
#

i mean the id, the thing like in the claims.getClaim(id) method

#

ah its based on a location

sterile token
#

Yeah

tardy delta
#

then do smth like
Claim getOrCreate(Location loc, Supplier<Claim>)

sterile token
#

So will be:

getOrCreate(Location, Supplier<Claim>)

tardy delta
#

yesj

ivory sleet
tardy delta
#

ayy

#

i stole conclures method

#

👉👈

ivory sleet
#

😌

tardy delta
#

i stole your cat

ivory sleet
#

aa

tardy delta
#

does that mean yes?

ivory sleet
#

du då? 😮

tardy delta
#

whats no?

ivory sleet
#

nej

#

oo

tardy delta
#

nej

sterile token
#

Whythe supplier?

tardy delta
#

njetz

tardy delta
viral crag
#

does anyone really know?

sterile token
#

me?

#

I always confused too

tardy delta
#

is this.create saving it in a map or smth?

sterile token
tardy delta
#

only that?

sterile token
#

yes

viral crag
#

add amazon

tardy delta
#

mye then it doesnt really matter

sterile token
#

So please give a conclusion im too confused lmao

#

😮‍💨

torn shuttle
#

I need a life

tardy delta
#

cache i'd say

sterile token
#

Instead of a map im using a set for cache

tardy delta
#

🤷

sterile token
#

And im saving into mongo

tardy delta
#

i saw a dude who was loading his whole database to the cache

#

🤣

tardy delta
#

ahaha

torn shuttle
#

you can load databases to cache just fine

#

depends on what you have in the db in the first place

tardy delta
#

not the whole database lmao

#

the whole player table

viral crag
#

depends on size

torn shuttle
#

why not, if your db isn't meant to be large you can load that bad boy all day long

ivory sleet
#

not particularly scalable but sure works

tardy delta
#

if you dont need it dont load it 🤷

sterile token
#

Im only loading into cache the claims objects, and when a player join his profile object

torn shuttle
sterile token
#

So dotn worry now i need to fix the claims creation haha

tardy delta
#

it was a player cache, load that when the user joins

#

but ye for othe things..

torn shuttle
#

like I said depends on the db but it's fine for some stuff

sterile token
#

Fourteen in conclusion do i have to add tgat mehotd?

torn shuttle
#

like if I had a db that gets changed every tick and is super tiny I probably wouldn't want to keep writing to the db on every damned tick

tardy delta
#

i guess ye

grim ice
#

How to check if a spawner

#

is naturally spawned

torn shuttle
sterile token
#

So what do i have to do...

echo basalt
#

put em all on the same package

torn shuttle
#

each class should be a standalone plugin that depends on your core plugin which just loads every class

echo basalt
#

put it all on 1 class

#

:)

torn shuttle
#

man I could be the first spigot author with over 1000 plugins within the week

#

and also banned

echo basalt
#

I have way too many classes, I should make it all in 1

torn shuttle
grim ice
#

I know

torn shuttle
grim ice
#

but that will only work

echo basalt
#

¯_(ツ)_/¯

#

I have maybe 200 classes here

grim ice
#

for the blocks placed after

#

natural spawners

#

can be broken

echo basalt
#

project is maybe 10% done tho

grim ice
#

but player placed cannot

echo basalt
#

man's writing java itself

torn shuttle
# grim ice Yes

if you don't catch players placing it down and register it yourself you're going to have to pull some dark magic to actually guess if a spawner is "natural"

echo basalt
#

¯_(ツ)_/¯

echo basalt
#

half of it is probably gradle

torn shuttle
#

I mean that's all of idea

#

if I do that I get crazy numbers too

echo basalt
#

¯_(ツ)_/¯

#

I got my entire 120gb ssd dedicated to intellij and mavenlocal

torn shuttle
# grim ice damn

I have no clue of what you're trying to do but if you are the one modifying these spawners you should be registering them to either a file or a database when they are placed

#

yeah it's a statistics plugin

mighty pier
#
        PlayerData.get().addDefault("Players. ", 0);
        PlayerData.get().options().copyDefaults(true);
        PlayerData.save();``` i want to make the default config look like ```Players:
  *uuid*:
    kills:
    otherstuff:``` how do i do that?
tardy delta
#

static meh

mighty pier
#

how do i put uuid in default

tardy delta
#

"players." + uuid.toString()

torn shuttle
#

no

mighty pier
#

its in the main class

#

ok wait nvm

torn shuttle
#

#addDefault("player.uuid", uuid.toString());

#

these are config defaults right

mighty pier
#

yes

torn shuttle
#

ok I guess it depends on whether you want they key to be the player uuid

paper lance
#
package me.snazzeh.main;

import java.util.HashMap;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {
    
    public HashMap<Player, Integer> mined = new HashMap<>();
    
    @Override
    public void onEnable() {
        getLogger().info("Successfully enabled.");
        Bukkit.getPluginManager().registerEvents(this, this);
    }
    
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        event.setJoinMessage("Welcome to the server" + p.getDisplayName() + "!");
    }
    public void onBlockBreak(BlockBreakEvent event, Player player) {
        Player p = player.getPlayer();
        p.sendMessage("You broke a block!");
        
    }
    
    @Override
    public void onDisable() {
        getLogger().info("Succesfully disabled.");
    }
}

Anyone know why when I break a block nothing happens?

torn shuttle
#

or if you want to store the uuid in the uuid key

#

the format is ambiguous

torn shuttle
#

that's not right

#

block break event is an event

paper lance
#

oh lmao what is it

torn shuttle
#

also you get the player from the event

#

the snozzberries taste like snozzberries

paper lance
#

u what 😭

tardy delta
#

@EventHandler

#

and remove the Player parameter

#

get it with event.getPlayer

viral crag
#

might want to save that map on disable too

paper lance
paper lance
mighty pier
#

why is my plugin 8mb, but other people make plugins that are like 800kb with more code

viral crag
#

the data will just vanish

tardy delta
#

where does that player comes from do you think?

#

magic player objects hanging around?

paper lance
#

im not sure thats why i put it in the event

viral crag
tardy delta
#

you do event.getPlayer().your stuff

paper lance
#

ohh

viral crag
paper lance
#

that makes sense okay thanks

mighty pier
viral crag
paper lance
#

cheers bro

torn shuttle
paper lance
#

cheers everyone aswell. legends <3

mighty pier
#

also why is there original-plugin.jar and plugin.jar

tardy delta
#

original is not shaded

#

or vice versa 👉👈

mighty pier
#

what do that mean

tardy delta
#

are you shadin?

quaint mantle
#

Ignore the original :p

tardy delta
torn shuttle
#

shaded means you have dependencies packaged with your plugin

#

usually through maven

#

or gradle if you are a man of culture

#

based on some of the errors I've seen related to detecting fake players as real players I am going to assume some people can produce player entities just by going to the bathroom

paper lance
#

How would I put the value of a hashmap into a message?

#

like You broke <x> blocks!

torn shuttle
#

sorry you used up your limited time trial of having people on here make your plugin line by line, may I recommend looking up how to use hashmaps on google or copying your solution from stackoverflow without ever really reading it

tardy delta
#

generics for primitives when

paper lance
#

nah i am tryna search it up bro i just cant find how to put it in a string 😭

#

ive been using skript for years pls save me smh

tardy delta
#

google how the hashmap works

#

and you ll find an answer :)

quaint mantle
#

hash_map.get(key)

torn shuttle
#

give a man a line of code and feed him for 5 seconds, set a man on fire and feed him for a lifetime

paper lance
#
@EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        int value = mined.get(event.getPlayer());
        mined.replace(event.getPlayer(), value + 1);
        event.getPlayer().sendMessage("You broke a block! (" + mined.hashCode() + ")");

Thats what ive got

paper lance
tardy delta
#

we told you the same thing as you would find it on the internet

torn shuttle
#

guys I learn better from seeing it work than reading who wants to develop my dream game for me so I can see it working

paper lance
#

nah its better here tho idk how to explain it but yeah lmao

paper lance
#

snippets and shit help because it works and then I know what to do for next time and eventually it builds up in memory and i know how to do it lol

#

can u link them pls

torn shuttle
#

?learnjava

undone axleBOT
tardy delta
#

if you would take a look at how it works, you would know that mined.hashcode() doesnt return te mined blocks for that player

quaint mantle
#

I told you the code 😅 and still :p

paper lance
#

wait im so dumb its .size() isnt it 😭

paper lance
tardy delta
torn shuttle
#

stop trying to guess it based on what your IDE is saying and actually look for it or learn java in general

grim ice
torn shuttle
#

if anything your question shows you're not ready to start making mc plugins quite yet

tardy delta
grim ice
#

:OOOO

paper lance
grim ice
#

snake case aint it sis

paper lance
grim ice
tardy delta
crisp steeple
#

i would suggest starting small and then working your way up, not starting big and working your way down

paper lance
#

i am asking for help so that i can learn how to java

torn shuttle
#

this is not a java education channel

paper lance
grim ice
#

you will just annoy people

grim ice
#

it is

#

help dev

torn shuttle
#

this is a support room for getting help with specific implementations of the spigot api

grim ice
#

is also for java

#

nah magma

#

i ask for web dev questions here

#

and java questions as well

torn shuttle
#

if your question is with java itself, unless it's a somewhat reasonable question or if you don't keep showing up with them you will be given the resources to learn java

quaint mantle
grim ice
#

this isnt only for spigot

crisp steeple
grim ice
#

@paper lance

#

spigot isnt the main thing here

#

99% of spigot plugins is java

tardy delta
#

kotlin 🤣

torn shuttle
grim ice
#

1% is actual spigot api

grim ice
#

and conclure said its fine

paper lance
#

yeah help-dev kind of assumes that its for plugin development

grim ice
#

oh

#

good for you

#

then you may as well leave this chat

torn shuttle
#

well thanks for defending my point and making your questions worse lol

grim ice
#

since what youre asking for isnt spigot

#

thats so funny

#

man defended a point against him

paper lance
#

if i went to a java discord with spigot stuff they most likely wouldnt know what to do lol

#

nah what

#

it says help-dev right?

torn shuttle
grim ice
#

they would

paper lance
#

im developing a plugin

#

so therefore its help for development?

grim ice
paper lance
#

or am i just not able to english anymore

grim ice
#

wht ur asking for

#

is basic java

#

not spigot

paper lance
#

oh alr

crisp steeple
viral crag
#

people will help you do something, but do not appreciate doing it for you

crisp steeple
#

i wonder how many java devs there are that started learning it just for minecraft

past brook
#

is it possible to add nbt data (like {example=1b}) that dont exist in vanilla minecraft to entities
and
how do i add nbt data

crisp steeple
#

nms?

#

or metadata

grim ice
#

that will send

#

You mined 999123 blocks

past brook
torn shuttle
grim ice
#

since thats hashcode

#

lol

crisp steeple
#

there’s a lot of ways you could go about it

torn shuttle
paper lance
past brook
# crisp steeple yeah

like what you would add to an entity with
/summon zombie ~ ~ ~ {gravity:1b}
in command blocks but in spigot

crisp steeple
grim ice
paper lance
crisp steeple
#

yes…

grim ice
#

how the fuck will the hashmap

#

know what player ur referencing to

#

with hashCode()

crisp steeple
#

ok don’t need to be toxic

grim ice
#

oh sorry

#

i didnt mean to

crisp steeple
#

but yeah that’s not how a hash map works

paper lance
#

mined.get(event.getPlayer()) thats what ive got

torn shuttle
paper lance
#

that works yeah?

grim ice
#

yes

#

also .replace aint gonna work

#

.put will

paper lance
#

thats what i was thinking its just been a long day lols

#

ohh okay

crisp steeple
past brook
#

im looking at persistant data like magmaguy said

paper lance
#

okay so like im really confused because theres no errors but the message just wont send.. :/

grim ice
#

code?

paper lance
# grim ice code?
@EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        int value = mined.get(event.getPlayer());
        mined.put(event.getPlayer(), value + 1);
        event.getPlayer().sendMessage("You broke a block! (" + mined.get(event.getPlayer()) + ")");
    }
grim ice
#

what

#

well

#

did u register the event

loud oracle
#

👁️

crisp steeple
#

i honestly have no clue why you’re using a hashmap

quaint mantle
#

hashmap.replace() should work fine iirc.

grim ice
loud oracle
#

👁️

grim ice
#

replace wont work if there is no key yet

#

it only replaces

#

an existing value

crisp steeple
#

use event.getBlock().getType().name() if you just want the name of the block

grim ice
#

so if its the first time a player is breaking a block it aint workin

paper lance
#

Bukkit.getPluginManager().registerEvents(this, this);

loud oracle
#

👁️👄👁️

paper lance
#

do i need to do this every time i make an event or just once?

#

like in the main class

grim ice
#

once

paper lance
#

okay yeah so its been registered

paper lance
grim ice
#

that should work

torn shuttle
#

once per class

grim ice
crisp steeple
#

still wondering what you’re trying to use a hashmap for

grim ice
#

hashmap is a key and a value

paper lance
grim ice
#

Name: 2Hex

#

Name is key

crisp steeple
grim ice
#

2Hex is value

paper lance
#

oh okay

crisp steeple
#

you’re never giving it a value

torn shuttle
#

fyi that code won't work because it will almost certainly NPE on the getter

quaint mantle
crisp steeple
#

you should be using getOrDefault(player, 0) when you assign that int

grim ice
#

not 0 ig

paper lance
#
@EventHandler
    public void onPlayerJoin(PlayerJoinEvent event, Player player) {
        mined.put(player, 0);
        event.setJoinMessage("Welcome to the server" + player.getDisplayName() + "!");

is this what you mean

grim ice
#

no

#

bruh

torn shuttle
#

0, he's counting blocks broken

grim ice
#

why do u have 2 params

torn shuttle
#

and immediately incrementing

crisp steeple
grim ice
#

blocks mined: 0

torn shuttle
#

the blind leading the blind

grim ice
#

this doesnt make sense

crisp steeple
#

yes and he adds that in the next line

grim ice
#

sis

#

if the value doesnt exist

#

and he broke a block

vast kelp
#

they changed it to playerjoinevent

grim ice
#

it should be 1

#

since he broke a block

crisp steeple
grim ice
#

then thats not how it should be ordered

crisp steeple
#

¯_(ツ)_/¯

torn shuttle
#

you just can't make this shit up

grim ice
#

the get should be after the put if im not bsing

torn shuttle
#

what

grim ice
#

cuz u want the value

#

to be updated

#

before sending it to the player

#

dont you

torn shuttle
#

jesus

paper lance
#

how would i use getOrDefault?

grim ice
#

im fasting

#

just tell me whats wrong

paper lance
grim ice
crisp steeple
grim ice
#

Magma guy ive never seen you help until now, youve only been either making fun of him or arguing

torn shuttle
#

you know 2hex somehow I feel like your strong suite isn't seeing things anyhow

crisp steeple
past brook
#

persistent data seems to be what i need thanks

torn shuttle
#

np

paper lance
#

where would i put getOrDefault in the hashmap tho im lowkey tripping rn 😭

crisp steeple
#

what?

torn shuttle
#

that makes less than no sense

#

if you put a value you're going to get the value you just put

#

and you're going to be putting the wrong value

grim ice
#

ur gonna put the value after the block was broken

#

then tell it

#

to the player

#

???

torn shuttle
#

yes

grim ice
#

if u do what u think ur doing

#

it will send

#

You broke 0 blocks

torn shuttle
#

no

grim ice
#

after he breaks a block

viral crag
#

you guys need to agree which logic you want to work with

torn shuttle
#
  1. get how many blocks have been broken
  2. increment that number and store it in the map
  3. tell the player what the number is
#

it's really simple

#

I don't see how this is confusing you

viral crag
#

both methods are valid but handled differently

torn shuttle
#

obviously you don't need to get the value from the map if you stored it in a field but hey

grim ice
#

but he was doing

torn shuttle
grim ice
torn shuttle
grim ice
#

before get was meant

#

the get to send to the player

#

you get it to send to the player

#

u wanna increase the amount of blocks placed before sending it

#

so u dont send the value before operating on it

viral crag
#

pre-increment vs post-increment rumble

torn shuttle
#

actually this is based on something much dumber because he was saying the default should be 1

grim ice
#

the default should be 1 since it will never fire except if he breaks a block

crisp steeple
#

but then he adds it again

torn shuttle
#

you realize that then you would need extra code to prevent it from adding to the counter

grim ice
#

Oh thats before the add

torn shuttle
#

this is like 4 lines of code how can you be this confused

grim ice
#

mb i confused things

#

sis ive only been eating in the last 4 hours of my day for 11 days

paper lance
#

but why wont it send lol

#

oh damn u fasting?

grim ice
#

yeah

viral crag
torn shuttle
#

I fasted for a year and I don't remember getting this confused

paper lance
viral crag
#

that would be the normal reason something doesnt happen

grim ice
#

I live in a desert country

quaint mantle
#

You did register the event right? :p

grim ice
#

its extremely hot here

#

yep he did

torn shuttle
#

summers are 42 celsius here, stop trying to find excuses

grim ice
#

Oh wow

#

i guess you can endure better than me

crisp steeple
grim ice
crisp steeple
#

connecting strings with null can do some weird things

grim ice
#

except if he got an exception

paper lance
torn shuttle
#

he's probably getting a npe

viral crag
#

lets start at the beginning: did the plugin unload itself?

crisp steeple
loud oracle
#

👁️👄👁️

paper lance
#

theres an error in console but its too big to send

grim ice
#

?paste

undone axleBOT
torn shuttle
#

does it say null pointer exception

paper lance
paper lance
torn shuttle
#

insert shocked pikachu

#

that would be the thing we've been mentioning for the past 15 min

paper lance
#

how do i fix it lol

#

yeah but idk what an NPE stands for im new smh

crisp steeple
#

what is the line that it refers to

paper lance
#

Line31

torn shuttle
#

you implement the getOrDefault hashmap method or you otherwise assign a default value / handle the null value

crisp steeple
#

which is?

paper lance
#

public void onBlockBreak(BlockBreakEvent event) {

crisp steeple
#

i don’t think it is

paper lance
#

but im not sure whats wrong wit hthat

crisp steeple
#

that is not where it is happening

grim ice
paper lance
#

it wont let me send an ss smh

#

ohh

grim ice
#

eitherway'

#

use getOrDefault

paper lance
#

yeah but where do i put getOrDefualt thats what im confused about loll

crisp steeple
#

unless he’s not rejoining when he reloads the server

torn shuttle
crisp steeple
#

but yeah you should use getordefault anyways

smoky oak
#

do i need to manually write constructors for every @smoky tinsel combination or is there a simpler way of doing it?

grim ice
#

int minedAlready = mined.getOrDefault(event.getPlayer(), 0);
int mined = mined.put(event.getPlayer, minedAlready + 1);
event.getPlayer().sendMessage(mined);

torn shuttle
#

lol poor nullable

smoky oak
#

oh ffs

grim ice
#

minedAlready is the amount of blocks the player has already mined

smoky oak
#

why does anyone have that username bruh

grim ice
#

if he hasnt mind anything yet its 0

#

it adds to it 1, and sends it to the player

torn shuttle
#

why do you need to account for every nullable combination anyhow

viral crag
#

gives you a known return you can work with ^

smoky oak
grim ice
#

aka
return map.get(object) == null : defaultValue : map.get(object);

#

but it doesnt get twice

grim ice
#

oh right

#

Uhhh

torn shuttle