#help-development

1 messages ยท Page 1937 of 1

quiet rune
quiet ice
#

Oh right, that one also exists

hollow bluff
#

it returns the entity that was used, yes

wintry badger
#

thank you!

quiet rune
#

idk what could be the issue ๐Ÿ˜”

quiet ice
#

It's 1.18.1-R0.1-SNAPSHOT not 1.18.1-R0.1-SNAPSHOT/

quiet rune
#

weird its the same issue

onyx flax
#

Hey peeps ๐Ÿ‘‹ long-time listener first-time caller ๐Ÿ˜‚ - I'm working with runTaskTimerAsynchronously - have web background but still feeling around in java and having an issue grasping what is meant by "You shouldn't use any Bukkit API in an async task" or "Never touch the world in an Async Task". Happy to go into more detail if need be, but I would assume if I can pass the player object to my Runnable object I could do as I see fit with them?

quiet rune
#
        Searched in the following locations:
          - https://repo.maven.apache.org/maven2/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/maven-metadata.xml
          - https://repo.maven.apache.org/maven2/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT.pom
          - https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/maven-metadata.xml
          - https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT.pom
        Required by:
            project :

edit: fixed

#

for some reason its not grabbing from spigot

quiet ice
#

The operations that can run fine in a concurrent manner are explicitly defined in their javadocs. Not respecting it might lead to strange issues

elfin atlas
#

How can I'll check if a player is sitting on a entity?

wintry badger
#

I think this is the shooter, but i dont know how to check if its a player event.getEntity().getShooter()

quiet ice
#

instanceof Player

quaint mantle
wintry badger
elfin atlas
quaint mantle
#

pretty sure not

wintry badger
quiet ice
#

Yea

wintry badger
#

๐Ÿ™

quiet ice
#

Although there could be better practices out there

onyx flax
quiet ice
#

It does not create a new thread

quaint mantle
quiet ice
#

The main thread is the thread that is responsible for the main ticking loop.

#

JavaPlugin#onEnable, JavaPlugin#onDisable, most (there are exceptions!) Event handlers and runTaskSynchronously (and family) are on the main thread

lunar forge
#

Hello, I have a hashmap with the items as keys and the % as value.

How can I make a method that gets a random key based on the % change of getting that item?

young knoll
#

Try something with a NavigableMap

#

Like this

wet breach
quiet ice
#

Now to come back to my "it does not create a new thread". Bukkit makes use of a shared thread pool for the scheduler. this means that you shouldn't do anything too expensive via the Scheduler as it may prevent other plugins from using async tasks themselves

lunar forge
#

I already have the percentage, private final HashMap<ItemStack, Integer> items. And I have a function called selectRandomItem, that gets a ItemStack from the HashMap based on the percent change of getting that. But I dont know how to make that function work

onyx flax
lunar forge
young knoll
#

Look at the link I sent

lunar forge
young knoll
#

Yes

onyx flax
# quiet ice Now to come back to my "it does not create a new thread". Bukkit makes use of a ...

Right that's the issue I was having, I originally doing stuff on the main thread apparently so the server was on a full-stop until the task was done. Someone moved the API call to an async in a pull request ( and it worked ) but kept the player-modifiying code on the main thread and for the life of me I can't fully understand how/why it works so I'm just trying to learn ๐Ÿ˜„

young knoll
#

Well the double is the weight

#

If the total adds to 100 it will be a percent

sterile token
#

Hi, how are you? I want to askyour opinion about creating minecraft plugins with JDK 9?

chrome beacon
#

No

#

Use 8, 11 or 17

young knoll
#

Use 8, 11, or 17

#

oh

quiet ice
#

No

delicate lynx
#

why 9

quiet ice
#

Use 16 or 17, nothing else

sterile token
#

I ask because in Java 9 i found something called Reactive Streams

young knoll
#

What mc version

sterile token
#

Less than 1.16

young knoll
#

Oh

chrome beacon
#

Use 11

sterile token
#

Ok

young knoll
#

Well if it's public you probably want to use 8

#

A lot of old servers don't run 11 because they smell

chrome beacon
#

^^

young knoll
#

If it's private use whatever you want

sterile token
lunar forge
# young knoll Yes

This should work right?

    public ItemStack selectRandomItem() {
        WeightedRandom<ItemStack> weightedRandom = new WeightedRandom<>();
        items.keySet().forEach(item -> {
            weightedRandom.add(items.get(item), item);
        });
        return weightedRandom.poll();
    }```
delicate lynx
#

try it

young knoll
#

Probably

#

But at that point just keep a weighted random instead of a map

sterile token
#

Allright another question, no matter the JDK version its should run on every server right?

young knoll
#

Not really

sterile token
#

Explain please

young knoll
#

The server has to use at least the version you compile for

lunar forge
young knoll
#

Ditch the original map and just use a weighted random

#

Unless you need the map for something specific

lunar forge
blazing scarab
wet breach
wintry badger
#

hi, how can i check if the entity of onEntityShootBow event, is a TippedArrow? TippedArrow is deprecated and i think somehow i need to check if the arrow has some potion or whatever

sterile token
hexed hatch
terse ore
#

How can I push a player upwards?

onyx flax
# quiet ice Now to come back to my "it does not create a new thread". Bukkit makes use of a ...

What I'm having an issue wrapping my head around is this:


        // Run check off the main thread
        Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
            try {
                String msg = chatPrefix+" ";
                if (plugin.check()) {
                    msg = msg + plugin.getLang("general.processed");
                } else {
...

The plugin.check() is a boolean which is whathandles the API request(s) and resides in the main plugin file. It will scheduleSyncDelayedTask() to modify player data eventually depending on the output. My understanding of Java's Lambda's when used on things like scheduling a task is that it forces the async task to run on the main thread, is that incorrect? If so, this seems like what we use in the PHP/JS world called an arrow function which would be basically a shorthand way of creating a method.

That also begs the question, if not, can one scheduleSyncDelayedTask from an async task?

chrome beacon
wintry badger
sterile token
#

But in conclusion which version of JDK should i use for working on multi spigot version?

tardy delta
#

wait cant i do two times target

delicate lynx
#

do case "enable" : {}

#

wrap it in brackets

tardy delta
#

lmao it works

hexed hatch
tardy delta
#

there is a break so why doesnt it accept it

paper viper
#

that is big brain

#

lol

delicate lynx
#

it is big brain

paper viper
#

ive always used a different variable name

tardy delta
#

it will never evaluate to the previous value

young knoll
#

I never thought of using {} in switchโ€™s

tardy delta
#

i didnt know it was possible

wooden fable
sterile token
young knoll
#

Because switch is cleaner than a ton of if else

young knoll
#

TAB plugin?

#

I hear it talked about a lot

sterile token
coarse shadow
#

i've made an itemstack for all enchanment available in the game and made a gui page system to obtain them, but when i open the gui all items are stacked by two why is this happening

sterile token
sterile token
wintry badger
#

how can i convert an entity (arrow) to an itemstack?

wooden fable
tardy delta
quiet ice
# onyx flax What I'm having an issue wrapping my head around is this: ``` // Run ch...

That also begs the question, if not, can one scheduleSyncDelayedTask from an async task?
Yes, you can.

Java's Lambda's implement functional interfaces. I. e. interfaces with just a single abstract method. See the javadocs of @FunctionalInterface.
However Java's lambdas do not dictate method flow. They are more or less just a shorthand to creating a class

young knoll
onyx flax
blazing scarab
onyx flax
quiet ice
#

Yes, internally they are different

wooden fable
young knoll
#

Ah

quiet ice
#

But for the developer (especially newcomers), they can be the same

#

There is no reason to annoy them with LambdaFactories, Method callsites, Method handles and all that shit

sterile token
# tardy delta because if else with 5 cases goes brr

You can use simply:

if (!(args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable"))) { return false; }
Player target = Bukkit.getPlayer(args[0]);
if (target == null) { bl bla}
more code
return true;
wet breach
onyx flax
#

I have a pretty good background in web ( php, JS, SQL, html, css, react, node.... ) just trying to learn more and draw some parallels between what I know and java

sterile token
tardy delta
#

doing if ! that and not that etc for 5 cases goes brr

wet breach
#

if else means the server has to at minimum run the check to see if the code block should run. In switches the cases are constants so checking wise it is faster usually in which to choose from. Not always the case, but for cases where it is not it might make it more cleaner in terms of viewing in understanding what it is going on.

tender shard
sterile token
wet breach
wooden fable
wet breach
#

but cases in a switch automatically return until they hit the last case unless there is a break clause

wooden fable
#

np

wet breach
#

I guess its more accurate to say, switch returns automatically once it hits the last case unless a break clause is encountered ๐Ÿ˜›

quiet ice
#

Well this is the same for everything

wet breach
buoyant viper
#

while(true) {}

#

he he

quiet ice
#

Example:

{
    System.out.println("abc");
    break;
    System.out.println("def");
}

In this case def will be dead code.

wet breach
#

so not true for everything, most things sure lol

quiet ice
#

Well, was more talking about the break behaviour

wet breach
#

oh right

tender shard
blazing scarab
#

who for the love of god uses while do syntax

wet breach
young knoll
#

Not java

#

Burn the witch!

quiet ice
#

And the fact that I am getting more and more tired caused me to read something along the lines of "switch statements do not stop until stopped via return or break."

tender shard
quiet ice
#

That sentence took far too long to formulate

wet breach
#

lol

sterile token
#

Http requests made from plugins should be Async right?

tender shard
buoyant viper
tender shard
sterile token
#

Thanks

tardy delta
tender shard
#

because I did Ctrl+F and there's not a single switch

young knoll
buoyant viper
#

theres not a single switch in that file

tardy delta
#

ah wait yea wrong one

#

but i need comments on this one too

quiet ice
#

It triggers me that your package names are not conventional

tender shard
wet breach
#

love how you say it is a perfect 5/7

#

what is an imperfect 5/7?

young knoll
#

Oh yeah upper case package names

buoyant viper
#

perfection comes in all kinds of shapes and sizes

tardy delta
#

why not on 10 ._.

young knoll
#

Thatโ€™s gonna make it 4/7

tender shard
#

5/7 is the best rating there is

buoyant viper
#

wrong

#

6/9

tardy delta
#

thats my plugin name probably

tender shard
#
Know Your Meme

5/7 refers to a rating for the 1999 drama film Fight Club shown in a Facebook status update attributed to user Brendan Sullivan. After the screenshot widely circulated on Imgur in December 2015, users began posting โ€œ5/7โ€ ratings in comments sections as an inside joke on the image-sharing site.

young knoll
#

Funneh number

#

Heck you imma rate things outta 13

blazing scarab
#

Ideally i'd avoid code in constructors

quiet ice
#

why that

#

Okay, registering listeners is a bit atypical, but otherwise I see nothing wrong with having code in constructors

blazing scarab
#

Hidden side-effects not requested by object owner. Those ones are visible in public contract

#

new Something(fst,snd,thd).register()

young knoll
#

See

tender shard
#

if constructors MUST be code free they would not exist

dusk flicker
#

^

young knoll
#

If I did that Iโ€™d have to parse everything outside the constructor and then pass it to the constructor

dusk flicker
#

yeah that some bs

quiet ice
#

I mean, the constructor is fine as is

young knoll
#

Or id have to make the variables non-final

quiet ice
#

There are no considerable side effects in that constructor

tardy delta
#

Hmm yea

blazing scarab
#

CreateBossBar

quiet ice
#

So, that one is a pure method afaik

tender shard
#

I mean stuff like that could be easily moved to their declaration instead

wintry badger
#

how to get the real amount of EntityShootBowEvent.getConsumable ?

tender shard
#

but "constructors must be code free" is a funny and untrue statement

tender shard
blazing scarab
#

"constructors must be logic free" if you want

tender shard
vocal cloud
#

If a constructor contains all your logic make it a method mmlul

quiet ice
#

And then you have a init method that MUST be called just after the ctor?

tender shard
#

yeah that doesn't make any difference

quiet ice
#

sure, it can be done lazily, but eh

wintry badger
blazing scarab
#

uhm, static factory method, for example?

young knoll
#

But an init method means you canโ€™t assign final variables

blazing scarab
#

Or move that logix to object's owner rather than actual object

tender shard
quiet ice
#

Overly zealous OOP

tender shard
#

look at JavaPlugin's constructor

#

I am pretty sure that I extended JavaPlugin quite often

blazing scarab
#

Bukkit is not the best example

#

And, extensible doesnt awlays mean directly that you can extend it

quiet ice
#

Well, if you cannot extend it, then why bother using it?

tender shard
blazing scarab
#

no. Here, author is against implementation inheritance at all

tender shard
#

and I simply think that the author is a bit stupid then

young knoll
#

Isnโ€™t there a book on like

#

Die hard OOP

blazing scarab
tender shard
#

okay you know everything better, I got it

#

and the java developers are all stupid because they invented stuff like constructors, super(), etc

#

oh by the way

#

the dude who claims that code in custroctors MUST not be used...

#

uses code in his constructors

#

here for example, first file I opened

minor fox
#

What entity collisions are there, other than between arrows and players?

tender shard
#

player <> zombie, pig <> sheep, ...

blazing scarab
tender shard
#

as I said, the dude who claims constructors must be code free uses code in his constructors too. so either he is stupid himself or his statement is just bullshit

blazing scarab
#

IOException does not accept integers

tender shard
minor fox
tender shard
minor fox
#

It changed at one point if I remember correctly

tender shard
young knoll
#

Yeah collision was re-added at some point

#

Donโ€™t remember when

tender shard
#

i'd just try it

blazing scarab
tender shard
#
public static HttpException fromReturnCode(int code) {
  return new HttpException(String.valueOf(code));
}

would be easily possible without problems but also pretty stupid

#

the statement that constructors must be code free is bullshit and the author didn't provide ANY good reason to explain why

young knoll
#

What about my giant constructor :p

tender shard
#

I don't have problems with constructors ๐Ÿ˜„

worldly ingot
tender shard
#

I do

worldly ingot
#

God, have some modesty for those of us who don't have as big of constructors as you

tender shard
#

I am into big constructors

hasty prawn
#

What a lovely first sentence to read, thank you Choco

tranquil viper
#

Using the CreatureSpawnEvent, after I check if it was spawned from a spawner, how can I get the location of the spawner?

young knoll
#

Isnโ€™t there an event for that

worldly ingot
#

You can't from a CreatureSpawnEvent but you can from a SpawnerSpawnEvent

young knoll
#

SpawnerSpa- yeah

tranquil viper
#

Didn't even know that existed

#

LOL

#

thanks

worldly ingot
#

o/

young knoll
#

See Alex likes my constructor

tender shard
#

yes but I am weird, always remember that

young knoll
#

Arenโ€™t we all

#

This is spigotmc

tender shard
#

oh right

#

sometimes I forget that

sterile token
#

Where i can find JDK 11 source code? Cuz i wanna check the source code of a specific package

#

But i cannot find the package on the github repo

sterile token
tender shard
#

oracle, openjdk, ... ?

sterile token
#

Ah

tender shard
#

here's openjdk 11

sterile token
#

The one who has support for http request

quaint mantle
#

jdk11 has

tender shard
quaint mantle
#

and anything above 11

midnight shore
#

Hi guys! How can i make a player teleport in the direction of facing like you would do with vectors?

tender shard
#

their implementation is just different

quiet ice
#

Well the diff between the JDKs is minimal

sterile token
tender shard
midnight shore
# tender shard wdym?

Like on hypixel the Aspect of the end, which makes the player "dash" in a straight line forward but with teleports

sterile token
tender shard
tender shard
#

you can use Player.teleport which accepts a location

#

and locations have a world, x,y,z, and pitch and yaw

#

pitch/yaw is basically the "direction"

#

if you meant that

midnight shore
#

i'm trying to do with something i already had... if i don't succeed i'll be back! ๐Ÿ˜…

tender shard
#

alright ๐Ÿ˜„ sorry but I really didn't understand what you meant ๐Ÿ˜›

young knoll
#

You can get the players facing vector, multiply it, and then convert it to a location

tender shard
#

(and normalize it before multiplying ๐Ÿ™‚ )

young knoll
#

Yes

midnight shore
#

nevermind! it worked!

young knoll
#

And then hypixel also ray traces to prevent you from going through blocks

wintry badger
#

how to check if an arrow entity, is a tipped arrow?

tender shard
wintry badger
#

hasCustomEffects does not do the trick for some reason

tender shard
#
if(arrow intanceof TippedArrow) // It's a tipped arrow
young knoll
#

No

tender shard
#

oh wait

young knoll
#

Thatโ€™s deprecated

tender shard
#

TippedARrow is deprecated

#

yes

wintry badger
#

yes ๐Ÿ˜ฆ

young knoll
#

tipped status depends only on base potion type not being UNCRAFTABLE and effects being empty.

tender shard
young knoll
#

Check those

tender shard
#

just check whether the list is empty

#

if(!arrow.getCustomEffects().isEmpty()) // tipped arrow

young knoll
#

Also the base type must not be uncraftable

#

But idk how much that matters

wintry badger
#

how to check if its uncraftable?

tender shard
young knoll
#

getBasePotionData

#

And then check the type of that potion data

tender shard
#

why not just check whether the customEffects is empty or not?

wintry badger
young knoll
#

Custom effects may only work for custom tipped arrows

tender shard
#

oooh

#

didn't know

young knoll
#

Vanilla ones may just use the base potion data

tender shard
#

tbh I have never ever used a tipped arrow in my whole life

young knoll
#

No idea how mojang did it

#

Heh, Iโ€™ve used them on some kit based servers

#

Never in survival

tranquil viper
#

My original question:

Hello! I am trying to make a mob stacking plugin. I have gotten most functionality down except for the part where I want the entities to stack when they get close to each other. I know I can track the movement of the entity and constantly check if there's entities around it, but I feel like there might be a more efficient way of detecting it. Thanks in advance 

The response I got:

Just loop all loaded chunks in the world & loop entities in the chunks and then compare distance between entities...

And yes, it will cost a little more performance

Am I wrong or is this a horrible idea for a server with 200+ constant players?

young knoll
#

Probably

#

Just stack on spawn

#

Donโ€™t stack natural spawns, only spawners

wintry badger
#

what should I exactly check with getBasePotionData ?

tranquil viper
wintry badger
#

i want to check if its "any" tipped arrow

young knoll
#

And stack with that

tranquil viper
#

What if the nearest mob is 500 blocks away xD

young knoll
#

If there isnโ€™t one in a reasonable distance, make a new stack

tranquil viper
#

I guess that works

#

Thanks

young knoll
#

You can look at other stacker plugins

#

There must be some open source ones

tender shard
#

well but

tardy delta
#

heheh BUUUURN

tender shard
#

what if an entitiy moves

tranquil viper
#

Every stacker plugin I have looked at is so confusing

tardy delta
#

I WANT THOSE EYES

#

._.

tender shard
tranquil viper
tender shard
#

I don't understand why everyone gets blind from light mode

tranquil viper
#

and light mode kinda fire

quiet ice
#

Also there is .getNearbyEntities

young knoll
#

Wtf

#

Mobile discord sucks

tranquil viper
wintry badger
#

so how can i check if getBasePotionData is not empty? i think its never null

tender shard
young knoll
#

I managed to call someone trying to tap on the text box

tender shard
#

I was like "Who tf is Josh"

young knoll
#

I donโ€™t... what

tender shard
tardy delta
#

i managed to do that too

quiet ice
#

Josh bloch?

young knoll
#

Iโ€™ve done it twice

#

Itโ€™s awkward

tardy delta
#

people have done it with me too

young knoll
#

Anyway, when I made a stacking plugin I made it only apply to player placed spawners

#

It would disable AI and stack them, but leave natural ones alone

#

That way it didnโ€™t remove the challenge from dungeons

tardy delta
young knoll
#

Are those just

#

Boolean

tardy delta
#

handled in onCommand

#

something weird i made myself

young knoll
#

I see

#

Iโ€™ll probably start using RedLibs command system

young knoll
#

But cloud is also tempting

#

But if I use cloud that means more shaded stuff, ahhhh

tardy delta
#

hmwoa i looked at it and it couldnt fully persuade me to use it

tender shard
#

github is so weird

young knoll
#

I wonder if redlib integrates with brigadier

#

I assume it does

tender shard
young knoll
#

Pfft

#

You act like we are short on ipv4s

tender shard
young knoll
#

Oof

#

A lot of shared hosts add extra charge for them too

#

I assume because they arenโ€™t cheap

tender shard
#

yeah understandable

young knoll
#

Why canโ€™t we just fully yeet ipv4

tender shard
#

if google would disable IPv4, everyone would have IPv6 in a week

young knoll
#

Eeeee

tender shard
young knoll
#

Well

#

Poop to them

#

How long have we known this was an issue

sterile token
#

Ipv6 address are infiite or what?

tender shard
quiet ice
#

there is an xkcd about it

wet breach
#

technically we could remove ipv4

young knoll
#

I mean

tender shard
#

it allows to use some words in the address

#

like fc00::cafe:babe

young knoll
#

We can at least transition away from it for most things

tender shard
#

I wouldn't need ipv4 at all except for email and github

young knoll
#

I want to shove a raw ipv6 in my minecraft server box and be done with it

tender shard
#

all my server only listen to local addresses lol

#

10.0.0.200 and fc00::200

young knoll
tender shard
#

no

#

only 0-9a-f

tardy delta
#

what kinds of dataabases should i support for my storage? i already have h2 and mysql now

young knoll
#

Aww hex

tardy delta
#

what's special about that?

young knoll
#

Now Iโ€™ve noticed cafebabe is valid hex

#

SQLite?

#

Idk the different between that and h2

tardy delta
#

neither do i

quiet ice
#

CAFEBABE is actually the first 4 bytes of each java class file

tender shard
#

sqlite doesn't require a server

tardy delta
#

mongo? ๐Ÿ‘‰๐Ÿ‘ˆ๐Ÿ˜ณ

tender shard
#

in german mongo is a bad word to insult disabled people

quiet ice
#

du mongo

tender shard
#

I might be homo but I'm not officially disabled

quiet ice
#

^ example usage of that word

young knoll
#

Does h2 require a server?

tender shard
#

yes

young knoll
#

TIL

tender shard
#

oh wait

#

it supports both

#

it does not REQUIRE a server but you can if you want to

young knoll
#

TIL again

tender shard
#

me too

#

never used H2

#

also it's german

young knoll
#

Iโ€™ve heard itโ€™s faster than SQLite

tender shard
#

the developer has the most german name ever

#

Thomas Mรผller

#

that's like "John Johnson" in english

young knoll
#

I wonder if it supports the same syntax

tardy delta
#

sqlite or h2 one of them is written in java

tender shard
#

h2 is java

tardy delta
#

other one in some dotnet lang

#

ah

tender shard
#

sqlite is C

#

and mysql no idea lol

#

probably C too

quiet ice
#

And don't use the one that is written in VB

tardy delta
#

ah C isnt dotnet ๐Ÿ˜ณ

young knoll
#

TIL where cafebabe came from

#

And also about 0xFEEDFACE

wet breach
tardy delta
#

TIL?

wet breach
#

TIL = Till I learned

tardy delta
#

Till i learned where cafebabe came from

#

nice english

#

wai-

young knoll
#

Itโ€™s today I learned

#

At least thatโ€™s what I know it as

tardy delta
#

is he coming from hell?

#

๐Ÿ’€

quiet ice
#

No, the java class file format

young knoll
#

Whatโ€™s the difference

tardy delta
#

idk

#

class file doesnt have fire

young knoll
#

True

wet breach
quiet ice
#

Till can also be a german surname

young knoll
#

Cinnamon

wet breach
#

considering we have people named after fruits and vegetables now XD

young knoll
#

Now?

tardy delta
#

cat

young knoll
#

We probably always did

tardy delta
#

banana

#

pineapple

#

๐Ÿ™„

young knoll
#

Fruits and vegetables

Cat

#

What

quiet ice
#

Do not question the hivemind

tender shard
wet breach
tardy delta
young knoll
#

Some states restrict them

tender shard
young knoll
#

Didnโ€™t Cali yell at Elon for whatever name he came up with

#

Yeah that one

wet breach
tender shard
#

I didnt mean to say it was banned

wet breach
#

otherwise, there is no ban on any specific names in the US

tender shard
#

I was just giving examples for stupid names

young knoll
#

California's ban on diacritical marks, such as in Josรฉ, a common Spanish name.

#

Not federal tho

quiet ice
#

Cali does not like the mexicans huh

young knoll
#

My middle name has a รซ

#

And my last name has a capital in the middle

tender shard
#

Burrito

#

Tequila

spiral light
tender shard
#

his name has a capitel e with dots above it in the middle

young knoll
#

Not quiet

tender shard
#

oh

young knoll
#

Middle name is Noรซl

tender shard
#

his last name has a capital letter in the middle

hasty prawn
tender shard
#

and his middle name has a e with dots in it

young knoll
wet breach
spiral light
#

why is that allowed ๐Ÿ˜ฎ way to complex naming

quiet ice
young knoll
#

I want a name that breaks databases

young knoll
#

I wanna be Bobby Tables

wet breach
tender shard
#

isn't a UUID to long for a long?

#

a long is only 64 bit

#

a UUID is 128

young knoll
quiet ice
#

Well you do not know the context

#

It will take a while to come up with a truely atomic way to deal with this

tardy delta
#

uuid is 4 longs iirc

young knoll
#

2

tardy delta
#

ah

tender shard
#

then how will you store a UUID inside a long if it's too long?

quiet ice
#

Basically something like

private final AtomicLong currentId = new AtomicLong(ThreadLocalRandom().nextLong()));

method () {

        long nextId = -1;
        while (true) {
            nextId = currentId.get();
            if (currentId.compareAndSet(nextId, nextId + 1)) {
                break;
            }
        }
        // Then use nextId
}
tender shard
#

oh ok

quiet ice
#

If you were to save the currentId across restarts you can guarantee uniqueness for a pretty long time

young knoll
#

Learning?

#

Thatโ€™s not CTRL C + V

quiet ice
#

You could use currentId.getAndIncrement but the issue is that I am not too sure about it's atomicity

tender shard
#

just use a NuclearLong

quiet ice
#

Yeah, looking from the javadocs of varhandle is appears to be

ivory sleet
#

Yuh

#

very pog

young knoll
#

Pfft thatโ€™s not how you program

#

Exactllllly

quiet ice
#

Okay, then you could use AtomicLong#getAndIncrement

daring lark
#

how can i add potionEffect to player?

tender shard
young knoll
#

?jd-apigot

#

Duck

daring lark
young knoll
#

?jd-spigot

undone axleBOT
tender shard
#

into the ( )

young knoll
#

Construct a new potion effect

daring lark
#

i mean new p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED)); not working

young knoll
#

Right

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.

young knoll
#

Because thatโ€™s not the constructor for potion effect

quiet ice
#

don't you need to add the level?

young knoll
#

Yes

#

And duration

#

The javadocs will show you this

daring lark
tender shard
#

this:

#

?notworking

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.

quiet ice
#

I hope that people are not that dum

young knoll
#

I mean we know why itโ€™s not working

quiet ice
#

Even if I knew the answer to it

tranquil viper
#

Anyone have a good tutorial on multiple config files?

young knoll
#

Wtf did I just read

tender shard
#

it throws an error

young knoll
#

I hope so

tender shard
young knoll
#

Made my eyeballs throw up

tender shard
sterile token
tender shard
#

pls stop trolling

delicate lynx
#

you don't need a library for multiple configs

tardy delta
#

^^

quiet ice
#

You need org.json:json

tranquil viper
quiet ice
#

Best config lib in the world

young knoll
#

We need one lib to rule them all

quiet ice
#

org.json:json already does it, sorry

#

And given that all json is valid yaml it is a fully valid yaml writer

daring lark
quiet ice
#

We already told the issue my man

young knoll
#

?jd-spigot

undone axleBOT
tender shard
#

because they tell you how things work

young knoll
#

Look at the PotionEffect class

tardy delta
#

bruh what that doesnt makes sense i copied the spigot docs link

young knoll
#

Something something spoon me

alpine urchin
#

you

tender shard
alpine urchin
#

shit, should've waited another day

tender shard
#

lol

alpine urchin
#

i've been waiting all this time

#

and did the math wrong

tender shard
#

and now, a premature answer

tardy delta
#

lmao

tender shard
#

how could you

alpine urchin
#

i have to wait another year

#

oh well

quaint mantle
#

What is the best way to query every 5 levels of a player? So I have an Int level that defaults to 1 and the player gets 3 xp per block removal. Every 5 levels the xp should increase by 2 for example.

im dumb atm

#

but i dont want 2 write it every 5 levels u know?

young knoll
#

3 * (level / 5 + 1)?

#

Wait no

#

3 + 2 * (level / 5 + 1)

quaint mantle
#

thanks m8

#

i got the idea

hybrid crest
#

Sup all! Got a problem where the player sending wayyyy to many packets when they press a "button" in a GUI and get teleported, anyone know why?

gui.setCloseGuiAction(e -> player.teleport(config.teleportLocation()));
#

Liek they get kicked for sending too many packets

vague swallow
#

How can I clear the ItemOnCourser?

red sedge
#
private static String addEmoji(Player p, String str, boolean requirePermission) {
        List<String> emojiList = Config.getStringList("emojis");
        for (String i : emojiList) {
            int o = i.indexOf(" | ", i.indexOf(" | ") + 3);
            String replacement = i.substring(0, i.indexOf(" | "));
            String syntax = i.substring(i.indexOf(" | ") + 3, o);
            String noColorSyntax = "!" + syntax;
            String permission = i.substring(o + 3);
            if (requirePermission &&
                    (!p.hasPermission("server.chat.emoji." + permission) && !p.hasPermission("server.chat.emoji.*"))) {
                continue;
            }
            str = str
                    .replaceAll(noColorSyntax, ChatColor.stripColor(Misc.coloured(replacement + "&f")))
                    .replaceAll(syntax, Misc.coloured(replacement));
        }
        return str;
    }```
and htis is why "it just works" is not a good idealogy
#

becaus eyeah

#

it works

#

but its also dogshit

hasty prawn
young knoll
#

Isnโ€™t it in the player

tardy delta
#

Config.getStringList

vague swallow
young knoll
#

Can we talk about replaceAll

#

And how misleading the name is

hasty prawn
#

I used it wrong for so long

young knoll
#

Me too

tardy delta
#

i still dont use it lol

hasty prawn
#

I thought replace just replaced the first one

tardy delta
#

i'm learning new things today ๐Ÿ‘€

tender shard
#

replace replaces all occurences

hasty prawn
#

No, I know now.

tender shard
#

replaceAll should actually be called replaceRegex

hasty prawn
#

Yes exactly

tardy delta
#

๐Ÿ˜ณ

tender shard
#

It took me 2 years to realize it

quiet ice
#

how

hasty prawn
#

Yeah, that's what I was saying KEKW

tardy delta
#

doesnt the normal one works with regex?

tender shard
#

no

quiet ice
#

I think I realized it the first time I used it

young knoll
#

Regexplace

tardy delta
#

oh not that i use it that often but yea

quiet ice
#

Well, I had no idea about regex back then so it wasn't so cool

tender shard
#

no he uses eclipse

hasty prawn
#

Oh right

quaint mantle
#

what is your way 2 go then :(

quiet ice
#

Quite the pain to figure out what went wrong back then

modern fox
#

?paste

undone axleBOT
young knoll
#

Someone say eclipse

quiet ice
#

no.

modern fox
#

Getting this error here: 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
https://paste.md-5.net/efucuzozip.java

tardy delta
#

casting?

young knoll
#

That would add every five levels

vague swallow
#

Can someone please tell me why this is not working:

if(t.getItemOnCursor().hasItemMeta()) {                             
    if(t.getItemOnCursor().getItemMeta().getDisplayName().equals("ยง7Head")) {
         t.setItemOnCursor(new ItemStack(Material.DIRT));
    }
}
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.

vague swallow
tender shard
modern fox
#

Getting this error here: 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
https://paste.md-5.net/efucuzozip.java

tender shard
#

my guess: the displayname is wrong

hasty prawn
#

^

quiet ice
#

^

mellow edge
#

should I store data from plugin into a file, for example home locs and this kind of things, or database

young knoll
#

Well, it would increase every 5 levels

quiet ice
#

Flatfile

young knoll
#

But a file is usable

modern fox
mellow edge
#

bdw I want to publish this plugin

quiet ice
#

Then use flatfile, most do not know how to setup a db

hasty prawn
#

Or have an option

quiet ice
#

Or use a db like h2

young knoll
#

SQLite

mellow edge
young knoll
#

Or that ^

mellow edge
#

lol

young knoll
#

CMI offers SQLite and MySQL

#

Therefor thatโ€™s all you ever need because CMI best

mellow edge
#

I don't want to make work for people

quiet ice
#

Never used CMI. Probably the reason I have a dead server

blazing scarab
#

EssentialsX + a couple of free plugins > CMI

tender shard
#

CMI is good but it also has a ton of unfixed issues without answers from the dev

mellow edge
#

I think flatfile is a way to go

opal juniper
#

Ok so i am using a multi module thing atm and i want opinions.

I have an API module that has a method that returns an instance of a class that is impl'd in the Main. Main implements the API so the API has no access to main cause thats a cyclic depend

If i set a singleton of that class, its fine and it works but i wanted a new instance for each call. How should i go about this?

tender shard
#

e.g. basic stuff like global chat isn't working in CMI and the dev hasn't replied in 2 months now

mellow edge
#

ty

quiet ice
tender shard
mellow edge
#

why?

quiet ice
#

Don't use YAML and always store a version byte or something like that

vague swallow
tender shard
quiet ice
#

If you want to do async saving you should also never use Collection#size

mellow edge
narrow yoke
#

Heyo guys. First time being here and I want to use that to ask you for some ideas about what to implement on my new SMP server.
Administration plugins are not the thing I'm asking for as I got already everything I need (some I don't even really need...)
Your ideas are appreciated!

opal juniper
narrow yoke
#

Is this an incorrect channel? Sorry.

opal juniper
#

i do already have an interface that gets impl'd

tender shard
tender shard
narrow yoke
#

Yeah, okay, I asked in the other channel.

lost matrix
red sedge
#

How can I convert a string to a list but like "{0} | {1} | {2}"

#

so it would only contai nthe values

#

and not the " | " part

tender shard
young knoll
tender shard
#

then you can do Arrays.asList

tardy delta
#

MessageFormat.format will replace "{0}" "{1}" etc strings with the corresponding arguments

opal juniper
red sedge
#

the string would be like "aaa | rsdfzh | saj"

sterile token
#

Omg im stressed im looking the class "okhttp3.OkHttpClient" on okhttp repo. But i cannot find where fucked its the class.

opal juniper
blazing scarab
red sedge
tender shard
#

String.toCharArray

#

and Arrays.asList

blazing scarab
lost matrix
red sedge
#

an array containing [0, 1, 2]

red sedge
sterile token
tardy delta
#

split it by " | "?

lost matrix
sterile token
tender shard
blazing scarab
#

what the fuck

grim ice
#

So um

blazing scarab
#

Thats not what he meant

tender shard
#

he said turn a String to a list

#

idk what he means then

wet breach
red sedge
vague swallow
# tender shard how did you determine this? did you add debug statements?

well the itemstack is right above:

ItemStack Item = new ItemStack(Material.IRON_HOE, 1);
ItemMeta Itemmeta = Item.getItemMeta();
Itemmeta.setDisplayName("ยง7Head");
Item.setItemMeta(Itemmeta);

if(t.getItemOnCursor().hasItemMeta()) {
   if (t.getItemOnCursor().getItemMeta().getDisplayName().equals("ยง7Head")) {
       t.sendMessage("hi");
   }    
}
tender shard
#

if you don't do that, I can't help

vague swallow
#

And the problem is at t.getItemOnCursor().hasItemMeta()

blazing scarab
tender shard
#

I wonder why Lists.newArrayList() exists

visual tide
#

does it legit just do new Arraylist<>()

tender shard
#

oh because ArrayList() doesn't take arrays maybe?

blazing scarab
#

yes it doesnt

tender shard
#

then it makes sense

lost matrix
#

Arrays.asList(T[])

opal juniper
blazing scarab
#

The problem is.. Hr wants an ArrayList

opal juniper
blazing scarab
opal juniper
#

i want a new instance for each time its called

tender shard
#

if your API creates an implementation specific thing it's bad design anyway imho

sterile token
#

For a plugin api, you should create only 1 instance and use it on every plugin

grim ice
#

how to fix this

#

i decompiled a plugin (with permission)

#

however classes look like this

blazing scarab
sterile token
quiet ice
#

So, what is the issue?

grim ice
#

its with permmission

#

lol

blazing scarab
#

Decompilers are not idea

#

L

grim ice
#

i was asked to decompile it

young knoll
#

Skid all the plugins

sterile token
quiet ice
#

Decompilers are perfectly fine

tender shard
grim ice
quiet ice
#

Yes, WHAT IS THE ISSUE

tender shard
#

yes that looks like valid java code to me

grim ice
#

whatever i type it wont even tell me an error

#

for example

quiet ice
#

Did you unzip the jar?

grim ice
#

yeah

#

i used jd gui

tender shard
#

the folder where it's inside must be tagged as sources folder

quiet ice
#

Ew, use Quiltflower to decompile stuff

#

And Recaf if you want to edit stuff

grim ice
#

oh there isnt a src folder

tender shard
#

right click the folder where it's inside

#

Mark Directory as -> Sources Root

#

@grim ice

tender shard
quiet ice
#

This does not look obfuscated, so CFR isn't the best choice here

#

(assuming that it is what it is)

#

oh, it does not use CFR

#

Eh, makes it even worse

tender shard
#

does someone know a good tutorial about coding intellij plugins?

tender shard
visual tide
#

create a project with the preset and play around with it ๐Ÿคท

visual tide
tender shard
grim ice
#

intellij on drugs bro?

visual tide
#

pretty sure there is?

jovial abyss
tender shard
dusk flicker
#

what the hell is that project

visual tide
#

uh

#

sec

tender shard
#

makes perfect sense

grim ice
#

ok then im on drugs

tender shard
#

you marked "me" as sources root

visual tide
grim ice
#

what do i mark then

tender shard
#

so the classes are now called border.something

#

you have to create an aupper directory called "src" or whatever

#

then move the whole "me" thing inside

grim ice
#

that makes sense

visual tide
#

src/main/java

tender shard
#

and mark "src" to be sources root

tender shard
#

it actually doesn't matter what you call it but yeah, usr /src/main/java

visual tide
tender shard
visual tide
#

bruh

tender shard
#

gotta check the marketplace

eternal night
#

whats wrong with the intellij platform sdk tutorial ?

visual tide
tender shard
visual tide
wet breach
visual tide
tender shard
wet breach
visual tide
#

because it has the preset ._.

tender shard
visual tide
#

dont you stay on an old version when your ultimate runs out

#

reinstall ez

tender shard
wet breach
#

lol

red sedge
visual tide
tender shard
#

found it

waxen plinth
#

stinky plugin

#

wait no I'm thinking of the minecraft plugin dev kit

#

that one's stinky

tender shard
grim ice
#

Sorry for still asking questions, but I've never really decompiled a whole plugin and tried to edit it

young knoll
#

Oh?

visual tide
#

why ._.

young knoll
#

Doesnโ€™t everyone here recommend it

tender shard
#

it provides almost 0 functions and it always keeps crashing after new intellij updates

grim ice
#

it doesnt matter what decompiler i use

#

its configuring intellij

tender shard
#

maybe it only sucks in ultimate, no idea I haven't used community edition in years

visual tide
tender shard
tender shard
grim ice
#

its fine

#

never crashed

hasty prawn
#

Isn't it more useful for mod dev than spigot dev

grim ice
#

i mean not if ur doing versions under 1.12

tender shard
#

yeah, for mods it might be helpful

#

but for spigot it literally doesn't do anything

buoyant viper
#

minecraft dev plugin is great for working with mixins

hasty prawn
tender shard
young knoll
#

Imma switch to IntelliJ just for that

tender shard
#

erm how does the mc intellij plugin even generate a pom?

grim ice
#

Alr

tender shard
#

there's no preset for it

grim ice
#

dunno

#

it just does

#

it doesnt need one does it

tender shard
#

erm of course I need a pom.xml

grim ice
#

or maybe it does have one but its internal or something, you dont certainly have to see it right?

delicate lynx
dusk flicker
#

the intellij plugin aint great

delicate lynx
#

it's there for me

tender shard
dusk flicker
#

its good for beginners but after that just do it yourself

hasty prawn
#

^

tender shard
#

ugh I am stupid. I installed the plugin but you also have to enable it afterwards

naive bolt
hasty prawn
#

It tells you the issue

dusk flicker
#

?stacktrace

#

we need that

hasty prawn
#

What does it respond with

#

"Read it."?

dusk flicker
tender shard
#

entity.result is null

dusk flicker
#

troubleshoot it

#

We arent here to do it for you

tender shard
#

entity.result is null

mortal hare
#

do you guys use @NotNull/@NonNull or @Nullable annotations? If so, do you guys use guard clauses to check them runtime, or let the IDE handle that for you?

#

oh no

#

nft monkey

tender shard
mortal hare
tender shard
dusk flicker
#

that doesnt really have anything to do with the annotations as far as I am aware

tender shard
#

@ NonNull is lombok I think and automatically adds those

mortal hare
#

no, intellij for example does annotation processing at runtime

#

to check if the values are null

dusk flicker
#

ah

tender shard
#

it doesn't add guard clauses. you need lombok @ NonNull

mortal hare
#

it actually does check it at runtime

#

if you're using intellij

tender shard
hasty prawn
#

So you should still check probably

grim ice
#

I need to also mark something related to pom xml now right?

tender shard
grim ice
#

this is the last question istg im annoying y'all sry

blazing scarab
#

Objects.requireNonNull tho

tender shard
#

see? plugin is @NotNull but there's no check in the code

ivory sleet
mortal hare
#
When you compile your project in IntelliJ IDEA, it instruments the bytecode of compiled classes to add runtime checks for various flavors of @Nonnull annotations. This behavior is controlled by the option:

Settings | Build, Execution, Deployment | Compiler | [x] Add runtime assertions for not-null-annotated methods and parameters.
tender shard
#

but it's disabled by default

quiet ice
#

Some decompilers remove the added code by default

tender shard
ivory sleet
#

For instance with gradle, (merely) using compileOnly would disregard the annotation processing

mortal hare
#

idk man

#

its ticked for me by default

tender shard
mortal hare
#

no

#

i reinstalled it

#

couple weeks ago

#

This feature was added back in IntelliJ IDEA 5.0, but at that time it only supported JetBrains' @NotNull annotations. The support for other annotations was added recently.

#

it was removed long time ago

dusk flicker
#

its enabled for me too

tender shard
#

for me the annotations have a specific subsetting

mortal hare
#

its 2021 release

tender shard
grim ice
mortal hare
tender shard
grim ice
#

?paste