#help-development

1 messages · Page 1782 of 1

mortal hare
#

oh yeah i forgot, yep its final, fuck bukkit

misty current
#

it also implements an interface

#

maybe i can make it implement it?

mortal hare
#

i've had this issue before

misty current
#

doubt it would do anything

#

PluginIdentifiableCommand

mortal hare
#

no it wouldnt work

#

wait nvm

#

it could

ivory sleet
#

What are you trying to do

mortal hare
#

he's trying to setup Command node system

#

for his plugin probs

ivory sleet
#

Ah

misty current
#

yea, tryna register commands outside plugin.yml

#

commandapi

ivory sleet
#

Technically don’t need PluginCommand at all

mortal hare
quaint mantle
#

Incendo/Cloud 👉 👉

mortal hare
#

for example getCommand() doesnt work anymore

#

since it checks instanceof PluginCommand

#

or something like that

#

afaik

ivory sleet
#

yeah sure but you could just create a new derived system based of Command ?

mortal hare
#

you need to sync commands yourself

#

just because of dumb final keyword

ivory sleet
#

Yuh

misty current
#

can't even construct the class

#

else it would be pretty useless

ivory sleet
#

Which class

misty current
#

PluginCommand

mortal hare
#

PluginCommand

ivory sleet
#

You can tho

#

Reflection

misty current
#

not like i can override its methods

ivory sleet
#

You can inject a custom command executor

#

And what not

#

Because most of its properties are mutable

misty current
#

hm i don't know, that sounds worse than just extending Command

ivory sleet
#

it’s a bit limiting sure

quaint mantle
#

Dam just use a command framework

ivory sleet
#

Bukkit’s command api roo_confuse

misty current
#

Bukkit's command api's kinda doo doo

quaint mantle
#

I wish we will get a better command api someday

ivory sleet
#

🙏

#

Might be a good time to redo the thing when md5 is gonna yeet the enums

misty current
#
new CommandBuilder("addenchant")
                .setAliases("addcustomenchant", "customenchant")
                .appendArgument(new StringArgument()
                        .setArgName("enchant id"))
                        .setTabCompleter(enchants::getRegisteredEnchantsIds)

                .appendArgument(new IntegerArgument(1)
                        .setArgName("level")
                        .setTabCompleter(1, 2, 3, 4, 5)
                )

                .appendArgument(new PlayerArgument(true)
                        .setTabCompleter(Utils::getOnlinePlayersList)
                )

                .executesPlayer((player, args) -> {
                    String ench = args[0];
                    int level = Integer.parseInt(args[1]);
                    Player playerArg = Bukkit.getPlayer(args[2]);
                    //code
                    }
                });

i like this more

quaint mantle
stone sinew
#

@ivory sleet @sullen marlin Thanks for your help. (Also anyone else I didn't mention but that had helped.)
https://github.com/TheCrappiest/TaskManagement
Output: ```
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] ForkJoinPool-1-worker-13
[2021-11-22 10:20:50] ForkJoinPool-1-worker-4
[2021-11-22 10:20:50] ForkJoinPool-1-worker-9
[2021-11-22 10:20:50] ForkJoinPool-1-worker-11
[2021-11-22 10:20:50] ForkJoinPool-1-worker-2
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:21:01] main was delayed.
[2021-11-22 10:21:01] ForkJoinPool-1-worker-2 was delayed.

misty current
#

yeah anyways i guess i'll stick with restarts

quaint mantle
#

Singletones ☹️
-1000000 social credit
☹️

misty current
#

i use singletones sometimes, they're useful

#

especially to store player data or such

quaint mantle
#

What stops you from not using singletones to store player data or such

ivory sleet
#

Singleton and unit tests pepeShocked

stone sinew
# ivory sleet Oo pog

Oh god... I just looked through the github... why does github add 8 spaces instead of 4 for spacing?

ivory sleet
misty current
waxen plinth
stone sinew
ivory sleet
#

Uh Idk then shrug

quaint mantle
misty current
stone sinew
#

I wish you could edit a class without needing to commit

waxen plinth
#

What

misty current
#

wait redempt you used to be a developer on orbitmc or something similar

#

didn't you

waxen plinth
waxen plinth
#

Wait I remember you from there

ivory sleet
waxen plinth
#

I knew I remembered you from somewhere!

ivory sleet
#

annots?

misty current
#

redlib made me remember

waxen plinth
misty current
#

you were talking about it in server chat too lmao

waxen plinth
#

But prettier I suppose

#

And more organized

ivory sleet
#

Yeah Idk what’s better either

quaint mantle
#

Annotations -> organized

waxen plinth
#

I would say annotation > builder

#

But command file > annotation 💪

ivory sleet
misty current
#

i'm proud of my builder :c

#

not that experienced

waxen plinth
#

Want to try an alternative

misty current
#

tbf i'm surprised it got it to work

ivory sleet
#

Proves you’re smarter than what you think (:

misty current
#

redlib?

#

:p

waxen plinth
#

👀

#

If you don't wanna try it you can say so and I will stop talking about it

misty current
#

i took a look at it before deciding to develop my own

quaint mantle
#

accidental reactions

misty current
#

just wanted to challenge myself so i made my own

#

i had found a similar one but it was for 1.13+

#

and i'm on 1.8

#

insults incoming

ivory sleet
#

Tbh builders with generic types would be nice once we get project valhallas primitive generic thingy jep

waxen plinth
#

Well that changes my tune

waxen plinth
mortal hare
#

Builder ftw. Annotations use reflections to process things

misty current
#

:d

quaint mantle
#

Well , enums, classes, and arrays

waxen plinth
#

Reflection is fine lol

misty current
#

i like builders, they are very sexy

waxen plinth
#

I love reflection

quaint mantle
#

You could probably abuse enum mutability but eh

misty current
#

i have a gui builder, item builder, command builder...

mortal hare
#

Reflection is fine until you don't use it as your main source of doing all the things

waxen plinth
#

And honestly I would be really surprised if the reflection overhead is higher than time it takes to process commands anyways

#

Considering how complicated that code is

quaint mantle
waxen plinth
#

How so

#

It has pitfalls but it has huge advantages too

ivory sleet
#

Yeah

#

Depends on what exactly you’re doing

misty current
#

afaik reflection abuse not gud

waxen plinth
#

Yeah conflating all reflection with abuse is also not good though

#

You can make a lot of really nice abstractions with reflection

#

Obviously you shouldn't use it for everything

#

But it's not nearly as slow as most people will lead you to believe

#

And it's getting much faster in java 18

mortal hare
#

its not slow af as it used to be

waxen plinth
#

As in, java 18 will have nearly no reflection overhead

ivory sleet
mortal hare
#

i love patterns in jdk14+

waxen plinth
#

Reflection is going to use method handles under the hood instead of its own pathways

ivory sleet
#

Ah

blazing scarab
#

i've heard it's going to use methodhandles internally

ivory sleet
#

That’s awesome

waxen plinth
#

Yep

#

And method handles have nearly no overhead

uneven lily
#

please help me
https://paste.md-5.net/exaliwosab.sql
error
if iam using any command regarding plugins it is showing a internal error occured while attempting this command how to fiix it
imaginedev bro please help me

ivory sleet
#

I know that if you use smtng like a method handle lookup where you unreflect a reflective object it’s going to be slow in invocation. But else yeah if you use lambda meta factory it’s darn fast.

mortal hare
#

so basically under the hood it would utilise some kind of address pointer under the hood

#

to find the method quickly

#

?

waxen plinth
#

Method handles are just a direct reference to a method basically

blazing scarab
waxen plinth
#

So yeah

#

They're much faster than reflection

waxen plinth
#

I thought unreflect made it faster

#

I haven't used it though so I don't know for sure

misty current
#

oh also a thing about reflection

mortal hare
#

this is more stream API mess than Reflection API mess for me

misty current
#

should you use it for NMS access?

ivory sleet
#

Yeah redempt, think matt switched over to method handles in triumph cmds where he basically just unreflect’d turned out to be slower than normal reflection iirc

waxen plinth
#

Stream API... Mess?

blazing scarab
#

isnt unreflect is just a convenience method to get a method handle from reflection method?

ivory sleet
#

Idk actually

blazing scarab
#

for sure you can do a lookup by yourself

waxen plinth
#

The overhead is really not a big deal for commands anyways though

ivory sleet
#

Indeed

waxen plinth
#

Commands aren't that performance critical

blazing scarab
ivory sleet
#

Stream api tends to make code cleaner, and not messier shrug

blazing scarab
#

oh wait nvm

waxen plinth
#

Stream API is a fucking godsend

mortal hare
#

its a choice

waxen plinth
#

Yeah it is

#

And streams are cleaner and easily parallelizable

mortal hare
#

maybe i should try to use streams more.

#

is the overhead big?

waxen plinth
#

You shouldn't do everything with them

waxen plinth
#

It's about 15-20% slower from benchmarks Matt ran

#

I don't use them on performance critical stuff

#

But for everything else they're cheff's kiss

mortal hare
#

well but parallel streams are really godsend

waxen plinth
#

Ok I gotta go, toodles

waxen plinth
ivory sleet
#

Can we choose the executor of a parallel stream? Haven’t used them so just out of curiosity

waxen plinth
#

@mortal hare

ivory sleet
#

Ah actually doesn’t look like its possible which might be a downside

mortal hare
#

yea it uses ForkJoinPool.commonPool()

#

just like CompletableFuture

#

but at least you can pass your own executor in completablefuture afaik

ivory sleet
#

CompletableFuture doesn’t necessarily use fjp cp

#

Yeah

#

But if the parallelism of cp is 1 then iirc it just has an executor which starts a thread for every supplied function

tribal gyro
#

how do you change the max hearts a player has

visual tide
#

?di

undone axleBOT
visual tide
#

pass your plugin instance

waxen plinth
#

Or config instance

visual tide
#

^

tardy delta
#

or string 😳

ivory sleet
quaint mantle
#

CharSequence

tardy delta
#

stfu real bros use a char[]

quaint mantle
#

const char*

tardy delta
#

dont break my brain again

tribal gyro
#

how do I make an indefinite potion effect

undone pebble
#

by using Integer.MAX_VALUE as your duration

quaint mantle
#

or 99999

#

How would you call an implementation of a Clan that also applies changes to the database? ClanImpl is already taken

#

AutoSavingClan maybe

tardy delta
#

yesh uwu

ivory sleet
#

FinalDatabaseManagableClanImpl 🥴

silent steppe
#

just a quick question, the runTaskTimerAsynchronously function runs the runnable on its own new thread right?

young knoll
#

It runs on one of the bukkit worker threads

quaint mantle
tribal gyro
#

how do i set max health of a player

young knoll
#

getAttribute(whatever the health one is).setBaseValue

tribal gyro
young knoll
#

Yes

quaint mantle
#

if i wanna run a task async, should i use CompletableFutures? Or BukkitScheduler is preffered?

ivory sleet
#

What are you doing in the task? 😮

quaint mantle
ivory sleet
#

Ah oui, hmm maybe a CompletableFuture with a custom executor.

quaint mantle
#

i made a tricky editor system to apply multiple changes at once

ivory sleet
#

I mean the Bukkit scheduler is fine, just that having your very own stuff gives you more power.

#

Oo

#

Like a bulk operator?

quaint mantle
#

Yeah, kinda

public static void editor(Clan clan, Component displayName, ClanMember member) {
        
        clan.edit(editor -> editor.setDisplayName(displayName).addMember(member));
    }

Using jdbc transactions

ivory sleet
#

Oo that looks neat

tardy delta
#

why dont function?

#

🤓

quaint mantle
#

🧐

tardy delta
drifting grove
#

How may I convert player to string? so I can get the player name instead of the whole player thing

quaint mantle
#

Question, how could I get the nearest player object from an entity?

quaint mantle
#

mmm how would does that work?

maiden thicket
#

so i'm using the steer packet to help the player control an entity, but i believe i did it a little janky

#

i have a player riding an arrow riding the entity

#

because i needed to position the player

#

so i had them ride an arrow

#
        Arrow arrow = (Arrow) entity.getWorld().spawnEntity(entity.getLocation().clone().add(0, 0, 1.5), org.bukkit.entity.EntityType.ARROW);
        arrow.setGravity(false);
        entity.addPassenger(arrow);
        System.out.println(arrow.isInsideVehicle());
        arrow.addPassenger(event.getPlayer());

        event.getPlayer().setCollidable(false);```
#

that's the player getting on, entity being the vehicle / entity to ride

drifting grove
# quaint mantle player.getName...

I tried that but I got this public HashMap<Zombie, Player> ZombieToName = new HashMap(); and im getting it by doing ZombieToName.get(zombie)) but when I do player.getname, it still doesnt actually just show the name but the whole player thing

maiden thicket
#
    @EventHandler
    public void onSteer(InputEvent event) {
        if (event.getPlayer().getVehicle().getType() != org.bukkit.entity.EntityType.ARROW) return;
        if (event.getPlayer().getVehicle().getVehicle() == null) return;
        if (!matches(event.getPlayer().getVehicle().getVehicle(), "helicopter")) return;

        float angle = new Vector(event.getPacket().getZza(), 0, event.getPacket().getXxa()).normalize().angle(new Vector(1, 0, 0));
        Vector vechileVelocity = event.getPlayer().getEyeLocation().getDirection().rotateAroundY(angle);
        event.getPlayer().getVehicle().getVehicle().setVelocity(vechileVelocity);
        event.getPlayer().getVehicle().setVelocity(vechileVelocity);
        event.getPlayer().setVelocity(vechileVelocity);
    }```
#

this is me listening to the steer packet event

#

the entity itself moves, but the player and the arrow remain still

tardy delta
#

why dont function?

mortal hare
drifting grove
#

thats how I store and how I use it

misty current
#

what happens if you set the damage to negative in an entitydamageevent?

#

does the victim heal?

mortal hare
#

if i had to guess he'll die

quaint mantle
#

Maybe a illegal argument exception

tardy delta
#

bruh

tardy delta
misty current
ember estuary
#

What's the alternative to the depricated World#regenerateChunk ?

tardy delta
#
From the JavaDocs
"Deprecated.
regenerating a single chunk is not likely to produce the same chunk as before as terrain decoration may be spread across chunks. Use of this method should be avoided as it is known to produce buggy results."

If you don't mind that, you can keep on using the regenerateChunk method.
If you do, you'd need to pretty much rewrite all world generation in order to support it. (Also, look below for another possible solution)
ember estuary
#

can you send me the docs?

tardy delta
#

uhh i found it on github

ember estuary
#

But doesn't deprecated mean its gonna be removed in the next versions

tardy delta
#

uhh i dunno how that works with the spigot api

ember estuary
#

Or do deprecated methods stay forever

#

idk either

#

wouldnt wanna use something thats about to be removed in 1.18/1.19

ember estuary
#

then whats the point of deprecated

visual tide
quaint mantle
#

Deprecated is used to striketrough questioniable methods

#

To get developer attention LoL

ember estuary
quaint mantle
visual tide
tardy delta
#

there is no better alternative, you could store the chunks so you get the exact state

ember estuary
ember estuary
#

just gonna use it then and hope it doesnt get removed xD

dense shoal
#

Good afternoon! I'm trying to add a mechanic to my plugin where a crossbow is automatically reloaded (in certain cases). I'm attempting to do this via CrossbowMeta, setting charged projectiles and then setting the item meta. Currently, my POC code and testing it, I'm firing a health 2 tipped arrow and am trying to reload the crossbow with a regular arrow.

What I'm expecting to happen: After firing the health 2 tipped arrow, the crossbow is loaded with a regular arrow after firing.

What is happening: after firing the health 2 tipped arrow, nothing more is happening. I can't fire the arrow that should supposedly be loaded.

What I have tried: My suspicion was that I was trying to set a charged projectile too early and then tried setting the charged project in a sync delayed task.

Here is my relevant code:

    @EventHandler
    public void onArrowFire(EntityShootBowEvent event)
    {
        // If the entity is a player
        if (MUtil.isntPlayer(event.getEntity())) return;
        
        Player player = (Player) event.getEntity();
        UPlayer uPlayer = UPlayer.get(player);
        
        // and the player is a level 1 Qadir
        if (!abilityCheck(uPlayer, 1)) return;
        
        // and the thing that the Qadir is shooting from is not null
        if (event.getBow() == null) return;
        
        // and the thing that the Qadir is shooting from is not a cross bow
        if (event.getBow().getType() != Material.CROSSBOW) return;
        
        ItemStack crossbow = event.getBow();
        
        System.out.println(crossbow);
        
        // and the projectile shot is an arrow
        if (!(event.getProjectile() instanceof Arrow)) return;
        Arrow arrow = (Arrow) event.getProjectile();
        
        // Prevent the arrow from being able to be picked up (don't allow people to dupe lol)
        arrow.setPickupStatus(PickupStatus.DISALLOWED);
        
        CrossbowMeta crossbowMeta = (CrossbowMeta) crossbow.getItemMeta();
        assert crossbowMeta != null;
        crossbowMeta.setChargedProjectiles(MUtil.list(new ItemStack(Material.ARROW, 1)));
        
        crossbow.setItemMeta(crossbowMeta);
        
        System.out.println(crossbow);
    }```

In my debugs, I can see that the first System.out.println() is outputting the crossbow with the tipped arrow and the second one is outputting the crossbow with the regular arrow. I could also observe this behavior with the IntelliJ debug evaluator. 

Please forgive me for any hilarious mistake I have made, I started working on this at roughly 2a today rip. A second pair of eyes would be appreciated though 😄

Here's a picture of the console debug output for good measure:
https://i.imgur.com/tKCtP9o.png
#

OH, I also tried just adding a new crossbow to my inventory, that works, I get a loaded crossbow.

ember estuary
#

What about player.updateInventory(); after the crossbow.setItemMeta(crossbowMeta);?

#

but just replacing the item entirely, like you're doing now, should also do the trick, yeah

dense shoal
# ember estuary What about player.updateInventory(); after the crossbow.setItemMeta(crossbowMeta...

Heya, thanks for your reply. Now I'm trying to just even remove the bow from the inventory after firing and I think I'm going nuts. I noticed that I was missing the updateInventory call a little bit ago. The following won't work:

    public void onArrowFire(EntityShootBowEvent event)
    {
        // If the entity is a player
        if (MUtil.isntPlayer(event.getEntity())) return;
        
        Player player = (Player) event.getEntity();
        UPlayer uPlayer = UPlayer.get(player);
        
        // and the player is a level 1 Qadir
        if (!abilityCheck(uPlayer, 1)) return;
        
        // and the thing that the Qadir is shooting from is not null
        if (event.getBow() == null) return;
        
        // and the thing that the Qadir is shooting from is not a cross bow
        if (event.getBow().getType() != Material.CROSSBOW) return;
        
        ItemStack crossbow = event.getBow();
        
        // and the projectile shot is an arrow
        if (!(event.getProjectile() instanceof Arrow)) return;
        Arrow arrow = (Arrow) event.getProjectile();
        
        // Prevent the arrow from being able to be picked up (don't allow people to dupe lol)
        arrow.setPickupStatus(PickupStatus.DISALLOWED);
        
        CrossbowMeta crossbowMeta = (CrossbowMeta) crossbow.getItemMeta();
        assert crossbowMeta != null;
        crossbowMeta.setChargedProjectiles(MUtil.list(new ItemStack(Material.ARROW, 1)));
        
        player.getInventory().removeItem(crossbow);
        
        player.getInventory().setItemInMainHand(new ItemStack(Material.AIR, 1));
        player.updateInventory();
        
    }```

I can remove other stuff though with success. I was doing `.removeItem(new ItemStack(Material.CHEST, 1))` with success. I think that if I get the above working, I can identify the root of the problem.

I noticed that when calling removeItem(), there's a hashmap that it returns with the items that could not be removed and the hashmap is empty. So, I believe that Spigot *thinks* that the item is being removed. But it persists in my inventory after relogging and disconnect, so I don't think it is a client side issue.
#

I also looped through the player's entire inventory and noted the crossbow was not there after the method completed.

subtle folio
#

How do i disable taking off armor with spigot?

dense shoal
#

Also I'm in survival

tardy delta
#

does player.updateInv() even does anything?

dense shoal
tardy delta
#

i update things and i dont need it

dense shoal
misty current
#

sometimes i'm getting NaN when dividing the event damage squared over the final damage. what might cause it?

ember estuary
#

maybe if its 0?

#

the damage

tardy delta
#

NaN in java 🤔

ember estuary
#

0.0 / 0.0 gives NaN

tardy delta
#

that gives a ..

ember estuary
#

it gives NaN

tardy delta
#

dividebyzeroexception or something?

ember estuary
#

nope

#

NaN

#

try it

tardy delta
#

rawr

ember estuary
dense shoal
#

Are you taking a square root of anything? NaN could result from the production of an imaginary number i. Otherwise, I think a floating point zero divided by 0 will output a NaN.

ember estuary
#

Just if damage == 0 return

#

Should fix it

misty current
#

it's basically to set the final damage

tardy delta
#

WHAT THE HECK

ember estuary
#

and if both is 0 your doing 0.0/0.0 = NaN. just check if its not 0

misty current
#

0/0 is an arithmetic exception whatever

#

but 0.0/0.0 is NaN

#

java being java

ember estuary
#

xD

dense shoal
#

IEEE 754

misty current
#

what if it is 1.0/0.0

ember estuary
#

infinity?

#

lemme try

misty current
#

think so

ember estuary
#

yeah

#

Infinity, as expected

misty current
#

what if a number is very small

#

like very close to 0

tardy delta
#

hey java.lang.ArithmeticException: / by zero
at Main.main(Main.java:3)

misty current
#

like 0.00000001

ember estuary
#

then it will just get close to infinity

misty current
#

does it approx to 0.0

tardy delta
#

java cringe

ember estuary
#

gives 1.0E10

tardy delta
#

noone ever told me nan exists in java

ember estuary
#

u know double can do really high and low right

misty current
#

yea

ember estuary
#

xD

misty current
#

because sometimes i've noticed my damage gets very close to 0

#

or sometimes doubles randomly gains 10 nines after the dot

ember estuary
#

that should be a worry tho

misty current
#

and i still don't understand why

ember estuary
#

wont give NaN

misty current
#

aight

tardy delta
#

i heard that too much this evening bye

misty current
#

k so i can just check if either getdamage or getfinaldamage is 0

#

and do stuff

ember estuary
#

yeah

#

should do the right

misty current
#

aight thanks

ember estuary
#

no problem

tardy delta
#

night uwu

misty current
#

night

ember estuary
#

You can just do
if (Double.isNaN(result)) System.out.println(theOneDamageValue +" "+ theOtherDamageValue);
to see what the values are in case you get NaN

#

but yeah i assume they're 0.0

misty current
#

o yea useful

#

thanks

ember estuary
#

no problem ^^

misty current
#

i'll send it as a warn

#

in the logger

ember estuary
#

yeah, better than println xD

misty current
#

:p

subtle folio
dense shoal
#

I have never touched 1.8.8, sorry

twilit wharf
#

how do I get unicode characters to show in chat? I want a star

subtle folio
#

dont worry, i just checked with that event if it was armor you were right.

twilit wharf
subtle folio
#

no recommened 1.8.8 unless pvp

ember estuary
#

thats probably why he uses it

ember estuary
#

whats the character you want

quaint mantle
#

fuck 1.8 pvp tho

ember estuary
#

1.8 pvp is great

#

xD

ember estuary
#

what star

twilit wharf
#

#

or U+2726

ember estuary
#

\u2726

#

put this in the string

twilit wharf
#

yeah, I just did that, testing now

ember estuary
#

alright

twilit wharf
#

yep, that worked

#

thanks

ember estuary
#

nice :D

#

no problem

twilit wharf
#

I appreciate it

ember estuary
#

glad i could help

subtle folio
ember estuary
#

ahhh sorry

subtle folio
#

no worries

dawn phoenix
#

So 1.16 to 1.17 --- NMS changed a ton... any write up on those changes?

quaint mantle
glossy venture
#
static String formatterPatternSwitch(Object o) {
    return switch (o) {
        case Integer i -> String.format("int %d", i);
        case Long l    -> String.format("long %d", l);
        case Double d  -> String.format("double %f", d);
        case String s  -> String.format("String %s", s);
        default        -> o.toString();
    };
}
``` duuuude
#

this is new in jdk 17

#

type checking switch statements

eternal night
#

it is still in preview isn't it

ivory sleet
#

That’s an expression I think but yeah pretty pog

glossy venture
#

minecraft 1.18 is in jdk 17

eternal night
#

seems to be in preview

dense shoal
glossy venture
#

the full jdk 17 launched in september this year

#

i think

#

at least it was scheduled to

eternal night
#

can't recall this being in first preview in java 15 tho

glossy venture
#

hm

#

idk

eternal night
glossy venture
#

ohk

#

the memory segments are already in it tho

#

i tested

ivory sleet
#

Yeah foreign memory api is all good to go

young knoll
#

Foreign who what

sullen marlin
#

damn foreigners

#

ruining our memory

vale cradle
gloomy edge
sullen marlin
#

seems your jar is broke

#

rerun BuildTools.jar --remapped

dawn phoenix
#

Speaking of development anyone have experience migrating nexus servers?
Got a lot of plugins depending on my nexus and i gotta move it off my box

sullen marlin
#

which nexus version

#

I'd stick with 2.x if you can

#

I upgraded one to 3.x and kind of regret it

#

but it should be as simple as just copying the directories

#

its all self contained

gloomy edge
#

I re-ran java -jar BuildTools.jar --rev 1.17.1 --remapped and tried to compile again and still the same error

sullen marlin
#

thats really weird

#

oh hm could be your plugin jar is corrupt

#

youre not coding in a onedrive folder or anything are you?

gloomy edge
#

No, but the project is on a different drive

sullen marlin
#

hmmm I'll try building your plugin

#

compiled for me

#

lol

#

it'd be interesting to find the issue

#

antivirus maybe?

#

something is corrupting the jar

gloomy edge
#

Let me test with antivirus off

#

Wow, It was Bitdefender the whole time.

sullen marlin
#

gottem

gloomy edge
#

Thank you! anyways I should've tried that before asking for help; my bad

sullen marlin
#

no worries, it's not always obvious

#

antivirus does seem to cause a lot of issues though

worn condor
#

Anyone know how I'd add enchanted books to a merchant using MerchantRecipe, I tried but it doesn't show the recipe in the trading UI
however when I print the recipes the merchant has, it does show it has that recipe
ItemStack{ENCHANTED_BOOK x 1, ENCHANTED_META:{meta-type=ENCHANTED, enchants={MENDING=1}}}

sullen marlin
#

doesnt show it how?

#

like at all? or do you need an enchanted book in your inventory

worn condor
#

In here

sullen marlin
#

sorry not super familiar with merchants

#

if you dont have an enchant does it work?

worn condor
#

Ye

sullen marlin
#

do merchants have enchanted items in vanilla?

worn condor
#

Ye, f.e. librarian villagers I think hold enchanted books

sullen marlin
#

hmmm

#

do you have a 5 liner I can test with

worn condor
#

uhh, it's a listener so it's rather complicated

#

1 sec

sullen marlin
#
        EnchantmentStorageMeta meta = (EnchantmentStorageMeta) enchanted.getItemMeta();
        meta.addStoredEnchant( Enchantment.LURE, 3, true );
        enchanted.setItemMeta( meta );

        WanderingTrader trader = l.getWorld().spawn( l, WanderingTrader.class );
        trader.setRecipes( Arrays.asList( new MerchantRecipe( new ItemStack( Material.ENCHANTED_BOOK ), 10 ), new MerchantRecipe( enchanted, 5 ) ) );```
#

does this look kind of similar

worn condor
#

ye

sullen marlin
#

ok testing

#

apparently merchant recipes need ingredients lol

#

silly api

worn condor
#

oop ye :3

sullen marlin
#

works for me

#
        EnchantmentStorageMeta meta = (EnchantmentStorageMeta) enchanted.getItemMeta();
        meta.addStoredEnchant( Enchantment.LURE, 3, true );
        enchanted.setItemMeta( meta );

        MerchantRecipe first = new MerchantRecipe( new ItemStack( Material.ENCHANTED_BOOK ), 10 );
        first.addIngredient( new ItemStack( Material.STONE ) );
        MerchantRecipe second = new MerchantRecipe( enchanted, 5 );
        second.addIngredient( new ItemStack( Material.COBBLESTONE ) );

        WanderingTrader trader = l.getWorld().spawn( l, WanderingTrader.class );
        trader.setRecipes( Arrays.asList( first, second ) );```
#

note: 1.18-pre5, but I doubt its different in 1.17.1

worn condor
#

could you print the .getResult() from the second one?

sullen marlin
#

like second.getResult() ?

#

[09:10:19] [Server thread/INFO]: ItemStack{ENCHANTED_BOOK x 1, ENCHANTED_META:{meta-type=ENCHANTED, stored-enchants={LURE=3}}}

#

oooh

#

I think the issue is you enchanted the book

#

not added a stored enchant to the book

#

use addStoredEnchant not addEnchant

#

they look similar aside from the text colour, but the result is different

crimson terrace
#

Hey md_5 ive been having trouble with my plugins perms. any ideas? ive been getting ignored a bit and I dont know if its because the question is too dumb

sullen marlin
#

too dumb

#

maybe :p

#

your code: "p.hasPermission("permissions.VB.SummonBosses")"

#

your permission: "VB.SummonBosses"

#

remove the permissions. part

#

(from your code, not yaml)

crimson terrace
#

oh the path i copied from the yaml had that in there. thanks 🙂

crimson terrace
worn condor
#

still doesn't work

peak badge
#

Hello, is there ProtocolLib fan? Can you explain me how set structure for this nms packet: (pls ping me 😉 )

class PacketPlayOutEntityEquipment {
    private final int b;
    private final List<Pair<EnumItemSlot, ItemStack>> c;
}
sullen marlin
#

Player#sendEquipmentChange

#

no protocollib required 🙂

young knoll
#

Wait hold up

#

That's a thing? cool

sullen marlin
#

only on 1.18 but yes

peak badge
#

Thanks md_5, but I'm writing npcs :<

young knoll
#

Woo new features

peak badge
#

Do we have 1.18? XD

young knoll
#

We have 1.18-pre5

sullen marlin
#

why do you even need packets for npcs

#

cant you just like y'know spawn them in the world

#

I feel like the leap to entirely API npcs is not very far

misty current
#

interesting

sullen marlin
#

what is the error

ancient plank
#

description 100

proud basin
#

I'm assuming it's a null pointer

foggy estuary
#

Does anyone know if it is possible to add potion effects if you walk on certain blocks…?

young knoll
#

Sure

ancient plank
#

anything is possible

#

smile

lean gull
#

anyone know how to use custom heads in a gui?

young knoll
#

Just add the itemstack

lean gull
#

idk how to make custom heads in java tho

#

is there a way to just set / add the nbt to the itemstack?

young knoll
#

It's a bit finicky

lean gull
lean gull
#

i can't use gameprofile, i've tried it before

proud basin
#

Why can’t you?

lean gull
#

idk

#

i'll try their method in a sec

paper viper
#

its cause you didnt import authlib as a dependency

young knoll
#

It's part of NMS, but you can also import it separately

sullen marlin
#

not part of nms in 1.18

paper viper
chilly hill
#

Is there a way to change the y level of where the player enters a different dimension?

sullen marlin
#

sure, just teleport them to the new location

#

PlayerWorldChangeEvent or something

sullen marlin
#

it'll be in your local repo if you've run buildtools

lean gull
#

can anyone help

late kraken
#

Trying to start a server on the 1.18-pre5 jar but every time it loads the end it gets stuck at a random percentage. Is this an issue for it right now?

sullen marlin
#

no

late kraken
#

Hmm weird then

sullen marlin
#

try and isolate it without plugins / a specific subsection of your world, then open a bug report

late kraken
#

Okay thanks

#

Hmm deleted the bundler folder seems to fix it

sullen marlin
#

seems surprising

golden turret
#

how could i do a crafter system without needing to check every single item of the inventory?

#

i have the recipe stored in my object

paper viper
#

you could try creating a hash based on the 9 slots of your inventory

#

and have a hashmap

#

that way you have O(1) efficiency

golden turret
#

forgot to metion, it is in a chest inventory

paper viper
#

i mean that doesnt matter

golden turret
#

and the items arent ordered

proud basin
#

Anyone know if protocolLib has a way to check if they are near a vehicle and if they are flying? Can't seem to find anything

maiden thicket
#

something like getNearbyEntities(params).stream().filter(entity -> entity.isFlying() && entity instanceof Vehicle)

proud basin
#

There is no reason to stream it

maiden thicket
#

¯_(ツ)_/¯

sacred mountain
#

i got this error after trying to load the 1.17 bungee proxy

#

oh i cant send images

young knoll
#

Verify or use something like imgur

sacred mountain
#

ok

#

i registered

proud basin
#

How would one calculate airticks?

eternal plume
#

I read it is to replace "bungee chat" api and is new improvement.

paper viper
#

it is however used in paper

eternal plume
#

ok I will keep using paper api

lean gull
tribal gyro
#

can plugins not edit text documetns?

paper viper
#

?

#

they can?

tribal gyro
#

then why it no workie

#

i think im doing it wrong smthg

paper viper
#

damn man idk either

#

its not like you showed any code lol

tribal gyro
#
        File dataFile = new File(fileName);
        FileWriter fileWriter = new FileWriter(dataFile, false);
        String condensedData = "";
        for (String s : text) {
            condensedData += s;
            condensedData += "\n";
        }
        fileWriter.write(condensedData);
        fileWriter.close();```
#

sorry

#

forgot

#

lol

#

assume fileName and text are all defined

#

text is an arraylsit

#

help :/

keen lily
#

hello

fickle helm
keen lily
#

i need help with replacing water with fire when the bucket empty event happens

tribal gyro
#

🤦‍♂️

subtle folio
#

There is nothing wrong with my plugin.yml. I dont know why im getting this error: ```[03:02:32 ERROR]: Could not load 'plugins/Tazpvp-6.9.jar' in folder 'plugins'

org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:160) ~[patched.jar:git-PaperSpigot-"4c7641d"]

at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136) [patched.jar:git-PaperSpigot-"4c7641d"]

at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [patched.jar:git-PaperSpigot-"4c7641d"]

at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [patched.jar:git-PaperSpigot-"4c7641d"]

at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [patched.jar:git-PaperSpigot-"4c7641d"]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]

Caused by: java.util.zip.ZipException: zip file is empty

at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_292]

at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:1.8.0_292]

at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:1.8.0_292]

at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_292]

at java.util.jar.JarFile.<init>(JarFile.java:130) ~[?:1.8.0_292]

at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:148) ~[patched.jar:git-PaperSpigot-"4c7641d"]

... 5 more```
quaint mantle
#

zip file is empty?

subtle folio
#

what zip file?

paper viper
#

cause you know, jars are still archives

tribal gyro
#

oops

#
        File dataFile = new File(fileName);
        FileWriter fileWriter = new FileWriter(dataFile, false);
        StringBuilder condensedData = new StringBuilder();
        for (String s : text) {
            condensedData.append(s).append("\n");
        }
        fileWriter.write(condensedData.toString());
        fileWriter.close();``` you know whats wrong?
paper viper
#

well, that seems right. But you called the method right? (brain fart check)

tribal gyro
#

yes

#
public static Hashtable<String, Integer> getData(Player player) throws IOException {
        String playerId = player.getUniqueId().toString();
        List<String> readData = readFile("playerData.txt");
        Hashtable<String, Integer> data = new Hashtable<>();

        boolean found = false;

        if (readData != null) {
            for (String read : readData) {
                String[] dataLine = read.split(" ");
                if (playerId.equals(dataLine[0])) {
                    found = true;
                    Bukkit.broadcastMessage("Data Found");
                    String[] playerData = read.split(";");
                    data.put("Strength", Integer.parseInt(playerData[1]));
                    data.put("MaxHealth", Integer.parseInt(playerData[2]));
                }
            }
        }

        if (!found && readData != null) {
            readData.add(playerId + " ;0;20");
            writeFile(readData, "playerData");
        } else if (!found) {
            List<String> newData = new ArrayList<>();
            newData.add(playerId + " ;0;20");
            writeFile(newData, "playerData");
            data.put("Strength", 0);
            data.put("MaxHealth", 20);
            Bukkit.broadcastMessage("Created new profile for " + player.getName());
        }

        return data;
    }``` is this correct?
sullen marlin
#

gosh you want HashMap not hashtable

#

also you store your data in a list not a map wish is very inefficient

keen lily
sullen marlin
#

perhaps just use the YamlConfiguration API and store in yaml rather than you rown config format

tribal gyro
#

:/

#

but i just wantt o know why it isnt working

#

oh wait it does work

#

just its not writing in the correct file

#

oh bruh im dumb

#

i forgot to put txt after the file name

tribal gyro
#
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        ItemMeta meta = item.getItemMeta();
        if(meta != null && meta.getLore() != null) {
            if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
                    PlayerData.changeData(player, 1, "Strength");
                    Bukkit.broadcastMessage("Strength");
                    PlayerData.updateData(player);
                } else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
                    PlayerData.changeData(player, 1, "Health");
                    Bukkit.broadcastMessage("Health");
                    PlayerData.updateData(player);
                } else {
                    meta.getDisplayName();
                }
                if (item.getAmount() == 1) {
                    player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
                } else {
                    item.setAmount(item.getAmount()-1);
                }
            }
        }
    }``` anyone know why this event keeps getting registered twice?
uneven lily
#

any one please help me i downloaded a plugin but it is not working properly but iam using via version still it is not working how to fix it

sullen marlin
#

check event.getHand or whatever

tribal gyro
quaint mantle
#

Hello, It's been quite a while since I've coded anything and I've recently been getting back into plugin development. I'm trying to make a very simple faction core.

Here is my code:

public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
        Player player = (Player) sender;
        if (args[1] == null) {
            player.sendMessage(Utils.chat("&cYou must provide a argument. Usage: /f create <name>."));
            return false;
        }
        Configuration config1 = (Configuration) plugin.getConfig();
        config1.createSection(args[1] + ": []");
        return false;
    }

Upon running it generates this error:

#
org.bukkit.command.CommandException: Unhandled exception executing command 'fcreate' in plugin funnyplugin v1.0
       
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
      
#

only left in the main parts ^

#

unsure exactly what the issue is, i suspect i may just be using the createSection method incorrectly

uneven lily
#

any one please help me i downloaded a plugin but it is not working properly but iam using via version still it is not working how to fix it

echo basalt
tribal gyro
echo basalt
#

Read the docs

echo basalt
#

@quaint mantle

quaint mantle
#

damn its been a while

#

i literally tried doing !args[1] at first

echo basalt
#

Lol

#

Happens

sullen marlin
#

@young knoll -Pdevelopment to check for missing annotations (@NotNull)

#

also mention ticket in commit message if you can please

quaint mantle
#

oml wtf did i just type

#

returns with the same error

echo basalt
#

Check before

quaint mantle
#
if (args[1].length() < 2) {
quaint mantle
echo basalt
#

No wtf

#

Legit my message

#

How are you going to obtain the second object on an array of size 1

grand escarp
#

does anyone know how to add a smithing recipe, but instead of the netherite ingot, it's a custom item in the same class? i cant seem to get smithing recipes working without custom items (normally) :(

grand escarp
#

idk what u mean lol

echo basalt
quaint mantle
# echo basalt No wtf

well now despite there being a argument provided, it returns with the error i provided if a argument isnt inputted

echo basalt
#

Invert the check

quaint mantle
grand escarp
#

nvm that

#

how do i add AttributeModifiers to items

quaint mantle
#

so does config.addSection() actually save a new entry to the config.yml or..

#

it seems to not be doing so for me

tribal gyro
#
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        ItemMeta meta = item.getItemMeta();
        if(meta != null && meta.getLore() != null) {
            if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
                    PlayerData.changeData(player, 1, "Strength");
                    Bukkit.broadcastMessage("Strength");
                    PlayerData.updateData(player);
                } else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
                    PlayerData.changeData(player, 1, "Health");
                    Bukkit.broadcastMessage("Health");
                    PlayerData.updateData(player);
                } else {
                    meta.getDisplayName();
                }
                if (item.getAmount() == 1) {
                    player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
                } else {
                    item.setAmount(item.getAmount()-1);
                }
            }
        }
    }``` anyone know why its doing this twice?
sullen marlin
waxen plinth
#

Easiest way is to add this line at the start:

#
if (e.getHand() != EquipmentSlot.HAND) return;```
tribal gyro
#

like before if(meta != null ....

tribal gyro
waxen plinth
#

Yeah just return if the interact was fired from the offhand

#

AKA not from the main hand

#

Speaking of which

#

You should use early return to clean up that code

#

Also 8 spaces for indentation?

#

🌚

#
    public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        ItemMeta meta = item.getItemMeta();
        if (meta == null || meta.getLore() == null) {
            return;
        }
        if (!event.getAction().toString().startsWith("RIGHT")) {
            return;
        }
        if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
            PlayerData.changeData(player, 1, "Strength");
            Bukkit.broadcastMessage("Strength");
            PlayerData.updateData(player);
        } else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
            PlayerData.changeData(player, 1, "Health");
            Bukkit.broadcastMessage("Health");
            PlayerData.updateData(player);
        } else {
            meta.getDisplayName();
        }
        if (item.getAmount() == 1) {
            player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
        } else {
            item.setAmount(item.getAmount()-1);
        }
    }```
#

Here, see how I flattened it by taking some of the conditions out, checking them first and returning if they are not met?

#

It works the exact same way but it's a lot less indented now, much easier to read

tribal gyro
#

ah

#

ty

#

im very inexperienced with java

#

👀

lavish hemlock
#

?learnjava :)

undone axleBOT
tardy delta
#

is there a good implementation somewhere about how to setup a tabcompleter in each command class?

quaint mantle
#

using command framework

west oxide
#

hey

#

i cant figure out what i did wrong on this one

#
        public String getPrefix(plugin prefix){
            plugin.getConfig().getString("prefix");
        }```
tardy delta
quaint mantle
#

incendo/Cloud is cool

west oxide
#

i want to be able to just call this on other classes and get the prefix from config.yml

glossy venture
west oxide
glossy venture
#
(Plugin prefix)
glossy venture
west oxide
#

still error

glossy venture
#

everywhere

west oxide
glossy venture
#

what is the code around it

west oxide
#
    public void onEnable() {
        Plugin plugin = this;
        public String getPrefix(Plugin prefix){
            plugin.getConfig().getString("prefix");
        }
        saveDefaultConfig();
        getCommand("info").setExecutor(new info());
        getCommand("Fly").setExecutor(new Fly());
        getCommand("enchant").setExecutor(new enchant());
        getCommand("Bangui").setExecutor(new Bangui());
        getCommand("Heal").setExecutor(new Heal());
        getCommand("Feed").setExecutor(new Feed());
        getCommand("Gmc").setExecutor(new gmc());
        getCommand("Gms").setExecutor(new gms());
        getCommand("Gmsp").setExecutor(new gmsp());
        getServer().getPluginManager().registerEvents(new JoinMessages(),this);
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "BasicEssentials is now working !");

    }```
glossy venture
#

you are defining a amethod in another method

#

not possible

#

put it outside

west oxide
#

oh

#

thank you

#

that fixed

glossy venture
#

do you know basic java

west oxide
#

it gives me other error now smh

west oxide
glossy venture
#

ok

tardy delta
#

hyped

west oxide
#

i watched few videos about constructors

#

and classes

#

i already know about variables

glossy venture
#

?learnjava

undone axleBOT
glossy venture
#

some good resources

west oxide
#

okay

#

thank you

#

i fixed the other error

glossy venture
#

k

tardy delta
#

anyways instead of in onEnable { instance = this; } and static Plugin getInstance { return instance; } cant u just return this?

glossy venture
#

no lol

#

its static

tardy delta
#

owh yea i forgot

glossy venture
#

java doesnt know that its a singleton

quaint mantle
#

if you implement tabcompleter at the same class that implemented commandexecutor

#

then when you register the command

tardy delta
#

yea i know i have it in that way rn

quaint mantle
#

it will automatically register tab completer for you

tardy delta
#

normally my onCommand method shared a private field with the onTabComplete by calling a method which initiliazes it but now i'm getting some nprs

#

so directly overriding onTabComplete doesnt really work as i should call super.onTabCOmplete every time to get the player object etc

quaint mantle
#

huh

#

what do you mean?

#

i dont understand-

tardy delta
#

rn i fixed it like this

#

but therefore i has no executor field in the method and it took the one from the parent class

#

which is null rn

#

so i have to cast it every time and thats stupid as i just want to share objects

plain helm
#

Guys does 1.12.2 support getConfig().getLocation() ?

quaint mantle
#

go find it yourself? idk

plain helm
#

Idk how

tardy delta
#

i use (Location) config.get(string)

#

i threw an error

#

i forgot which one

#

on 1.16

quaint mantle
#

lol.... 1.16 already support getlocation

tardy delta
#

i dunno it never worked with me

plain helm
#

It works with 1.16.5

#

I know that for sure

quaint mantle
#

oh yeah

#

i used 1.16.5

#

or an alternative

#

getConfig.get(location here, Location.class)

west oxide
#

hey i have question about java , so basically i did this and if i understood well , if am inside the same class i can just do getPrefix(); and it will do the action on the method ?


    Plugin plugin = this;
    public void getPrefix(Plugin prefix){
        plugin.getConfig().getString("prefix");
    }
quaint mantle
#

huh...?

#

:madman:

quaint mantle
#

Go learn java

#

Your code makes literally no sence

#

i wonder if he is trolling

#

or that is actually his code...

west oxide
#

lol

quaint mantle
#

no

#

i literally have a pretty good start with java

#

while looks like you dont lol

west oxide
#

yeah

tribal holly
#

I bump my problem, because i still don't understand why my event is not fire

#

i register it, and even remove all my code expect the System.out and he still print nothing when i'm in my area

torn shuttle
#

I'm not too hooked into things but wasn't 1.18 meant to do some changes to chunk loading with visual only and mob chunk loading?

#

wait the scoreboard api changed to a max of 32767 characters?

#

what is this dark magic

#

does it autoscroll now?

sullen marlin
#

probably just glitches tbh

#

idk why mojang changed it

tardy delta
#

what is the generic U?

sullen marlin
#

generic names are just like variable names

#

they can be anything

tardy delta
#

sometimes i'm wondering what they mean

#

like K is key

sullen marlin
#

totally depends on what the author wants them to mean

tardy delta
#

oki

torn shuttle
#

honestly I prefer glitching out to erroring at 16, that thing made me want to pull the few hairs I have left out

#

so is there going to be an event for simulation chunks loading separate from the "visual" chunks now?

sullen marlin
#

There's no real difference

#

Spigot has had essentially the same feature at various times

#

Notably entity activation range in 1.17

#

The block version was removed forever ago because everyone hated that it stopped their crops growing

#

Simulation range is really just that, entity and block activation range

torn shuttle
#

well the real question is it detectable because if it is not this will effectively kill any plugins that scan entities on chunk load

sullen marlin
#

How so?

#

Did entity activation range kill them?

torn shuttle
#

I've come across with some issues, I can't tell exactly why, with persistent entities not being loaded on chunk load

sullen marlin
#

That's a 1.17 thing and has been fixed months ago

torn shuttle
#

has it?

#

I ended up taking the long way around that one lol

#

so it was a bug and not me going insane after all

#

though if entities don't load when non-sim blocks load and non-sim blocks "always*" load first, wouldn't that result in being unable to scan persistent entities in those chunks 100% of the time?

sullen marlin
#

You're overthinking what simulation distance is

torn shuttle
#

just activation?

sullen marlin
#

Yes, as I said

torn shuttle
#

I guess I assumed they went a step further and were sending players the chunk info without "really" loading it

#

so if one of those crash-happy entities resides in a chunk and it gets loaded into visual it will still crash a server just fine, right

sullen marlin
#

Depends why it crashes?

torn shuttle
#

excessive nbt data or whatever that exploit was

#

it's been a while

#

man just activation is pretty lame, for some reason I expected way more

#

huh barrier not a particle anymore in 1.18, interesting

#

that's a shame, it was super useful

#

does that mean barriers have a completely different display behavior then?

#

ah block_marker

sullen marlin
#

If they're actually identical we can add a remap

torn shuttle
#

they act the same

#

as it stands, just updated my 50k line codebase with only having to change 2 lines of code for the barrier particles, thanks for all the hard work with keeping things consistent throughout versions md_5 💯

sullen marlin
#

Thanks, I'll look if we should add a remap and make it 0 tomorrow

torn shuttle
#

that'd be awesome, I can verify in .5 seconds if they're the same behavior

#

actually it will take about as long as it takes to dl mc 1.18 snapshot 5, I was on 6

#

now that's interesting, the barrier particles did change

#

they used to take up the whole block

#

they are still as wide as a block on the barrier but via the API they are now noticeably smaller, maybe 50% of the original size

#

I don't have a banana for scale but I think you can sort of see it

#
    private void doParticleTrail(Particle particle) {
        bukkitTasks.add(new BukkitRunnable() {
            @Override
            public void run() {
                //In case of boss death or chunk unload, stop the effect
                if (!livingEntity.isValid()) {
                    cancel();
                    return;
                }
                //All conditions cleared, do the boss flair effect
                Location entityCenter = livingEntity.getLocation().clone().add(0, livingEntity.getHeight() / 2, 0);
                livingEntity.getWorld().spawnParticle(particle, entityCenter, 1, 0.1, 0.1, 0.1, 0.05);
            }
        }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1));
    }

that is the code I am using to spawn particles, I am decently sure none of the settings should affect scale and they certainly didn't in the previous version

#

it would be cool if there is a way to fix this as I was personally using barrier block's ability to fully take up a block in width to preview block locations / visualizing specific locations in air without actually putting anything on there

#

should I report this as an issue or is it possibly intended 1.18 behavior

worldly ingot
#

If you explicitly pass the BlockData to the particle it may expand outwards

#

Block markers accept BlockData as a data argument (because you can show literally any block), I'd just imagine that barrier is the default one

torn shuttle
#

hm

worldly ingot
#

livingEntity.getWorld().spawnParticle(particle, entityCenter, 1, 0.1, 0.1, 0.1, 0.05, Material.BARRIER.createBlockData());
(and tbh, ideally that BlockData would be a constant you can refer to instead)

stoic osprey
#

can anyone help me to setup the worldedit API for my plugin - I have no idea how

worldly ingot
#

Worth a shot I suppose

#

They might increase the size for blocks

#

Not much to do there

torn shuttle
#

could be

tardy delta
torn shuttle
#

why minify it at all, I will be among the few who will ever even see that they are tiny when spawned manually

#

oh well

#

so out of curiosity is the non-sim distance as simple as setting mobs to have a noAI tag?

mint fern
#

I'm having a hard time manipulating BookMeta right now. Does anyone have a good resource on it so I can fully understand how it works?

wispy plume
#

Is it possible to make silent lava?

ember estuary
#

maybe theres a sound event which you can cancel?

#

so theres Player#stopSound, but i think it only stops already playing sounds. running it every tick doesnt seem like a good option. lemme search for something better

#

probably gotta use a packet listener, i dont think spigot has any SoundEvent implemented

#

but would be a great addition @admins

#

Question:
Do maps support RGB values?
I could only find MapCanvas#setPixel(int x, int y, byte color), but what the heck is the byte for? what combination of 1s and 0s is what color?

torn shuttle
#

oof yikes this 1.18-pre-5 fps isn't feeling so hot

#

20 view distance tanks my fps down to 20 even when not moving and I have a beast of a pc

#

an i7 9700k and a rtx 3090

#

this is the one thing that minecraft has consistently failed to do and it breaks my heart every single time, I don't think we'll ever actually be able to see really far into the distance in this game

ember estuary
#

Is it bad or good practise to make your plugins main class a singleton?

public class MyPlugin extends JavaPlugin {
    public static MyPlugin instance;

    @Override
    public void onEnable() {
        instance = this;
    }
}
ivory sleet
#

That’s not a singleton

ember estuary
#

its not?

#

MyPlugin.instance. ....
there will only ever be one

ivory sleet
#

A singleton design pattern where you have a function which returns one instance

ember estuary
#

well then add a .getInstance()

ivory sleet
#

Your static field is public and non final thus its mutable

torn shuttle
ivory sleet
#

So it breaks the pattern since you allow it to be mutated

torn shuttle
#

these are likely two different particles

ember estuary
#

but i wont, so effectively its a singleton

ivory sleet
#

No its not lol

ember estuary
#

its just that i didnt implement it right

#

whats the difference if mutable or not, if im not gonna mutate it

torn shuttle
#

the ability to mutate it

ember estuary
#

but that doesnt change anything if i dont use that ability

#

i dont really see a point in making it unmutable, if i know its supposed to be unmutable

ivory sleet
#

It’s not a singleton then

fallow hearth
#

Yeah you are right but they are too, just create a static get-method to be safe

ember estuary
#

alright, will do that then, even tho i dont get the point

#

just good practise i guess

torn shuttle
#

it's not a crime to make it unmutable, you were the one showing up here saying you made it unmutable in the first place

#

or a singleton to be more exact

fallow hearth
#

Think about it this way: If you do not develop the project for 2 years and come back to it you might not remeber that part. Thats why you want to keep yourself from using it wrong

ivory sleet
#

Anyways Bukkit actually provides a way to retrieve the plugin instance JavaPlugin::getPlugin

#

Also it’s called immutable not unmutable lol

ember estuary
#

sorry, im not english xD

torn shuttle
#

yeah that didn't sound right, it's time for me to go to bed

ivory sleet
#

No worries was just picking on your words

ember estuary
#

:D

torn shuttle
#

I was just getting disappointed at 1.18 before going to bed

#

18 fps man

#

it hurts

ivory sleet
#

Oof

ember estuary
#

sad xD

torn shuttle
#

I can't even tell what's capping

#

46% cpu use, 35% gpu

#

but it is going between 8-20 fps on idle

ember estuary
#

Wait, so i dont have to make a singleton, so instead of
MyPlugin.getInstance()
I can just use
MyPlugin.getPlugin()
?

torn shuttle
#

I wonder if it's single-threaded performance

ivory sleet
ember estuary
#

thats too long for me, gonna use singleton

#

x'D

ivory sleet
fallow hearth
ivory sleet
#

Anyways I avoid singletons since it makes unit tests a pain

torn shuttle
#

I'm at current cap 32 vd and 10 sim

#

funny thing is

#

I get the same framerate at 20 that I get on 32

ember estuary
#

you unit test your plugins? :o
Sounds like a good idea, but a lot of work

quaint mantle
fallow hearth
#

Resolution?

torn shuttle
#

4k

fallow hearth
#

LUL

ivory sleet
ember estuary
#

but you cant really test ingame stuff, can u?

fallow hearth
#

with vd 32, sm 10, 4k i have 30 fps

ember estuary
#

with a website you can test if it looks how it should - but with minecraft you probably cant

ivory sleet
#

Yes you can

ember estuary
#

how

#

any framework?

ivory sleet
#

You can use MockBukkit and emulate certain events and actions

Yes it’s a bit inconvenient but it works

fallow hearth
#

Oops sorry vsync was on by default, 57

ember estuary
#

Oh wow, very useful, thank you

ivory sleet
#

Yeah no worries 🍉

torn shuttle
#

this sucks

ember estuary
#

If you dont use Singleton, which is like the only way i've seen plugins made, how does your main class usually look like?

torn shuttle
#

well it's always good to get a little disappointment before going to bed

fallow hearth
#

@ember estuary Just make sure you dont expose a map from a singleton or something similar. That typically ends in bad design

ember estuary
#

wym with map

ivory sleet
ember estuary
#

you mean Objects in general? pass by reference n stuff?

fallow hearth
#

For example Map<UUID, UserSettings> do not give out a reference to something like that

ember estuary
#

ok yeah

ivory sleet
#

It’s probably smart to use proper encapsulation and abstraction

fallow hearth
#

A lot of devs start with stuff like Map<UUID,Player> resulting in a clusterfuck of a plugin

ivory sleet
#

Yeah makes the plugin very implementation dependent

torn shuttle
#

oh wow I'm getting huge fps dips even at 10 view distance

#

even at 8 I get big spikes, is this even playable for other people?

ivory sleet
#

I will give it a try once I get home

torn shuttle
#

I am running it through spigot on localhost

fallow hearth
torn shuttle
#

I do get cpu spikes when just walking around

#

but they're insanely high

#

oh actually could be the server messing up

fallow hearth
#

Maybe check CPU-Temps, might not be correctly setup?

ivory sleet
#

Altho this never got finished

ember estuary
#

alright, sure

#

cuz im having trouble understanding how you'd do it xD

torn shuttle
#

ok yeah the dips was the server loading enough blocks for my 32 view distance

#

though I still don't hit fps cap on idle at 15 vd which is not a good sign for performance

#

I feel like this update is going to leave a lot of people in the dust

ember estuary
#

thanks Conclure

#

thats a loooong constructor xD

fallow hearth
#

Compare with SP. On VD 15 i get 250 fps... With 9700k you should get at least like 150 @ idle

ember estuary
#

but it makes sense, yeah

ivory sleet
#

Yuh

#

Could maybe have a builder there

#

Though I have disbanded that shit lol

torn shuttle
#

I'll compare with SP but I feel like SP performance tends to not match server client performance

ember estuary
#

wym with builder

ivory sleet
#

Google builder design pattern (:

ember estuary
#

ah, i think i had that in university

#

also had factory and stuff like that

#

but i dont remember a single thing haha

ivory sleet
#

Yeah

torn shuttle
#

bdp is fine but it gets to be a massive chore a lot of the time

#

singleplayer idling at max view range I actually get exactly the same fps, 20

ember estuary
#

In MapCanvas#setPixel(int x, int y, byte color), what is the byte for? what combination of 1s and 0s is what color?

torn shuttle
#

idling at 15 I get lower fps than in the server

#

significantly so too

#

about half

ivory sleet
#

MapPalette.matchColor is probably what you want to use

ember estuary
#

deprecated :c

#

i wonder whats the alternative

#

ill just use that for now tho

#

why would they deprecate useful methods like that, there has to be an alternative

ivory sleet
#

Magic values

#

Which basically means ambiguous api

ember estuary
#

When you try to make a Github Account, use your super strong password that you use everywhere else too, and github just says "Password is in a list of passwords commonly used on other websites"
Bruh :c xD

last ledge
ivory sleet
last ledge
#

my github account

ember estuary
#

lol, thats cool

ivory sleet
#

Your GitHub account is a link?

last ledge
#

ye lmao

#

see it

ember estuary
#

click the link

#

xD

last ledge
#

xD

ivory sleet
#

Hmm, I’d rather not

last ledge
#

I bought the domain, just for that purpose

ember estuary
#

:D

#

i dont care if he has my ip, can just restart the router

last ledge
#

its not a ip grabber

ember estuary
#

and i dont think he owns the url, or do u

#

well, everything can be

#

xD

last ledge
#

ye I do

ember estuary
#

you can see which ips connected to your server, so technically it could be

last ledge
#

but did u see the homepage right

#

its a joke