#development

1 messages Β· Page 33 of 1

tired olive
#

no

lethal lava
#

How do i give a player a kit after they respawn?

tired olive
dusty frost
#

imagine my surprise when I found out that Set#retainAll() modifies the set in place instead of returning a new set that's the intersection of both of them?!?!?

#

like come on

#

give me vavr style

lethal lava
tired olive
#

thats what im saying

lethal lava
#

Okay how?

tired olive
#

listen to the PlayerPostRespawnEvent event then give them a kit 🀯

lethal lava
#

Simpler terms

tired olive
lethal lava
#

oh okay

worn jasper
#

uhm so in MongoDB, am I able to put an arraylist into a DBObject?

#

Since DBObject accepts an object as value, I assume it works?

icy shadow
#

Try it and see

worn jasper
#

currently on laptop, on vacation

#

without access to the mongodb

icy shadow
#

Then why does it matter lol

#

Anyway the answer should be yes

worn jasper
#

thx lol

dense drift
icy shadow
#

You must be having very full showers

dark garnet
#

HELLO, im trying to make plugin where 1 person dies everyone dies
however, ive came into problem where killing all the other players throws the death event again, causing the plugin to kill everyone again, creating a loop

spiral prairie
#

set a boolean to true

#

and then to false

dark garnet
#

what

spiral prairie
#

and check if its true when the event comes in

dark garnet
#

and set it to false when it kills everyone else?

spiral prairie
#

no the other way around but yeah

dark garnet
#

wouldnt it always be true then :/

#

if (boolean) boolean = true

spiral prairie
#

what?!

dark garnet
spiral prairie
#

im explaining the principle

#

you can decide on the value

#

when death -> bool = true
death event comes in because killed -> check if bool == true, if yes, skip
after loop -> bool = false

stuck hearth
#

if(playersLeft == 1) return;

dark garnet
#

oh now i see how i couldve fixed the system i was just using (i was saving players that just died [by plugin] to a set and then if set contained them, it wouldnt run event, if i cleared the list after looped, it wouldve worked)

dusky harness
#

so a boolean but into a set

#

πŸ₯²

spiral prairie
#

yup

forest jay
dark garnet
forest jay
#

oh, yeah, my bad.

#

Would the best way to save a furnace's contents be just grabbing the inventory contents and saving it? I am not sure how the furnace and other non-chest inventories work.

spiral prairie
#

yeah

#

is probably x y problem though

stuck hearth
#

They have slots with Items in them.
What do you mean

west socket
#

Anyone know if theres a way to spawn NPCs with CitizensAPI from a texture file?

#

My server keeps getting fucking Mojang API rate-limited and I don't know what I can do

spiral prairie
#

too many npcs

forest jay
#

unless that is what you are using

west socket
#

Only issue is that our skins periodically change based on different factors. So it looks like we'll need to use their API for that.

#

Do you know if they have a rate-limit that is higher than mojangs?

forest jay
west socket
#

Basically we constantly scrape the name of nitro boosters in our discord

#

To use them as skins ingame

#

I think I can use their API to load the textures into an SQL database and then have it query that for future uses

spiral prairie
#

They change more than 600 times per 10 minutes?

dusky harness
#

πŸ₯²

#

thats a lot of skins

hoary scarab
#

100+ players looping logins can do that easily.

dusky harness
#

like in your launcher and you select Upload skin (or whatever its called)

#

the actual skin loading is done in the client (which I assume has a very very very lenient ratelimit if it has one at all to avoid botting since the client can load many many skins due to skulls, npcs, and other players)

#

ok im gonna go to sleep now so if I don't respond to your response (if you make one), that's why πŸ‘

hoary scarab
#

Player skulls and NPC's also request skins from mojang's API the client requesting these skins is a different situation.

unborn ivy
#

does anyone know how i can set an iron golem's health to just half a heart, it looks like there is no method for this
(context: using SpawnerSpawnEvent to find out if iron golem is spawned from a spawner, if so, set health to half heart and set it on fire)

    @EventHandler(ignoreCancelled = true)
    public void IGSpawn(SpawnerSpawnEvent e) {
        EntityType entity = e.getEntity().getType();
        if (entity == EntityType.IRON_GOLEM) {
            Entity ent = e.getEntity();
            \\ ?????? 
hoary scarab
#

ent.setHealth(1)?

unborn ivy
#

that doesnt work

#

like i said there is no method for it

leaden sinew
unborn ivy
#

i cast it to an entity

#

it still doenst work

#

i tried this with CreatureSpawnEvent aswell

#

same thing

#
    @EventHandler
    public void aaa(CreatureSpawnEvent e) {
        EntityType ent = e.getEntity().getType();
        if (ent == EntityType.IRON_GOLEM) {
            if (e.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) {
            }
        }
    }
}
leaden sinew
#

Try LivingEntity ent = e.getEntity()

unborn ivy
#

Ill try the code ingame

#

thanks for now

leaden sinew
#

No problem for now

grim pumice
#

how can i get the block coordinate player is looking at even from very far in java

shell moon
#

Easiest way to make/port a mod to work for all fabric versions? (i mean, multiversion)

#

context: there is a fabric mod for 1.19 i want to make it 1.16.5+ (or older)

stuck hearth
#

@slow junco noob

shell moon
#

good, bad? xdd

    public static ModifierKey fromString(String modifier) {
        switch (modifier.toUpperCase()) {
            case "LEFT_SHIFT":
            case "LS":
            case "L_SHIFT":
                return ModifierKey.LEFT_SHIFT;
            case "RIGHT_SHIFT":
            case "RS":
            case "R_SHIFT":
                return ModifierKey.RIGHT_SHIFT;
            case "LEFT_ALT":
            case "LA":
            case "L_ALT":
                return ModifierKey.LEFT_ALT;
            case "RIGHT_ALT":
            case "RA":
            case "R_ALT":
                return ModifierKey.RIGHT_ALT;
            case "LEFT_CTRL":
            case "LEFT_CONTROL":
            case "LC":
            case "L_CTRL":
            case "L_CONTROL":
                return ModifierKey.LEFT_CTRL;
            case "RIGHT_CTRL":
            case "RIGHT_CONTROL":
            case "RC":
            case "R_CTRL":
            case "R_CONTROL":
                return ModifierKey.RIGHT_CTRL;
        }
        return ModifierKey.NONE;
    }```
lyric gyro
river solstice
#

where are the spaceless ones

#

RIGHT_CTRL = RIGHTCTRL

#

🀠

stuck hearth
#

At what point do you just use regex/pattern checking

shell moon
#

If a method returns Optional<Something>

#

can i use reflections there?

stuck hearth
#

For what and why

shell moon
#

Wanna do this, but with reflections

#
        MythicBukkit.inst().getSkillManager().getSkill(id).ifPresent(skill -> {
            AbstractPlayer trigger = BukkitAdapter.adapt(player);
            GenericCaster genericCaster = new GenericCaster(trigger);
            SkillMetadata skillMeta = new SkillMetadataImpl(SkillTriggers.API, genericCaster, trigger, BukkitAdapter.adapt(player.getLocation()),
                    new HashSet<>(), null, 1.0F);
            if (skill.isUsable(skillMeta, SkillTriggers.API)) skill.execute(skillMeta);
        });
lyric gyro
#

what the fuck

stuck hearth
#

Bro I'm going to do laundry πŸ’€

shell moon
#

yeah, its a soft depend of a plugin i'm editing but since that plugin is compiled in j16 or j17

#

i can't use it in my project j8 xd

#

so one thing leads to the other and thats it xd Β―_(ツ)_/Β―

sterile hinge
#

@lyric gyro do multi release jars work fine with spigot?

lyric gyro
#

i don't know

#

they should work on paper tho

sterile hinge
lyric gyro
#

I can't care to know about spigot kekw

sterile hinge
#

fair

sterile hinge
shell moon
#

impossible :,c

#

I know i can pepecatcry

dense drift
#

Or two jars tbh

#

One for legacy shit and one for new versions

icy shadow
#

catch Throwable πŸ˜–

#

and ignoring it too πŸ˜΅β€πŸ’«πŸ˜–πŸ˜΅β€πŸ’«

tired olive
#

and non final constants πŸ˜΅β€πŸ’«

river solstice
#

um.
I'm trying to print some debug messages (via Bukkit.getLogger().info) in a BukkitScheduler.runTaskTimer and async one, but I'm not getting any in the console. Is this intended?

#

or am I dumb as usual

dusky harness
#

no it is not intended

river solstice
#

it is incremented by one every 20 ticks

#

I have a placeholder for it, I can see the number increasing, all the logic somewhat 'working', it gets set back to 0

#

but I get 0 messages in the console, still

tired olive
#

if its just debug then try sout

river solstice
#

tried that too, nothing

tired olive
#

oh

#

thats odd

river solstice
#

oh, well

#

turns out it was getting filtered out

stuck hearth
#

They're in the async console

river solstice
#

the owner put in a plugin to filter out some messages from the console I wasn't aware of πŸ’€

tired olive
#

why would u want that lol

stuck hearth
#

Honestly in a Forge environment that could be nice.
So many pointless errors

tired olive
#

you can just turn off that logger though

stuck hearth
#

What logger, info?

#

Or per mod?
Either way seems rough

tired olive
#

which ever logger is logging the pointless errors

stuck hearth
#

They wouldn't be forge mods without pointless errors

worn jasper
#

Uhm quite random but am I able to set the amount of an itemstack to more than 64 on drop?

#

Aka I am doing a block that drops an item every X seconds, but to optimize it, I was thinking in looping all blocks around, checking if they are also "generators" and if so, simply adding 1 to the amount of that drop.

#

unless there is a simpler way?

torpid raft
#

why do you need a stack size over 64 to do that?

#

just loop to count and then drop in stacks of 64 instead of 1 by 1

#

if you really want to get crazy you can spawn a custom item and listen for a pick up event and then give the player the correct amount of items

signal grove
#

i dont understand what he means by 'adding 1 to the drop', so if there are 2 generators near each other, one of them spawns 2 items instead of they each spawn 1?

#

or something different

hoary scarab
signal grove
#

i think ivans solution is best if your goal is to stack "infinite" items, capping the drop amount at 127 and giving it some meta which stores the actual amount

signal grove
#

btw for the case of multiple generators - you dont need to check for nearby generator blocks, it's probably easier just to have each generator look for item stacks within a certain radius

#

using getNearbyEntities

worn jasper
signal grove
#

i mean how many generators are there, thousands? if no, i think its negligable

worn jasper
#

aka I loop the gens around that first gen, remove them from the list and so on

worn jasper
#

might have more

#

not in my control

signal grove
#

i see, but i think this isn't the design servers would expect

#

if they place two near each other, they expect 2 stacks

#

and if you have a feature so they can control the rate of each generator, then they wouldnt need to have multiple nearby

worn jasper
#

its one item per drop

#

not stacks

#

and its what was asked so ye

signal grove
#

by 'stack' i mean item entity, which can be 1 or 64 or whatever

sonic light
#

Hi i need help

signal grove
#

barry where are you now

sonic light
#

i need to setup a progress bar (from autorank) on Featherboard

#

how i can do?

signal grove
sonic light
#

Thanks

forest jay
#

I am looking into the source code of a plugin, and it uses the methods and references from WorldGuard and WorldEdit which are only available on 1.13+ versions, yet the plugin works all the way back to 1.8. I looked, and there is no version checking or reflection code in the plugin, how are they achieving the backwards compatibility?

worn jasper
#

maybe the api they are using also exist in earlier versions? idk

#

what plugin is it?

leaden sinew
worn jasper
# leaden sinew I think what you're saying is your going to cache the generators around other ge...

nono, I already do that on place, I clone that list and loop all gens around the first generator in that list, add 1 to a temp var that tells how many generators are in that rafius and removes them from that clonef list, and then I start again at the start and do the same. Technically I will save a lot of loops since instead of looping for every single one, I only loop for the ones that werent in a radius before.

leaden sinew
#

Idk what you mean by start again at the start though

azure cobalt
#

hi, I'm developing some plugin and i need to store some data, i don't want to have some hard dependency as an sql db. Do you have a solution to stone data in file? (i already try json, yml) and the library that i used what horrible to make work.
Do you have a good tuto that u used to do that ?

river solstice
#
    public static void save(Object obj, String path) {
        File f = new File(path);

        if(!f.exists()) {
            try {
                f.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        try {
            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));

            oos.writeObject(obj);
            oos.flush();
            oos.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }
#
    public static Object load(String path) {
        Object result = null;

        try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
            result = ois.readObject();
            ois.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }

        return result;
    }
#

I use this when I need to store a list or something to persist through restarts

#

then you just cast the Object the load method returns to the Object type you passed to Save

icy shadow
#

try with resources and nio >

worn jasper
#

SQL is a perfect choice, you can support MySQL and SQLite

#

I also like mongodb though

sweet cliff
#

Hewwo, there's a way to remove the Honey Block properties for mobs?

forest jay
#

I can send source if you want

worn jasper
#

no need, I would def. recommend sql

#

if you want to go for local, SQLite exists

#

otherwise MySQL/MariaDB

#

technically can also be done with MongoDB

forest jay
forest jay
dense drift
#

Is the plugin open source?

worn jasper
#

sorry.

forest jay
#

Your good

forest jay
#

I want to edit it

#

But can't get it to work on 1.8

spiral prairie
#

dont use 1.8

#

xD

dense drift
#

you are using it on 1.8 and it errors or?

#

maybe the worldedit class is only instantiated on 1.13+

hoary scarab
#

Well this is annoying...

dense drift
#

well this is a normal behaviour*

hoary scarab
dense drift
#

Team#setPrefix not coloring the string? πŸ™‚
Idk where Logger#log is coming from but that shouldn't color it either unless it is a custom class

hoary scarab
#

Logger is a custom class. and setPrefix is coloring the string hence the yellow lol. And I can configure the color but for some reason %vault_prefix% won't color (in scoreboard).

spiral prairie
#

Oh my god minecraft doesn't automatically translate ampersands

#

what news

#

Logger is probably translating them

#

Really hard to know what's really going without any information

hoary scarab
#

I feel like you both aren't looking at the images lol

spiral prairie
#

what is prefix

#

and i feel like you are not reading?

#

mind sending the log method?

hoary scarab
spiral prairie
#

it does get translated though by something else

#

or is team another custom class

hoary scarab
# spiral prairie mind sending the log method?
public static void log(LogLevel level, String message) {
    if (message == null) return;

    switch (level) {
    case WARNING:
        Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&6WARNING&8] &f" + message));
        break;
    }
}
spiral prairie
#

Well there you go

#

youre translating it here but not there

hoary scarab
spiral prairie
#

i am looking at them bro

#

it would be easier if you tell me what i got wrong

hoary scarab
#

The scoreboard is colored. But the prefix is uncolored. Then in console its colored correctly

spiral prairie
#

my guess:
config read -> translate codes -> then replace placeholders -> thus, &e is translated but the stuff added later isn't

hoary scarab
#

🀦

#

the prefix is colored even before setting the team prefix

spiral prairie
#

nah bro dont facepalm me

#

how should I know

#

im not magician having access to your hard drive btw

hoary scarab
#

I literally showed the images of whats wrong LMFAO

spiral prairie
hoary scarab
#

And debugging isn't helping which is why I originally posted it.

spiral prairie
#

because you are translating them

#

in your "debug" method

hoary scarab
spiral prairie
#

alright, now we have that sorted

hoary scarab
spiral prairie
#

nope

sterile hinge
#

if placeholders are replaced before coloring, I'm really interested how you managed to fuck it up that bad

hoary scarab
#

Trying something else give me a min

spiral prairie
#

what about code?

#

like the stuff actually needed xD

sterile hinge
#

well you didn't show any code doing your magic

hoary scarab
#

🀦

hoary scarab
spiral prairie
#

what was it?

hoary scarab
spiral prairie
#

Core.getInstance()

hoary scarab
#

"coloredPrefix" 🀦

spiral prairie
#

but yeah

#

that ... seems like the issue

hoary scarab
#

I had suffix right but fucked up prefix xD

spiral prairie
#

is that a plugin class or

hoary scarab
#

I should really recode this plugin from scratch. Issue would be it being a whole new plugin lol

dense drift
#

Util classes are static though

spiral prairie
#

yeah the fact that a class that isnt a util class has a static instance but the util class has xD

hoary scarab
#

🀷 Not my original code anyways

sterile hinge
dense drift
#

True, idk why I said that part

shell moon
#

Can someone tell me if for 1.8.8, to send action bar message it used "GAME_INFO" for getChatTypes or (byte)2 for getBytes

#

i swear i used to use GAME_INFO before and it worked fine, but now it seems that (byte)2 is the only working for 1.8.8

#

maybe a protocollib or viaversion thing?

dense drift
#

To send action bar message you use adventure PepeLaugh

shell moon
signal grove
#

Protocollib won’t touch any vanilla packets unless it’s told by a plugin, so the issue is probably from via version

#

(ViaVersion using protocollib)

shell moon
#

weird, i used to create a packet using GAME_INFO before and it threw errors when 1.8.8

#

but now it seems it doesnt

#

anyways, changing topic, possible to run bungee commands as player from spigot plugin?

#

player.chat("/end")
doesnt seem to work (does it?)

forest jay
#

How does one go about adding multiple different versions of a plugin (like WorldGuard or WorldEdit) to their gradle project without conflicting with the other versions?

spiral prairie
#

abstract your logic and add plattform modules

forest jay
#

I know how to do the coding part, its just that gradle wont let me add the same dependency but different versions

#

(not sure what the platform modules are)

leaden sinew
forest jay
#

How do I do it with different versions, not just different server types?

leaden sinew
#

The same way

forest jay
#

sorry if this super simple, but I just dont understand how (like, I dont even know how to do it with different server types. I looked in the gradle files, and there seems to be nothing relating to that. I know this is just me missing it)

dense drift
odd prawn
forest jay
#

I am not sure how to use Maven (I am using clean compile package to compile), this is a project made by someone else, I just want to compile it. I am getting an error relating to Lombok:

class lombok.javac.apt.LombokProcessor (in unnamed module @0x2b547149) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x2b547149

Here is the dependency code:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.12</version>
  <scope>provided</scope>
</dependency>

Is there anything visibly wrong? Is this a code issue?

pulsar ferry
#

Update lombok maybe, and also you don't need compile in there, clean package is more than enough

shell moon
#

plugin message system is safe to use o hacked clients can "fake" it?

#

(i know nothing about it so i'm asking, thanks in advance)

icy shadow
#

?

shell moon
#

dumb question? xd

#

i remember i read somewhere

pulsar ferry
#

You're messaging between servers, what would client have anything to do with that? (proven wrong ;p)

shell moon
#

i mean, if my bungeecord server listens to a plugin message

#

as mods can also send plugin message, i was wondering about how they are related xd

#

sorry im dumb xd

steep dragon
#

they are related in that they are literally the same thing

icy shadow
steep dragon
#

mishandling of bungee plugin message events can lead to a client mod being able to read them if you're lucky enough to be chosen as the connection to be bridged over

icy shadow
#

additionally clients can also send messages to servers, so theoretically a hacked client could send a "fake" message if it was able to somehow reverse engineer your system

steep dragon
#

(speaking from experience having made little packet interceptor tool just for that)
i think the fix is to cancel the events after having processed them, not really sure on the details because it's been a while

icy shadow
#

which may or may not have consequences

shell moon
#

so, the channel "BungeeCord" is secure or not?

steep dragon
#

protecting against sent messages is easy if you check the sender to be a server

shell moon
#

what about custom "my:plugin"

steep dragon
#

it's secure if you handle it securely

icy shadow
#

define "secure"

shell moon
#

mmm

#

secure like to be used in a plugin xd

#

i mean, if i want to an order from spigot to bungee using plugin message

#

lets say to execute a console command in bungee

#

would players be able to "fake" it

icy shadow
#

yeah lol

#

also who are you?

minor summit
#

Dr. Samuel Hayden

#

I'm the head of this facility

icy shadow
#

i see

shell moon
#

we know that

#

definitely not emily

hushed badge
#

#1456

dusky harness
#

Is that Emily

#

What happened to Emily

pulsar ferry
#

No

#

That is definitely not Emily

dusky harness
#

But like

#

Actually

#

I am confused

shell moon
minor summit
#

LuckPerms is a mod/plugin with many millions of downloads, over 2 million downloads last year alone

#

I would argue that it's doing it right

pulsar ferry
#

looks at griefprevention

minor summit
#

well

#

let me add to that that it is created, designed and maintained by an actual software engineer :D

shell moon
#

and if a hacked client sends a plugin message

#

what is it? if not an instanceof ProxiedPlayer

#

just curious

icy shadow
#

it would be ProxiedPlayer

#

hacked or not

signal grove
#

trying to make a forge mod on intellij using the "Minecraft Development" plugin

#

but there's no available versions for forge, mcp, or minecraft
^ nvm solved, i just reinstalled the addon

craggy zealot
#

what are your guy's opinion on minigame apis

torpid raft
#

they exist

hoary scarab
#

Uggg my message has 4 char to spare yet it won't let me post it. Damn it discord

#

So I'm currently trying to send/receive packets with TCP and I'm trying to handle the Server List Ping packet from the minecraft client but I have been unable to get it to work correctly.

https://pastebin.com/fLybLVWd
I am fairly certain I have everything right but if something is wrong I would assume its the favicon or my writing to the "OutputStreams"

[INFORMATION] Initializing ConnectionBase... (Port: 25569)
[INFORMATION] Initialized ServerSocket
[DEBUGGING] PingRequest [Recieved] >> 127.0.0.1
[DEBUGGING] Handling packet [0]...
[DEBUGGING] Handling ping...
[DEBUGGING] Response: {"version":{"name":"1.19.3_Beta-0.0.1","protocol":761},"players":{"max":100,"online":1,"sample":{"name":"yapperyapps","id":"8e73185f-845c-4336-86f6-b9c5d475e6fd"}},"description":{"text":"1.19.3 Beta"},"favicon":"data:image/png;base64,base64,RTpcQ3JhcHBpZXN0WVQgU3R1ZmZcTmV3IE1DU2VydmVyIGljb24ucG5n","previewsChat":true,"enforcesSecureChat":true}
[DEBUGGING] PingRequest [Recieved] >> 127.0.0.1
[DEBUGGING] Handling packet [122]...
[DEBUGGING] Handling pong...
[DEBUGGING] Payload: 792718197936651264
java.net.SocketException: An established connection was aborted by the software in your host machine
    at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420)
    at j.b/s.n.c.NSI.write(NioSocketImpl.java:440)
    at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826)
    at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1035)
    at java.base/java.io.DataOutputStream.writeLong(DataOutputStream.java:230)
    at <package>.UninitializedConnection.handlePong(UninitializedConnection.java:109)
    at <package>.UninitializedConnection.handlePacket(UninitializedConnection.java:83)
    at <package>.UninitializedConnection.run(UninitializedConnection.java:38)
    at java.base/java.lang.Thread.run(Thread.java:833)
    at <package>.ConnectionBase.run(ConnectionBase.java:67)
    at java.base/java.lang.Thread.run(Thread.java:833)
icy shadow
#

is there an error in the client logs?

#

that would be more helpful than the generic error

hoary scarab
#

One sec

#

Actually... yes lol.

icy shadow
#

sounds like the json isn't being written properly then

hoary scarab
#

Wait, sorry current error is [11:50:37] [Render thread/ERROR]: Can't ping localhost:25569: Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: Index 123 out of bounds for length 2

icy shadow
#

πŸ€”

#

full stack trace?

queen plank
#

I want to get the instance of each ItemFrame that is loaded on the server. But for some reason the ones already placed isn't caught by the EntitySpawnEvent when the server is rebooted. Is there another way to do it?

hoary scarab
hoary scarab
#

Right lol

icy shadow
#

uh

#

im not sure how you would debug / log the client events

#

but how are you writing the string?

#

there's a medium-high chance that you're not encoding varints properly, that caught me out a lot

hoary scarab
#
public void writeString(DataOutputStream out, String string, Charset charset) throws IOException {
    byte[] bytes = string.getBytes(charset);
    writeVarInt(out, bytes.length);
    out.write(bytes);
}
icy shadow
#

and writeVarInt is?

hoary scarab
minor summit
#

pakkit I think it's called?

icy shadow
#

looks like it

#

electron tho πŸ˜΅β€πŸ’«

minor summit
#

discord

icy shadow
#

@hoary scarab why case 122:? why 122? the ping request is 0x1
similarly the pong response id is 0x1 not 0x00

hoary scarab
#

Cause thats what was outputting in my earlier debugs.

icy shadow
#

oh hang on

#

no

#

that's not right at all

hoary scarab
#

Actually the debug is still there lol

#

Look at the output I posted and look at Handling Packet lines

icy shadow
#

okay but why are you writing 0x00 when the pong id is 0x01?

#

similarly i have a hypothesis for the 122, you're not consuming the bytes from the Handshake packet so they're still in the stream, messing up when you try and read the next packet id

hoary scarab
#

Because I've tried both as well as 0xFF and 0xFE

icy shadow
#

the pong id is 0x01

hoary scarab
#

I know

spiral prairie
#

so

#

use it lol

hoary scarab
#

Read the output of the debug

icy shadow
#

if you're writing the wrong id then the client is gonna interpret the data in a completely different way

#

the debug of what the server is receiving has nothing to do with the data the server is sending

hoary scarab
icy shadow
#

where does it say that?

hoary scarab
#

the incoming packetid is 0 client -> server based on all the code given

icy shadow
#

which... is correct. i'm talking about a completely different stage lmao

hoary scarab
#

One sec

icy shadow
#

Handshake = 0
Status Request = 0
Status Response = 0
all fine
Ping Request = 1, should definitely not be 122 but i've already mentioned that
Pong Response = 1, you're writing 0

#

even if you're not handling it you need to consume all the packet's bytes

hoary scarab
#

🀦 java int packetSize = varMethods.readVarInt(in); int packetId = varMethods.readVarInt(in); I changed packetSize to in.readByte() and now packetId is 0 or 1

icy shadow
#

ah

hoary scarab
#

Same error though

#

both client and server

icy shadow
#

Pong Response = 1, you're writing 0

hoary scarab
#

I updated the code

icy shadow
#

show the new code

hoary scarab
#

Its on the pastebin

#
private void handlePong(DataInputStream in, DataOutputStream out, int packetSize, int packetId) {
    Output.debug("Handling pong...");
    try {
        long payload = in.readLong();
        Output.debug("Payload: "+payload);
        out.writeByte(0x01);
        out.writeLong(payload);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
icy shadow
#

ok

#

one other thing that raises eyebrows is that you don't seem to actually be following the packet format: https://wiki.vg/Protocol#Packet_format

unless im missing something you're not writing the packet length at all

hoary scarab
#

One sec

icy shadow
#

and you didn't think in these days that writing packets incorrectly could be causing the issue?

hoary scarab
#

Or atleast to get it to output something legible

icy shadow
#

right...

#

well generally the correct way of writing it is the best

#

removing the arguably most important part of the packet is certainly unlikely to fix the issue

#

incidentally

hoary scarab
#

I was trying everything

icy shadow
#

ok

#

the string length is not the same as the entire packet length

#

the easiest way is to write the packet data into a buffer, then write the buffer length, then all the buffer data

hoary scarab
#

Saw that on a few things. Not using any external API's at the moment. Will try to write something up give me a bit.

hoary scarab
#

🀦 I kept seeing ByteBuf which is netty lol

#

Thanks one sec

hoary scarab
#
private void handlePing(DataInputStream in, DataOutputStream out, int packetSize, int packetId) {
    Output.debug("Handling ping...");
    try {            
        Output.debug("Response: "+response);
        byte[] serverListMessage = varMethods.readString(out, response, StandardCharsets.UTF_8);
        ByteBuffer buffer = ByteBuffer.allocate(9999);
        buffer.putInt(0x01);
        buffer.put(serverListMessage);
        buffer.flip();
            
        Output.debug("Buffer: "+buffer.limit()+" SLM Size: "+serverListMessage.length);
            
        out.write(buffer.limit());
            
        byte[] outBytes = new byte[buffer.limit()];
        buffer.get(outBytes);
        out.write(outBytes);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
#

Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonParseException: JSON data was null or empty in client log
[DEBUGGING] Buffer: 720 SLM Size: 716 in server log

spiral prairie
#

have you read the exception?

steady torrent
# hoary scarab ```java private void handlePing(DataInputStream in, DataOutputStream out, int pa...
    Output.debug("Handling ping...");
    try {
        int payloadSize = in.readInt();
        byte[] payload = new byte[payloadSize];
        in.readFully(payload);
        String response = new String(payload, StandardCharsets.UTF_8);
        
        Output.debug("Response: "+response);
        byte[] serverListMessage = varMethods.readString(out, response, StandardCharsets.UTF_8);
        ByteBuffer buffer = ByteBuffer.allocate(9999);
        buffer.putInt(0x01);
        buffer.put(serverListMessage);
        buffer.flip();
        
        Output.debug("Buffer: "+buffer.limit()+" SLM Size: "+serverListMessage.length);
        
        out.writeInt(buffer.limit());
        
        byte[] outBytes = new byte[buffer.limit()];
        buffer.get(outBytes);
        out.write(outBytes);
        out.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}```
hoary scarab
#

Response is suppose to be the json string. But your message sets response as the input.

marble nimbus
#

May I ask what you are trying to achieve thinkies

wraith scarab
#

Hi,
How can I increase corp growth by like 100% in 1 chunk only

hoary scarab
forest jay
#

I am getting a ClassNoDefFoundError for a plugin that I have not shaded into the jar, but have it as a provided dependency. It is in the depend section of my plugin.yml, and the plugin is on the server, I checked. Is there something I am doing wrong?

marble nimbus
#

can you send the plugin name and your plugin.yml?

forest jay
#

yeah, just so you know, it is a physical jar on my machine that I am adding, here is the dependency code: ```xml
<dependency>
<groupId>pets</groupId>
<artifactId>pets</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/PrisonPets.jar</systemPath>
</dependency>

forest jay
# marble nimbus can you send the plugin name and your plugin.yml?

PrisonPets, here is my plugin.yml:```yml
name: PrisonCore
version: ${project.version}
main: me.drawethree.ultraprisoncore.UltraPrisonCore
depend: [Vault, WorldGuard, WorldEdit]
softdepend:

  • PlaceholderAPI
  • JetsPrisonMines
  • Multiverse-Core
  • PrisonPets
    authors: [kyematzen]
    api-version: 1.13
    load: POSTWORLD
dusky harness
#

is the actual error ClassNoDefFoundError or something like ClassNotFoundException (as the "root" error)?

forest jay
#
Caused by: java.lang.NoClassDefFoundError: me/reb4ck/prisonpets/api/PrisonPetsAPI
at me.drawethree.ultraprisoncore.autosell.UltraPrisonAutoSell.lambda$registerListeners$5(UltraPrisonAutoSell.java:199) ~[?:?]
at me.lucko.helper.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:150) ~[?:?]
at me.lucko.helper.event.functional.single.HelperEventListener.execute(HelperEventListener.java:136) ~[?:?]
dusky harness
#

anything below that?

forest jay
#

just this ... 17 more

dusky harness
#

huh

#

interesting

marble nimbus
#

and you are sure "PrisonPets" is what it says in the plugin.yml of "PrisonPets"

forest jay
#

yes

marble nimbus
#

PrisonPets is custom I suppose?

forest jay
#

yeah

#

I can send the plugin.yml if you need

marble nimbus
#

yes please

forest jay
#
name: PrisonPets
version: 1.0.0
description: A Prison Pets Plugin
main: me.reb4ck.prisonpets.PrisonPets
api-version: '1.13'
author: Reb4ck
load: STARTUP
softdepend: [WorldEdit, WorldGuard, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Multiverse-Core]
commands:
  pets:
    description: Main plugin command
marble nimbus
#

interessting, does PrisonPets start up at all?

forest jay
#

yes

marble nimbus
#

mind sharing your latest.log

forest jay
#

yeah one sec

marble nimbus
#

it does look fine, both plugins start up and in the correct order.

forest jay
#

yep

marble nimbus
#

when does the error occur?

forest jay
#

when I try to access any of the PrisonPetsAPI methods

#

like, the second I touch PrisonPets it runs into errors

marble nimbus
#

can you open PrisonPets with winrar/7zip and check if the PrisonPetsAPI class is present?

forest jay
#

its there

marble nimbus
#

so the verify first error that appears is ClassNotFoundException

#

so for some reason it can't find your API Class

forest jay
#

its actually NoClassDefFoundError

marble nimbus
#

Caused by: java.lang.ClassNotFoundException: me.reb4ck.prisonpets.api.PrisonPetsAPI

#

nope

#

The NoClassDefFoundError appears afterwards

marble nimbus
#

the verify first exception thrown by your Plugin is ClassNotFoundException, all attempts to access PrisonPetsApi will fail with NoClassDefFoundError because, well its not there

forest jay
#

oh yeah

#

and since it isnt there, it then produces the NoClassDefFoundError error

marble nimbus
#

correct

#

so your issue is that for some reason it can't find your Class

leaden sinew
forest jay
marble nimbus
#

doesn't scope system just use it for compiling?

leaden sinew
#

I don't remember, I use gradle

forest jay
#

should I change it to provided and see what happens

marble nimbus
#

Yea its provided

leaden sinew
#

But might as well open the jar and check

marble nimbus
forest jay
steady torrent
# hoary scarab Response is suppose to be the json string. But your message sets response as the...

Is this what you mean?

    Output.debug("Handling ping...");
    try {
        int payloadSize = in.readInt();
        byte[] payload = new byte[payloadSize];
        in.readFully(payload);
        String response = new String(payload, StandardCharsets.UTF_8);
        
        Output.debug("Response: "+response);
        byte[] serverListMessage = varMethods.readString(out, response, StandardCharsets.UTF_8);
        ByteBuffer buffer = ByteBuffer.allocate(9999);
        buffer.putInt(0x01);
        buffer.put(serverListMessage);
        buffer.flip();
        
        Output.debug("Buffer: "+buffer.limit()+" SLM Size: "+serverListMessage.length);
        
        out.writeInt(buffer.limit());
        
        byte[] outBytes = new byte[buffer.limit()];
        buffer.get(outBytes);
        out.write(outBytes);
        out.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}```
marble nimbus
#

Riches can you show those lines:

    at me.drawethree.ultraprisoncore.enchants.managers.EnchantsManager.handleBlockBreak(EnchantsManager.java:264) ~[?:?]
    at me.drawethree.ultraprisoncore.enchants.UltraPrisonEnchants.lambda$registerEvents$19(UltraPrisonEnchants.java:345) ~[?:?]```
forest jay
#
if (plugin.getCore().isPluginPresent("PrisonPets")) {
  multiplier = PrisonPetsAPI.getMoneyMultiplier(e.getPlayer());
}
#

isPluginPresent just checks if the plugin on the server plugin manager doesnt equal null

marble nimbus
#

Uhm

#

I am not really sure that is correct, not sure if you can access the Class without somehow loading it

#

I remember there was something like : (MyCoolPlugin) Bukkit.getPluginManager().getPlugin("CoolPlugin");

but someone else needs to answer that

forest jay
#

I am pretty sure the API does that

dusty frost
#
        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new PAPIExpansion().register();
        }

This is the recommended PlaceholderAPI style

#

so i'm sure that would work for your scenario

forest jay
#

that is pretty much what I do, just a little more complicated

#

I just made a method on the main class to check for that

#

the issue is that the plugin there, and the my plugin knows that, its just when it goes to interact with it, it gets a ClassNotFoundException

dusty frost
forest jay
#

I tried that

#

it broke maven

dusty frost
#

in what way lol

forest jay
#

all this goes away when the scope is system, it appears when the scope is provided

dusty frost
#

did you read the second line of that

marble nimbus
forest jay
#

I cant omit it

marble nimbus
#

the dependency doesn't come from mavenLocal

forest jay
#

it is a local file

dusty frost
#

oh bizarre

marble nimbus
#

it comes from his libs\some.jar

forest jay
#

a physical .jar in a libs folder

dusty frost
#

are you sure the class you're referencing is in the jar on the server?

forest jay
#

yes

dusty frost
#

like, you've unzipped the jar that is literally on your server and clicked on the class file?

forest jay
#

yeah

dusty frost
#

yeah I mean i'm not sure, the system scope is deprecated in maven, so probably not the best idea

#

i guess you could use a debugger connected to the server and check the classpaths loaded or something?

dusky harness
#

right?

#

if the class was missing

#

ok i gtg

dusty frost
#

that's literally what it's giving lol

forest jay
#

should I just install it to my maven local?

dusty frost
#

yeah

#

or, even better, put it in a maven repository

dusky harness
#

no its giving classdefnotfound iirc

dusky harness
#

ah i did not see that part

forest jay
hoary scarab
forest jay
#

same as before

dusty frost
#

well i mean that wouldn't fix it, just good practice lol

#

yeah like you're gonna have to inspect the actual loaded classpath or something man

forest jay
#

how do I do that?

#

Would it be best to just put the api in my own plugins source?

dusty frost
#

well no, because then it wouldn't work

#

the whole point of maven/gradle is to be able to get api definitions for type safety and then when you run it in spigot it will load them to the classpath and you can link to the actual implementations

forest jay
#

so then how do I inspect the actual classpath?

feral raptor
#

Why does this return a ArrayIndexOutOfBoundsException?

  int[][] imageData={{100,90,255,80,70,255,60,5},
                     {255,10,5,255,10,5,255,255},
                     {255,255,255,0,255,255,255,75},
                     {255,60,30,0,30,60,255,255}};

  int[] newImage = new int[4][6];

    for (int i = 0; i < imageData.length; i++) {
      for (int j = 0; j < imageData[i].length; j++) {
        if (j <= 5) {
          newImage[i][j] = imageData[i][j];
        } 
      }   
    }
#

Purpose: taking the data from 2D Array imageData and assigning it to newImage while explicitly excluding the last 2 columns

dusky harness
feral raptor
#

Ah yeah, I see that error now. But still, why does this cause an out of bounds exception

#

the terminating condition prevents the loop from traversing beyond the length of the array

#

Ah, hold on, I see the error now x2.

past ibex
#

imagedata has 8 in length

feral raptor
#

I should've broke the loop within the if statement

#

I was conditioning it to assign the next imagedata element to newImage if j was <= 5 instead of conditioning it to break if that was the case

#

Realistically I realize now I should've just had the terminating condition be against the column length of newImage, not imageData and I wouldn't even need the if statement, but I was being a dumbass.

sudden sand
hoary scarab
#

@steady torrent

private void handlePing(DataInputStream in, DataOutputStream out, int packetSize, int packetId) {
    Output.debug("Handling ping...");
    try {
        byte[] payload = new byte[packetSize];
        in.readFully(payload);
        String pingResponse = new String(payload, StandardCharsets.UTF_8);
        out.write(0x09);
        out.write(0x01);
        out.write(pingResponse.getBytes());
        
        Output.debug("Response: "+response);
        
        byte[] serverListMessage = varMethods.readString(out, response, StandardCharsets.UTF_8);
        ByteBuffer buffer = ByteBuffer.allocate(9999);
        buffer.putInt(0x01);
        buffer.put(serverListMessage);
        buffer.flip();
        
        Output.debug("Buffer: "+buffer.limit()+" SLM Size: "+serverListMessage.length);
        
        out.write(buffer.limit());
        
        byte[] outBytes = new byte[buffer.limit()];
        buffer.get(outBytes);
        out.write(outBytes);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
    
private void handlePong(DataInputStream in, DataOutputStream out, int packetSize, int packetId) {
    Output.debug("Handling pong...");
    try {
        long payload = varMethods.readVarLong(in);
        Output.debug("Payload: "+payload);
        out.writeByte(0x01);
        varMethods.writeVarLong(out, payload);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
```So getting close. (I hope) The MOTD still doesn't show but the client log is returning `Can't ping localhost:25569: Finished` So better then an error I guess lol
#

Huh... Shows a ping now though

signal grove
#

nice ping bro

#

Several minutes

hoary scarab
#

🀷

#
public void run() {        
    try {
        DataInputStream packetIn = new DataInputStream(socket.getInputStream());
        DataOutputStream packetOut = new DataOutputStream(socket.getOutputStream());
            
        handlePacket(packetIn, packetOut);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

private void handlePacket(DataInputStream in, DataOutputStream out) {
    try {
        int packetSize = in.readByte();
        //int packetSize = in.readInt();
        //int packetSize = varMethods.readVarInt(in);
        int packetId = varMethods.readVarInt(in);
        Output.debug("Handling packet [id:"+packetId+", size:"+packetSize+"]...");
        switch(packetId) {
        case 0:
            handlePing(in, out, packetSize, packetId);
            break;
        case 1:
            handlePong(in, out, packetSize, packetId);
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
```How is this outputting `[DEBUGGING] Handling packet [id:1, size:-2]...`
minor summit
#

I believe packet size is a varint, not a byte?

hoary scarab
minor summit
#

According to wiki.vg both packet size and id are varints so idk

hoary scarab
minor summit
#

assuming no compression

#

but by that stage it can't really be compressed

shell moon
#

To play a custom sound for a player is it necessary to specify the Sound category in
Player#playSound(Location,String,SoundCategory,volume,pitch) or
Player#playSound(Location,String,volume,pitch) can be used (even if category is specified in the custom sound file)?

minor summit
#

I mean it's not necessary but like if you're playing mob sounds from an NPC perhaps put it in the animal or mob category

hoary scarab
#
int packetSize = <>;
Output.debug("Handling packet [id:"+packetId+", size:"+packetSize+"]...");

int packetSize = in.readByte(); -> Handling packet [id:0, size:16]...
int packetSize = in.readInt(); -> Handling packet [id:9, size:268499205]...
int packetSize = varMethods.readVarInt(in); -> Handling packet [id:0, size:16]...

#

When it proceeds to the "pong" packet using varInt or readInt it makes the packetId something other then 0 or 1

minor summit
#

what does it do when read as varint

dense drift
shell moon
#

i mean because im just adding a method so it can play custom sounds (in my plugin)

hoary scarab
shell moon
#

and i cannot set a category since that depends on the custom sound file in the resource pack

dense drift
#

Alonso, have you heard of adventure?

shell moon
dense drift
#

I guess that is a no

#

now you did

minor summit
#

I mean, what does it do to the packet id when you read both the size and id as varint

shell moon
#

i dont want to update my plugin when a new version appears

#

thats why i dont use it (well, one of the reasons)

dense drift
#

how do you plan to support custom sounds then?

shell moon
#

isn't player#playSound(Location,String,volume,pitch) a thing?

hoary scarab
minor summit
#

you don't have to update your plugin on every library update lol

dense drift
#

d;player#playsound

uneven lanternBOT
#
void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch)```
Description:

Play a sound for a player at the location.

This function will fail silently if Location or Sound are null. No sound will be heard by the player if their client does not have the respective sound for the value passed.

Parameters:

location - the location to play the sound
sound - the internal sound name to play
volume - the volume of the sound
pitch - the pitch of the sound

shell moon
dense drift
#

ah I think you can get it by name ig

pulsar ferry
#

You just need to pass the string of the sound

shell moon
#

the sound category if the custom sound files

#

has a category specified or not

dense drift
#

give it a try ig

#

i just let my users specify their own category

shell moon
#

sadly i know nothing about custom resource packs

shell moon
dense drift
shell moon
#

I read a post with an example

#

the question was like, if a custom sound has a category specified (like in this case "hostile")

#

the code used must specify the category too?

#

or simply the name is enough

#

void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch)

hoary scarab
#

@minor summit https://pastebin.com/fLybLVWd Here is the updated class. (With all comments from debugging removed lol)
Server Output;```
[INFORMATION] Initializing ConnectionBase... (Port: 25569)
[INFORMATION] Initialized ServerSocket
[DEBUGGING] PingRequest [Recieved] >> 127.0.0.1
[DEBUGGING] Handling packet [id:0, size:16]...
[DEBUGGING] Handling ping...
[DEBUGGING] Buffer: 9999 SLM Size: 716
[DEBUGGING] PingRequest [Recieved] >> 127.0.0.1
[DEBUGGING] Handling packet [id:122, size:254]...

Minecraft (Client log);```
[08:00:08] [Render thread/ERROR]: Can't ping localhost:25569: Finished
dense drift
#

yes I understand your question, theoretically it should use the custom category, but is spigot we are talking about, so it is better to double check it

shell moon
#

mmm, the example uses the command

/playsound yoursound:example.sound.name_1 hostile YourUsername

#

but the file doesnt have a category

#

{
"example.sound.name_1": {
"sounds": [
"whatever/path/example_1"
]
},

#

i guess i'll have to find someone to test it

dense drift
#

yeah but the example with category has id 3

#

scroll down alonso

#

sound.name_3 has a category set

shell moon
#

yeah, i know but no the _1 or _2

#

and thats after they use the command

#

so wonder how the hell it works

#

i just wanna know if i need to specify it or not xd

#

well, time to find someone to test it

slate mirage
#

Hello, I am using Guilds, but I type /guilds memeber only can display 54 players

#

/guilds memeber 2 is not work

dense drift
slate mirage
#

Ok thanks

hoary scarab
minor summit
#

I am a bit confused, packet sizes don't really correspond to the IDs for the ping/status ones, where are you handling the handshake packet?

hoary scarab
minor summit
#

Before either the ping or status packets, the handshake packet is to be handled

#

The client tells the server through handshake what the next "handling state" is (status state or login state)

hoary scarab
#

That might be the issue then. I thought the handshake wasn't passed if the server list ping was being passed.

#

I'll do some more testing when I get home.

stuck hearth
hoary scarab
#

So "Handshake" says no client bound packet... So what would be the response?

minor summit
#

there is no response, it's an immediate state switch to either status or login states

#

it's more like "hi, i am a client, I want to login/retrieve status", and so the server prepares itself accordingly to respond to the following packets

hoary scarab
#

Ok so I was correct in sending the json message?

hoary scarab
#
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
Output.debug(reader.toString());
StringBuilder sb = new StringBuilder();
String current;
            
while((current = reader.readLine()) != null) {
    sb.append(current);
    Output.debug(current);
}
            
Output.debug("Protocol: "+protocolVersion+" | "+sb.toString());
reader.close();
```Why is the `current` not outputting and the while is never exited?
tight junco
#

i could be reading this wrong but

#
  • doesnt assign current to literally anything
  • why isnt current outputting
#

wait

#

i am reading it wrong

#

uh skill issue i believe

#

maybe reader.readLine() is empty shrug

minor summit
#

uh

#

is in the input stream from the socket?

#

'cause i don't think that would work? the protocol isn't exactly composed of newline-separated chunks

hoary scarab
#

Ill check for empty as well as null then

#

Even with !.isEmpty it won't get passed the while loop

#

Exception in thread "Request Reciever Thread (25569)" java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because the return value of "java.io.BufferedReader.readLine()" is null lol so it is null

tight junco
#

ima assume you did != null && !isEmpty

hoary scarab
#

yeap

#

and just .isEmpty()

#

So I'm trying to read the handshake packet but if I have to read all bytes to get the address/port how can I read the final byte (status or login) using the varInt method? Because I only see readFully().

midnight viper
#

how can i make my own custom placeholder and add into server?

lyric gyro
#

I dont know if this is the right channel but I need help with skript could someone help me make a gui for papermc 1.19.3 all the ones I tried dont work

dusky harness
#

or doesn't skript have a discord server?

lyric gyro
river solstice
#

Skript πŸ’€

#

You're in the wrong neighborhood

forest jay
#

Hello! I am working on my Dialogue system, and I have a NPC who tells you your resources. I want each resource and its corresponding value to be inline, and an equal space from the next one. Currently, I am getting this. In production there will be spaces, but for debugging I put a , for when it adds a space to counteract the number of characters, and then . for when it adds 2 spaces at the end of a resource (in case a resource is the max amount of allowed characters).

#

Currently, the first line of silk is offset by two spaces, and I am not sure why. The last line is also weird, and I am not sure why as well. It might be the fact that it is periods and commas instead of spaces. This is the code I am using to achieve this, is there something noticeably wrong that I am doing? ```java
String toAdd = ChatColor.GRAY + key + ": " + ChatColor.GOLD + ChatUtils.convertLongToFormattedLong((long) value); // TODO ADD SUPPORT FOR DOUBLES AND LONGS

System.out.println(ChatColor.stripColor(toAdd) + ": " + ChatColor.stripColor(toAdd).length() + ", " + (19 - ChatColor.stripColor(toAdd).length()));

toAdd += ",".repeat(19 - ChatColor.stripColor(toAdd).length());
// treasury is a list strings of what to send the player, with each line being a value in the list.
treasury.set(page.get(), treasury.get(page.get()) + toAdd + "..");

#

The println prints what is expected, but it still is offset for some reason.

forest jay
# dusky harness mc font is not monospaced

I didnt know that would have such a significant effect. I am planning on using unicode to make my own characters. It might be becuase silk has 3 characters that are vertical lines (or similar).

dusky harness
#

wait

#

i might've misunderstood

#

yeah I'm confused

forest jay
#

so am I lol

dusky harness
#

no I mean I'm confused on the issue

#

also note that your custom font would have to be monospaced or else you could run issues like this:
a |
A |
a |
It's impossible to line the | up with the A and a (first line has 11 spaces, second & third lines have 10 spaces)

forest jay
#

I understand that and I am ok with a little misalignment, just not 2 whole spaces.

forest jay
dusky harness
#

i think it's a monospacing issue

#

although thats pretty big

#

Β―_(ツ)_/Β―

forest jay
#

I want it to show this```
silk: 0 fur: 0
glass: 0 lumber: 0
spice: 0 ruby: 0

dusky harness
#

silk: 0 fur: 0
glass: 0 lumber: 0
spice: 0 ruby: 0

#

even discord shows it offset

forest jay
#

the different is in the spacing between silk and fur

dusky harness
#

because silk has i and l which are very very thin

forest jay
#

but my code should account for everything except the monospacing since silk is 1 character less than the others, it should have 1 more space.

#

Oh wait, yours is spaced like that

#

you have that accounted for.

dusky harness
#

yes
monospacing affects it by a lot

forest jay
#

@dusky harness look at this, it is more than monospaced

dusky harness
#

the . have to be monospaced too

#

along with the 0 (well it doesn't really matter here bc they're all 0)

forest jay
#

the 2nd one on the right should be aligned with the ones below it. there is something wrong witht he code

forest jay
dusky harness
dusky harness
#

2nd one?

#

it is aligned, no?

#

the first one is missing a box so that's expected to not be aligned but the rest are aligned

forest jay
#

that is the point of the code

dusky harness
forest jay
#

its what this line does

toAdd += ".".repeat(19 - ChatColor.stripColor(toAdd).length());
#

wait so, one . is different than another .?

#

the first two lines are identical (text wise) besides the number of characters

dusky harness
#

replace . with the box

forest jay
#

oh yeah

#

lol

#

my brain is not working today

#

I understand what you mean

#

when I add/remove a period, it isnt big enough to counteract the lost/gained character

dusky harness
#

or else it's gonna be misaligned

forest jay
#

yeah

molten wagon
#

Hi, I wonder how others do to access the main class in a api?
See some use refection to set the instance to main class in a static field (other ways Is use same path as the main class has). Is it a better way to do it?

proud pebble
#

adding the main class as a parameter of the constructor

#

your not supposed to do the static instance of the main class as thats a bad practise

#

but sometimes its less messy

#

or can be

dense drift
#

Depends what the api does I guess? For example, for spigot id use the service system thing, instead of static access

molten wagon
dusk schooner
#

Why with the placeholderAPI plugin my ./hub no longer works

molten wagon
stuck hearth
#

Singleton moment

molten wagon
# proud pebble adding the main class as a parameter of the constructor

That sound like interesting approach (will look on that, if I use that way I hope not they try use the constructor also πŸ˜› (they could not also make new instance of the class)). I think on setter approach also (but I scratch that idea, because someone can be stupid and try use that).

molten wagon
# stuck hearth Singleton moment

yeah main class are almost as a Singleton class , but at the same time not (according to several google result). So can't confirm what that really fit πŸ˜„

molten wagon
dusk schooner
#

no you misunderstood the question

#

when I do the command ./hub in the minecraft chat it doesn't work with the plugin

molten wagon
dusk schooner
#

plugin support

molten wagon
#

Also you should provide more info about were this hub command is from. I not think that command exist in placeholder-api, if i'm not remember wrong.

icy shadow
molten wagon
icy shadow
#

just use service manager or a static getter tbh

#

although im still not entirely sure what you're actually talking about lmao

river solstice
#
    private final Map<UUID, Map<LevelType, Integer>> cachedLevels = new HashMap<>();

    public boolean addExperience(Player p, long amount, LevelType... types) {
        Map<LevelType, Long> currentExperiences = this.experiences.getOrDefault(p.getUniqueId(), Collections.emptyMap());
        
        List.of(types).forEach(type -> {
            int currentLevel = getLevel(p.getUniqueId());

            long newXP = currentExperiences.getOrDefault(type, 0L) + amount;
            
            currentExperiences.put(type, newXP);

            this.experiences.put(p.getUniqueId(), currentExperiences);
        });

        return true; // TODO
    }
}

odd question.
If I I update the map (currentExperiences.put ...), do I have to update the original map where I pulled it out from?

#

or in this use case since it's getOrDefault I have to put it in the original map regardless?

dusky harness
#

Not getOrDefault

river solstice
#

first time I hear about computeIfAbsent lol

molten wagon
river solstice
#

so if it's empty, then it will set it to the value I provide? that's how computeIfAbsent works?

#

okay, well, i read the docs, I think I understood

icy shadow
#

if it's empty it computes a new value and puts it

#

so yes

molten wagon
stuck hearth
#

You only want a single instance of the class?

#

Singleton 😌

molten wagon
#

I only see one or two examples others use the api in there plugin (one use reflection to set the field).

molten wagon
wary spindle
#

Hey

torpid raft
#

hay 🐎

wary spindle
#

Can someone help me with a plugin fork made by me not compiling?

torpid raft
#

was it compiling before you made changes to it?

wary spindle
#

Yeah

#

ERROR: incompatible types: java.lang.String cannot be converted to org.bukkit.entity.Player

torpid raft
#

sounds like you're trying to coerce a String into a Player object

#

post the line the error points to

wary spindle
#

I can give you the code

#

And i got it from another part of the plugin

torpid raft
#

dont post all of it just the part the error references

wary spindle
#

Which i got it from

#

But works fine

#

.add("{target_ping}", BukkitReflection.getPing(target.getName()))

#

That's the faulty line

#

got it from this:

#

.replace("{player-ping}", String.valueOf(BukkitReflection.getPing(player)))

torpid raft
#

looks like getPing accepts a player object as a parameter

#

not a string object

#

so remove your .getName() call

wary spindle
#

ty!

#

If it works, I'm going to let you know.

torpid raft
#

sounds good

wary spindle
#

Now this appears:

#

/home/runner/work/Practice/Practice/src/main/java/rip/crystal/practice/match/duel/DuelProcedure.java:[58,80] cannot find symbol
Error: symbol: method target()
Error: location: class rip.crystal.practice.match.duel.DuelProcedure

torpid raft
#

post the code you just changed as it is now

wary spindle
#

.add("{target_ping}", BukkitReflection.getPing(target()))

#

wait

#

I changed it to .add("{target_ping}", BukkitReflection.getPing(target))
now

#

i have to go

torpid raft
#

ok

worn jasper
#

Kinda need help with gradle stuff lol... getting this error, is it because it isn't getting the java?

#

I am quite confused

#

trying to build a normal java app with gradle

trail burrow
#

I run mvn complie and it don't create the jar, what am I doing wrong?

dusky harness
#

or mvn clean package

trail burrow
#

still nothing, I have not worked with this plugin for a few years

signal grove
#

does it give an error

dusky harness
#

the command is supposed to work so we need more info

trail burrow
dusky harness
#

there's no jar in Main\target?

trail burrow
#

yes thats been my issue

trail burrow
#

can anyone refresh my memory of what this line does? LocalDateTime.ofInstant(Instant.ofEpochMilli(firstPlayed), ZoneId.systemDefault());

stuck hearth
#

Gets the localdatetime of an instant and uses the timezone of the system I think

trail burrow
#

ok, thats what I thought, I'm looking for a line that gets first login date for a player

turbid hemlock
#

Is there anyway to cut bStats from PlaceholderAPI specifically for me????

edgy lintel
#

lmao why would you ever want bstats cut

turbid hemlock
#

I can't stand it, I downloaded the oldest version of the Placeholder API, and there it is also present, how do I get rid of it????

edgy lintel
#

like you dont want your server versions and player statistics leaked out?

#

its anonymous tho

robust crow
#

You can disable bstats from the bstats folder

#

(as pictured above)

edgy lintel
turbid hemlock
#

In my case, I need her not to appear at all

robust crow
#

Yeah if you toggle it off it won't send anything

turbid hemlock
#

I run the server remotely from a USB drive with a read speed of less than 1 megabyte, and every file that appears is important to me

edgy lintel
#

ahh...what?

turbid hemlock
#

how can I remove the appearance of the PluginMetrics folder due to PlaceholderAPI????

robust crow
#

If it's critical you could compile your own version of PlaceholderAPI that doesn't include bstats as it's open source

#

But that can be quite advanced for beginners.

turbid hemlock
# edgy lintel ahh...what?

It sounds very strange, but it works, and every file, whether it's a folder, it really aggravates the situation, so I try to use everything I need for me.

torpid raft
jade wave
#

Yup that sounds like it

torpid raft
#

silly πŸ˜”

unborn ivy
#

the bstats folder can’t be deleted

turbid hemlock
#

It's really nice to the eye

torpid raft
#

i see

#

well if you did it then more power to ya

#

but frankly that folder will have exactly 0 impact on performance regardless of what storage media you use or what the transfer rate is

turbid hemlock
#

But the eye is happy)))

torpid raft
#

russian?

turbid hemlock
#

yes

torpid raft
#

me too πŸ‘

turbid hemlock
#

ΠžΡ‚Π»ΠΈΡ‡Π½ΠΎ! 🎰

bronze linden
#

I'm a web3 full stack developer with 7+ years of experience in full stack development and 3 years of web3 experience. Currently looking for job.

torpid raft
warm steppe
#

Hello. So I got this regex problem. I need to group player name and message in two separate groups, but i have many possible ways that player chat string could look like.

Currently I have: ^\[\#\d?\] *.*\s.* (.*) \Β» (.*)$
That does: https://i.imgur.com/Fgis3Hi.png

Test strings:

[#] 㐕 Uzkuri [BOOMER] Β» asd
[#] 㐕 Uzkuri Β» asd
[#] Uzkuri [BOOMER] Β» asd
[#] Uzkuri Β» asd

[#1] 㐕 Uzkuri [BOOMER] Β» asd
[#1] 㐕 Uzkuri Β» asd
[#1] Uzkuri [BOOMER] Β» asd
[#1] Uzkuri Β» asd
#

Uzkuri is name of the player and asd is their message

#

I dont really understand on how to make regex ignore the [BOOMER] tag...

#

Ideally i'd have only 2 groups

dense drift
#

([\w_]{3,16}) .+ <arrow thing> (.*) maybe smth like this?

warm steppe
dusky harness
#

@warm steppe wb (\w{3,16})(?: (?:.+)|) Β» (.*)

#

its just gaby's regex but an | to match either the [stuff] or nothing (whereas gaby's required the [stuff])

#

group 1 = username
group 2 = message

warm steppe
#

i also see the non-capturing group

#

that's new to me, but seems very handing

signal grove
mystic gull
#

Hello in a Inventory menu, should i put tags on items to listen or only their name and check if the click from this inv ? Bcz when i use f3 + H in servers they don't seem to add tags

forest jay
#

How can I paste a schematic (WorldEdit) on top of existing blocks not get things like lanterns to drop their items?

forest jay
dusky harness
#

TriumphGUI 😌

proud pebble
sour apex
#

need help

#

how do i add a permission

#

like

#

make it so u need a certain permission to be able to click on a button in my gui

#

e.g. if i make a gui using deluxemenus and i want to click on an item for it to claim a kit, however if you haven't got a certain permission, you can not claim the kit

dark garnet
#

HELLO, i need help with some worldedit stuff yeah yeah
i have 2 CuboidRegions (region1 and region2). i want to copy all the blocks with a certain material from region1 into region2 in the same positions (assuming the regions are the same size)
how can i do this? could i get the centers of both of them and find the difference between them, then loop thru blocks of region1, applying the difference to each block?

fiery pollen
#

Yeah, I would get the center of both regions and just have a xOffSet, yOffSet and zOffSet for each block from the center. And then apply difference later using the offsets

dark garnet
signal grove
#

why would you use the center instead of one corner

dark garnet
signal grove
#

if one corner is the same, and they are the same size, then the regions are both exactly the same

dark garnet
signal grove
#

yeah, but you're not picking an arbitrary corner, pick like "north east" corner of both regions

dark garnet
#

i c

signal grove
#

then make your offsets relative to that specific corner

#

you won't need to worry about rounding if the size is uneven

hoary scarab
#

So I'm pretty sure this has been my issue with packets...

Why does the ping packet come in like this?

#

And not the normal
Size,ID,Data?

forest jay
#

I have a class, and then a bunch that extend it and provide modifications. How can I check if it is the plain class and not one of the modified extended classes?

stuck hearth
hoary scarab
#

Its 1.19.3 though...

stuck hearth
#

Oh, if the client doesn't receive a properly formatted response then it will try a legacy ping (1.6 protocol)

hoary scarab
#

Hmmmm

#

Back to debugging the json message I guess

sharp hemlock
#

i eat code for dinner

tight junco
#

eat deez fuckin nuts

stuck hearth
#

Do you like print it out and eat it as paper, or?

signal grove
#

although if you need to do that, there’s probably a design flaw in your oop

#

you should instead call overridden methods that differ per subclass

hoary scarab
#

Is this json invalid for use in the status packet?
{"version":{"name":"1.19.3_Beta-0.0.1","protocol":761},"players":{"max":100,"online":1,"sample":[{"name":"yapperyapps","id":"8e73185f-845c-4336-86f6-b9c5d475e6fd"}]},"description":{"text":"1.19.3 Beta"},"favicon":"data:image/png;base64,","previewsChat":true,"enforcesSecureChat":true}

stuck hearth
#

Maybe the favicon entry? Looks like it's missing info

hoary scarab
#

Could be. just says base64 to path of file

#

Even with that info doesn't work

stuck hearth
#

I don't think it's a path, I think it's the image encoded at base64 isn't it?

hoary scarab
#

Even with an image converted to base64 it doesn't work. Same issues occurs. (Attempts 1.6 ping)

stuck hearth
#

Hm, I dunno then. The output looks right compared to the one on Wiki.vg (outside of the favicon thing that I presume you fixed)

hoary scarab
#

Yeah can't find the default one though was trying to test with that as well.

#

Will try again when I get on my pc

stuck hearth
#

I wonder if the name should just be 1.19.3 instead of 1.19.3_Beta.xxx

hoary scarab
#

Maybe. Will try that to later.

icy shadow
#

name doesn't matter

#

the client doesn't care about that

#

the data itself looks fine, make sure you're sending it properly

#

i.e. prefixed with length and with all the right packet metadata

stuck hearth
#

If the client doesn't care why is it even there 😦

forest jay
signal grove
#

if they are empty, perhaps it should be abstract class or an interface

#

this will force instantiation

forest jay
#

it was an abstract, but I wanted to access the data, and didnt feel like making a class that has nothing in it that is just a "empty class" since it has nothing different than the blank class it extends.

signal grove
#

you can access the data with getters, no?

forest jay
#

I could, but if it was abstract it wouldnt be able to stand on its own

#

I already tried that and IntelliJ yelled at me

signal grove
#

thats the goal, is there a need to have a non-specific implementation of the class?

#

otherwise you should force objects to be initialized as subclasses

forest jay
#

They are plots, and the plain plot class just holds the location information and such, and then each extending class is for things like a lumber mill, or a mine. I am using the plain plots as a location holder to symbolize an empty plot in the grid. I need them to be there holding information to check when things go in and out of them.

forest jay
signal grove
#

ok so you should have a base class called "Plot" or something, and implement the methods for getLocation() and all the shared information

#

then define abstract methods for anything specific to MinePlot or LumberPlot

forest jay
#

but I am going to have 150+ plots

#

I dont have abstract methods on the Plot class for all of those

signal grove
#

150+ plots, or 150+ plot types?

forest jay
#

plot types

#

currently the mine plots and lumber plots handle everything on their own, and I just check if they are an instance before I interact with them.

signal grove
#

abstract methods are ones that should be different for each subclass

signal grove
forest jay
#

well, I share the information through the Plot class constructor

forest jay
#

Do you want code examples?

signal grove
#

yeah

#

do you really need 150+ implementations of Plot?

#

i can't imagine that so many behaviors will differ

forest jay
#

my brain is not working that well today lol. I will probably have like 50 implementations. I also have various implementations of Plot that are abstract as well, like some have stuff for the plots that generate resources, and others have stuff for the plots that have dynamic buildings and stuff

#

here is my plot class

signal grove
#

ok, so will there be objects of the base type Plot at all? or will they always be subtypes like MinePlot

forest jay
#

pretty much all subtypes

#

I was only using the Plot class as a placeholder

signal grove
#

ok, you should make it abstract class then

#

or an interface, i havent bothered much to learn the best use-cases for them but im sure everything is possible using either

forest jay
#

Yeah, I just didn't feel like making a whole subclass just for an empty plot, since it would contain nothing more than what it extends but I guess that is what needs to happen for the structure to make sense

dusky harness
signal grove
#

ah ok, what is an example of a feature from abstract classes, that interfaces wont have?

dusky harness
#

Interfaces do not have any implementations

minor summit
#

conceptually, interfaces are more of a "contract" than anything else, "here is what this type is capable of doing, here is how you operate with it", but how it does what it does is not (or should not) be relevant (so called implementation detail), so long as the impl complies with the interface contract and you are aware of it

dusky harness
#

Yea

minor summit
#

abstract classes are more like unfinished classes, they might do some operations, have methods with working implementations, but they can have abstract methods (unimplemented methods) for subclasses to "fill in the blanks" and complete some functionality

signal grove
#

ok, but if you want to use polymorphism than arent abstract classes the better option?

icy shadow
#

not necessarily

signal grove
#

the only option?*

icy shadow
#

interfaces are "more" polymorphic than ac's

minor summit
#

polymorphism can, ironically, take many forms, not just through inheritance

icy shadow
#

umm that's not ironic it's apropos πŸ€“ πŸ€“

icy shadow
# icy shadow interfaces are "more" polymorphic than ac's

from wikipedia:

Interfaces are used to encode similarities which the classes of various types share, but do not necessarily constitute a class relationship. For instance, a human and a parrot can both whistle; however, it would not make sense to represent Humans and Parrots as subclasses of a Whistler class. Rather they most likely be subclasses of an Animal class (likely with intermediate classes), but both would implement the Whistler interface.

having a Whistler interface gives you far more flexibility of polymorphism than a pure parent-child relationship would

signal grove
#

so then interfaces can be like characteristics of a class

minor summit
#

Picture this scenario:
I make a plugin that stores some kind of player data, and I want the user to have the ability to choose what kind of storage my plugin uses (mysql, mongodb, sqlite, ...)
Then my plugin would have some Storage interface that defines the contract of what methods it has and what they do (savePlayerData, loadPlayerData, deletePlayer... etc)
Then from that interface I create many implementations, one for each storage method (MySQLStorage, SQLiteStorage, MongoDBStorage etc), those are concrete classes

Overall, the plugin works with the single Storage interface, it is abstract, but the underlying implementation is one specific kind of storage (since there are many implementations, it can take many forms)

#

mongodatabase

icy shadow
#

mongodatabase

dusky harness
#

Mongodatabase

icy shadow
signal grove
#

ok, and that makes it so they dont need to directly descend from it

#

thanks

icy shadow
#

i mean

#

there is still a hierarchy

#

honestly tldr is use interfaces unless you specifically need it to be an abstract class (having certain fields / constructors / methods implemented)

icy shadow
#

can you quote that again?

dusky harness
minor summit
#

πŸ€“

signal grove
#

hmm. what do i do if i require features of an abstract class

icy shadow
#

use... an abstract class?

#

theyre not illegal

signal grove
stuck hearth
#

Remember when discord added in this sorry excuse for a quote

tired olive
#

Mixin-based inheritance would encourage the same coupling even more

#

Also single inheritance increases performance by allowing invokevirtual calls instead of invokeinterface

minor summit
#

any performance increase is literally unmeasurable

#

unless the entirety of the jvm runs in interpreter mode by disabling compilers

#

which is a very dumbass move

icy shadow
#

They should remove inheritance entirely

#

That would be good I think

dusty frost
#

jvm trait system when?!?!