#help-development

1 messages · Page 908 of 1

young knoll
#

?pdc

analog mantle
#

I'm just trying to run a spigot plugin in a development enviroment to test a few things. I have zero plugin dev, but copious modding experience. There has gotta be a thing where I can run the plugin in the development enviroment without having to compile it each time right?

plucky rock
#

ty

river oracle
#

spigot nor paper comes with any utilities to just start a server from your IDE out of the box afaik

eternal night
#

....

river oracle
#

I'm still trying to wrap my monkey brain around this!! How ta fuq do I go about making a api module for my plugin CH_PepeThinking. I want to depend on some libraries I relocate but if I add them as a compileOnly dependency SHIT EXPLODES and all hell breaks loose.

eternal night
analog mantle
eternal night
#

fantastic gradle plugin to start a server straight from your IDE for your plugin ^

#

should support hot reloading fine when started in debug mode

young knoll
#

Yeah but it can’t start a spigot server

#

👀

eternal night
#

indeed

#

personal issue I think

eternal night
#

See @river oracle when coll sends the gif its more threatening

river oracle
#

I need staff now

young knoll
#

That’s cuz I actually have a hammer

eternal night
#

and you look more like yoshi yea

young knoll
#

Y2K has one of those novelty foam hammers

river oracle
#

I should have never turned down the offer of reccomendation from Conclure. I mean I could have threateningly sent the gif!!!

eternal night
#

giving off miles vibes

river oracle
#

actually

#

my name is Y2K_ to you buddy

#

only the real ones call me miles

#

I hate to be that guy perpetuating the very serious paper spigot beef, but how could a paper contributer ever be a real one eyes_sus

#

on the bright side I will send you a video of my cat as a peace offering

#

@eternal night I sent the peace offering prayge

eternal night
#

wait

eternal night
#

this you ?

#

with the shitty little 8 there

river oracle
#

yeah :P wait till I get inventory PR going

eternal night
#

I am more of a spigot contributor than you are

river oracle
#

I can separate that into atleast 10

eternal night
#

how can you be the real one

river oracle
eternal night
#

@young knoll this guy hasn't even managed double digits yet

#

who is this guy

river oracle
#

@young knoll ban him bro ban him

#

he has too many valid poitns

#

I CANT TAKE IT

#

lay off bro I just sent you a video of my cat couldn't you be a bit nicer to me

river oracle
# eternal night

ayo check under Y2K_ or something I think I have like 1 or 2 commits under than too

eternal night
#

I am a dog person 💔

river oracle
#

dude

#

literally L

#

fuck you

eternal night
#

1 commit

river oracle
#

okay we are beefing now

eternal night
#

under Y2Kwastaken

river oracle
#

beast I'm at 9

#

once MD merges my next I will finally be in the "double digit club"

eternal night
inner mulch
#

yo guys do you like the open closed principle

river oracle
river oracle
#

who tf cares about OOP princples

eternal night
#

I have other projects to maintain Sadge

#

and no time

#

damn you uni

river oracle
#

I have UNI too??

#

your point!!??!?!

eternal night
#

Pleb uni I presume

river oracle
eternal night
#

I see

river oracle
#

whose is that

#

lol

eternal night
#

yours

river oracle
#

what how lmao

eternal night
#

HMM das public bro

river oracle
#

genuinely wonder if this image is a good or bad thing lol

river oracle
eternal night
#

privacy is dead smhduck

river oracle
#

its all stored plain text CH_BossThumbsUp

young knoll
#

You’ve done 8 PRs?

rough ibex
#

you can hide your contribution history

young knoll
#

Tbf I thought it was less

rough ibex
#

but it makes you sus

eternal night
#

miles getting rolled

river oracle
#

literally in shambles

#

literally coping

analog mantle
# eternal night https://github.com/jpenilla/run-task
Could not create task of type 'RunServer'.
Could not create an instance of type xyz.jpenilla.runtask.pluginsapi.DownloadPluginsSpec.
Could not generate a decorated class for type DownloadPluginsSpec.
Cannot have abstract method NamedDomainObjectSet.named().```
#

what gradle version do i need to use

eternal night
#

what gradle version are you on kekwhyper

#

I'd try with latest

analog mantle
eternal night
#

should be

#

is this in a module or something

analog mantle
#

uh

#

idk

eternal night
#

do you use a root build.gradle.kts and then modules inside of its settings.gradle.kts

analog mantle
#

Yes i use a kotlin gradle

eternal night
#

not really what I was asking sorry 😅 can you share your build.gradle.kts

#

?paste

undone axleBOT
quaint mantle
#

huh

eternal night
#

Enjoy kekwhyper

quaint mantle
#

isn't byte final anyway

eternal night
#

final?

#

oh

quaint mantle
#

ye its a final class ion need super

eternal night
#

yea but generics don't care

eternal night
#

that project is using gradle 7.4

#

in its wrapper

#

I presume those are not compatible kekwhyper

analog mantle
eternal night
#

kekwhyper works perfectly fine for me

analog mantle
#

with the plugin added?

eternal night
#

yea

young knoll
#

Paper tax

eternal night
#

the diff in question ^

#

(emitted changes to gradlew and gradlew.bat)

analog mantle
eternal night
#

make absolutely sure your gradle wrapper is running 8.6

analog mantle
eternal night
#

nice 😅

#

idk how well it does hot re-loading, I think partially depends on IJ quirks

#

like

#

it does hot-reloading

#

it might not do deletion instructions

young knoll
#

Is that more or less jank than /reload

eternal night
#

less

#

hot swapping things vs the fucked classloader close and re-open bs

eternal night
#

Well, best of luck with it PepeSalute

young knoll
#

Idk replacing bytecode live sounds pretty janky

eternal night
#

I mean, the JVM at least properly supports it kekwhyper

young knoll
#

It’s been a while but last I remember trying it I could only edit stuff

#

Trying to add or remove anything just imploded

buoyant viper
#

there's a replacement for hotswap that supports it i think

#

started with a d

young knoll
#

Is this a deez nuts setup

eternal night
#

but its kinda dead

#

most stuff is part of JetBrainsRuntime tho

#

but yea, for removal you need a custom flag too

young knoll
#

Smh IntelliJ isn’t the only ide

eternal night
#

Their runtime is packaged separately

remote swallow
#

i love jbr

#

its so useful

eternal night
young knoll
#

So just never delete things

#

Got it, best programming strategy

cedar flint
#

This is my anvil listener code. Btw no outside classes with InventoryClick affect it, but for some reason when I for example combine a pickaxe and a custom enchanted book with Protection and a compatible custom enchantment the output slot does show the item with the correct lore and custom enchantment, but I cant take it out. and it doesnt get past: if (event.getSlotType() == InventoryType.SlotType.RESULT && event.getRawSlot() == 2) { so it is not like the methods get activated again.
Here is my code:

#

Thank you for helping in advance

young knoll
#

On you’re using inventory click event

#

Use PrepareAnvilEvent

eternal night
#

Ah it was -XX:+AllowEnhancedClassRedefinition

remote swallow
eternal night
#

right downloading the fucking hotswap

#

did they merge t hat into JBR

#

I recall they had it in DCEVM 11

#

it does not

#

fucking sadge

remote swallow
#

i didnt know about it till like a month ago and got annoyed when my lambdas wouldnt hotswap

young knoll
#

Those are some wild startup args

eternal night
#

hotswap agend is wild

young knoll
#

So you just what

#

Run that and then attach from your ide

eternal night
#

Yea

#

attach from IDE in remote JVM debug

young knoll
#

What’s fatjar

eternal night
#

a flag for the hotswap agend

young knoll
#

Is it meant to point to something tho

eternal night
#

no

#

did you download JBR and place the hotswap agend release in the folder it belongs to?

#

das the important part

young knoll
#

No I’m not even on my pc :p

eternal night
#

yea

#

oh

#

why you asking then OMEGALUL

remote swallow
#

i wasnt

eternal night
#

not you

#

coll

remote swallow
#

oh

#

its lib not libs

#

but same thing

young knoll
#

Idk incase I wanted to try it tomorrow

#

Google is for nerds

eternal night
#

facts

rare rover
#

got a question for y'all, since metadata is hella slow compared to other things, and currrently i am accessing the player's pickaxe's metadata every block which a no no, on my part

#

how else would i approach this

#

store the data i need in memory? Or what

young knoll
#

You can do that, yeah

rare rover
#

okay.. So how would i do this?

#

should i store it in the player's metadata instead then grab it everytime they join?

#

then store it in memory, ect

young knoll
#

You can, yeah

#

What exactly are you storing

cedar flint
#

I recoded it now using PrepareAnvilEvent, but still I cant take the item out of the output slot.

young knoll
#

Hmm, I’ve never had issue when doing it that way

#

Oh wait wait

#

I think you need to set a non-zero cost

cedar flint
#

Il try

#

omg thank you. You are a god. It works!

rare rover
#

which im grabbing every block broken and is hella slow (as shown in the profiler)

#

which is a no no

young knoll
#

I didn’t think cloning ItemMeta was that slow

#

But I guess it makes sense

remote swallow
#

store the data urself and just track the slot location

rare rover
#

it was 100% the bottleneck of my system

#

~70ms for the PDC alone

#

was 140ms in total

rare rover
#

i could also lock the pickaxe in slow 1

remote swallow
#

people dont like that

echo basalt
#

sounds like you had way too much pdc

remote swallow
#

some people have it in there 7th slot witha keybind

rare rover
buoyant viper
rare rover
#

instead of the item and i can grab it when the join and unload it when they leave

remote swallow
#

depends what data it is

#

context?

rare rover
#

its literally just integers

#

one sec

remote swallow
#

might be fine to do that then

#

just do periodic saving for modification and crash protection

balmy jacinth
#

sorry

rare rover
#

all im storing

young knoll
#

I mean if it’s in the players pdc it’ll already be periodically saved

#

Assuming you update directly to the pdc

#

But putting it in a map is probably better

rare rover
#

that's what im doing rn and its slow, i'm wanting to use a map instead

#

alr

slender elbow
#

something something getting the itemmeta is expensive

plucky rock
#
            if (attacker instanceof Spider) {
                if (AttackerName.contains("§5King of Spider's Servant")) {
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            Vector up = player.getVelocity().setY(0).setX(0).setZ(0);
                            player.setVelocity(up);
                            player.sendMessage("Debug3333");
                        }
                    }.runTaskLater(this, 20L * 1L);

                }

            }```
any1 know why the bukkitrunnable doesn't run
#

ill swap to PDHs later

drowsy helm
#

pretty sure Bukkit.getScheduler() is the more accepted way of doing it

#

AttackerName.contains("§5King of Spider's Servant") wont match

plucky rock
#

oh

drowsy helm
#

use PDC

plucky rock
#

the name thing worked tho?

#

also yea ill swap to PDCs

drowsy helm
#

dont see why that owuldnt run otherwise

plucky rock
#

huh

#

ok

drowsy helm
#

is it inside the main class?

plucky rock
#

ill try swapping to PDC

#

no

#

ill send the full

#

code

drowsy helm
#

'this' should be plugin instance

young knoll
#

Then you can’t use this for the runnable

#

That shouldn’t even compile

plucky rock
#

ohh

#

ok

#

huh

#

i thought this was the plugin not the class

#

i mea this not this

young knoll
#

this is always the current instance of whatever class you use it in

plucky rock
#

ah

#

ok

minor junco
#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

plucky rock
#

cool

#

ty

#

didnt know thats a thin

#

thing

plucky rock
#

however

#

            if (attacker instanceof Spider) {
                if (AttackerName.contains("§5King of Spider's Servant")) {
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            Vector up = player.getVelocity().setY(0).setX(0).setZ(0);
                            player.setVelocity(up);
                            player.sendMessage("Debug3333");
                        }
                    }.runTaskLater( TEST.getPlugin(), 20L * 1L);

                }

            }```
this doesnt cancel momentum
#

soo

#

no clue why

young knoll
#

Did you try running it after 1 tick

#

Rather than 20

plucky rock
#

yea

#

i just tested that

#

ot worked tysm

#

ur awsome

shut field
#

how do you deserialize a HashSet<>?

#

more specifically

 Set<String> set = memorySection.getKeys(false);
        for(String path : set){
            String rawPath = path;
            path = memorySection.getCurrentPath() + "." + path;
            if(rawPath.equals("chunks")){
                HashSet<Long> chunks;
                chunks = (HashSet<Long>) Sylv.data.getConfig().get(path);
                result.setChunks(chunks);
            }
}
#

what do I use instead of .get() which returns a MemorySection, because there is stuff like, "getList()" but no "getSet()"

#

do i have to turn the HashSet to a list before serializing

echo basalt
#

woeisme a set and a list are really similar

#

You could just load it as a stringlist and convert?

young knoll
#

Yeah you’ll have to convert it to a list

#

Spigot can’t serialize sets

shut field
#

I see

#

not very difficult ig

#

Arrays#asList(HashSet#toArray)

young knoll
#

Can’t you do new ArrayList(set)

echo basalt
#

you can

#

p sure

worldly ingot
#

Yeah it takes a Collection

slender elbow
#

no u

rare ridge
#

Hello, I need to implement a cooldown on my custom item, but for some reason the cooldown applies to the vanilla item, how can I fix this? (cooldown is implemented in the form of logic like end pearls)

young knoll
#

Cooldown is for the entire material

#

Not much you can do

rare ridge
#

Is it possible to distribute it only to your subject?

young knoll
#

What

worldly ingot
#

If you mean to only apply it to a specific item, no, you cannot do that

#

That's not how Minecraft's cooldown system works. It applies to the whole item type, not a specific item stack

young knoll
#

Sadly

#

Mojang plz?

echo basalt
#

I feel like it'd be a pain in the ass to track that

worldly ingot
#

otherwise you'd just be able to switch to a new ender pearl and use it instead

worldly ingot
echo basalt
#

or like

#

timestamp the meta hash?

worldly ingot
#

idek what that means

echo basalt
#

like

#

put the meta on cooldown not the item type entirely

worldly ingot
#

Oh, hash the meta and assign a value to it lol

echo basalt
#

yeah

worldly ingot
#

but then if its meta changes

echo basalt
#

no cooldown

#

ezpz

worldly ingot
#

suddenly, no more cooldown

#

😎

young knoll
#

What if it just has empty meta

echo basalt
#

0

#

you aren't gonna be expecting ppl to /rename their enderpearls in 0.1ms

#

help im sleepy

young knoll
#

You never know

remote swallow
#

keybind

#

some servers give irename from essx

echo basalt
#

bro fuckin make it configurable n fuck off

#

ezpz

young knoll
#

You could probably jank it with some resource pack magic

rough ibex
#

or you could track the cooldown yourself

#

and just cancel the applicable event

echo basalt
#

just like

#

actionbar an overlay

#

bunch of offsets n stuff

#

it'd look a bit janky

#

but if you fine tune it all

rare ridge
#

But if you create an item with the NBT tag and put a cooldown on it, is this even feasible?

river oracle
#

I'd suggest maybe doing something with the item/meta to make it look different when its cooling down. If you're already using a texture pack applying different model data is the obvious solution here

quaint mantle
#

a question nms is for a server version right?

#

if i want to make plugin work on all versions i would have to do extra coding right?

remote swallow
#

if it requires nms yeah

#

if you only need api you just use the lowest api you wanna support

quaint mantle
#

wym?

remote swallow
#

do you use nms currently

mighty gazelle
#

How can I send "you are swear1 "?
Code:

public class AntiSwear implements Listener {
    public static String maskSwearWord(String word) {
        if (word.length() <= 2) {
            return word;
        }
        return word.substring(0, 2) + "*".repeat(word.length() - 2);
    }
    private static final String[] knownMessage = {
            "swear1",
            "swear2"
    };
    @EventHandler
    public void onPlayerSendMessage(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        String message = event.getMessage();
        String blocketmessage = "Swear Word";

        for (String knownMessage : knownMessage) {
            if (message.contains(knownMessage)) {
                player.sendMessage(blocketmessage);
                String maskedMessage = message.replace(knownMessage, maskSwearWord(knownMessage));
                event.setMessage(maskedMessage);
                for (Player allplayer : Bukkit.getOnlinePlayers()) {
                    if (allplayer.hasPermission("group.admin")) {
                        allplayer.sendMessage("Der Spieler " + player.getName() + " hat versucht " + message + " zu sagen");
                    }
                }
            }
        }
    }
}
sullen marlin
#

You want to use a loop with an int counter not enhanced for loop and then print counter value

sterile flicker
#

Is there no getClientViewDistance in 1.12.2?

sullen marlin
#

I doubt the client had that in 1.12.2

sterile flicker
#

        int chunkDistanceX = Math.abs(playerChunk.getX() - npcChunk.getX());
        int chunkDistanceZ = Math.abs(playerChunk.getZ() - npcChunk.getZ());

        return chunkDistanceX <= viewDistance && chunkDistanceZ <= viewDistance;
    }``` I need to process the player's approach to the NPC in playermovevent, or more precisely the moment when the player sees the npc in order to send packets
#

I am currently sending packets for fake nms npc only when logging into the game

sullen marlin
#

Just pick a distance or use view distance

#

There's no reason it has to match

sterile flicker
#

view-distance=10 that is, can I use the default value from server.properties?

rotund ravine
#

Sure

sterile flicker
#

it is too big, I have moved to a very large value and it is still being executed

#

that is, I will move 100-200 blocks away and only then will it stop

terse ore
#

would it be possible to replace a player with a zombie? So instead of displaying a player to other players it displays a zombie

shadow night
#

I thought of that before, I'd like to know the answer too

rotund ravine
#

I mean there was that diguise plugin that did it

#

Sadly you can’t do it for the player hidden

terse ore
#

player hidden?

#

you mean the one who disguises

sterile flicker
#

what is the difference between CLIENTBOUND and SERVERBOUND nms fake entity

fierce whale
#

Is there a way to get blockface of bed?
this code doesn't works 😦

            Bed bed = (Bed) block.getBlockData();
            System.out.println(bed.getPart());
            Location loc = block.getLocation();
            bed.getFacing();
lost matrix
fierce whale
#

I wanna get another location of bed block

lost matrix
#

Then get the block in the facing direction

fierce whale
#

how can I get the facing direction of block?

lost matrix
#
Bed bed = (Bed) block.getBlockData();
BlockFace facing = bed.getFacing();
fierce whale
#

I did

#

but (Bed) casting doesn't work

lost matrix
#

Then show your code

lost matrix
fierce whale
#

is org.bukkit.block.data.type.Bed wrong?

lost matrix
#

Thats the right import

#

Explain "doesn't work"

minor junco
#

try as any

#

¯_(ツ)_/¯

fierce whale
#

It throws ClassCastException

minor junco
#

Get the type of the block

lost matrix
#

Did you check if the Block is actually a Bed first?

minor junco
#

And print it out, doesn't seem like the block is actually a Bed

fierce whale
#

yeah I checked 😓

minor junco
#

Well, check again 😆

lost matrix
#

Ok before anyone gives any more advice:
Show your whole code and any exception you encountered.

This could have been solved minutes ago

fierce whale
#

?paste

undone axleBOT
minor junco
#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

fierce whale
minor junco
#

print out the block data

#

Or the class name

lost matrix
#

?!

fierce whale
#

OH

shadow night
#

300 iq move

fierce whale
#

sry 😅

#

Thanks so much

minor junco
#

WTF

#

Happens 😆

fierce whale
#

my eye is gone because of lot of code :🥲

minor junco
#

That's why you should separate things out a bit imo

#

But that's for a different topic

fierce whale
#

anyways, thanks 🙂

lost matrix
#

Btw... what am i seeing here?

fierce whale
lost matrix
#

that looks like

pdc.clear();

But with a lot of unnecessary code

fierce whale
#

OMG

sterile flicker
fierce whale
lost matrix
# sterile flicker please tell me someone)

ClientBound means its heading is bound to the client (The packet will be sent to the client from the server)
ServerBound means the heading is bound to the server (The packet will be sent to the server from the client)

Those have nothing to do with nms fake entities. Those are only prefixes for packets so you know where they will be sent to.

lost matrix
fierce whale
#

cause it's final field

sterile flicker
lost matrix
sterile flicker
#

now it looks much better, but there are questionable points that make something not work as expected

sterile flicker
lost matrix
#

Sure, send it

sterile flicker
#

The NPC entity spawns well only when the player enters the sevrer.

#
[11:50:51 INFO]: visible```
#

after deleting the entity and when I go back to it, it only shows up in the tab but does not spawn

lost matrix
#

Those two lines should be removed.
You dont want a fake entity to be added to the world.

sterile flicker
#

I'm also worried that the entity will disappear for other players and not just for 1 player who has moved away from the entity.

lost matrix
#

Btw in 1.12 you can just listen to the ChunkLoadEvent and send All NPCs in that chunk to all players.
Then in the ChunkUnloadEvent you simply hide them from all player.
The client decides himself when to display them.

#

No need to listen for all that PlayerMove stuff

sterile flicker
#

thanks

lost matrix
#

Hm. Honestly if you want a proper fake entity, then you dont need to extend EntityPlayer.
Just create a new class with all the needed properties (GameProfile etc) and then send packets to players.
Here is how that looks for one of my implementations:

#

The sendTo simply looks like this

sterile flicker
#

how do I hide a fake player?

#

Player#hidePlayer?

#

ChunkUnloadEvent

lost matrix
#

Send the despawn and remove info packet

sterile flicker
#

1.12.2)

lost matrix
#

Yes in 1.12 it should be the same. Despawn packet or its called entity destroy i think, and after that you send the info hide packet
or its called info update with the enum action REMOVE

sterile flicker
#

PacketPlayOutEntityDestroy

#

?

lost matrix
#

This one hides the entity, right

#

Cant remember 1.12 protocol by heart. That came out before i started developing

sterile flicker
#

should I send packets to all players or should I send packets to all players in the chunk?

#

ChunkLoadEvent

lost matrix
#

To all players

sterile flicker
lost matrix
#

Good. This means almost all of your code was flawed.

#

Now make sure to send those packets and debug it.

sterile flicker
#

Maybe it will work now

lost matrix
#

Well... sending an empty packet confuses the client ofc.

sterile flicker
lost matrix
sterile flicker
#

so connection.sendPacket(new PacketPlayOutNamedEntitySpawn(entity.getBukkitEntity().getHandle()));

lost matrix
#

entity.getBukkitEntity().getHandle() is the same as just entity

#

*If entity is your EntityPlayer

sterile flicker
# lost matrix *If entity is your EntityPlayer

unfortunately, I see the entity only in the tab ```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) throws IOException {
Player p = event.getPlayer();

    if ((int) p.getLocation().getX() >> 4 == Npc.nurseChunk.getX() && (int) p.getLocation().getZ() >> 4 == Npc.nurseChunk.getZ()) {
        CraftPlayer ep = hasEntityPlayer(p.getLocation().getChunk());
        if (ep == null) {
            EntityNurse entity = EntityNurse.create("Nurse", Npc.plugin.getServer().getWorld(Npc.plugin.getConfig().get("world").toString()), Npc.nurseLocation);
            PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(entity.getBukkitEntity().getHandle()));
            PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity);
            connection.sendPacket(info);
        }
        else {
            PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(ep.getHandle()));
            PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ep.getHandle());
            connection.sendPacket(info);
        }
    }

}```
#
public static EntityNurse create(String name, World world, Location location) throws IOException {

        MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
        WorldServer nmsWorld = ((CraftWorld) world).getHandle();
        UUID uniqueId = UUID.randomUUID();

        GameProfile playerProfile = new GameProfile(uniqueId, name);
        EntityNurse nurse = new EntityNurse(nmsServer, nmsWorld, playerProfile, new PlayerInteractManager(nmsWorld));
        nurse.getProfile().getProperties().clear();
        nurse.getProfile().getProperties().removeAll("textures");
       
        nurse.getBukkitEntity().setRemoveWhenFarAway(false);
        nurse.setCustomName("nurse");
        nurse.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());
        nurse.playerConnection = new PlayerConnection(nmsServer, new NetworkManager(EnumProtocolDirection.SERVERBOUND), nurse);

        return nurse;
    }```
lost matrix
#

Bc otherwise you are trying to spawn a player with completely unknown properties.

sterile flicker
# lost matrix Bc otherwise you are trying to spawn a player with completely unknown properties...
private static CraftPlayer hasEntityPlayer(Chunk chunk) throws IOException {
        for (Entity entity : chunk.getEntities()) {
            if (entity.getCustomName() != null && entity.getCustomName().equals("nurse")) {
                return (CraftPlayer) entity;
            }
        }
        return null;
    }

    @EventHandler
    public void onChunkLoad(ChunkLoadEvent event) throws IOException {
        Chunk chunk = event.getChunk();
        CraftPlayer ep = hasEntityPlayer(chunk);
        if (ep != null) {
            System.out.println("visible");
            for (Player p : Bukkit.getOnlinePlayers()) {
                PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ep.getHandle());
                connection.sendPacket(info);
                connection.sendPacket(new PacketPlayOutNamedEntitySpawn(ep.getHandle()));
            }
        }
    }

    @EventHandler
    public void onChunkUnload(ChunkUnloadEvent event) throws IOException {
        CraftPlayer ep = hasEntityPlayer(event.getChunk());
        if (ep != null) {
            for (Player p : Bukkit.getOnlinePlayers()) {
                PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                connection.sendPacket(new PacketPlayOutEntityDestroy());
                PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ep.getHandle());
                connection.sendPacket(info);

                System.out.println("invisible");
            }
        }
    }``` the next problem is that most likely hasEntityPlayer does not work, because even if I teleport 1000 blocks away from the entity and return, I do not see invisible and visible messages in the console
lost matrix
sterile flicker
#

i can add entity id argument to the packetconnection.sendPacket(new PacketPlayOutEntityDestroy(ep.getEntityId()));

south mason
#

Hi, I am writing a plugin for minecraft and I have a question. How to make a file with localization correctly. So that plug-in users can change any plug-in text into their own language in the config. I would also like the localization file to be uploaded only 1 time.

sterile flicker
lost matrix
lost matrix
sterile flicker
sterile flicker
#

I want to see it

#

when I added the entity to the world, minecraft crashed)

proud badge
#

Do all bukkit async tasks run on the same seperate thread, or does each async task create its own thread?

lost matrix
lost matrix
lost matrix
#

This makes them not virtual anymore

proud badge
#

So if my server has only 3 threads (one for the main) does that mean I can only have two async tasks running at the same time? Or how many can I have?

umbral ridge
#

🤓

#

nerd question

sterile flicker
umbral ridge
sterile flicker
#

playerinteractentityevent

#

not working

lost matrix
echo haven
#

hey gang just wondering if there's a way to create an itemstack of a item frames that have their visibility toggled off?

tender shard
#

you can add a custom PDC tag to the itemstack and then in HangingPlaceEvent, check the itemstack and if it has that tag too, then make the placed itemframe invisible

icy beacon
#

Alex what time is it

tender shard
#

11:44

icy beacon
#

Thx

echo haven
ivory sleet
#

but u can have a lot more than 3 threads

drowsy helm
#

3 threads is not realistic

ivory sleet
#

when a thread is blocked (lets say it awaits some io stuff) its then suspended

tender shard
#

he's probably talking about some mc hosting company that sells "4gb 2 vcores (threads)" or sth similar and the answer is, he can still schedule 100+ async tasks

drowsy helm
#

yeah the whole physical/virtual/OS thread thing can be confusing

ivory sleet
#

The amount of available processors is usually a good number to base ur thread pools and other mechanisms on (well ofc doesnt rly apply to virtual threads)

inner mulch
#

When i create more threads than my PC has and let them do tasks at the same time will it crash?

tender shard
#

ofc not - open your task manager

rotund ravine
#

Depends on the tasks ur making the jvm do memory limit is a thing

tender shard
#

I only have 8 cores and not 1500

rotund ravine
inner mulch
#

Threads are infinite?

rotund ravine
#

No

#

Obviously limits but yeh

inner mulch
#

I thought there where always 8 cores and then 16 Thresds so always double

drowsy helm
inner mulch
#

Okay

drowsy helm
#

there is a limit to how many threads you can address in java but it's pretty high

#

high enough to the point where if you are hitting that limit you are doing something very wrong

ivory sleet
# inner mulch Threads are infinite?

You have os threads then jvm threads getting mapped to those, and then virtual threads and coroutines getting mapped to the jvm ones more or less

#

a mapping can usually even be surjective

inner mulch
#

What if i have a thread for each method will i have the fastest program ever?

ivory sleet
#

depends

drowsy helm
#

However, you can't just creat a 100 threads and say I have 100x performance. This is where the cores come into picture.

ivory sleet
#

Usually you either wanna minimize waiting time (that is doing something async like downloading a file), or u wanna distribute a computation that takes long time

#

when distributing a computation, its rarely ever worth to allocate a billion threads or so, as its still only gonna use what cpu hardware resources u have available, so limiting it to the amount of available processors is usually reasonable

inner mulch
#

Ok

upper hazel
#

Is it possible to make the plugin API a separate plugin like in Citizes and his API?

#

it would be more accurate to make it public for maven, but the implementation itself is not

sterile flicker
# lost matrix You should def use an NPC library like citizens then and write a few more plugin...
public class NPCManager {

    private static Map<UUID, CraftPlayer> npcMap = new HashMap<>();

    public static CraftPlayer hasEntityPlayer(Chunk chunk) throws IOException {
        for (CraftPlayer p : npcMap.values()) {
            System.out.println(((int) p.getLocation().getX() >> 4) + " " + chunk.getX() + " " + ((int) p.getLocation().getZ() >> 4) + " " + chunk.getZ());
            if ((int) p.getLocation().getX() >> 4 == chunk.getX() && (int) p.getLocation().getZ() >> 4 == chunk.getZ()) {
                return p;
            }
        }
        return null;
    }
    public static void addNpc(CraftPlayer npc) {
        npcMap.put(npc.getUniqueId(), npc);
    }

    public static void removeNpc(UUID npcId) {
        npcMap.remove(npcId);
    }

    public static CraftPlayer getNpc(UUID npcId) {
        return npcMap.get(npcId);
    }

    public static List<CraftPlayer> getAllNpcs() {
        return (List<CraftPlayer>) npcMap.values();
    }

} -12 -3 -2 -12
[14:30:39 INFO]: -12 -22 -2 -12
[14:30:39 INFO]: -12 -2 -2 -12
[14:30:47 INFO]: -12 -23 -2 -7
[14:30:47 INFO]: -12 -23 -2 -6
[14:30:47 INFO]: -12 -23 -2 -5
[14:30:47 INFO]: -12 -23 -2 -4
[14:31:07 INFO]: -12 -23 -2 -7
[14:31:07 INFO]: -12 -23 -2 -5
[14:31:07 INFO]: -12 -23 -2 -6
[14:31:07 INFO]: -12 -23 -2 -4
[14:31:58 INFO]: -12 -23 -2 -7
[14:31:58 INFO]: -12 -23 -2 -6
[14:31:58 INFO]: -12 -23 -2 -5
[14:31:58 INFO]: -12 -23 -2 -4
[14:32:07 INFO]: -12 -23 -2 -7
[14:32:07 INFO]: -12 -23 -2 -5
[14:32:07 INFO]: -12 -23 -2 -6
[14:32:07 INFO]: -12 -23 -2 -4``` something is wrong with the chunk coordinates(hasEntityPlayer)
#

how do I do this in a better way?

inner mulch
#

what is wrong with the coordinates?

lost matrix
sterile flicker
# lost matrix No. The method is useless to begin with. The server doesnt know that the entity ...
@EventHandler
    public void onChunkLoad(ChunkLoadEvent event) throws IOException {
        Chunk chunk = event.getChunk();
        CraftPlayer ep = NPCManager.hasEntityPlayer(chunk);
        if (ep != null) {
            System.out.println("visible");
            for (Player p : Bukkit.getOnlinePlayers()) {
                PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ep.getHandle());
                connection.sendPacket(info);
                connection.sendPacket(new PacketPlayOutNamedEntitySpawn(ep.getHandle()));
            }
        }
    }

    @EventHandler
    public void onChunkUnload(ChunkUnloadEvent event) throws IOException {
        CraftPlayer ep = NPCManager.hasEntityPlayer(event.getChunk());
        if (ep != null) {
            for (Player p : Bukkit.getOnlinePlayers()) {
                PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                connection.sendPacket(new PacketPlayOutEntityDestroy(ep.getEntityId()));
                PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ep.getHandle());
                connection.sendPacket(info);

                System.out.println("invisible");
            }
        }
    }```then how do I use these two methods?
#

what should I do next, I created the npcmanager class

#

but it doesn't make sense yet.

eternal oxide
#

Packet based NPC's don;t exist on the server

#

Only your plugin knows about them, and the client you told

sterile flicker
#

then how to implement what 7smile7 was talking about

#
Then in the ChunkUnloadEvent you simply hide them from all player.
The client decides himself when to display them.```
eternal oxide
#

Correct, so YOU track where your fake NPC's are

sterile flicker
inner mulch
#

just save it bro

sterile flicker
#

?

eternal oxide
#

when you created it you shoudl have given it a position

inner mulch
#

?

eternal oxide
#

um, why are you using CraftPlayer for your NPC's?

#

not ServerPlayer? NMS

sterile flicker
#

1.12.2)

eternal oxide
#

um

#

I didn;t think you could create a CraftPlayer if it wasn;t in the world

tender shard
#

but it shouldn't be a separate plugin

upper hazel
#

how will the API get access to the implementation if to create a repository the implementation must be open source

tender shard
#

why would the API need access to the implementation?

upper hazel
#

wait, I'm confused

#

no more questions

#

i see

tender shard
sterile flicker
# lost matrix No. The method is useless to begin with. The server doesnt know that the entity ...
@EventHandler
    public void onChunkLoad(ChunkLoadEvent event) throws IOException {
        Chunk chunk = event.getChunk();

        if (chunk == null || !chunk.isLoaded()) {
            return;
        }
        System.out.println("NurseChunk X: " + Npc.nurseChunk.getX() + ", Z: " + Npc.nurseChunk.getZ());
        System.out.println("Loaded Chunk X: " + chunk.getX() + ", Z: " + chunk.getZ());

        if (Npc.nurseChunk.getX() == chunk.getX() && Npc.nurseChunk.getZ() == chunk.getZ()) {
            for (CraftPlayer npc : NPCManager.npcMap.values()) {
                System.out.println("visible");
                for (Player p : Bukkit.getOnlinePlayers()) {
                    PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                    PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc.getHandle());
                    connection.sendPacket(info);
                    connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc.getHandle()));
                }
            }
        }
    }```  I haven't been able to figure out these chunks for a long time.  is there an event for loading a chunk on the client side or is that not the case? it's just that nursechunk and loadedchunk show me completely different chunks coords, although I'm right in the npc chunk
#

I'm not using the position of an entity that the server doesn't know about, but a variable with coordinates, but it still doesn't work

lost matrix
sterile flicker
#

I do not know what to add to the manager

inner mulch
#

What do you want it to do?

chrome beacon
#

you really should stop adding static to everything

sterile flicker
shadow night
#

static is almost always a problem.

lost matrix
shadow night
inner mulch
chrome beacon
#

They're using static on a lot more than just that

#

pretty much all of their code is static

inner mulch
#

Really?

hazy parrot
#

i wouldn't make my manager classes static

chrome beacon
#

^ this too

inner mulch
#

If there is only one?

#

Why wouldnt you make it stqtic

ivory sleet
cursive loom
#

Hello i have a problem with VaultAPI, I try to do an economy plugin with the vault API, I have add the depedencies in my plugin ans I have install vault in the server but when I start the server the plugin was disabled for "No vault plugin foud", do you know how I can fix that ?

ivory sleet
# inner mulch If there is only one?

Your vision is quite narrow if this is the only reason for u to make something static, you have to consider eventual consumers of your class, maintainability in the long run, does it incorporate statefulness - in such case what about thread safety, is your manager going to be testable, etc

zinc moat
#

Where can i get ideas to code? i am not creative so i cant really come up with ideas 😭

zinc moat
cursive loom
undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

sterile flicker
# lost matrix Start by making all your fields private and and remove the static keyword from e...

something like this?```java
manager = new NPCManager();
try {

               manager.addNpc(EntityNurse.create("nurse", Npc.plugin.getServer().getWorld(Npc.plugin.getConfig().get("world").toString()), nurseLocation).getBukkitEntity(), nurseChunk.getX(), nurseChunk.getZ());
           } catch (IOException e) {
               e.printStackTrace();
           }
           EventListener eventListener = new EventListener(manager);
           getServer().getPluginManager().registerEvents(eventListener, this);
           public class NPCManager {

private Map<ChunkPosition, List<CraftPlayer>> npcMap = new HashMap<>();

public void addNpc(CraftPlayer npc, int chunkX, int chunkZ) {
    npcMap.computeIfAbsent(new ChunkPosition(chunkX, chunkZ), k -> new ArrayList<>()).add(npc);
}


public List<CraftPlayer> getNpcsInChunk(int chunkX, int chunkZ) {
    return npcMap.getOrDefault(new ChunkPosition(chunkX, chunkZ), Collections.emptyList());
}

private static class ChunkPosition {
    private final int x;
    private final int z;

    public ChunkPosition(int x, int z) {
        this.x = x;
        this.z = z;
    }
}

@EventHandler
public void onChunkLoad(ChunkLoadEvent event) throws IOException {
Chunk chunk = event.getChunk();

    if (chunk == null || !chunk.isLoaded()) {
        return;
    }

    for (CraftPlayer npc : manager.getNpcsInChunk(chunk.getX(), chunk.getZ())) {
            System.out.println("visible");

}``` still not working

inner mulch
zinc moat
cursive loom
# tender shard ?nocode

Inside my main class


public static Economy econ = null;

on enable{
if (!setupEconomy() ) {
            getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
}


private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) {
            return false;
        }
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) {
            return false;
        }
        econ = rsp.getProvider();
        return econ != null;
    }

    public static Economy getEconomy() {
        return econ;
    }

error


[13:23:57] [Server thread/INFO]: [KingdomCore] Enabling KingdomCore v1.0.0
[13:23:57] [Server thread/ERROR]: [KingdomCore] [KingdomCore] - Disabled due to no Vault dependency found!
[13:23:57] [Server thread/INFO]: [KingdomCore] Disabling KingdomCore v1.0.0

zinc moat
#

but like what does the chatmanager do?

tender shard
#

well it looks like you don't have any economy plugin installed

inner mulch
eternal oxide
#

You likely don;t have an Economy plugin

cursive loom
tender shard
#

then why are you disabling your own plugin?

#

you are supposed to register the economy provider yourself

icy beacon
cursive loom
cursive loom
tender shard
#

you have to implement the Economy class yourself and then register it

shadow night
sterile flicker
cursive loom
#

Sry for the question I think I just tired xD Have a good day lmao

icy beacon
shadow night
#

then depends on what kinda economy plugin yk

icy beacon
#

i presume an econ provider

#

when are we getting an ACTUAL economy plugin?

shadow night
#

economy plugin can extend in twenty million branches

icy beacon
#

like, inflation, corruption etc

shadow night
icy beacon
#

not just i give money you get money monke

#

here is top bal

#

i want my money to depreciate

shadow night
#

that plugin would need to also be a shop plugin and stuff yk

icy beacon
#

let it be so then

#

i am talking an actual economy plugin

shadow night
#

economy 2000

icy beacon
#

2024*

shadow night
#

lol

#

let's call our plugin Rubleconomy

#

what better way to represent a plugin with inflation and corruption than the ruble

icy beacon
#

trueee

#

actually let it be just an "ActualEconomy" and then there are modes like "ruble", "usd", "yen", etc

#

that define the rate of inflation, corruption and pricing of goods

zinc moat
icy beacon
#

and i guess like

#

pull actual data from some rest

#

for accurate currency conversion and pricing

mighty gazelle
#

How can I make it so that you can write everything in but only the word is filtered?
e.g. "you are swear1 "
Code:

public class AntiSwear implements Listener {
    public static String maskSwearWord(String word) {
        if (word.length() <= 2) {
            return word;
        }
        return word.substring(0, 2) + "*".repeat(word.length() - 2);
    }
    private static final String[] knownMessage = {
            "swear1",
            "swear2"
    };
    @EventHandler
    public void onPlayerSendMessage(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        String message = event.getMessage();
        String blocketmessage = "Swear Word";

        for (String knownMessage : knownMessage) {
            if (message.contains(knownMessage)) {
                player.sendMessage(blocketmessage);
                String maskedMessage = message.replace(knownMessage, maskSwearWord(knownMessage));
                event.setMessage(maskedMessage);
                for (Player allplayer : Bukkit.getOnlinePlayers()) {
                    if (allplayer.hasPermission("group.admin")) {
                        allplayer.sendMessage("Der Spieler " + player.getName() + " hat versucht " + message + " zu sagen");
                    }
                }
            }
        }
    }
}
echo basalt
#

uh

#

I'd prob just use regex for this tbh

#

You could also go with an iterative solution

echo basalt
#

try and see

#

?tryandsee

undone axleBOT
acoustic pendant
#

Can someone tell me the name of some app to see .jar codes?

echo basalt
#

jd-gui, recaf

acoustic pendant
#

Had one but don't remember the name

acoustic pendant
echo basalt
#

Recaf lets you edit code and has a dark mode but jd-gui feels faster

acoustic pendant
#

Yea, i used jd-gui

sterile flicker
ocean hollow
#

Do I need to create the NamespacedKey once and save it somewhere and then use it? Or can I create a new one several times?

chrome beacon
#

both will work

#

but creating it once is more resource friendly

kindred sentinel
#

Soo, how to get If entity is in the block of nether portal without entity teleport event

#

?

river oracle
kindred sentinel
#

IT WORKS

#

Thanks

devout pivot
#

Im trying to make it so composter gets filled instantly after the composter level gets above 1. This code works but updates the composter to filled only if I left click or right click with a non compostable item. I think when I right click with a compostable item in hand, instead of my code running and instantly setting the level to filled, minecraft overwrites it with it's code of progressing the level of composter normally. any way to fix it?

tacit arrow
#

Hey! I am just wondering what the best way to store and load player inventorys would be?

e.g:
user leaves - save users inventory in db

user joins - load users inventory from db with all the correct information such as name, lore, nbt data etc

#

I dont want to be spoonfed i want to be given a path u can say

kindred sentinel
#

Does anyone know how to fix this?

java.lang.IllegalStateException: Cannot query another world's (world_nether) chunk (-3, -1) in a ServerLevelTickThread
tender shard
#

show the full stacktrace

kindred sentinel
young knoll
tender shard
#

what the heck is sparklypaper :X

young knoll
#

?whereami

kindred sentinel
young knoll
#

What am I looking at

#

@eternal night can I get a downstream opinion on this

kindred sentinel
young knoll
#

So does paper

tacit arrow
young knoll
#

That doesn't make this paper support

kindred sentinel
#

it makes sense

#

Just asked maybe someone could know how to fix this

young knoll
#

Seems like the do some wacky one thread per world thing

#

So that's probably your issue

kindred sentinel
#

Yeah, it separates every world with Parallel World Ticking, so, nether portal can't teleport mobs, and I was trying to fix it, but it didn't work

eternal night
#

Some of their patches made it into paper

eternal night
#

some other are too experimental to pull or very specific to the usage of the software

#

the maintainer is a chill guy tho

young knoll
#

Oh did we absolutely destroy a vanilla mechanic? oopsies

eternal night
#

happens

kindred sentinel
#

:/

young knoll
#

Smh I really should just sell my revolutionary paper fork that removes all ticking

kindred sentinel
#

For optimization it's really good

young knoll
#

$349.99

eternal night
#

At least its not one of the "oh I just collect patches from every fork under the moon" fork

young knoll
#

More patches = more good

eternal night
#

there was a folia fork somewhere that added synchronized to everything to "improve plugin compat"

#

We need more of such revolutionary thinking

lost matrix
upper hazel
#

I don’t understand how to separate the api and its implementation from each other so that another plugin can connect and use the api and its implementation through maven, but so that the implementation itself in the form of source code or a Jar file is not available

young knoll
#

Basically like bukkit does

#

Bukkit is the API, cb is the impl

upper hazel
#

i mean how create repository for this

lost matrix
upper hazel
lost matrix
upper hazel
#

Sorry, I misspoke, I mean I won’t get it

lost matrix
sterile flicker
#

I handed over my code. can you take one last look at it, now it should meet requirements?

lost matrix
#

?paste

undone axleBOT
lost matrix
#

🙂

upper hazel
#

and how to access 1 API implementation created for its interface?

acoustic pendant
#

Hey, was wondering if there was a fastest way to do this checks?

sterile flicker
young knoll
#

iirc there is Block#getDrops

sterile flicker
upper hazel
#

I just don’t understand how the api will understand that I am accessing 1 of its implementations through the api

acoustic pendant
#

oh, ok thanks

upper hazel
#

if I connect only api

sterile flicker
#

I had to use the block position because the regular one didn't work in chunkloadevent(*16)

lost matrix
#

You need a gateway where the api user can request the implementation at runtime

tardy delta
#

seeing the word nurse over and over is starting to scare me

lost matrix
#

isNPCVisible remove this method

sterile flicker
#

but it doesn't work without multiply by 16 in chunkloadevent

lost matrix
#

What exactly doesnt work?

sterile flicker
#

it just throws different coordinates of chunks when I am in the npc chunk, but not the coordinates of the npc chunk themselves.

#

playerjoinevent is working but chunkloadevent is not

#

without blockposition

lost matrix
#

Remove this method

    public static boolean isNPCVisible(int chunkX, int chunkZ) {

        int chunkDistanceX = Math.abs(chunkX - Npc.nurseChunk.getX()*16);
        int chunkDistanceZ = Math.abs(chunkZ - Npc.nurseChunk.getZ()*16);

        return chunkDistanceX <= 1.0F && chunkDistanceZ <= 1.0F;
    }

And then use the chunk X and Z.
To get the chunk X and Z from your entity you have to divide its location X and Z by 16

#

Here as well

sterile flicker
#

and there manager.addNpc(EntityNurse.create("Медсестра", Npc.plugin.getServer().getWorld(Npc.plugin.getConfig().get("world").toString()), nurseLocation).getBukkitEntity(), nurseChunk.getX() * 16, nurseChunk.getZ() * 16);

#

I need to remove the multiplication by 16 everywhere?

lost matrix
#

Yes. Multiplying by 16 everywhere is kind of pointless. The only thing you need to do is divide the location by 16

sterile flicker
#

I just need to compare the distance between the npc and the unloaded chunk

sterile flicker
# lost matrix Why?

if the distance, for example, is more than 10, i need to send remove entity packets

#

ChunkUnloadEvent

#

Oh I'm confused

lost matrix
#

ChunkLoadEvent:

  1. Get all NPCs in this chunk from your manager
  2. Send all players the spawn packets for the NPCs

ChunkUnloadEvent:

  1. Get all NPCs in this chunk from your manager
  2. Send all players the despawn packets for the NPCs
#

You never need to check any distance to anything

sterile flicker
# lost matrix You never need to check any distance to anything
@EventHandler
    public void onChunkLoad(ChunkLoadEvent event) {
        Chunk chunk = event.getChunk();

        for (CraftPlayer npc : manager.getNpcsInChunk(chunk.getX(), chunk.getZ())) {
                System.out.println("visible");
                for (Player p : Bukkit.getOnlinePlayers()) {
                    PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                    PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc.getHandle());
                    connection.sendPacket(info);
                    connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc.getHandle()));

                    npcSpawned.put(p, true);
                }
        }
    }
    @EventHandler
    public void onChunkUnload(ChunkUnloadEvent event) throws IOException {
        for (CraftPlayer npc : manager.getNpcsInChunk(Npc.nurseChunk.getX() , Npc.nurseChunk.getZ() )) {
                if (npc != null) {
                    for (Player p : Bukkit.getOnlinePlayers()) {
                        if (npcSpawned.containsKey(p) && npcSpawned.get(p)) {
                            PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                            connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getEntityId()));
                            PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc.getHandle());
                            connection.sendPacket(info);

                            npcSpawned.put(p, false);
                            System.out.println("invisible");
                        }
                    }
                }
        }
    }```can you tell me where I should apply the division by 16
lost matrix
# sterile flicker ```java @EventHandler public void onChunkLoad(ChunkLoadEvent event) { ...

First you are going to remove your "npcSpawned" collection because you are not using it in any meaningful way.
Next you should clean up those methods there is too much nesting going on.

Inside your NPC class add the following methods:

public void showTo(Player player) {
}
public void hideFrom(Player player) {
}

After that you simply apply those methods for chunk loads and unloads.

@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
  Chunk chunk = event.getChunk();
  for (CraftPlayer npc : manager.getNpcsInChunk(chunk.getX(), chunk.getZ())) {
    for (Player player : Bukkit.getOnlinePlayers()) {
      npc.showTo(player);
    }
  }
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) throws IOException {
  Chunk chunk = event.getChunk();
  for (CraftPlayer npc : manager.getNpcsInChunk(chunk.getX(), chunk.getZ() )) {
    for (Player player : Bukkit.getOnlinePlayers()) {
      npc.hideFrom(player);
    }
  }
}

The division comes into play for your NPC manager:

public void addNpc(CraftPlayer npc) {
  int chunkX = npc.getX() / 16; // Something like that. Location X / 16
  int chunkZ = npc.getZ() / 16; // Same here
  npcMap.computeIfAbsent(new ChunkPosition(chunkX, chunkZ), key -> new ArrayList<>()).add(npc);
}
#

@sterile flicker I changed the unload method again, because your nurse chunk in there is also weird

sterile flicker
#

I can't believe my eyes, what a detailed answer

#

thanks

quaint mantle
#

Hi , i am writing a plugin about ip but is there a question on my mind that can Player spoof ip and use other Player's ip?

lost matrix
#

Also: You wont be able to use CraftPlayer in your manager. It needs to be your custom NPC or else they dont have your custom methods.

lost matrix
quaint mantle
lost matrix
#

The IP address is taken from the TCP packet (Which builds on the IP packet containing the IP address).
All packets will be sent back to the sender listed in the packet. If you dont actually have that IP address, then the routing
will send those answer packets back to the original owner of that IP address, making your "spoof" practically useless.

You would have to own the entire route or a critical choke point between the attacker and the server.

So right at your servers host location, or right at the house of the spoofed player.

acoustic pendant
#

if (player.getItemInUse().containsEnchantment(Enchantment.SILK_TOUCH))
block.getWorld().dropItemNaturally(block.getLocation(), brokenBlock);

Why is this returning null?

lost matrix
#

*But keep in mind that ISPs can distribute dynamic IPs

lost matrix
acoustic pendant
lost matrix
acoustic pendant
quaint mantle
lost matrix
acoustic pendant
#

oh, okay, i'll try thanks

lost matrix
sterile flicker
dusky pollen
#

Mojang's /give command accepts item names in the following fashion enchanted_book{StoredEnchantments:[{id:"minecraft:unbreaking",lvl:5s}]}. Does anyone here know how this is done, or how I can do the same thing?

young knoll
#

It's called SNBT

chrome beacon
#

^^ and you can use this

young knoll
#

Dangit I was getting that

#

:p

dusky pollen
#

Thanks @young knoll and @chrome beacon . I'd have never found that. ❤️

young knoll
#

Is there not a method to convert an itemstack to that format

chrome beacon
#

There is one in CraftItemStack iirc

#

but not in the api

young knoll
#

wacky

icy monolith
#

I have this case opening thing and now i want to add it so that there is a large list of items that can spawn from it, but each item has its own rarity. The chest takes 4 random items based on rarity and spits them out. How do i go about making such system?

young knoll
#

I would look into a weighted random system

icy monolith
#

Are there examples of that algorithm i could look at. Preferably java or kotlin

young knoll
#

I still use this old example

lost matrix
icy monolith
#

Oh so you have a string of items and a string of weights

Then you sum up all the weights

Then pick a random number between 0 and weight sum

And then the part i dont get is you some how take that and turn it back into the item

lost matrix
#

By a binary tree search. But thats hidden in the TreeMap

chrome beacon
lost matrix
#

Im currently using the RangeMap from guava for this instead of a TeeMap

young knoll
#

Whats the difference

quaint mantle
#

?paste

undone axleBOT
tacit arrow
#

I have been trying to make user's inventory save in the db for a while now and load ofc and since i am making this ticket obviously its all bad code and dosent work. So iam here for guidence on how to achieve this goal before i go insane.

Please ping me once you respond.

quaint mantle
tender shard
wet breach
#

perhaps maybe you just don't know what type to make the inventory stuff to properly save in the DB?

tacit arrow
# tender shard what exactly is the issue? what's your current code?

the code is terrible i deleted that shit but basically

when i have attempted to save itemStack data to the mongodb it was working partially the nbt data didn't go through though, and whenever i searched on google the information to me was irrelevant.

I am using spigot 1.8.8
I am unable to use realistically higher versions since my pc starts lagging everytime i boot up the server

tacit arrow
tacit arrow
wet breach
#

if you need another example I have one as well 🙂

quaint mantle
tender shard
#

what are those GuiItem etc things?

quaint mantle
#

i used Triumph GUI

#

and i used document or wiki of Triumph GUI

ancient marsh
#

Hey guys, have any of you used the 1.20.4 NMS for duning the Scoreboard, When yes -> please DM me

raven vale
#

economyshopgui 1.20.4 red bug

tender shard
dusty totem
#

In case of ServerInfo is there a implementation available or I need create my own class for it?

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

ancient marsh
eternal night
dusty totem
eternal night
#

oh

#

sorry I thought we were talking about spigot

tender shard
#

oh too late

dusty totem
#

It was stuppid from my side, I should find it before give the question, sorry

tender shard
#

the better question is, why do you need the implementation?

raven vale
#

the plugin 1.20.4 EconomyShopGUI-6.4.1 does not work

ancient marsh
#

Does anyone know how I have to use the NumberFormat in 1.20.3 for a packet scoreboard? -> For the "ScoreboardObjective"

hazy parrot
tender shard
kind hatch
dusty totem
tender shard
ancient marsh
kind hatch
#

?mappings

undone axleBOT
tender shard
#

yeah the proper name is Objective. I'd just pass in an instance of one of the existing formats and see what happens lol

#

just throw in a BlankFormat

ancient marsh
#

i current using: NumberFormat numberFormat = BlankFormat.a;, you mean this?

tender shard
#

idk, you should use mojang mappings instead of the obfuscated names

#

either StyledFormat.SIDEBAR_DEFAULT or new BlankFormat()

ancient marsh
#

i try

tender shard
#

ofc it depends on how you want it to get displayed. do you even want to show the score number?

#

or do you just want to use the scores to sort some arbitrary lines of text?

ancient marsh
tender shard
#

if you want to show the numbers, use StyledFormat.SIDEBAR_DEFAULT (or create a custom one with new StyledFormat(Component)), otherwise BlankFormat.INSTANCE

ancient marsh
#

i try, but i dont know what i make wronge. I use not the mapped Src.

`` PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(objective, 1);
PacketPlayOutScoreboardObjective createPacket = new PacketPlayOutScoreboardObjective(objective, 0);
PacketPlayOutScoreboardDisplayObjective display = new PacketPlayOutScoreboardDisplayObjective(DisplaySlot.b, objective);

    sendPacket(player, removePacket);
    sendPacket(player, createPacket);
    sendPacket(player, display);``

i dont know what i make here wrong lol

tender shard
#

what's the issue exactly?

#

and why don't you use remapped 🥲

ancient marsh
ancient marsh
#

bringt mir auch nichts

#

lol

tender shard
#

Show the code where you're creating the objective

ancient marsh
#

`` NumberFormat numberFormat = StyledFormat.c;

    ScoreboardObjective objective = scoreboard.a(displayName,
            IScoreboardCriteria.a, IChatBaseComponent.a(chatData.message("%1%§lLobby")),
            IScoreboardCriteria.EnumScoreboardHealthDisplay.a, true, numberFormat);

    PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(objective, 1);
    PacketPlayOutScoreboardObjective createPacket = new PacketPlayOutScoreboardObjective(objective, 0);
    PacketPlayOutScoreboardDisplayObjective display = new PacketPlayOutScoreboardDisplayObjective(DisplaySlot.b, objective);

    sendPacket(player, removePacket);
    sendPacket(player, createPacket);
    sendPacket(player, display);``
#

public void sendPacket(Player player, Packet<?> packet) { ((CraftPlayer) player).getHandle().c.a(packet); }

lost matrix
#

Just came here. Why are we using nms for scoreboards?

tender shard
#

no clue

dry hazel
#

😵‍💫

lost matrix
#

I think whatever he is doing should be done via the spigot api and not nms in the first place

ancient marsh
dry hazel
#

any particular reason against using the api?

ancient marsh
sterile flicker
# lost matrix First you are going to remove your "npcSpawned" collection because you are not u...
    public void onPlayerJoin(PlayerJoinEvent event) throws Exception {
        Player p = event.getPlayer();
        for (CraftPlayer ep : manager.getNpcsInChunk(p.getLocation().getChunk().getX(), p.getLocation().getChunk().getZ())) {
            if (ep != null) {
                System.out.println("sended packets");
                manager.showTo(p, ep);
                npcSpawned.put(p, true);
            }
        }
        Npc.injectNetty(p, manager);
    }``` unfortunately, the length of the array manager.getNpcsInChunk is now zero and ```System.out.println("sended packets");
                manager.showTo(p, ep);
                npcSpawned.put(p, true);``` is not executed
#

by the way, I have implemented the decoder injector, "npc_interact" into the code

#

he works

#

but when 2 player join, the NPC disappears

lost matrix
frank flicker
#

Could anyone check this out if you get the chance? I am trying to change nametag colors in this plugin and I have still not been able to find a solution. The server uses paper 1.18 https://jd.papermc.io/paper/1.18/index.html , and I cant seem to get the nametag color to change no matter what, is it possible? Any help would be greatly appreciated.

ancient marsh
#

?nms

sterile flicker
inner mulch
#

Can i set someones glow effect color without changing any scoreboard stuff?

young knoll
#

no

#

Glow color is based on team

echo basalt
#

If you're using neznamy's tab you can set it with a placeholder md_5

inner mulch
#

😔

torn shuttle
#

@echo basalt have you actually used the rotation methods you have on your blockdisplaypacketentity class?

echo basalt
#

I believe I used the scaling ones, but not rotation

torn shuttle
#

how the hell are these even meant to work man

#

I am making a quaternion based on a eulerangle rotation and it just disappears

echo basalt
#

lmfao

#

you might need interpolation idfk

#

just look at how craftblockdisplay wraps it

#

brb buying chicken

tender shard
#

get one for me too

#

pls

torn shuttle
#

ok I'm getting trolled, no way

#

[20:14:24 INFO]: INITIALIZATION Left rotation: ( 0.000E+0 0.000E+0 0.000E+0 1.000E+0)
[20:14:24 INFO]: INITIALIZATION Right rotation: ( 0.000E+0 0.000E+0 0.000E+0 1.000E+0)

works

[20:14:24 INFO]: Left rotation: ( 0.000E+0 0.000E+0 0.000E+0 1.000E+0)
[20:14:24 INFO]: Right rotation: ( 0.000E+0 0.000E+0 0.000E+0 1.000E+0)

made the model disappear

#

am I on drugs

echo basalt
#

Lmao

tardy delta
#

make it NaN

torn shuttle
#

actually it flips to 0 0 0 0 a couple of ticks later so that might be it?

dusky pollen
#

I've come with another question. Is there some type of registry for namespaced keys? I'm currently just using the values from the Material enum, but that feels wrong.

young knoll
#

hmm?

#

Material has a getKey

dusky pollen
#

I'll look into it, thanks.

#

That works perfectly, thanks @young knoll ❤️

ancient marsh
#

do any know what i put in in PacketPlayOutScoreboardScore?

#

net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore

#

the last 3, i know what i know what i put it in

lost matrix
#

Use mojang mappings pls

ancient marsh
#

can you make me a picture what i must have in them?

dry hazel
#

?mappings

undone axleBOT
tender shard
#

?switchmappings too

cedar flint
#

What is the best way to add a fake enchantment glint to items without effecting the item in any other way?

zinc moat
#

can someone explain nms like really simple?

lost matrix
lost matrix
# zinc moat that is really simple

But people didnt want to use mojangs code (as it changes a lot)
So they created bukkit (which keeps the same code "visible" for developers)
Bukkit/Spigot makes sure that what you are writing once, will work for all the nms versions.
nms -> Changes every version
spigot -> Should rarely change

The idea was to write code once and make it work for the future without updating

zinc moat
#

oh

#

Alrigth thanks

#

Didnt know that

lost matrix
#

Thats why if you write a 1.8 plugin, it will work all the way to 1.20 (mostly)

zinc moat
lost matrix
#

Not really because Spigot constantly adds new features to their api, and we cant really add those features to older versions

zinc moat
#

Makes sense

lost matrix
#

But we encourage you to use the latest version for your development and server

zinc moat
#

also whats the difference between jdk 1.8 and jdk 17 some people say to use 1.8 jdk

next plume
#

Unless you're writing plugins for old versions of Minecraft, you should use 17.

lost matrix
#

1.8 is really old at this point

zinc moat
#

oh alrigth

#

Thanks

echo basalt
#

think3d I gotta make a friend system

#

p sure past conversations here recommended using some sort of graph

inner mulch
#

yes

#

conclube recommended it to me

echo basalt
#

think3d how am I gonna do this to not completely break cross-proxy

#

gotta add a bunch of packet wizardry

lost matrix
inner mulch
#

wait was it you ?

#

im sorry

echo basalt
#

hm

#

that's one of the solutions

#

store all the online player friend data on redis

#

but then if a guy accepts a friend request from an offline player I gotta load it from the db

#

eh whatever not that complex

inner mulch
echo basalt
#

my original idea was that each proxy would have data for their online players and I'd add a bunch of packets so the proxies talk to each other

#

be like "ayo this the new data"

#

and do like 5 trillion checks

inner mulch
echo basalt
#

not exactly no

#

But then imma have friend menus and only the proxies have data context

#

hm

#

Should I make a friend service 🤔

inner mulch
#

i think redis is the best solution if you have that many servers, smile told me about having 1 master server with the data and the rest are relying on the master

echo basalt
#

I think the solution is just redis & persistence

#

bunch of interface magic

#

Maybe I toss it all on the spigot module and call it a day

lost matrix
# echo basalt be like "ayo this the new data"

Or you simply only edit your data in the Database/Redis and keep a read-only view.
I have an auto synchronized collection for that.

Write:

  1. Write <K, V> to local map
  2. Write <K, V> to redis
  3. Send <K> on a redis topic to notify update
  4. Every subscriber loads <K, V> into local map from redis

Read:

  1. Read from local map

Synchronized Compute (for currency etc):

  1. Ack lock from Redis
  2. Read <K, V> from Redis
  3. Predicate -> Compute on <V>
  4. Write modified <V> to Redis
  5. Release lock
  6. Send <K> on a redis topic to notify update
  7. Every subscriber loads <K, V> into local map from redis

This way im assuring a 100% consistent data state with an eventually-consistent read-only cache on multiple instances.

echo basalt
#

Hm

#

I'm still thinking of using redis but I also gotta fetch friend data from mysql

#

don't think mongo's set up

inner mulch
#

mongo < sql

lost matrix
#

*>

inner mulch
#

?

echo basalt
#

mongo's nicer

inner mulch
#

why's that?

echo basalt
#

but I can't use it here

lost matrix
#

I like mongo because i will never have to write a schema or any queries ever.
Back the Codec with Gson and boom, store everything without having to write a serializer.

echo basalt
#

I also don't need the "local caching" as it adds a bunch weird complexity given I'll also need proxy logic for like

#

getting what server your friends are on type deal

lost matrix
#

I literally wrote this

echo basalt
#

so I don't mind just like

#

having 2 redis caches and fetching a read only snapshot every time I mess with the data

lost matrix
#

Use MongoDB like a Map for anything

echo basalt
inner mulch
#

schema's are nice because they ensure you dont put anything where it doesnt belong

echo basalt
#

sometimes your data doesn't have a fixed schema

#

But yeah as for gson in mongo the problem is like

#

weird generics

#

For example at a server I worked for I made a settings system that supported complex types

#

And I couldn't just yeet generic setting values because I needed context of how I'd read it

#

And adding the class name to every value just adds overhead

#

It also gave me weird issues if I were to change the class spec

#

So I just went back to the classy ways and wrote codecs