#help-development

1 messages · Page 503 of 1

young knoll
#

:p

exotic zinc
#

what

tall furnace
#

Useful info: When running your server, it now unpacks the libraries it uses into a folder so you can just grab the version of Apache Lang (or whatever you want) that Spigot is using without having to look for the jar online

#

Snakeyaml for instance gets unpacked into the folder. It's great.

exotic zinc
#

you can also download the javadoc with maven if you decide to use maven

young knoll
#

Sure but why would you need the jar

tall furnace
young knoll
#

Why would you need the jar of the dependencies

tall furnace
#

Well, if you need to use StringUtils for a bunch of stuff, that is available with Lang. If you want to use YAML for a bunch of stuff, snakeYaml is right there available.

#

I guess alot of people here don't code outside of spigot though

young knoll
#

True but if you want to use other dependencies you probably should be using a build tool

tall furnace
#

Depends on if it's a proper project or if it's a distraction-type side-chick of a project that you're doing out of curiosity and procrastination

livid elbow
#

Vaggos22 just create something unique or search good plugin ideas

tall furnace
#

Or take an existing idea and just make it yourself. Excellent practice.

#

Also that way you get to customize everything

livid elbow
#

ye kinda forgot about that

#

but ye it is for sure a exellent practice

tall furnace
#

I'm making a currency plugin, a chest-shop plugin, a cobblestone-ore generator plugin, and a skyblock plugin simultaneously. I have a hard time doing one thing at a time.

weak bear
#

can we help me pls I have a NullPointerException
final DbConnection dbConnection = loginFactionPlugin.getDatabaseManager().getDbConnection();

#

import java.sql.SQLException;

public class DatabaseManager {
    private DbConnection dbConnection;

    public DatabaseManager(){
        System.out.println("Mysql co");
        this.dbConnection = new DbConnection(new DbCredentials("localhost", "root", "", "faction", 3306));
        System.out.println(dbConnection);
    }

    public void close(){
        try {
            this.dbConnection.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public DbConnection getDbConnection() {
        return dbConnection;
    }
}```
#

Here is my DatabaseManager Class

exotic zinc
#

and you open the connection?

weak bear
#

yes my database is connected

#

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;

public class DbConnection {
    private DbCredentials dbCredentials;
    private Connection connection;

    public DbConnection(DbCredentials dbCredentials){
        this.dbCredentials = dbCredentials;
        this.connect();
    }

    private void connect(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            this.connection = DriverManager.getConnection(this.dbCredentials.toURI(), this.dbCredentials.getUser(), this.dbCredentials.getPass());

            Logger.getLogger("Minecraft").info("Successfully connected to DB.");
        } catch (SQLException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public void close() throws SQLException {
        if(this.connection != null) {
           if(!this.connection.isClosed()){
               this.connection.close();
           }
        }
    }

    public Connection getConnection() throws SQLException {
        if(this.connection != null){
            if(!this.connection.isClosed()){
                return this.connection;
            }
        }
        connect();
        return this.connection;
    }
}```
#

is my DatabaseConnection

remote swallow
#

dont use minecrafts logger, and you are prob better using hikaricp

weak bear
#

Okay so you think that can be better with HikariCP?

#

but do you have a request for resolve the problem ?

remote swallow
#

its a lot better setup and you dont need to include a driver

little panther
#

Hello, im getting an error when im trying to start my plugin. Is someone able to help?
error: https://pastebin.com/rimn42qT
Main-class: https://pastebin.com/Tjyq3fsc

#

should be another class

#

oh alright. that helps

#

thanks for now

pseudo hazel
#

does anyone know im I am allowed to use minecraft textures/models in a web editor for my plugin?

eternal oxide
#

no

#

you can use images you create .

pseudo hazel
#

okay that's too bad

#

understandable but oh well

#

i guess I wont make a web editor 😛

tardy delta
#

bruh last time i use gradle

sterile token
young knoll
#

What

#

Why did you give them an email

sterile token
exotic zinc
#

when?

#

i just downloaded gradle 8.1.1 like 2 days ago

sterile token
#

oh weird, in my case its asked to signup, like doesn Java for downloading Jdk's

exotic zinc
#

where do you donwload gradle from?

sterile token
exotic zinc
#

`?

sterile token
#

oh no its was diff

young knoll
#

Yeah I’ve never given gradle an email

tardy delta
#

dunno what they needed it for but it seems it was required or i wouldnt have done it

#

damn gmails ui looks still that outdated like 10 years ago

rough ibex
#

not for me

#

what does it look like to you

soft hound
#

Okay so I need some help from you guys, is it possible to connect to a server with a .jar file, something similar to an afk client?

#

I know this is not spigot related, but I couldn't find anything.

tardy delta
#

well when going into settings actually

#

looks like the html i write in college

soft hound
#

Something like an AFK client, where you just put your email/password into a config.yml and it logs into a server.

exotic zinc
#

so basically you want to hack?

sterile token
#

Maybe he wants to do what i was planning, creating a real fake client which stays afk for the reason of plugin messaging channel, so then it doesnt sucks telling theres no online players - Hahaha

little panther
quaint mantle
little panther
quaint mantle
#

Command does not exist

#

That yo tried to dispatch

tardy delta
#

what happened again with emails and passwords in a text file hmm?

young knoll
#

Wut

jagged bobcat
#

How could I make it so player can continue flying after switching to survival from creative. This isn't working

    @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
    public void onGamemodeChange(PlayerGameModeChangeEvent event){
        event.getPlayer().setAllowFlight(true);
        event.getPlayer().setFlying(true);
    }
young knoll
#

Try delaying it a tick

jagged bobcat
#

kk

jagged bobcat
arctic shuttle
#

I was wondering if someone could help me code something?

exotic zinc
#

what

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!

arctic shuttle
#

?ask

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!

exotic zinc
#

ask what you want

arctic shuttle
#

?ask help coding

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!

exotic zinc
#

NO

#

just ask your questiopn

#

without the stupid command

arctic shuttle
#

?ask coding a /withdraw command

exotic zinc
#

tell us what you are looking for

arctic shuttle
#

?ask coding a /withdraw command

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!

arctic shuttle
#

Ok

exotic zinc
#

why is it so hard to understand?

sterile token
arctic shuttle
#

Not that good

rough ibex
#

what does this /withdraw command do

exotic zinc
#

i think he wants us to code it

arctic shuttle
#

Withdraws attack dmge

arctic shuttle
sterile token
exotic zinc
#

do you already have a code?

sterile token
#

We cant help you if we dont know if you know how to code

arctic shuttle
#

Its when you kill someone you get +1 atk dmge

#

I was trying to make a command to withdraw strength

sterile token
sterile token
#

right, let start from begining

#

I suppouse you already learnt java Âż?

arctic shuttle
#

I have

#

I have a plugin to work with

orchid trout
#

đŸ„°

sterile token
#

right

#

So whats exactly yo uare trying to do

#

You want to get help about coding smth?

arctic shuttle
#

Make a /withdraw command to withdraw attack damage

arctic shuttle
sterile token
#

perfect

orchid trout
#

learn java -> learn spigot api

#

youtube videos

arctic shuttle
#

k

orchid trout
#

i watched kody simpson

sterile token
orchid trout
#

he has to learn the spigot api too

rough ibex
#

it's not rude

sterile token
arctic shuttle
arctic shuttle
rough ibex
#

knowing how to code != knowing every API

#

he should be familiar with spigot methods

sterile token
#

If you havent code anything, first steap is learning how to code in plain Java. Then learn how to use apis or libraries

arctic shuttle
#

Ty lemme try

kind hatch
#

What do you have so far?

#

?paste code

sterile token
undone axleBOT
vivid skiff
#

How can i change a player vision with the enderman vision in nms?

rough ibex
#

enderman vision is through a shader

#

i'm not sure you can

#

since I believe those shaders are loaded client side and there's no server packet for it

young knoll
#

You could force them to spectate an invisible enderman I guess

vivid skiff
rough ibex
#

then find those plugins and look at their source

rough ibex
brave sparrow
#

they won't be able to move/look around though

#

since they're spectating an entity

orchid trout
#

jail

young knoll
#

Ender jail

rough ibex
#

condemned to being an enderman

#

not that bad

#

just extremely hydrophobic and non confrontational

vivid skiff
brave sparrow
orchid trout
#

ok, alex

weak bear
#

Do you know why I have this error ?

#

org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/zaxxer/hikari/HikariDataSource

#

I try to compile hikariCP in my plugins but it doesnt work

#

dependencies {
compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation("com.zaxxer:HikariCP:5.0.1")
}

exotic zinc
#

did you provide a scope?

#

ah gradle

weak bear
#

yes

#

but it wont to be add on my plugin

remote swallow
#

dont use the jar, its on maven central iirc

weak bear
#

I dont use the jar

#

I use implementation("com.zaxxer:HikariCP:5.0.1")

#

in gradle

exotic zinc
#

they are using central

weak bear
#

what's that?

exotic zinc
#

can you decompile the jar?

#

or wait

weak bear
#

I don't have the jar

exotic zinc
#

do you have multiple jars in the build folder?

weak bear
#

no I just have my plugin in libs/

exotic zinc
#

what

#

ah yeah

#

ok

#

build/libs/

weak bear
#

yes

#

I dont know how can I add HikariCP on my plugin

young knoll
#

Use the shadow gradle plugin

#

Or the spigot libraries feature

weak bear
#

How? can you explain pls

young knoll
weak bear
#

ok so what I can do for implement Hikari CP in my plugin

exotic zinc
weak bear
#
    id 'java'
}

group = 'fr.spectr2155e'
version = '1.0'

repositories {
    mavenCentral()
    maven {
        name = "spigotmc-repo"
        url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
}

dependencies {
    compileOnly "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation("com.zaxxer:HikariCP:5.0.1")
}

def targetJavaVersion = 8
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}```
#

Here is my build.gradle

exotic zinc
#

question

weak bear
#

How I can do for implement hikari CP while using shadowJar

exotic zinc
#

why do you use gradle if you don't know how to use it. If you want to start with developing use maven. its easier to understand and iirc you don't have to worry about shading since the plugin is added automatically by the intellij plugin.

young knoll
#

Fairly sure all you need to do is add the plugin and then run gradle shadowJar

exotic zinc
#

probably

timber mural
#

bruh why am i not able to send images here

exotic zinc
#

but don't use gradle if you don't know how to use it and if you are clearly not willingly to learn groovy/kotlin. If you want to use a builds stem then use maven. It does its job for small plugins

remote swallow
#

no verified

timber mural
#

Alright so i have a question, how to get all of 3x2 empty spaces in radius of 50 and spawn a mob in the center of them?

young knoll
#

Ideally you’d cache them

#

Because scanning for them won’t be fast

timber mural
#

i dont care honestly

#

i'm sure it won't take 1 hour

young knoll
#

Well you’d have to scan every block in that radius, if it’s air then check if it’s the right shape/size and then spawn the mob

#

Of course you can do some optimization

#

Since you are looking for spaces that are 2x2 you can scan every other block instead

timber mural
rough ibex
#

and you can only scan below a certain Y

timber mural
#

i tried doing it and it does the thing instantly

timber mural
#

but the empty spaces are in the blocks

#

like in the picture

young knoll
#

I mean of course it isn’t going to take several seconds

#

But if you are doing it continuously it’s going to hurt

timber mural
#

only one manual use through the command

young knoll
#

You’ll probably be fine then

timber mural
#

yep but i still don't know how i should do it

#

i just need a general idea of how to

#

because i do not know

tardy delta
#

subtitles be like

timber mural
young knoll
#

Once you find air, check nearby blocks to see if they match the shape you want

timber mural
#

if I want to have a custom radius

young knoll
#

Yes

timber mural
#

and then since it's air space in blocks i just need to check if it's surrounded by something that is not air

young knoll
#

Yep

timber mural
#

alright

#

thank you

river oracle
#

are dashes an illegal character in SQL? is there anyway I can force the ability to use dashes or will I have to change up my current format

#

?paste

undone axleBOT
river oracle
exotic zinc
#

why do you use dashes?

river oracle
#

simply kept the same format

#

it'd be bothersome if it was an illegal character though

exotic zinc
#

i would switch to proper sql conventions

river oracle
#

as I'd need to add a restriction to every implementation of my database

river oracle
exotic zinc
#

then its time to not ignore those

river oracle
#

so if I can use dashes I'd like to know how

river oracle
exotic zinc
#

where exactly do you have dashes?

#

table?

#

variable

#

column

river oracle
#
    private static final String CONNECTION_STRING = "jdbc:sqlite:";
    private static final String SQLITE_DATABASE_PATH = System.getenv("SQLITE_DATABASE_PATH");
    private static final String COLLECTION_NAME = "test-collection";
    private static final String DOCUMENT_ID = "test-document";
#

pretty much everything

exotic zinc
#

oh

#

sqlite

exotic zinc
#

that %s is confusing me

river oracle
#

yes, but prior to execution the %s is replaced with a table name

#
    private static final String INSERT_EMPTY_DOCUMENT = "INSERT INTO %s (_id, document) VALUES (?, ?))";

    private static void addEmptyDocument(Connection connection, String collectionName, String id)
            throws IllegalStateException {
        final String query = String.format(INSERT_EMPTY_DOCUMENT, collectionName);

        try (final var statement = connection.prepareStatement(query)) {
            statement.setString(1, id);

            final Document document = new Document();
            document.put("_id", id);
            statement.setString(2, document.toJson());

            statement.execute();
        } catch (SQLException e) {
            throw new IllegalStateException("Failed to add empty document to table '" + collectionName + "'", e);
        }
    }
exotic zinc
#

you can try something like

INSERT INTO "%s" (_id, document) VALUES (?, ?))
river oracle
#

unfortuantely looks like neither '%s' nor "%s" works

exotic zinc
#

huh

river oracle
#

nope error seems to be around the - as well

#

- is blacklisted I didn't know _ was as well

#

mm musta miss clicked

#

one second let me try wrapping table name with %s again

#

okay yeah I got it working now

exotic zinc
#
create table "abc-wwww" (
    "_id" int,
    "name" varchar(255),
    "age" int
)
#

this works for me

exotic zinc
river oracle
#

- is blacklisted if you don't wrap it in string tags

exotic zinc
#

but you can use _ and -

#

yes

exotic zinc
#

thats why i thought adding string tags may be the solution

#

first issue is not using proper sql conventions

#

bit if it works eh

#

can do views or stored procedures though

river oracle
#

Realm currently doesn't work on computers

#

and they don't have plans on adding support either

river oracle
#

doesn't h2 use sql

#

atleast I looked at that one and it seemed like it did

exotic zinc
#

ah you want a nosql

#

ok sorry

river oracle
#

Issue is I much prefer mongo when it comes to server databases however there is nothing locally outside of json

#

which would be a mess to make my own database for instead of just using something that already exists even if I have to abuse it a little

exotic zinc
#

I did not enjoy the time with mongo

#

i love creating tables and playing around with stored procedures

river oracle
exotic zinc
#

gotta love these statements

-- fetch the data from the OLTP database
open cursor for select od.order_id,
                       od.product_id,
                       od.price_per_unit,
                       od.quantity,
                       od.discount,
                       o.order_date,
                       o.shipped_date,
                       o.freight_cost,
                       cs.customer_id,
                       cs.company_name as customer_name,
                       cs.city         as customer_city,
                       cs.country      as customer_country,
                       pe.personnel_id,
                       pe.first_name,
                       pe.last_name,
                       si.shipper_id,
                       si.company_name as shipper_name,
                       p.product,
                       c.category_id,
                       c.category_name,
                       s.supplier_id,
                       s.company_name,
                       s.city,
                       s.country
                from oltp.order_details od
                         join oltp."order" o on o.order_id = od.order_id
                         join oltp.product p on p.product_id = od.product_id
                         join oltp.category c on c.category_id = p.category_id
                         join oltp.supplier s on s.supplier_id = p.supplier_id
                         join oltp.customer cs on o.customer_id = cs.customer_id
                         join oltp.personnel pe on pe.personnel_id = o.personnel_id
                         join oltp.shipper si on o.shipper_id = si.shipper_id;
river oracle
#

Java drivers suffice for me :P they are very nice to work with

young knoll
#

Beautiful

river oracle
#

in python yeah

#

not java

exotic zinc
river oracle
#

the other day I looked a few hours for nosql alternatives

#

pretty much everywhere

young knoll
#

It was uhh

#

The first google result for “local nosql database java”

river oracle
exotic zinc
#

f

river oracle
#

Duck Duck Go moment

exotic zinc
#

bruh

river oracle
exotic zinc
#

baeldung my beloved

young knoll
#

🩆

river oracle
river oracle
#

need to try google after Duck Duck GO next time

remote swallow
#

Thats quackers

exotic zinc
river oracle
#

duckduck go doesn't touch the dark web

ivory sleet
#

Lol ye

river oracle
#

I can't wait to start using my database API :3

#

I've never been so genuinely excited to finish something

echo basalt
#

same with cosmos

#

even started writing a wiki

river oracle
river oracle
#

hmm looks interesting

#

I'm trying to reimpl what database type of thing we used at my work in an open source project

#

so essentially had to start from scratch and code this myself with keeping the data model in mind

tender shard
#

why ping here

ornate patio
#

How can I check if a block is a sign

#

but any kind of sign, i dont wanna list out every wood type

#

nvm just found it

#
if (Tag.SIGNS.isTagged(block.getType())) {
    
}
sullen marlin
#

instanceof Sign probably better

#

tags are đŸ’©

ornate patio
#

wait really

#

why

ornate patio
sullen marlin
#

state or data

young knoll
#

Tags can be modified with datapacks

#

However datapacks can also make new tags which can be very useful

ornate patio
#

i dont see the issue

young knoll
#

Well

#

Datapacks might be stupid and add potatoes to the sign tag

#

Granted no datapack worth using is going to do that

#

But still

regal scaffold
#

Hey,

I have the following code in 1.17.1 using spigot mappings

        PacketPlayOutPosition positionPacket = new PacketPlayOutPosition(
                0,0,0,
                recoil,
                recoil / 2,
                Set.of(
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.a,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.b,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.c,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.d,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.e
                ),
                0,
                true
        );

I want to update to 1.19.4

  1. Do I keep using spigot mappings so I don't have to change every single line where nms was used? Do I start using mojang-mappings and just deal with changing everything correctly? (It was pretty big)
  2. I need some tips using screamingsandals or any other tool to find out how the nms was changed
echo basalt
#

Just convert to nms mappings and use screamingsandals to figure out what goes where

regal scaffold
#

What do you mean to nms mappings

#

So obfuscated?

echo basalt
#

moj mappings

#

Just like

#

setup moj mappings

regal scaffold
#

So convert in 1.17.1 to mojang mappings

kind hatch
#

If you ask me, I'd switch to mojang mappings because it's not obfuscated. As for converting, just go to the version on screaming sandals, select Spigot and type the obfuscated packet name

regal scaffold
#

Then update to 1.19.4

#

And fix things?

echo basalt
#

yes

regal scaffold
#

Wouldn't it also be better at the same time to use protocolLib?

kind hatch
#

Depends on how good you are with or without it.

regal scaffold
#

I can get around with it enough

#

Just when updating code that I didn't write it's confusing

#

Alright i kinda get what I need to do now

#

Last question

#

I see people use ProtocolLib + packet wrapper

#

Why

echo basalt
#

Packet wrapper is just like

#

basically a multi-platform wrapper where each packet type gets its own class

#

auto-generated by scanning nms packet classes and just making a version where every single param is wrapped

regal scaffold
#

So it's usually better to use both together

echo basalt
#

I'd just use plib

regal scaffold
#

Oh alright

echo basalt
#

but if you're clueless about a certain packet, the wrapper might help

regal scaffold
#

Gotcha

#

Alright lastly

#

If I check that, which is the 1.17.1 version of the PacketPlayOutPosition

#

Where did

Set.of(
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.a,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.b,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.c,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.d,
                        PacketPlayOutPosition.EnumPlayerTeleportFlags.e,
                )

come from

#

Like what even is EnumPlayerTeleportFlags

#

I know this

#

But I'm trying to figure out how the packet was made in 1.17.1 so then I can translate it

regal scaffold
#

I'm just confused as in

#

Where does that even come from

#

Cause I know in 1.19.4 it no longer exists

echo basalt
#

In 1.19.4 instead of having flags we just have like 2 or 3 constructors

#

and variants of the same packet

regal scaffold
#

I assume you mean that

#

And that's where the Set comes from

#

I assume now is when I need to seach for how the packet is made using .vg

upper niche
#

Is there a method that can calculate the damage on an entity given a certain ItemStack? I can't use attack because it's not a main hand item

vocal cloud
#

You can pull the damage attribute I think? If it doesn't have one it's 0.5 by default isn't it?

young knoll
#

If it doesn’t have a damage attribute it may have default attributes

#

If it doesn’t have either then the default is 1 damage (0.5 hearts)

#

But you also have to consider strength buffs, enchantments, etc

fierce prawn
#

error: cannot find symbol
meta.spigot().setUnbreakable(true);
^
symbol: method spigot()
location: variable meta of type ItemMeta

#

anyone able to help?

vocal cloud
#

?paste full error with code please

undone axleBOT
vocal cloud
#

Oh wait is this on compile? What are you using as a package manager?

fierce prawn
#

gradle

vocal cloud
#

can't help there

fierce prawn
#

Its undifed but you cant define ti lol

quaint mantle
#

Is there any way to calculate moon's phase / current location?

heady wasp
#

(when i try to join i get that error)

#

here's the full class

desert loom
#

getDouble returns a Double instance and when you assign a Double instance to a primitive it unboxes itself but because the instance is null an npe happens

quaint mantle
#

Hey, I need help! I have a Crystal PvP arena in my SMP and basically, it allows explosions and I'm wondering if there are any plugins that can reset the arena!

#

Please @ me if you have a response!

jagged bobcat
#

I can't find way to detect player jump is there no way to see if player is jumping? Do I need to make my own detectors?

#

I've google and people in the past have made their own detectors

agile anvil
#

There is no already-made way

#

You have to check your own way

jagged monolith
jagged bobcat
#

Creating my own event for it and checker so I can just use event for it

agile anvil
jagged bobcat
#

PlayerJumpEvent. I can make my stuff faster with it

agile anvil
#

Yeah or just directly call your code when you detect a Jump, instead of launching a bukkit event which is way longer

#

it takes 30ms to launch an event iirc (at least few years back then)

jagged bobcat
#

I'll test how long it takes

agile anvil
timber mural
#

I need help with my code, so this is my current one, what it does it it spawns mobs in empty spaces, but it does it in every block that is air (so if the space is 2x2 it spawns 4 mobs), i want it to spawn only one mob per empty space but i don't know what i should do

    private List<Block> getEmptySpacesInRadius(Block centerBlock, int radius, int emptySpaceSize) {
        List<Block> emptySpaces = new ArrayList<>();
        for (int x = centerBlock.getX() - radius; x <= centerBlock.getX() + radius; x++) {
            for (int y = centerBlock.getY() - radius; y <= centerBlock.getY() + radius; y++) {
                for (int z = centerBlock.getZ() - radius; z <= centerBlock.getZ() + radius; z++) {
                    Block currentBlock = centerBlock.getWorld().getBlockAt(x, y, z);
                    if (currentBlock.getType() == Material.AIR) {
                        boolean isSurrounded = true;
                        for (int dx = -emptySpaceSize; dx <= emptySpaceSize; dx++) {
                            for (int dy = -emptySpaceSize; dy <= emptySpaceSize; dy++) {
                                for (int dz = -emptySpaceSize; dz <= emptySpaceSize; dz++) {
                                    Block surroundingBlock = centerBlock.getWorld().getBlockAt(x + dx, y + dy, z + dz);
                                    if (surroundingBlock.getType() != Material.AIR) {
                                        isSurrounded = true;
                                        break;
                                    }
                                }
                                if (!isSurrounded) {
                                    break;
                                }
                            }
                            if (!isSurrounded) {
                                break;
                            }
                        }
                        if (isSurrounded) {
                            emptySpaces.add(currentBlock);
                        }
                    }
                }
            }
        }
        return emptySpaces;
    }
#

i just need a suggestion how i would do it

agile anvil
#

Mark each block where you spawn a mob, and when going to a new block, check if the block isn't near a marked block

#

Then you can fix a minimum radius for instance, and a probability to it

#

You can also work with a radius in only some planes

#

See that as a distance

#

Then, if you need 1 and only 1 mob in every walled area (and that they could be of any size), you'll probably have to identify them

#

Idea: use pathfinding (such as A*) to see if there is a way between them, if not, it's a new space

jagged bobcat
#

would like if my event would fire

#

This is using nano time with simple event

                                              Start            End              Diff
[10:45:01] [Server thread/INFO]: [AstrolPr] 837583716029300 | 837583716061900 | 32600
agile anvil
#

It's really fast lmao

jagged bobcat
#

Using milliseconds

                                                 Start          End          Diff
[10:46:13] [Server thread/INFO]: [AstrolPr] 1683359173625 | 1683359173625 | 0
ornate patio
#

I’ve got some proof of concept in my head to make players one block tall without a client side mod

  • Force player into crawl mode
  • Give player big speed boost to counteract crawl speed
  • Make player invisible and disguise as baby villager with players head instead

Do y’all think this would actually work

agile anvil
#

Yeh it's like 0.03ms

agile anvil
jagged bobcat
#

On different classes

            start              end              diff
[AstrolPr] 837789279700400 | 837789279722500 | 22100
charred blaze
#

is it required to have ondisable?

#

i have no code in it

#

so i want to remove it

eternal oxide
#

not needed

#

you can delete

tender shard
#

but

#

it's already declared in JavaPlugin

#

so you don't need one yourself

charred blaze
#

okay

tender shard
tender shard
#

nested for loops

#

how else would you do it

eternal oxide
#

If I were him I'd just set a minimum spawn distance

#

He's never going to get a mob in every single cave

#

and caves connect

tardy delta
#

atleast use continue

tender shard
eternal oxide
#

not many inhabited caves these days

#

was his name osama? 🙂

tender shard
#

no, Leon

#

what's wrong with my code

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        try {
            Warp warp = warps.get(args[0]); // Might cause ArrayIndexOutOfBoundsException
            Location location = warp.getLocation(); // Might cause NullPointerException
            ((Player)sender).teleport(location); // Might cause ClassCastException
            return true;
        } catch (NullPointerException exception) {
            sender.sendMessage("The specified warp does not exist.");
            return true;
        } catch (ClassCastException exception) {
            sender.sendMessage("This command is only available for players.");
            return true;
        } catch (ArrayIndexOutOfBoundsException exception) {
            sender.sendMessage("Please specify a warp.");
            return true;
        }
    }
wet breach
tender shard
#

duuude

#

1st that wouldn'T allow proper error messages
2nd try/catch for control flow is baaaad

wet breach
#

you just have to check which exception it is

tender shard
#

but then it's the same thing, just in worse

eternal oxide
#

more work to do in a multi

tender shard
#

I mean, the current code already is a joke lol

wet breach
#

lol

eternal oxide
#

nothing wrong with it 😉

#

If it works

wet breach
tender shard
tender shard
eternal oxide
#

ah I see your error, you used separate return true. you could have done a single

tender shard
#

ok that is true

wet breach
tender shard
#

no, I don't lol

#

it should actually look löike this

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("This command is only available for players.");
            return true;
        }
        if (args.length == 0) {
            sender.sendMessage("Please specify a warp.");
            return true;
        }
        Warp warp = warps.get(args[0]);
        if (warp == null) {
            sender.sendMessage("The specified warp does not exist.");
            return true;
        }
        ((Player) sender).teleport(warp.getLocation());
        return true;
    }
eternal oxide
#

I like the first one 🙂

tender shard
#

no D:

eternal oxide
#

ok second one is 12 lines, first one is 13 so second must be better

#

fix those returns though and first winsa

tardy delta
#

so much boilerplate code

opal juniper
#

mY CoMmAnD FrAMEwoRk sO mUcH beTTEr!!!

pseudo hazel
#

mine looks just like this

#

and I can work with it so its good

#

some things dont require insane rewrites to function

tardy delta
#

does it use functional interfaces?

tender shard
tardy delta
#

ah turns out the moment you connect windows enterprise to the internet with a expired license, it shuts down

wet breach
tender shard
wet breach
tender shard
#

or just use debian :3

wet breach
#

depends on what you want to do

#

you can use linux in combination with enterprise

#

which is actually common to do

#

but linux can't control windows desktops so you need enterprise for that

tender shard
#

idk I dislike windows from the soul of my... erm... stomach

wet breach
#

where linux comes in handy is for handling the network booting stuff and holding the images

#

it does it much better then enterprise does and is easier to setup with linux

tender shard
#

what even is windows enterprise? desktop or server`?

#

I never heard of it

wet breach
#

its basically both

tender shard
#

hm ok

wet breach
#

but its purpose is to handle the group policy and settings of the desktops in the network

#

basically its the domain controller

tender shard
#

like LDAP

wet breach
#

yes similar in a way

tender shard
#

i love james franco

wet breach
#

lol

jagged bobcat
# jagged bobcat I can't find way to detect player jump is there no way to see if player is jumpi...

Did it

package com.qntcore.minecraft_server.eventsextendedapi.events.movement;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

/**
 * Event used for detecting when player jumps.
 * This is not triggered using climbing ladders
 * This is not triggered using potion effects (except jump boost)
 * @author antritus
 * @since 06/07/2023
 */
public class PlayerJumpEvent extends PlayerMoveEvent {
    private static final HandlerList HANDLERS = new HandlerList();
    public PlayerJumpEvent(@NotNull Player player, @NotNull Location from, @NotNull Location to) {
        super(player, from, to);
    }

    public static @NotNull HandlerList getHandlerList() {
        return HANDLERS;
    }
    @Override
    public @NotNull HandlerList getHandlers() {
        return HANDLERS;
    }

    @NotNull
    @Override
    public Location getTo() {
        return Objects.requireNonNull(super.getTo());
    }
}

#

Fixing problems if you encounter em (If you test it ever)

wet breach
jagged bobcat
#

which class?

#

wait

#

1 sec

wet breach
#

at minimum, the to location should be the same as the from

#

in this way, it should never be null otherwise it would be interesting to see what happens if a null was in there lol

jagged bobcat
tender shard
#

send it as code block pls

#

or ?paste it

#

?paste

undone axleBOT
tardy delta
#

why not just check player move event y change

tender shard
#

paper's listener is in the paper-hacks module

eternal oxide
#

or watch the jump statistic

tender shard
#

iirc there's an issue with that

eternal oxide
#

you can set the y velocity to 0 to cancel jumps in teh statisitic increase event

tender shard
#

I used that earlier but there was some issue with it, which I cannot recall rn

wet breach
#

yeah it isn't quite accurate

#

it will consider some things as jumps when they really are not

tender shard
#

oh wait, I DO use the statistics for that event

eternal oxide
#

If MC considers it a jump is it not?

tender shard
#

yeah probably

wet breach
#

not always

#

but for the most part yeah

#

so it should be fine to use it as long as you catch edge cases

jagged bobcat
#

Changed to paste.md-5

#

Listening to jump statistics would have been easier

#

oh well

tender shard
jagged bobcat
#

I saw it

heady spruce
#

Does scheduleSyncDelayedTask only get executed once?

eternal oxide
#

yes

heady spruce
#

Tzhanks

tender shard
#

only "repeating" tasks are run more than once

heady spruce
#

Okay tsym

young knoll
#

Sadly jumping is impossible to detect with 100% accuracy since it’s client side

tender shard
#

Yeah people can always fake their movement

#

But i mean, after all its mc and not counterstrike

noble crown
#

Hi, how can I set item's display name to basecomponent?

tender shard
#

Display names are just text

#

They dont have any „hover event“ etc features

noble crown
#

Yes, but default item's display name is a translatable component

#

So there should be a way to change it

rotund ravine
#

Probably through the spigot interface

tender shard
#

Iirc

#

I might be wrong

noble crown
noble crown
rotund ravine
#

Rip

#

?jd-s

undone axleBOT
rotund ravine
#

Guess go say hi to paper

noble crown
#

I know that paper has api for this

tender shard
#

If it works though, @worldly ingot should PR it to spigot:p

noble crown
tender shard
#

Yeah but you could also just say „some“ features are paper only

#

It doesnt have to support spigot 100%, its fine to add paper-only features

#

But as said, i doubt itll work in paper

noble crown
#

Okay, so for now, I'll make it paper only

noble crown
#

It works

exotic zinc
noble crown
#

command

#

/give @p diamond_sword{display:{Name:'{"translate":"block.minecraft.diamond_block"}'}} 1

exotic zinc
#

lol

rotund ravine
#

Paper allows components in names and lore.

exotic zinc
#

ok

rotund ravine
#

Thought there was a spigot interface đŸ„Č

noble crown
exotic zinc
#

haha

#

doubt thats going to happen

rotund ravine
#

It probably will

exotic zinc
#

i dont think so

#

would be much work

eternal oxide
#

have you tried to see if it will translate json?

#

It won;t in titles

#

but perhaps in names?

noble crown
#

I don't think it'll work

#

And also I don't have time to try

rotund ravine
#

@worldly ingot Didn’t you say a bit ago you’d pr it?

tender shard
#

@worldly ingot translatable components for display name when?

eternal night
#

chocos PR did add item component support

#

just not merged

tardy delta
#

hmm isnt it useless to store both a timestamp and a date if the date of the timestamp is the same as the date (sounds weird lol)

#

date and time in dutch btw

rotund ravine
tardy delta
#

dunno what my databases teacher was on

wet breach
#

but 99% is still pretty good though

tardy delta
cinder abyss
#

Hello, how can I check if a player fall in water ?

eternal oxide
#

check the block at hsi feet is water

cinder abyss
eternal oxide
#

only if he is stood in water

wet breach
#

besides, it would be better having the timestamp anyways because then you can convert to whatever calendar you want to use

#

if that is even necessary

tardy delta
#

not really, its just a college assignment where i have to implement a database from an erd

wet breach
#

oh well if its a DB, then just use Timestamp

#

the DB should be able to obtain a date automatically using native methods

#

so don't even really need to create conversion code yourself 🙂

tardy delta
#

hmm lets not worry about timezones then

wet breach
#

is it necessary to worry about timezones?

#

as long as you base the time off a timezone like GMT, you can factor timezones in later

#

might be better to use UTC

twilit roost
#

im trying to optimize my plugin (minigame)
which makes new void world for instance

I tried unloading all worlds and loading them only on demand, but this resulted in Loading terrain when player tries to access them, even tho I loaded that world before hand.

any ideas why it occurs?

my load world:
https://paste.md-5.net/bopotahuce.java

tardy delta
eternal oxide
#

no point in using a scheduler. It still runs on the main thread

#

you could also force load the spawn chunk after the world is loaded

twilit roost
eternal oxide
#

that method is not Async

#

you can;t load worlds async to start

twilit roost
#

not load world
but from where I execute it

eternal oxide
#

but runTask is sync

#

oh you call it FROM async, I get you

twilit roost
#

yeye

#

imma try making it keep spawn

tardy delta
#

hell ye manually resetting sequences in postgres in fun

#

wdym not the class itself

#

isnt the value of the entry the class you want

#

you need the EpicItemHandler and not the class you mean?

#

are you looking for a functional interface?

#

.class yes

#

you want to get an instance of a PoisonHandler?

#

and you also need the class?

remote swallow
#

why would you need the class, just use an instance

tardy delta
#

why dont you store an instance then, look it up and call getClass on it

remote swallow
#

PoisonHandler

tardy delta
#

? extends EpicItemHandler

remote swallow
#

im guessing thats an interfact or an abstract class

tardy delta
#

Map<String, EpicItemHandler>

remote swallow
#

yeah

#

thats what the instance is for

#

interface**

tardy delta
#

are we thinking about a Map<String, Supplier<EpicItemHandler>>

remote swallow
#

okay, so have an abstract class that is extended on all classes that have enchants then you store the data in the abstract class

#

issue?

tardy delta
#

meaning you can put whatever instance that extends epicitemhandler in there

#

yes

#

you can call map.put("poison", new PoisonHandler())

remote swallow
#

^^

tardy delta
#

well why are you working with entries and not Map#get

remote swallow
#

define the methods in the abstract class for them to be overriden in the class and your done

tardy delta
#

thats how Map#get works

#

looks up a value based on a key

#

what value

remote swallow
#

map#get needs a key

tardy delta
#

it checks the string

#

or do you need a map with a class as key?

#

well im still wondering what you ned the class for, isnt an instance enough

remote swallow
#

so Map<String, AbstractClass>

tardy delta
#

you can always call getClass() on the instance

hazy parrot
#

So what is problem with string as key and abstract class as an value?

remote swallow
#

okay one minute

tardy delta
#
Map<String, EpicItemHandler> map = [...];
map.put("poison", new PoisonHandler());
map.get("poison") /* returns some kind of EpicItemHandler */ .handle(player);```
#

does your map stores classes as keys

hazy parrot
#

Get requires whatever is first value inside of <>

tardy delta
remote swallow
#

public abstract class MyAbstractClass {
    final String infoExample;

    public MyAbstractClass(String info) {
        this.infoExample = info;
    }

    public abstract String getData();
}


public class Manager {
    private final Map<String, MyAbstractClass> map = new HashMap<>();

    public MyAbstractClass getInstance(String name) {
        return map.get(name);
    }
}

public class ExampleAbstractUsage extends MyAbstractClass {

    public ExampleAbstractUsage(String firstInfo) {
        super(firstInfo);
    }


    @Override
    public String getData() {
        return infoExample.toUpperCase();
    }
}
tardy delta
#

records :)

#

wait no

#

stupid java with their "records cannot extend classes" policy

#

atleast give us record classes then

quiet ice
#

Well records are meant to have a special memory layout

tardy delta
quiet ice
#

I think it was regarding their hashcode or something

tardy delta
#

im thinking too much in c++ ways lol

quiet ice
#

The fields can be written to if that is your question

#

I think idk

#

I don't use records that often anymore

tardy delta
#

i just use them for avoiding the boilerplate code

quiet ice
#

Unfortunately Java 9+ ended up proving itself to be unviable with what I mainly do, so there is rarely a circumstance where I can even use records.

tardy delta
#

hmm

#

i tried to extend Enum last time but java didnt like that

quiet ice
#

Well the JLS doesn't allow that since Java 1.7 (or something along the lines thereof)

#

The JVMS does allow that though

tardy delta
#

jvms = jvm?

glossy venture
#

anyone know why gradle is building fucking .jar.jar files? its fucking with my maven publications

quiet ice
tardy delta
#

ah ye it allows some things that the compiler doesnt đŸ„Č

tardy delta
#

ah thats what they mean with those object headers

quiet ice
#

Primitive classes != Records

glossy venture
# quiet ice What is your build.gradle?

uh its kinda complex im including a general purpose build script i wrote so a lot of shit is provided by that

plugins {
    // java
    id 'java'
    id 'java-library'

    // package publishing
    id 'maven-publish'
    id 'signing'

    // for shading in dependencies
    id "com.github.johnrengelman.shadow" version "7.1.2"
}

version '1.0.4'

ext {
    hasPaper = false
    hasTesting = true
    desc = "General purpose static utility library"
}

apply from: '../buildsrc/module.gradle', to: project

dependencies {

}
``` this is the build.gradle
<https://github.com/cold-src/buildsrc/blob/master/module.gradle> this is the module.gradle included
quiet ice
glossy venture
#

ah ill try

quiet ice
remote swallow
#

im going to advise heavily against this

#

use env vars

glossy venture
#

oh nvm

#

the filename includes .jar ofc

#

shit

quiet ice
#

Yep

cinder abyss
#

How can I sink players into the ground like quicksand?

tardy delta
glossy venture
#

why cant i cast this bruh fucking generics stop crying

cinder abyss
#

I'll place a cobweb inside

tardy delta
#

its probably with packets, i dunno the context in which that video was sent i only saw it

ivory sleet
#

its like List<T> vs List<Object>

glossy venture
#

but why is that uncastable

#

it should be unchecked

#

or unsafe ig

exotic zinc
ivory sleet
glossy venture
#

nah

ivory sleet
#

Do an intermediate cast

#

(Callback<ReceivedPacket<T>>) (Object) c

glossy venture
#

mind that its Callback<ReceivedPacket> -> Callback<ReceivedPacket<T>> so its like deeper

glossy venture
ivory sleet
#

Its a hacky trick

#

But it works

exotic zinc
ivory sleet
#

Since java type erasure đŸ€Ą

glossy venture
#

lol

#

works

#

if type erasure wasnt a thing and generics was enforced at runtime id quit java rn

quiet ice
#

Casting to object and back is quite frequent

ivory sleet
#

Well its not that frequent to do explicitly, but ye it happens alot when compiling etc

ocean hollow
#

Guys, hello everyone. I have 2 plugins and they are in conflict. If you hover over a block, a title should appear. But after adding the plugin - it stops working.

quiet ice
ivory sleet
#

Well I guess if you’re on a bytecode level like with mixins or similar stuff it may be more common to work with

#

But most applications should not have to deal with it on an infrastructure level

tardy delta
#

but "it stops", are you using a scheduler or an event or smth?

#

bruh this a thing in sql too

cinder abyss
#

Hello, how can I make a block invisible for a player ?

chrome beacon
#

player#sendBlockChange

cinder abyss
chrome beacon
#

Time to debug then

#

Does the code run

cinder abyss
chrome beacon
#

When are you calling it

#

Is it the correct location

cinder abyss
# chrome beacon When are you calling it
@EventHandler
    public void onPlace(BlockPlaceEvent event) {
        Material material = event.getItemInHand().getType();
        Block block = event.getBlock();
        Location loc = block.getLocation();
        block.setType(Material.COBWEB);
        block.getWorld().spawn(loc, BlockDisplay.class, b -> {
            b.setBlock(material.createBlockData());
        });
        event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData());
    }```
#

all is working except event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData());

chrome beacon
#

Delay by 1 tick

cinder abyss
ocean hollow
#

scheduler

cinder abyss
# chrome beacon Delay by 1 tick

I made thisjava @EventHandler public void onPlace(BlockPlaceEvent event) { Material material = event.getItemInHand().getType(); Block block = event.getBlock(); Location loc = block.getLocation(); block.setType(Material.COBWEB); block.getWorld().spawn(loc, BlockDisplay.class, b -> { b.setBlock(material.createBlockData()); }); new BukkitRunnable() { @Override public void run() { event.getPlayer().sendBlockChange(loc, Material.BARRIER.createBlockData()); } }.runTask(this); }And it's the same result

chrome beacon
#

Are you sure you're not seeing the block display

cinder abyss
#

and now, it replaces the block

cinder abyss
glossy venture
#

you can use reflections library by idk their name

chrome beacon
#

Yeah you can use reflection

cinder abyss
#

this is no longer a cobweb block

chrome beacon
#

good

cinder abyss
chrome beacon
cinder abyss
chrome beacon
#

The client controls the movement

glossy venture
#

probably need to open the JAR file and list all files under the directory
otherwise it only works for loaded classes i think

chrome beacon
#

If it doesn't know there's a cobweb there it won't be able to walk in to it

cinder abyss
chrome beacon
#

You can't

cinder abyss
chrome beacon
#

Get a display entity that covers the cobweb I guess

heady spruce
#

does anybody knows why this wont stop obsidian from generating?
also tried:

  • BlockFormEvent
  • BlockPhysicsEvent
@EventHandler
    public void onBlockFromTo(BlockFromToEvent event) {
        //blocks.add(event.getBlock());

        //startLiquidDelete(event.getBlock());
        Block block = event.getBlock();
        if (block.getType() == Material.STATIONARY_LAVA || block.getType() == Material.LAVA) {
            Block toBlock = event.getToBlock();
            if (toBlock.getType() == Material.WATER || toBlock.getType() == Material.STATIONARY_WATER) {
                event.setCancelled(true);
            }
        }
    }```
cinder abyss
#

but inside it's a cobweb

chrome beacon
#

No not right now

glossy venture
#

you cant do it with reflection
the jvm doesnt organize classes under packages

#

i think

#

you can only loop through all loaded classes

tardy delta
#

damn chatgpt is very original

glossy venture
#

or open the JAR file and list the class files

#

not all classes are loaded

#

only when u use them they get loaded from the jar

tardy delta
#

just dont

heady spruce
#

Yea, tried that but obsidian and cobblestone generation doesnt seem to get catched by this

#

(I mean by the event)

#

Tried that in GrowEvent too, so idk im clueless tbh

chrome beacon
heady spruce
#

oh bruh

#

give me a sec

#

no its FromTo

#

nvm

#

FormEvent didnt work too for me and it didnt catch that too

#

maybe could be that im coding in 1.8.8 and it wasnt implemented there or smth

chrome beacon
#

1.8 💀

heady spruce
#

1.8 pvp is better change my mind

chrome beacon
#

Make sure your fork of fork of fork of fork of fork of fork of fork of fork isn't breaking anything

heady spruce
#

i understand that people like the new one

#

but i like 1.8 more so i code things i like there yk

ivory sleet
#

1.8 game features might be nice, but the code base is so dog water

worn tundra
#

what data u want from it

heady spruce
#

and if someone recommends me to remove cooldown im going to be mad bc it doesnt feel the ssame even without the cooldown

ivory sleet
#

.forEach(value -> {


});

#

or for (V value : map.values()){

}

glossy venture
#
try {
    final String pk = "my.package";
    List<Class<?>> classes = new ArrayList<>();
    
    Class<?> kl = getClass();
    CodeSource source = kl.getProtectionDomain().getCodeSource();
    URL jar = source.getLocation();
    File jarFile = new File(jar.getFile());
    
    JarInputStream stream = new JarInputStream(new FileInputStream(jarFile));
    ZipEntry entry;
    while ((entry = stream.getNextEntry()) != null) {
        if (entry.getName().startsWith(pk) && entry.getName().endsWith(".class")) {
            String className = entry.getName()
                    .replace(".class", "")
                    .replace("/", ".");
            classes.add(Class.forName(className));
        }
        
        stream.closeEntry();
    }
} catch (Exception e) {
    e.printStackTrace();
}
``` this is like ultra stupid but i think smth like this might work
heady spruce
#

so i see in the docs that BlockFormEvent doesnt cover obsidian and cobblestone generation, so anybody have some other recommandations (1.8.8 it does cover it in the newer versions)

ivory sleet
chrome beacon
ivory sleet
#

Java 7?

glossy venture
#

lmao bro u using java 7?

ivory sleet
#

Benchmarks?

heady spruce
exotic zinc
#

my guy still coding at java 7

#

wow

heady spruce
#

and as I said, i code in 1.8.8

glossy venture
#

what server version are you developing for

heady spruce
#

i know it does cover it in the newer versions

glossy venture
#

lmao

#

u can use java 11

#

maven or gradle?

ivory sleet
#

1.8 uses an older netty version and older lwgjl @quaint mantle which both are less performant

heady spruce
#

I could try that

ivory sleet
#

Do you have benchmarks?

#

Sure

#

Yes

#

A lot of bugs

#

🐛

#

Na that’s beneath their dignity

#

It’s improved significantly tho

#

Idk

#

Its pretty decent most of the times

#

mye perhaps

#

I mean

#

That’s what paper was doing in 1.8

#

Poeple dont fork to do nothing

#

^

#

Like sometimes fixing bug A introduces a new bug B

#

Generally yes

#

Always have zero day vulnerabilities

quiet ice
#

Because they fix those issues in the core server implementation

reef forge
#

How can I give a player a custom permission?

ivory sleet
#

Plugins are harder if you wanna fix bugs

#

^ easier to fork, and run som patches

quiet ice
#

Also FYI, anything below 1.19.4 pretty much has 0 support from spigot, paper and co

ivory sleet
#

True

quiet ice
#

They won't fix bugs retroactively

ivory sleet
quiet ice
#

The only exception I know of was Log4J

#

But that is about it

glossy venture
#

@quaint mantle
this works if ur loading from a jar file

try {
    final String pk = "the.package";
    List<Class<?>> classes = new ArrayList<>();

    Class<?> kl = getClass();
    CodeSource source = kl.getProtectionDomain().getCodeSource();
    URL jar = source.getLocation();
    File jarFile = new File(jar.getFile());

    JarInputStream stream = new JarInputStream(new FileInputStream(jarFile));
    ZipEntry entry;
    while ((entry = stream.getNextEntry()) != null) {
        if (entry.getName().startsWith(pk) && entry.getName().endsWith(".class")) {
            String className = entry.getName()
                    .replace(".class", "")
                    .replace("/", ".");
            classes.add(Class.forName(className));
        }

        stream.closeEntry();
    }

    System.out.println(classes);
} catch (Exception e) {
    e.printStackTrace();
}
reef forge
tardy delta
#

try with resources 😳

quiet ice
quiet ice
glossy venture
#

nah i dont think so

tardy delta
#

hmm i see so much bad code on daily base it doesnt even surprise me đŸ€Ą

glossy venture
#

because the condition is evaluated after the first iteration right

reef forge
#

Aigbt

#

Aight*

tardy delta
#

before?

quiet ice
quiet ice
glossy venture
#

to what

#

null?

quiet ice
#

stream.getNextEntry()

tardy delta
#

stream.getNextEntry()?

glossy venture
#

oh

tardy delta
#

works like an iterator

glossy venture
#

while looks cleaner tho

quiet ice
#

yea ... and then you proceed to do an assignment within a boolean expression

exotic zinc
quiet ice
exotic zinc
#

there is a reason while loops exist

glossy venture
#

better than writing entry = stream.getNextEntry twice

tardy delta
#

thats 2 extra lines with a while

quiet ice
#

I generally try to avoid (X = Z)

exotic zinc
glossy venture
#

yeah

quiet ice
#

at that point you can just use while loops for everything

tardy delta
#

assembly looks scuffed too, will you also tell them?

quiet ice
#

Especially because you define your var outside the loop

#

Which is honestly a no-go since it won't be used after the loop

#

if it were to be used outside the loop it would be okay to have it be a while loop, but not like this

exotic zinc
#

aha they used while loop before

glossy venture
#

wait does zip store entries like this

dir a | file a/b | file a/c | file a/d | close dir a
#

because then once youve found the package you can just break

#

instead of going throuhh the whle jar

glossy venture
tardy delta
#

what the

#

i really could use variables now

quiet ice
#

unless you have reproducible file order that is - but chances are you do not

tardy delta
#

blocking?

#

i was thinking about a blockingqueue

quiet ice
#

java.util.Vector is not thread-safe

#

Unless you never want to iterate over it as well as adding and removing elements that is

tardy delta
#

Vector is synchronized. If a thread-safe implementation is not needed, it is recommended to use ArrayList in place of Vector.

#

javadocs

quiet ice
#

But chances are you will either iterate, add or remove some element of it

quaint mantle
#

Vector is thread safe

quiet ice
tardy delta
#

personally never used that class

quaint mantle
#

You can sync arraylist too.

quiet ice
#

It's thread safe, but cannot be read in a concurrent environment

#

Unless you are very sure that an index exists

rough basin
#

what should I do to make RPM / rate of fire

tardy delta
#

wdym with cannot be read concurrently?

quiet ice
#

If you do something like vector.get(vector.size() - 1); and another thread removes an element after size() but before .get() you have an issue

tardy delta
#

ah ye

#

classic concurrency issue

quiet ice
#

And the iterator will straight up fail if any concurrent modification is performed

#

The only real concurrent list impl is CopyOnWriteArrayList

tardy delta
#

hmm ye copying elements đŸ„Č

#

i once had to work with a copyonwrite arrayset and i had to add 1800 elems :(

quiet ice
tardy delta
#

i measured it and addAll was even slower due to the toArray call 💀

#

decided to not care about it

quiet ice
#

If you know the size of the array at init time you can use AtomicReferenceArray

tardy delta
#

never heard of that tbh

quiet ice
#

Or just straight up use arrays but beware of store fences and other bullshit that arises from highly concurrent environments

tardy delta
#

just smth like an atomicref<T>[]?

wet breach
quiet ice
tardy delta
#

does that guarantee threadsafe writes?

wet breach
#

jar files don't have compression at least not that I recall

tardy delta
#

feels more like you're guarding the array instance

#

actually

quiet ice
tardy delta
#

ahh hmm i saw minestom doing smth similar

cinder abyss
#

Hello, how can I make an entity emit light ?

tardy delta
#

but i thought it was a volatile write with a varhandle which backs an array

heady spruce
#

im ooc mad

quiet ice
tardy delta
#

ah private static final VarHandle ITEM_UPDATER = MethodHandles.arrayElementVarHandle(ItemStack[].class);

#

setting an element seems to use a synchronized block 💀

quiet ice
#

most likely due to indexing constraints

cinder abyss
#

Hello, how can I make a block emit light ?

quiet ice
#

If you use an AtomicInteger and use CAS for incrementing/decrementing that integer you can avoid the sychronized block

tardy delta
#

ye

quiet ice
#

However that only allows appending after the last element or removing the last element.

#

Having a truely thread-safe and fully implemented list is impossible without the usage of synchronized

tardy delta
#

wait and notify?

quiet ice
#

sounds unsafe

tardy delta
#

that does use the waitset instead of the lockset but has the same principle ig

#

i wouldnt really know what to do with the interruptedexception that it can throw but whatever

gleaming grove
#

What can I do to have unique hashCode or some kind of ID for every new instance of object?

tardy delta
#

let it use some combination of the fields hashcodes

gleaming grove
#

In case all fields have null value, the hashcode will be excatly the same, right?

quiet ice
#
int hashcode() {
  return [...] ^ System.identitiyHashcode(this);
}
ivory sleet
tardy delta
#

System.identitiyHashcode(this) will be the same for every instance right?

quiet ice
wet breach
tardy delta
#

ahh

quiet ice
#

But uh, at that point you wouldn't want to override the hashcode method

#

Like, XOR'ing the identity hashcode with what is basically just a salt makes no sense

slim wigeon
#

Hashcode?

#

MD5, SHA256 and SHA512?

tardy delta
#

no

#

thats hashing

quiet ice
#

hashcode is basically some number

#

What it means is irrelevant in most cases. It should be the same number for equal objects though

tardy delta
#

ah now i understand why youre using System.identitiyHashcode(this)

gleaming grove
quiet ice
#

however it's usage is noteworthy: It is used to improve the performance of maps such as the HashMap or other various Hashtable-derived structures

quiet ice
wet breach
#

its how the buckets are formed

glossy venture
quiet ice
#

Not really unique