#help-development

1 messages · Page 616 of 1

rare rover
#

ye

#

so the reason for Function and Predicate is for like mega softcoded code basically

#

kinda

worldly ingot
#

Yeah, just pushing functionality to the caller instead

rare rover
#

ohh

worldly ingot
#

Helps make methods, or really anything that accepts a functional interface, a bit more flexible

rare rover
#

and it helps people edit the code quickly

#

i seeeee

#

thanks so much

#

this helps alot

worldly ingot
#

We do some callback stuff in Bukkit. The ones that come to mind immediately is a Consumer<T extends Entity> for World#spawn() to call methods on an entity before it's added to the world, and a Consumer<BlockData> for Material#createBlockData() to edit BlockData before it's returned

#

We seldom expose Predicates because it can be leaky API but the aforementioned methods are exclusive to Bukkit API so it's fine

young knoll
#

Doesn’t Bukkit api have its own consumer too

quaint mantle
#

If im writing a licence system with JNI is it fine to make the onEnable native?

worldly ingot
worldly ingot
young knoll
worldly ingot
#

Though a license system is already a red flag

rare rover
#

ah

#
public class Main {

    public static void main(String[] args) {
        Testing<Integer> testing = new Testing<>();
        testing.function(integer -> integer * 5);
    }

    static class Testing<K> {
        
        public void check(Iterable<K> iterable, Predicate<K> predicate) {
            iterable.forEach(integer -> {
                if (predicate.test(integer)) {
                    System.out.println("Test passed");
                } else {
                    System.out.println("Test failed");
                }
            });
        }

        public void function(Function<Integer, K> function) {
            System.out.println(function.apply(5));
        }
    }
}``` which would return `25` right?
#

since apply would replace integer with 5

#

5 * 5 = 25

worldly ingot
#

Yes

#

And believe it or not, there's an IntFunction too aPES_Laugh

rare rover
#

ye lol

#

just noticed

#

xD

worldly ingot
#

There is an IntUnaryOperator as well which would accept an int and return an int which is probably better suited in this specific scenario, but ye

rare rover
#

hmm

#

alr

#

so

#
public class Main {

    public static void main(String[] args) {
        Testing<Integer> testing = new Testing<>();
        testing.function(integer -> integer * 5);
    }

    static class Testing<K extends Integer> {

        public void check(Iterable<K> iterable, IntPredicate predicate) {
            iterable.forEach(integer -> {
                if (predicate.test(integer)) {
                    System.out.println("Test passed");
                } else {
                    System.out.println("Test failed");
                }
            });
        }

        public void function(IntFunction<K> function) {
            System.out.println(function.apply(5));
        }
    }
}```?
worldly ingot
#

Yeah that would print out 25

quasi stratus
#

Is there an API to check plugin updates, changelogs, etc. from spigot?

worldly ingot
# rare rover ```java public class Main { public static void main(String[] args) { ...

And if one of the stdlib interfaces don't fit your needs, you can make your own functional interface pretty easily

@FunctionalInterface // Compiler hint. Yells at you if there's more than one method in the interface
public interface PersonCreator {

   public Person createPerson(String name, int age); 

}

PersonCreator creator = (name, age) -> new Person(name, age); // Can technically be simplified to Person::new
Person choco = creator.createPerson("Choco", 23);
rare rover
#

ah i see

#

yeah i see what you're talking about now

#

lol

worldly ingot
#

I don't remember how to get the RSS stream

young knoll
#

They said plugin updates

#

Silly

rare rover
#

lol, also one more question if you dont mind

worldly ingot
#

oh

rare rover
#

um, i have troubles naming classes / interfaces. I follow the java naming conventions but i just cant think of good names for them

#

any tips for that?

worldly ingot
#

tbf, just follow CamelCase conventions and name it whatever you think makes the most sense

#

There's no strict guidelines for how to name your classes one way or another

rare rover
#

i lied one more question xD

#

the best way to tackle enums is switch cases?

#

i've always wondered how to fully use enums

#

i'm guessing so since i've seen these in API's on github

worldly ingot
#

That's some ugly code. In Java 17 we'd do this because we have switch expressions now

public static InteractionHand fromEquipmentSlot(EquipmentSlot slot) {
    return switch (slot) {
        case HAND -> MAIN_HAND;
        case OFF_HAND -> OFF_HAND;
        default -> null;
    };
}```
rare rover
#

yeah

#

but switch cases is the way to go for enums?

worldly ingot
#

Depends on what you need. Sometimes you don't need the exhaustiveness of a switch to handle all cases

#

Sometimes you only need to check one or two constants

rare rover
#

so, what would i do then?

#

just if statements?

worldly ingot
#

Yeah

rare rover
#

alr

#

huge help

#

thanks alot

quaint mantle
rare rover
#

okay i got

#
    @Override
    public void saveData(@NotNull PlayerData value, @NotNull Predicate<PlayerData> predicate) {
        if (predicate.test(value)) {
            // TODO: save data to storage file
        }
    }``` this would be right correct?
river oracle
blazing flare
#

The same issue still occurs to what I had before (currently serializing to byte stream, then to base64, then into the json object) but I found out that after deserializing, it somehow becomes org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack as opposed to org.bukkit.inventory.ItemStack. Not really sure why, but I assume this is GSON's doing so to that I say sod it and I'll just create configuration sections instead. For context, I'm randomly generating a quest - it picks 5 random objectives and 5 random rewards, but I need to save that quest data. I'll figure something out.

worldly ingot
worldly ingot
#

If you pull it from an inventory, or from an event, or really anywhere where it wasn't directly constructed by new ItemStack(), it's probably going to be a CraftItemStack

quaint mantle
#

I would likely post on BBB

worldly ingot
#

I mean listen, you can try and make your onEnable() function native, but I'm unsure what benefit you believe it will bring

quaint mantle
worldly ingot
#

Someone will do it anyways

quaint mantle
#

Cause license system in

#

It just makes it more repelling to crack

river oracle
#

ugh license system people

#

you do more harm than good

#

your code isn't that good, if your plugin is simple enough someone will recreate it and release it for free

quaint mantle
river oracle
#

those people wouldn't purchase from you anyways

#

flawed ass logic, don't go try to cater to the people who wouldn't buy it in the first place, its annoying

wet breach
#

Cant serialize an interface

young knoll
#

ItemStack isn’t an interface

wet breach
#

I thought it was

young knoll
#

How you think people be doin new Itemstack(material) then :p

blazing flare
#

Nah it's that I use an adapter for ItemStack, so it handles it but I'd need an adapter for that specific version of CraftItemStack too, entirely redundant at that point tbh

wet breach
#

Maybe its from type erasure then

#

Only thing i can think of from that

rare rover
#

it feels very chunky with ? super Player

#

which idk if i need

#

lol

#

now i think of it

#

😓

worldly ingot
#

A few notes:
a. I don't imagine PlayerData will be generic with anything other than Player. Nothing extends Player (or nothing should). You're probably fine removing that generic entirely and saving yourself some headaches down the line
b. The Predicate in saveData() probably isn't super necessary if you're using it like that. The caller can probably just do a simple if statement before calling the method

#

Everything else seems fine

rare rover
#

yeah i changed ? super Player to just Player xD

worldly ingot
#

Well, your Optionals are annotated as @Nullable but the whole point of Optional is that they wrap a nullable value and they don't ever return null, so those should probably be NotNull but that's a nitpick

rare rover
rare rover
#

my methods even do ofNullable

#

lol

wet breach
worldly ingot
rare rover
#

true dat

worldly ingot
young knoll
#

PlayerData<Ocelot>

rare rover
#

well

worldly ingot
#

On another note, does your PlayerData hold reference to the UUID it's associated with?

#

As a field, that is? Do you have a PlayerData#getUUID()?

#

Because this method is confusing to me

    @Override
    public void unloadData(@NotNull UUID key, @NotNull Map<UUID, PlayerData<? super Player>> map) { }```
1. I would imagine you wouldn't need both a UUID key and a Map<UUID, PlayerData>. You would want one or the other, probably
2. If you do just want the Map to unload multiple player data instances, perhaps a Collection<PlayerData> is better because PlayerData would have #getUUID() you could refer to rendering the Map's keys redundant
rare rover
#

ahhh true

#

i do want K extends Player

#

so i can change if i need too

#

but it looks wayyy cleaner now

worldly ingot
#

What would you change it to though?

rare rover
#

idk

worldly ingot
#

Like I said, there's no other type than Player

#

That's the end of the line ;p

rare rover
#

iggg

#

but everything else is good?

young knoll
#

HumanEntity > Player

buoyant viper
#

did somebody say... Optionals?

young knoll
#

Facts

#

Tf is a hukkit

buoyant viper
#

my bukkit lib LOL

#

just to reduce my boilerplate

young knoll
#

At least it isn’t a cursed fork

buoyant viper
#

not yet

worldly ingot
#

I'm switching to fukkit

wet breach
#

Eventually you probably can use nothing but fork names to create some kind of story

rare rover
#

okayy

#

it looks pretty clean to me

#

honestly

echo basalt
#

There's room for improvement

rare rover
#

like?

#

if you dont mind

echo basalt
#

Not repeating yourself, returning futures because doing database operations in the main thread is bad etc

echo basalt
#

I'd name the class SQLStorage etc

#

This seems like a weird wrapper

#

This is how I do database stuff

rare rover
#

ah

#

i was going to learn more about CompletableFuture

#

all ik is its better for multithreading

echo basalt
#

bam

rare rover
#

@echo basalt srry for ping but i needa know if im doing this right so i dont keep going

#
    @Override
    public CompletableFuture<Optional<PlayerData<Player>>> getDataFromFile(@NotNull Player player) {
        return CompletableFuture.supplyAsync(() -> sqlHandler.loadData(player)).thenApply(data -> {
            if (data == null) return Optional.empty();

            PlayerData<Player> playerData;
            try {
                playerData = data.get();
            } catch (InterruptedException | ExecutionException e) {
                throw new RuntimeException(e);
            }
            dataMap.put(player.getUniqueId(), playerData);
            return Optional.of(playerData);
        });
    }```
#

or remove data == null and replace it with Optional.ofNullable

#

😭

#

idk if im doing this right

#

i asked ChatGPT and it says its right

#

but idk if i believe it

echo basalt
#

What's your data.get() method about

rare rover
#

its from CompletableFuture

#

i'm fixing the >>>

#

its annoying me

echo basalt
#

I mean

rare rover
#

also

#

do i need Optional?

echo basalt
#

I expected PlayerData to be a data class

rare rover
#

no

#

so should i remove it?

#

it is

#

im removing the generic

#

😆

echo basalt
#

Ideally your loadData method returns the data object itself

rare rover
#

wait

#

can CompletableFuture be null?

#

yes?

#

never used this before

#

srry

#

xD

echo basalt
#

You can supply a null value

rare rover
#

but cant actually be null

#

?

echo basalt
#

It's a.. future

rare rover
#

yeah that tells me nothing

#

ima say no

echo basalt
#

Sure

#

You wouldn't return null, you'd return a future that resolves to nothing

rare rover
#

oki

echo basalt
#

A future is basically a reference of an object that'll be available in the.. future

rare rover
#

so what should i do?

#

i changed somethings

#
    @Override
    public CompletableFuture<PlayerData> getDataFromFile(@NotNull Player player) {
        return CompletableFuture.supplyAsync(() -> sqlHandler.loadData(player)).thenApply(data -> {
            PlayerData playerData;
            try {
                playerData = data.get();
            } catch (InterruptedException | ExecutionException e) {
                throw new RuntimeException(e);
            }
            dataMap.put(player.getUniqueId(), playerData);
            return playerData;
        });
    }```
echo basalt
#

is your sqlHandler.loadData method returning a future?

rare rover
#

oh whoops

#

yep

echo basalt
#

Then you just

rare rover
#

well shouldn't i not do that?

echo basalt
#

return sqlHandler.loadData(player).thenApply(data -> {
...
});

rare rover
#

since it's already async?

echo basalt
#

And just work with that single future instead of creating a future of a future and joining

rare rover
#

oh my

#

thanks

#

that helps alot

#
    @Override
    public CompletableFuture<PlayerData> getDataFromFile(@NotNull Player player) {
        return sqlHandler.loadData(player).thenApply(data -> {
            dataMap.put(player.getUniqueId(), data);
            return data;
        });
    }```
#

its not goofy code anymore

#

😄

echo basalt
#

Exactly

rare rover
#

so for my loadData method

#

should i do:

    @Override
    public CompletableFuture<PlayerData> loadData(@NotNull Player key) {
        return CompletableFuture.supplyAsync(() -> {
            return null;
        });
    }```?
crude drift
#

I have a technical question- would it be possible to connect to the backend servers with online mode? You see, I'm attempting to join an external server but the problem is that I can't connect on online mode, I would happily put my credentials in the proxy as its running on my local machine.

#

I simply want to modify packets with bungeecord plugins

unborn sable
#

I am trying to use NMS (I am learning how to make plugins) and get this error when trying to add NMS to the pom.xml:
Missing artifact org.spigotmc:spigot:jar:1.20.1-R0.1-SNAPSHOT Java(0)

XML:

<dependency>
     <groupId>org.spigotmc</groupId>
     <artifactId>spigot</artifactId>
     <version>1.20.1-R0.1-SNAPSHOT</version>
     <scope>provided</scope>
</dependency>
crude drift
unborn sable
buoyant viper
#

"spigot" (not spigot-api) installs into ur local .m2 repository

crude drift
buoyant viper
#

you ran java -jar BuildTools.jar --rev 1.20.1 --remapped ?

buoyant viper
#

you need to run BuildTools to be able to use NMS

#

?nms

unborn sable
buoyant viper
#

do u have BuildTools downloaded?

unborn sable
#

I have no idea what I'm doing (never used NMS or BuildTools)

undone axleBOT
trim creek
#

This should help ^

unborn sable
#

Does it matter where I put the jar file?

trim creek
#

Yes.

buoyant viper
#

BuildTools? nah

trim creek
#

In some way, very yes.

#

If you want to keep it in your downloads folder, just make a seprate folder for it

#

Then you are good to go

buoyant viper
#

cant run it from DropBox, GDrive, or OneDrive sync folders

#

thats abt the only hard limit on where u cant run it

trim creek
#

The servers won't just check your session twice.

crude drift
trim creek
#

(for security reasons obviously)

#

How did you even use JavaScript for an MC JAVA server...?

crude drift
#

I mean having frontend bungee in offline mode and backend server (not mine) in online

trim creek
#

Not possible.

crude drift
#

it is

strange wolf
#

Using relative position in command arguments

trim creek
#

Neither Bungee and Spigot will accept it hehhahh huhh...

buoyant viper
trim creek
#

Bungee doesn't even let's you join an online mode spigot server

crude drift
#

No I used the raw node mc protocol

trim creek
#

I am sure you used some unsupported crap.

crude drift
#

"unsupported"

trim creek
#

But I'm tellin' ya, that BungeeCord DOES NOT allow you to connect to online mode Spigot servers.

crude drift
#

eh it may right now

#

I could probably git clone it and make it do that

trim creek
#

Jézus gyere le ments meg!

#

Ámen

#

🙏

wet breach
trim creek
crude drift
trim creek
crude drift
#

If its possible in one simple js file then how hard would it be to implement it in a proxy

crude drift
wet breach
#

If you set bungee to offline and the servers to online in theory it should work

trim creek
#

Neither of them allowed me to connect.

crude drift
#

I'm fine with my credentials being in the bungee

#

as its on my computer

wet breach
#

Bungee doesnt handle credentials

crude drift
#

I'm sure I could do some reverse engineering and see how the regular minecraft client authenticates

#

and replicate that on bungee side

trim creek
#

MCPReborn

wet breach
#

Basically client shares with server auth session data. Server then asks mojang auth servers if they are legit

crude drift
buoyant viper
wet breach
#

Mojangs auth lib is on github fyi

crude drift
#

honestly what im thinking is making it as easy as a drop in plugin

wet breach
#

Really all that needs to pass through is auth packets

#

In the proxy which shouldnt be hard

#

Only hard part is when players want to switch servers lol

crude drift
#

personally I dont need to switch servers

wet breach
#

Hence encryption stops at bungee

buoyant viper
#

if u dont want to switch servers.... why even run a middle-man ?

trim creek
#

I just tested to put bungee in offline mode, and put the Spigot into online mode. Safe to say it will not let me go on.

crude drift
#

without having to mod my client

grizzled oasis
#

Something to ask, how can i get the coordinate between 2 points, i have this "cube" selection (blockslist) and i want to get the corner a and b like a worldedit selection
https://paste.md-5.net/ivanatufej.cs

echo basalt
#

uHH

#

You want to make a cuboid that contains all the blocks in the list?

grizzled oasis
#

imagine like a corners and i want get them to then delete all of them, i already have the method i just need to get the pos1 and pos2 to delete all that amount of block

#

ded chat

echo basalt
#

P much

#

You got weird phrasing

#

Just start writing something

grizzled oasis
#

yes even in my main language i can't express myself so that's cool, i can't even in another language

wet breach
echo basalt
#

just a

#
double minX = Double.MAX_VALUE;
minY, minZ

double maxX = Double.MIN_VALUE;
maxY, maxZ

loop through points
if(x > maxX) maxX = x;
...

grizzled oasis
wet breach
#

Then you only need 2 loops to interate between two opposing corners.

wet breach
#

Yep that is the easy way

echo basalt
#

That is the proper way**

wet breach
#

Hard way is using math to calculate all the coords. In 2d space not all that hard

quaint mantle
#

Never touched SQL, how do formatting this work like what are the standards?

CREATE TABLE products
(
    id VARCHAR PRIMARY KEY,
    display_name VARCHAR NOT NULL,

)
wet breach
#

As long as you use , to separate the params. Format however. Just remember there needs to be a ; at the end

grizzled oasis
# echo basalt That is the proper way**
private Location getMinLocation(List<Block> blocks) {
        double minX = Double.MAX_VALUE;
        double minY = blocks.get(0).getY();
        double minZ = Double.MAX_VALUE;

        for(Block block : blocks) {
            if(block.getX() > minX) minX = block.getX();
        }
    }
#

should be this way?

wet breach
#

Almost

quaint mantle
echo basalt
#

flip the <

grizzled oasis
#

and for the max the other way, even intelli said that was an error didn't notest

#

soo should be correct for the rest?

echo basalt
#

something like that

#

I'd probably return a CuboidRegion so we don't loop twice

wet breach
#

You can do both max and min in the same loop. As you would increase one way decrease the other

grizzled oasis
#

im making it so i can use it in a code to delete blocks that requires the locations and i don't need to recall it again

echo basalt
#

I swear I've made this code before wait

grizzled oasis
#

Probably from X-Prison or old UltraPrisonCore

wet breach
#

If i was home i have a snippet for this but it uses bitshifts instead lol

echo basalt
#

I don't write prison stuff

#
private void calculateCuboid(Set<BlockVector> vectors) {
    BlockVector min = new BlockVector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    BlockVector max = new BlockVector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);

    for (BlockVector vector : vectors) {
        min.setX(Math.min(min.getBlockX(), vector.getBlockX()));
        min.setY(Math.min(min.getBlockY(), vector.getBlockY()));
        min.setZ(Math.min(min.getBlockZ(), vector.getBlockZ()));

        max.setX(Math.max(max.getBlockX(), vector.getBlockX()));
        max.setY(Math.max(max.getBlockY(), vector.getBlockY()));
        max.setZ(Math.max(max.getBlockZ(), vector.getBlockZ()));
    }

     master = new Cuboid(min, max);
}
#

yeah

#

I have

grizzled oasis
#

lol

wet breach
#

Looks like someone was nice tonight. Praise them uwu

wet breach
#

We dont always just give complete code to people

grizzled oasis
grizzled oasis
#

one question im asking why Air is Air_Void and Air_Cave only for sounds? or for some game mechanics unkown?

wet breach
#

Air cave is below the ground. Air void is in void space

grizzled oasis
wet breach
#

Mostly has to do with lighting since lighting is no longer stored in the chunk but separately

echo basalt
#

It might just be backwards-compatibility tbh

#

I don't see any uses in nms

#

And it doesn't exist in nms

wet breach
#

Probably could be for that

#

Havent dived into new nms stuff yet

echo basalt
#

It's an old material

wet breach
#

Well its probably from 1.16 or so. Old i suppose in that sense

grizzled oasis
#

looks like microsoft doesn't change, they done it with windows and now with minecraft, using old code and build only on top and just put more and more

wet breach
#

Its a mojang thing for remapping old worlds to new formats

echo basalt
#

Cave air is the air you find in caves. In this type of air you will hear cave sounds more often and bats will spawn more easily. Void air is pretty self explanatory. It's the air you find under bedrock

wet breach
#

Otherwise old worlds would crash

echo basalt
#

added in 1.7 pretty sure

grizzled oasis
wet breach
grizzled oasis
#

now in mines i will put cave_air So people will hear minecraft scary sounds

echo basalt
#

cave_air is 1.13+ huh

wet breach
#

I should break out the 1.5 spigot server at some point

grizzled oasis
#

Wtf?

echo basalt
#

And void air is 1.18+

#

odd

wet breach
#

Spigot

grizzled oasis
#

Does someone have the wiki of spigot 1.5? imagine coding plugin for that version

wet breach
#

Explains why i never seen those materials then

wet breach
grizzled oasis
echo basalt
#

frosty got a collection

wet breach
grizzled oasis
#

even dev builds

echo basalt
#

Frosty the kind of guy to buy 512gb sd cards to patch spigot on the go

grizzled oasis
#

if bro has dev builds from the computer of md_5 is top

wet breach
#

I dont have dev builds that md is working on. But i do have some of the dev builds that were released

grizzled oasis
#

now go on md_5's dms and ask him

#

so that way your collection is perfect

wet breach
#

He would just tell me to do it myself since i know the process of how its all done

wet breach
#

Both myself and md have been part of bukkit dev staff. I joined bukkit team a bit after md left them

wet breach
#

Almost

#

But i been messing with mc since the beginning though

#

And java since nearly its beginning uwu

grizzled oasis
#

how old are you, for messing on java?

wet breach
#

I am 32

#

Started messing with java in 2000

grizzled oasis
wet breach
#

98

crude drift
wet breach
#

Lol

crude drift
#

two words: Eaglercraft Legacy

wet breach
#

Think i have heard of that before

drowsy helm
#

honestly 1.5 was an iconic version of mc

crude drift
#

web browser minecraft yes

crude drift
#

I would play it at school with my friends

#

Finished with math work? Lets play minecraft!

#

I ran a server with it

#

That old server is gone

#

RIP HellTech SMP

#

Nowaways eaglercraft is on 1.8.8

#

And of course I run a server

#

its simply a bungeecord plugin

#

well its a plugin to allow connections from eagler

#

you still need to get a client from somewhere to join

rare rover
#

hmm

#

why isn't this running?

    @Override
    public void createTable() {
        CompletableFuture.runAsync(() -> {
            String SQL = "CREATE TABLE IF NOT EXISTS players (uuid TEXT PRIMARY KEY, generators TEXT, max INTEGER)";
            try {
                Connection conn = getConnection();
                Statement statement = conn.prepareStatement(SQL);
                statement.execute(SQL);
                conn.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        });
    }```
hybrid spoke
rare rover
#

ye

#
    public static void setupDatabase() {
        if (isAPILoaded() && !isDatabaseLoaded) {
            manager.setupDatabase();
            isDatabaseLoaded = true;
            plugin.getLogger().log(Level.INFO, "Successfully loaded InvoiceGens database!");
        }
    }```
hybrid spoke
#

well then

eternal night
#

don't swallow exceptions

hybrid spoke
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

rare rover
#

it just ain't executing

#

idk what else to say

eternal night
#

CompletableFutures require you to actively handle exceptions

#

throwing a runtime exception there won't print to the terminal unless you handle it

rare rover
#

okay...

#

so how would i do that?

#

but i tried broadcasting

#

before the try

#

and it didn't work

#

logging*

hybrid spoke
eternal night
#

^

hybrid spoke
rare rover
#

so like

#
    @Override
    public void setupDatabase() {
        CompletableFuture.runAsync(() -> {
            File file = new File(folder);
            if (file.exists()) return;

            file.mkdir();
            createTable();
        }).exceptionally(e -> {
            Bukkit.getLogger().log(Level.SEVERE, "Error setting up database: " + e.getMessage());
            return null;
        });
    }```?
eternal night
#

ye

rare rover
#

👍

#

okay

#

it executes now

#

but

#

doesn't create the .db

eternal night
#

did you also add .exceptionally to the createTable

rare rover
#

ahh

#

i see

#

[01:02:17 ERROR]: Error creating table: java.lang.IllegalStateException: Cannot connect to the database

#

i got

#
    private static String folder = String.valueOf(InvoiceGens.getPlugin(InvoiceGens.class).getDataFolder());
    private static String URI;

    private SQLConverter converter = new SQLConverter();

    static {
        URI = "jdbc:sqlite:" + folder + "/storage.db";
    }

    private Connection getConnection() {
        Connection conn;
        try {
            conn = DriverManager.getConnection(URI);
        } catch (SQLException e) {
            throw new IllegalStateException("Cannot connect to the database", e);
        }
        return conn;
    }```
#

for my connection

eternal night
#

provide the entire exception

rare rover
#

that's the whole exception

eternal night
#

oh

#

update your thing to print the whole stacktrace

#

instead of just the message

rare rover
#

alr

#

so i dont flood chat

#

ohh

#

i see why

#

let me fix

eternal night
#

yee

hybrid spoke
#

yeee

rare rover
#

hmm

#

wouldn't

#
URI = "jdbc:sqlite:" + folder + "/storage.db".replace("\\", "/");``` fix it?
#

but it didn't

#

for some reason

#

its not compiling that

#

cuz its reduntant

rare rover
#

im just using spigots

hazy parrot
#

Oh spigot include it

rare rover
#

ye

#

is my problem

#

ohh

hazy parrot
#

Add Class.forName("org.sqlite.JDBC"); before making connection

rare rover
#

wait wait

#

i might not have sqlite downloaded on my pc

#

i reset my pc

hazy parrot
#

What

rare rover
#

you need sqlite downloaded

hazy parrot
#

You don't need, it's shaded into spigot

rare rover
#

ah

#

so um

#

i fixed this:
[01:11:45 WARN]: Caused by: java.sql.SQLException: No suitable driver found for jdbc:sqlite:plugins/InvoiceGens/storage.db

#

but still giving error

sour folio
#

How am i ment to identify an inventory for a plugin, the only way i can think of is by name or an item in the inventory

rare rover
#

since it was jdbc:sqlite:plugins\InvoiceGens/storage.db before

#

hmm

#

now i get this

#

i fixed

#

tsm

#

xD

grizzled oasis
#

someone good with math?

#

Something went wrong on the code i "made"
https://paste.md-5.net/ekipawuvit.cs
I REMOVED 800 MILLIONS PIECES OF GRASS in like 1ms but thats something else
ok found out the max X is like -4.89E.
ok so clear things the biggest number in the X block on getMaxLocation should be -581 but it return false when checking X > Double.MIN_VALUE

hazy parrot
sour folio
grizzled oasis
grizzled oasis
#

ded chat

drowsy helm
#

just break blocks in a radius?

grizzled oasis
odd cobalt
#

please help how to Cannot resolve symbol 'EntityArmorStand', i'm switch from gradle to maven using mojmap

grizzled oasis
#

and then using a simple api to break all of them

odd cobalt
#

missing Cannot resolve symbol 'PacketPlayOutSpawnEntity'

drowsy helm
eternal oxide
#

using the wrong jar or you are not remapping

grizzled oasis
drowsy helm
#

no what are you defining as a layer

#

layer is amiguous

grizzled oasis
odd cobalt
#

where i can post my pom.xml

grizzled oasis
#

?paste

undone axleBOT
eternal oxide
#

so a layer is a 9x9x1 area?

#

or similar size

grizzled oasis
odd cobalt
#

this is my pom.xml whats wrong

eternal oxide
smoky anchor
eternal oxide
#

and your specialsource version is old

drowsy helm
#

like IWrappedRegion, ICuboidSelection

#

also have you tried debugging values and seeing where its messing up?

grizzled oasis
#

so the value remains Double.MIN_VALUE

drowsy helm
#

so -508 > min double value is being equated as false?

smoky anchor
eternal oxide
#

um

drowsy helm
#

wtf lmao

grizzled oasis
#

java broken

drowsy helm
#

looks like any negative number wont evaluate

grizzled oasis
#

so how to fix that?

eternal oxide
#

reverse the test

grizzled oasis
#

you mean from < to >

drowsy helm
#

x > -Double.MAX_VALUE

grizzled oasis
#

i tried that

#

doesn't work

drowsy helm
#

works for me

eternal oxide
#

-Double.MAX_VALUE < -508

warm mica
eternal oxide
#

or that ^

drowsy helm
smoky anchor
drowsy helm
#

you could also use Double.NEGATIVE_INFINITY

#

i think that is probably best in your usecase

#

removes precision errors

grizzled oasis
#

something to ask

#

but if the number is positive?

#

then doesn't go back to the same error

drowsy helm
#

like 508 > Double.MIN_VALUE?

grizzled oasis
#

it gives true but no reply to break blocks

drowsy helm
#

just use Double.NEGATIVE_INFINITY

echo basalt
#

damn I wasn't aware that jshell was a thing

#

saves my life

buoyant viper
#

ikr

#

lol

eternal oxide
#

the correct way should be -Double.MAX_VALUE

echo basalt
#

This is cool

smoky anchor
#

wait is Double.MIN_VALUE the smallest possible value like as a fraction ?

grizzled oasis
echo basalt
#

writing minigame

hybrid spoke
grizzled oasis
#

ok so the code that you suggested me for taking coordinate doesn't work because X goes in to 4.89E-342

drowsy helm
#

which code

#

we suggested alotta things lol

grizzled oasis
#

suggested me this code

hybrid spoke
#

what code

echo basalt
#

Why are you trying to replace like 19 quintillion blocks in a single for loop is my concern at the moment

grizzled oasis
drowsy helm
#
        double maxX = Double.NEGATIVE_INFINITY;
        for(blah blah x blah blah){
            maxX = Math.max(maxX, x);
        }```
echo basalt
#

ths is why you use integers instead

eternal oxide
#

Do not use MIN_VALUE

drowsy helm
#

yeah this could all be solved with ints lol

grizzled oasis
#

so just int

hybrid spoke
#

int or -Double.MAX_VALUE

drowsy helm
#

isnt double comparison more taxing anyway

grizzled oasis
#

solved with the easiest thing

#

int

eternal oxide
#

She's workign with block replacement so no point in Doubles anyway

grizzled oasis
#

nothing else

hybrid spoke
grizzled oasis
#

and again ImIllusion saved my day

wet breach
#

Generally the max of double wont fit into an integer and doubles use exponents to represent numbers unlike integers

drowsy helm
#

damn thats a kick in the teeth lol

wet breach
#

So would explain the weird numbers if you tried to stuff the max double into integer lol

wet breach
#

Really the only thing that makes it more taxing lol

tender shard
#

why do people always assume they can keep using the old, wrong class names, after switching to mojang maps?

#

I mean if the names wouldn'T change, then what would be the purpose of mojang maps

wet breach
chrome beacon
wet breach
#

And its like in some ways amazing because it would be nice to have that ability to just see something online throw it into my project and then not worry about it until some problem comes along and then come up with some weird bad aide fix for it

torpid idol
#

I have a question

#

How or where can i start to learn to code in bukkit

echo basalt
wet breach
wet breach
undone axleBOT
torpid idol
#

thanks

vapid verge
#

When you open up a tooltable (like a crafting table, furnace, loom, etc), does that utilize the CraftingInventory?

drowsy helm
#

no just inventory and crafting table

smoky anchor
#

. . . what are they asking about ?

drowsy helm
#

they're asking if furnaces and stuff count as CraftingInventory

chilly hearth
#

um

#

my code isnt working

smoky anchor
smoky anchor
undone axleBOT
#

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

drowsy helm
chilly hearth
#

public class freezecommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

    if(commandSender instanceof Player){

    Player player =(Player) commandSender;

    player.setInvulnerable(true);

    if(!player.isInvulnerable()){
    player.setInvulnerable(true);
    }else{
        player.setInvulnerable(false);
        }

    }

    return true;

}

}

smoky anchor
#

oh god

chilly hearth
#

bro

#

it doenst

drowsy helm
#

pls use code block

chilly hearth
#

?codeblock

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
chilly hearth
#

ops

smoky anchor
#

freezecommand
no
FreezeCommand

chilly hearth
#

?codeblock public class freezecommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

    if(commandSender instanceof Player){

    Player player =(Player) commandSender;

    player.setInvulnerable(true);

    if(!player.isInvulnerable()){
    player.setInvulnerable(true);
    }else{
        player.setInvulnerable(false);
        }

    }

    return true;

}

}

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
smoky anchor
#

use your brain a little bit

drowsy helm
#

so does the code not execute?

#

which bit doesnt work

tender shard
drowsy helm
#

` not '

chilly hearth
#

iam gona lose my mind

smoky anchor
#

Just copy the character....

chilly hearth
#

OMG

smoky anchor
#

Also, rename the fricking class to what I sent

chilly hearth
#

e

#

bro

#

i cant send the codeblock

#

i cant hit enter

smoky anchor
#

hit enter when you're outside of the backticks, the `

chilly hearth
#
public class freezecommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

        if(commandSender instanceof Player){

        Player player =(Player) commandSender;

        player.setInvulnerable(true);

        if(!player.isInvulnerable()){
        player.setInvulnerable(true);
        }else{
            player.setInvulnerable(false);
            }

        }

        return true;

    }
}
#

finaly

drowsy helm
#

yay

chilly hearth
#

lets go

#

anyhow its not working

smoky anchor
#

now you're just missing the "java" at the start
for pretty colors

smoky anchor
chilly hearth
#

heh ?

#

when

chilly hearth
#

sry i was figurign out codeblcok

chilly hearth
#

but ima still try again

tender shard
smoky anchor
#

does "invulnerability" work for players ?
Don't you have to go through abilities ?

tender shard
#

fuck discord

smoky anchor
#

LMAO

chilly hearth
#

@Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

        if(commandSender instanceof Player){

        Player player =(Player) commandSender;

        player.setInvulnerable(true);

        if(player.isInvulnerable()){
            player.setInvulnerable(false);
            
        }else{
            player.setInvulnerable(true);
        }
        }

        return true;

    }
}
#

will it work now ?

smoky anchor
#

no

chilly hearth
#

why ?

smoky anchor
#
player.setInvulnerable(true);

if(player.isInvulnerable()) {
  player.setInvulnerable(false);
}
else {
  player.setInvulnerable(true);
}
chilly hearth
#

so what it should be ?

smoky anchor
#

and the message I respond to

chilly hearth
#

and then i set it on based on the player

#

;-;

smoky anchor
#

I was explaining your error...
what you do is incorrect

chilly hearth
#

player.setInvulnerable(true);

#

A

#

I SEE

#

so what should it be ?

smoky anchor
#

if you do that the rest of the code will work with "true"

smoky anchor
#

you have literally been given a line of code

chilly hearth
#

i paste that there?

#

ok

#

let me try

drowsy helm
#
player.setInvulnerable(!player.isInvulnerable());
vapid verge
#

Digging a little deeper to what I'm trying to do.

When you put an item into a loom, what event is triggered?

smoky anchor
#

for like any inventory interaction (- creative inventory)

vapid verge
#

The slots in a loom count as inventory?

drowsy helm
#

yes

smoky anchor
#

are you writing a plugin ?

vapid verge
#

oh wild. Ok.

smoky anchor
drowsy helm
chilly hearth
#

where the heck i replace it with

#

do i replace in if statement ?

smoky anchor
#

All of that

#

should be deleted, burned in the flames of hell

#

and replaced with that single line of code
TWO ppl have provided you with

drowsy helm
#

chill he learning

chilly hearth
#

and that like of code will work ?

smoky anchor
#

||no, we gave you a wrong one for fun...||
Yes it will work

smoky anchor
chilly hearth
#

it worked

#

but

#

i dont still understand how that work and my code didnt it made sense ;-;

smoky anchor
#

Can someone else try to explain that ?

#

'cause I have failed

chilly hearth
#

iam new to java man

drowsy helm
#
boolean value = !player.isInvulnerable(); // Get the opposite of the current invulnerability state
player.setInvulnerable(value);
#

so you are inverting the current value

smoky anchor
chilly hearth
#

lol

drowsy helm
#

so with your code you were setting invulnerability to true, then checking if it was true, which is always true

chilly hearth
#

bro if i dont understand java how can i understand the points u giving in english man

drowsy helm
#

so it's always going to set it to false

chilly hearth
#

?

smoky anchor
#

it inverts the current value

chilly hearth
#

AHHHHHHHHH

#

GOT IT

#

but then why my code dditn work ? it was also right ?

smoky anchor
#

no
no it wasn't

#

you were first setting the value to true

smoky anchor
#

so the rest of the code always worked with "player is invulnerable"
And then it set it to false

chilly hearth
#

alr

#

ok now i want to send thnem a message on vanuralble and invanurable

#

but there is no else ;-;

drowsy helm
#

you don't need an else

chilly hearth
#

then ?

drowsy helm
#

just do an if statement on isInvulnerable

#

then print accordingly

chilly hearth
#

alr

smoky anchor
drowsy helm
#

else statements exist lol

smoky anchor
drowsy helm
#

he said there is no else im assuming he meant on the whole blockl

chilly hearth
#

a

#

guys

#

  public void onPlayerMove(PlayerMoveEvent e){

        Player p =(Player) e.getPlayer();
       if(p.isInvulnerable()){
       e.setCancelled(true);

    }else{
           e.setCancelled(false);
       }


    }



}
smoky anchor
#

mhm
that is certainly a piece of code
that may or may not do something that you may or may not want
we don't know

drowsy helm
#

looks like a rubberbanding nightmare lol

smoky anchor
#

I am way too hostile aren't I

chilly hearth
#

bro

#

i want them to be freezed

drowsy helm
#

consider using slowness 1000

#

instead of cancelling movement

chilly hearth
#

they can still jump

#

otherwise before i did setwalkspeed 0

smoky anchor
#

wasn't riding an entity a better solution ?

chilly hearth
#

riding ?

smoky anchor
#

I guess not in your case actually

drowsy helm
#

i mean it should

#

but itll be laggy

chilly hearth
#

its not working

#
        getCommand("freeze").setExecutor(new freezecommand());
        getServer().getPluginManager().registerEvents(new MoveEvent(), this);

    }


}```
smoky anchor
#

well... from what little I see, you're missing the @EventHandler

chilly hearth
#

we register it like that right

drowsy helm
#

yes

smoky anchor
#

bro, rename the class freezecommand to FreezeCommand

chilly hearth
drowsy helm
#

does MoveEvent implement Listener

#

and does the method have @Eventhandler

chilly hearth
#

i forgot eventhandler

#

thx steve

smoky anchor
chilly hearth
smoky anchor
#

Because the class name is wrong

chilly hearth
#

does that cause any issues ?

smoky anchor
#

It does not matter that it works, it is wrong

smoky anchor
chilly hearth
#

welp its works means it works : )

#

fine i will

smoky anchor
#

never open source that code then

smoky anchor
chilly hearth
#
public class Freezecommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {

        if(commandSender instanceof Player) {

            Player player = (Player) commandSender;

            player.setInvulnerable(!player.isInvulnerable());

            if(player.isInvulnerable()){
                player.sendMessage("you have been freezed!");
            }else{
                player.sendMessage("Your free!");
            }
        }

        return true;

    }
}```
#

there u go

#

: )

drowsy helm
#

lesgo

smoky anchor
drowsy helm
#

steve nitpicking everything lmao

smoky anchor
#

Well... I just do what I do at my job, review code and provide review comments :D

#

Tho at work they are less aggressive

drowsy helm
#

i lvoe passive aggressive code review comments

chilly hearth
#

xD

worthy moat
#

How can I sort a List of Players in a HashMap<TeamType, Array<UUID>> so every Team has not more than 6 players and the rest does equalliy have the same amount?

#

For example I have 4 Teams.... 2 of them are already full and there are only 2 or 3 player left to get sorted into the rest

drowsy helm
#

ideally each team should be it's own class

#

but just iterate over the map enty and check the count

worthy moat
#

cant follow

eternal oxide
#

add the next player to the team with the lowest member count

#

If you know how many players you start with

#

its even easier

worthy moat
#

With the lowest ArrayList

eternal oxide
#

You can use a TreeMap with a Comparator to always have the lowest member count teams first

worthy moat
eternal oxide
ivory sleet
#

Use two maps bro

#

One TreeMap and one HashMap

#

or maybe even just a TreeSet

#

Then u have TreeSet::ceiling and ::floor, ::last, ::first etc

twilit creek
#

Hey, is Custom Pathfinder Goals in 1.20 possible?

ivory sleet
#

They’re possible

#

But iirc no api in spigot for it

#

So u need to use nms

twilit creek
ivory sleet
#

What error?

#

Also, u probably need to override the methods that already register goals

eternal oxide
#

spawn mob in spawn event again

twilit creek
#

'z()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'z()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type

dire marsh
#

Is there a way to resend every visible chunk to a player, or is the only way to manually check distance and use nms to resend the packet

eternal oxide
undone axleBOT
hybrid spoke
twilit creek
#
package de.splatcrafter.leavessimulator.entity.craftentity;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.monster.EntityVex;
import net.minecraft.world.level.World;
import org.jetbrains.annotations.Nullable;

public class CraftBee extends EntityVex {
    public CraftBee(EntityTypes<? extends EntityVex> entitytypes, World world) {
        super(entitytypes, world);
    }

    @Nullable
    @Override
    public Entity v() {
        return null;
    }

    @Override
    public boolean f_() {
        return false;
    }
}

public class CraftBee extends EntityVex Error: 'z()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'z()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type

dire marsh
#

lol

dire marsh
#

isn't it f3+a anyway

hybrid spoke
#

yeah corrected it

#

idk my keyboard doesnt have an f3

dire marsh
#

I tried resendChunk on the entire world's loaded chunks but 0 packets get sent to the player so ig that's just not working

odd cobalt
#

please help, i use mojmap why this is missing:

import net.minecraft.core.Vector3f;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.protocol.game.*;
import net.minecraft.world.entity.EnumItemSlot;
import net.minecraft.world.entity.decoration.EntityArmorStand;

need to add local library for this?, but the mojmap work, thanks for help me

chrome beacon
#

Since you're using Mojmapped

odd cobalt
#

i need to add local lib for this?

tender shard
#

No

#

?switchmappings

tender shard
#

^

odd cobalt
#

okay thanks, let me test

tender shard
#

EntityArmorStand eg is not a mojang mapped name

odd cobalt
#

okay i understand

twilit creek
#

Is the mojang mapped name from EntityVex = Vex?

tender shard
#

?nms

tender shard
#

check it out yourself ^

#

oh wait wrong link

#

?switchmappings

tender shard
#

this ^

remote swallow
#

?mappings

undone axleBOT
vapid verge
#

What is the Material for banners? I see a bunch of different type of banners. Is there a class that emcompasses them all?

smoky anchor
#

no, but you can use the Banners tag

smoky anchor
tender shard
#

you can either do Tag.BANNERS.getValues() which returns all banners, or Tag.BANNERS.isTagged(Material.SOMETHIING)

tender shard
vapid verge
#

something like this for a check?: Tag.BANNERS.getValues().contains(bannerItem.getType())

tender shard
#

no, rather do isTagged

vapid verge
#

Ah ok.

#

4am coding is frying my brain. That makes way more sense lmfao

tender shard
vapid verge
#

Wild

paper cosmos
#

Can I hide damage and attack speed in a tool itemstack?

paper cosmos
#

thank you

spark lynx
#

How does real players keep chunks loaded & ticking the area?
i wan't to make my fake player close to how real player does.

deft summit
#

How do I show a Player an entity that only exists for him? In older versions I would just send a specific packet, but it seems that packets don't really exist anymore??

smoky anchor
#

packets don't really exist anymore
How would servers work then ?
Email ?
They do exist, you're probably not looking at the right place.

young knoll
#

Packets definitely still exist

deft summit
#

The thing is i literally don't have any imports from net.minecraft

#

so im hella confused

eternal oxide
#

They stopped using packets as they found Magic was more efficient.

young knoll
#

?nms

young knoll
deft summit
eternal night
#

send the updates by owl

eternal oxide
#

Not sure what kind of ping that would give

young knoll
#

Depends on the speed of the owl

onyx fjord
#

does spigot api have a method that is similar or the same as bed respawning position finder?

smoky anchor
onyx fjord
#

?

#

i mean like the logic bed uses to choose a safe position

mellow pebble
#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
__**Admin:**__

selfrole Add or remove a selfrole from yourself.

__**Cleanup:**__

cleanup Base command for deleting messages.

__**Core:**__

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

__**Downloader:**__

findcog Find which cog a command comes from.

__**Mod:**__

names Show previous names and nicknames of a member.
userinfo Show information about a member.

__**ModLog:**__

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

__**Permissions:**__

permissions Command permission management tools.

twilit creek
#

I have used nms mojang mapping for my class:

package de.splatcrafter.leavessimulator.entity.craftentity;

import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vex;
import net.minecraft.world.level.Level;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;

public class CraftBee extends Vex {
    public CraftBee(@NotNull Location location) {
        super(EntityType.VEX, level);
    }
}

but where can i get "level" (net.minecraft.world.level.Level)?

smoky anchor
smoky anchor
young knoll
#

^

twilit creek
young knoll
#

It’s ((CraftWorld)location.getWorld()).geHandle()

smoky anchor
#

you can't cast spigot World to MC world, you have to go throught the handle

onyx fjord
#

what event triggers when player sets respawn bed by right click?

twilit creek
young knoll
#

I thought worldserver inherited level

#

Somewhere

twilit creek
#

Required type:
Level
Provided:
WorldServer

super(EntityType.VEX, ((CraftWorld)location.getWorld()).getHandle());

eternal night
#

isn't WorldServer a spigot name

quiet ice
#

World is Level

eternal night
#

yea

#

WorldServer shouldn't exist anymore, its called ServerLevel

twilit creek
#

But not extends it

eternal night
#

fam

quiet hearth
#

I wanna access material by its ordinal but i dont want to clone a 1000 sized array is it better to just use reflection to access enum's array

eternal oxide
#

ordinal is a bad idea

twilit creek
eternal night
#

What does

#

Are you not using the remapped server

eternal oxide
#

Spigot mappings are not used in new versions

twilit creek
eternal night
#

can you share your pom.xml

#

?paste

undone axleBOT
twilit creek
eternal night
#

you have a duplicate dependency

#

remove the one without remapped-mojang

twilit creek
eternal night
#

ye

twilit creek
#

i removed it

#

oh now it works

#

thanks, i hope the other code from me works too.

#

But how to spawn the Bee or in our case the CraftBee extends Vex?

eternal night
twilit creek
#

i mean i want to spawn the entity in the world on the location from the player

smoky anchor
#

level.addFreshEntity(yourFancyVexBeeMutantEntity)

#

I think

twilit creek
smoky anchor
#

idfk
I haven't done custom entities in years lol
Try it and see

twilit creek
#

if i only create a new instance from it on calling it in a command it not works.

smoky anchor
#

well you can't spawn this custom entity with vanilla commands
You would have to listen to some event

#

what command did you try btw :D

twilit creek
#

an own command like /debug for me.

#
                } else if (args[0].equalsIgnoreCase("bee")) {
                    Location loc = player.getLocation();
                    CraftBee bee = new CraftBee(loc);
                    player.sendMessage("§aBiene gespawnt!");
                }
smoky anchor
#

does it work if you run the command as a player ?

#

like from chat

twilit creek
#

i get the message but the entity dont spawn.

smoky anchor
#

ye I can't help much with this
Hope someone who knows custom entities comes to help you :D

sullen wharf
#
    public CustomBee(Location location) {
        super(EntityType.BEE, getWorld(location.getWorld()));
        setPos(location.getX(), location.getY(), location.getZ());

        level.addFreshEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    }

    private static ServerLevel getWorld(org.bukkit.World bukkitWorld) {
        return ((CraftWorld) bukkitWorld).getHandle();
    }
twilit creek
#

thanks, i try it.

sullen wharf
#

simply do new CustomBee(player.getLocation()) and then you might want to track that custom entity, if you need it

sullen wharf
#

you can always use instanceof to check if x entity is that custom one

twilit creek
sullen wharf
#

test it

twilit creek
#
package de.splatcrafter.leavessimulator.entity.craftentity;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Vex;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull;

public class CraftBee extends Vex {

    public CraftBee(@NotNull Location location) {
        super(EntityType.VEX, getWorld(location.getWorld()));
        setPos(location.getX(), location.getY(), location.getZ());

        getWorld(location.getWorld()).addFreshEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    }

    private static ServerLevel getWorld(org.bukkit.World bukkitWorld) {
        return ((CraftWorld) bukkitWorld).getHandle();
    }
}
                } else if (args[0].equalsIgnoreCase("bee")) {
                    Location loc = player.getLocation();
                    new CraftBee(loc);
                    player.sendMessage("§aBiene gespawnt!");
                }

its not working but i dont get errors or other things. "player.sendMessage("§aBiene gespawnt!");" is executed and works but the bee dont spawn. (or in our case the vex)

eternal oxide
#

Don;t Vex only spawn on a grass block?

twilit creek
#

oh i think i am stupid

#

ooohhhh i am so stupid

#
@EventHandler
    public void onMobSpawn(EntitySpawnEvent event) {
        if (!(event.getEntity() instanceof Player) && !(event.getEntity() instanceof Bat) && !(event.getEntity() instanceof FallingBlock)) {
            event.setCancelled(true);
            try {
                event.getEntity().remove();
            } catch (Exception ignored) {
            }
        }

Oh nooo, im stupid af.

sullen wharf
#

🤔

eternal oxide
#

must be another mob I'm thinking of

twilit creek
#

now it works without it.

#

im sooo sorry for all the time i wasted from all who wanted to help me.

#

Can i set custom pathfinder goals on the entity?

smoky anchor
#

yes

twilit creek
#

Can you show me how or is there an tutorial?

smoky anchor
#

You can look how vanilla mobs do AI

twilit creek
#

i think

smoky anchor
#

That's good
Means you are

twilit creek
#

registerGoals is the method i think

spark lynx
#
serverplayer.connection.send(new ClientboundSetChunkCacheCenterPacket(serverplayer.chunkPosition().x,serverplayer.chunkPosition().z));

i tried to send this packet by the serverplayer (fake player) , it doesn't keep it's positioned chunk loading.
or is there other ways to let fake player chunk load.

eternal night
#

sending a packet to a fake player obviously does nothing ?

spark lynx
#

isn't the packet sent to the server?

eternal night
#

no ?

#

Clientbound

#

just load chunks via plugin tickets

#

or actually spawn the server player in the world and have the server believe it is a real player

#

that is rather dangerous tho

eternal oxide
#

fake players have null send methods

#

at least when implemented correctly

smoky anchor
eternal oxide
#

when not it crashes your server

eternal night
#

when half the logic on it is not gonna work

#

e.g. no movement

#

or plugins doing hacky things with the player instances

smoky anchor
#

just bundle the plugin with a minecraft client smh
||don't, legally you can not :D||

spark lynx
#

the only ticket found in serverplayer.class is TicketType.POST_TELEPORT, how real player does load the chunk then

eternal night
#

the server maintains tickets for every real player

ionic terrace
#

For a minecraft plugin, do you think having each server having their own way of storing the data such as file based or their own database or do you think a way of centralizing the data such as what luckperms does like a website?

hybrid spoke
#

anyways, that really depends on the usecase

#

but normally you want to use a database