#help-development

1 messages · Page 2055 of 1

ivory sleet
#

yeah, it looks a bit overkill and complicated at first perhaps, but collectors come real handy

dapper ether
#

how do i import worlds?

ivory sleet
#

probably wanna look at world creator

dapper ether
#

but i got the world as a folder

tender shard
#

I just noticed I need the class instance

dapper ether
#

its just not imported

tender shard
#

to return them in PersistentDataType#getComplexType

granite owl
#

@valid solstice can i be honest

#

if you wanna work with vectors

#

go learn how to do it on paper first

desert musk
#

math!

granite owl
#

because if u dont really understand what ur doing its not going to work anyway

desert musk
#

physical paper

quiet ice
#

yes, physical

granite owl
#

i mean physical paper xD

#

if you really wanna do it

desert musk
#

math is good

granite owl
#

learning vectors is 1 week of your time

quiet ice
#

can you even make a parallel vector?

granite owl
#

the basics

#

ive counted in not knowing linear functions

desert musk
#

just learn linear algebra 🤷

#

a minor pause from your project

quiet ice
#

Because the bukkit vector is only x,y,z but does not include any xoff, yoff, zoff and stuff like that

glossy venture
#

vector is just an array of weights which can then produce one weight/line in any direction

#

right

granite owl
#

ive hated those topics

#

but if u need it

#

its deff worth it

granite owl
#

but in essence yes

granite owl
#

an array with the size of n

glossy venture
#

offsets?

quiet ice
#

xOffset

glossy venture
granite owl
#

and if its a multidimensional array its called matrix

glossy venture
valid solstice
#

multiplication, cross multiplaction, dot product etc..

granite owl
#

but u didnt learn what u need

#

cause im 100% sure

#

that this is basic school material

#

for higher degrees

#

i just didnt pay good attention i guess

#

🤣

spare canyon
#

if i make a listener and the register events with getServer().getPluginManager().registerEvents(), can i delete the listener later in the process?

#

like wont it cause errors or stuff

glossy venture
#

yes use HandlerList.unregisterAll(Listener)

#

or something along those lines

spare canyon
#

oh thanks

#

i was looking for an unregister function but couldnt find it

#

in the PluginManager at least

quiet ice
granite owl
#

btw dumb question of mine, PDC is just a wrapper class for nms tags right?

quiet ice
#

Depends, but mostly yes

tender shard
#

yes and no

glossy venture
granite owl
#

whats the no part of it

tender shard
#

for the example that you cannot access vanilla NBT tags

granite owl
#

yea

tender shard
#

PDC can only access NBT tags that were also created using PDC

quiet ice
glossy venture
#

how does pdc store chunk info

granite owl
#

but like putting pdc keys is in the backend accessing nms methods right?

tender shard
granite owl
#

kk

errant narwhal
#

hi

#

someone help please

tender shard
#

?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!

glossy venture
#

if you want to describe an object you use two

#

ive never heard of vector offsets

dapper ether
#

how do i teleport to other worlds?

errant narwhal
#
Block o = event.getBlock();
                                          x.remove(o.getX());
                     y.remove(o.getY());
                     z.remove(o.getZ());
                     plugin.getConfig().set("x", x);
                     plugin.getConfig().set("y", y);
                     plugin.getConfig().set("z", z);
                     plugin.saveConfig();
errant narwhal
#

but

quiet ice
#

Well the vector offset that I mean is mostly just the origin point of the vector

glossy venture
errant narwhal
granite owl
#

ur trying to remove individual coords from a block?

dapper ether
glossy venture
#

yes

dapper ether
glossy venture
#

yeah

granite owl
dapper ether
#

well how

glossy venture
#

oooh you mean through commands tp to other world

dapper ether
#

yes

glossy venture
#

idk

errant narwhal
# granite owl u

sure i make an arraylist but when i using x.remove it have errors

granite owl
#

tp to another world

dapper ether
#

mh okay then i will just create my own command for this

#

thanks orbyfied for helping

granite owl
#

u can code one

granite owl
#

the bukkit method always takes the targetworld as a param

glossy venture
#

you need to give more information

#

and not write 10 messages after eachother inbetween other conversations

granite owl
quiet ice
#

The execute command supports this

granite owl
#

the code

glossy venture
#

give us the stack trace

quiet ice
#

Not sure what the syntax is, but I certainly know that execute supports cross-world tp @dapper ether

granite owl
#

feels so messy

glossy venture
granite owl
#

@errant narwhal

Caused by: java.lang.ArrayIndexOutOfBoundsException
glossy venture
#

oh no nevermind

#

areayindexoutlfbounds

errant narwhal
granite owl
#

the mem address hes pointing to is null

granite owl
#

ur pointing to a higher integral number

#

than ur index is big

glossy venture
#

ignore what i said

granite owl
#

because .getX is giving a number

#

so ur lf the .getX()'st array entry

errant narwhal
granite owl
#

i dont think u get me bro

errant narwhal
#

about change this to long?

granite owl
#

u remove the .getX()'st list entry

#

not the first find

#

with that value

#

u need to

#

list.remove(list.find(.getX()))

#

something like that

errant narwhal
#

ok

granite owl
#

dont forget the guard clauses

errant narwhal
granite owl
#

lists dont contain find only maps do

#

iterate your array til you have a match

glossy venture
#

its list.indexOf(...)

granite owl
#

tbh i always use maps whenever the order is irellevant

#

working very well with ini files

#

after all

glossy venture
#

whats a good way to record short clips of a specific part of the screen as a video

#

i see people sending quick videos here always

#

but i need to open obs and then focus it and then record it and then send it

granite owl
#

microsofts built in recording software?

glossy venture
#

?

#

how

granite owl
#

ctrl windows R or so

#

and then ur in the xbox game menu

#

from there u can start recordings

glossy venture
#

oh

#

win + G

granite owl
#

or u use nvidias

#

recorder

glossy venture
#

i have a better gpu: the intel uhd integrated graphics 680

granite owl
#

i think most ppl nowadays use nvidias recoder

#

which makes sense since u need to control the gpu anyway

#

makes sense that the manufacturer offers a software for it

glossy venture
#

ok so im having weird behaviour with this code:

InventoryAction action = event.getAction();
switch (action) {
    case HOTBAR_SWAP:
    case PLACE_ALL:
    case PLACE_SOME:
    case PLACE_ONE:
    case DROP_ALL_SLOT:
    case DROP_ONE_SLOT:
        event.setCancelled(true);
        return;
}

ItemStack cursor = event.getCurrentItem();
if (cursor == null) return;
inv.setItem(slot, cursor.asQuantity(1));
if (event.getClick().isRightClick()) {
    cursor.setAmount(64);
}
event.setCursor(cursor);
#

it seems like it always places one back

#

into the inventory

#

while im only clicking once

#

how can i prevent this?

#

should i cancel the event and set the cursor?

granite owl
#

yea

#

thats not weird

glossy venture
#

ah ok

granite owl
#

it does what ur telling it to xD

#

so

#

u set it only once as quantity 1

#

and then u adjust the itemstack to Q64

#

but never apply it to the slot

glossy venture
#

i mean im clicking to pick up an item but then i set the cursor and it places it back

glossy venture
#

i want 64 in my hand when i right click

granite owl
#

just get the itemslot of the cursor and set the item to it

glossy venture
#

thats what im doing

#

but i changed it to this now:

#

oh that seems to almost work

granite owl
#

the bukkit api is too big needa check it myself although ill do some rl tasks first

tender shard
#

Am I stupid or is this a MockBukkit bug?

@Test
    void testItemStack() {
        final NamespacedKey key = getKey("itemStack");
        final ItemStack itemStack = new ItemStack(Material.DIAMOND_ORE);
        player.getPersistentDataContainer().set(key, DataType.ITEM_STACK, itemStack);
        final ItemStack savedItemStack = player.getPersistentDataContainer().get(key, DataType.ITEM_STACK);
        assert itemStack.equals(savedItemStack);
    }
[16:40:19 SEVERE]: Could not call method 'public static org.bukkit.inventory.ItemStack org.bukkit.inventory.ItemStack.deserialize(java.util.Map)' of class org.bukkit.inventory.ItemStack for deserialization
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.732 s <<< FAILURE! - in com.jeff_media.morepersistentdatatypes.AllTests
[ERROR] com.jeff_media.morepersistentdatatypes.AllTests.testItemStack  Time elapsed: 0.031 s  <<< ERROR!
java.io.IOException: Failed to deserialize object
    at com.jeff_media.morepersistentdatatypes.AllTests.testItemStack(AllTests.java:81)
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because the return value of "org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(java.util.Map)" is null
    at com.jeff_media.morepersistentdatatypes.AllTests.testItemStack(AllTests.java:81)
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   AllTests.testItemStack:81 » IO Failed to deserialize object
granite owl
#

is ItemStack serializable?

glossy venture
quiet ice
tender shard
glossy venture
#

testing world lmfao

granite owl
#

ur new itemstack instance is missing the quantity param

#

so ur calling a different constructor

#

might be the problem idk

tender shard
#

wdym? new ItemStack(...) creates a stack with amount 1

#

also the error message is clearly about the deserialization and not about creating an itemstack 😛

granite owl
#

well not neccesseary

#

if it got scrambled during serialization

#

it obv cant be deserialized

tender shard
#

so you want to tell me that ItemStack's that were created using new ItemStack(Material) cannot be deserialized again? Because I 100% doubt that

granite owl
#

idk it just peaked out

vague swallow
#

!paste

glossy venture
#

every item stack has a quantity

vague swallow
#

?paste

undone axleBOT
glossy venture
#

so i dont think thats it

granite owl
#

wait

#

ur not passing an instance to the key either

#

try to use this as 0st param

#

@tender shard

tender shard
vague swallow
#

Please help me,
I am saving UUIDs in a configuration file and can read them from the config but when I'm reloading the server then it fales to load the config and I'm getting a huge error. This is my error: https://paste.md-5.net/gosugixunu.rb

granite owl
#

to identify the plugin the key belongs to

tender shard
#

bruh if anything except the serialization was a problem, then I would have gotten another error message

tender shard
#

getConfig().set("something",myUuid.toString())

#

then load it again using
UUID.fromString(getConfig().getString("something"));

vague swallow
#

I'll try that

desert musk
#

is anyone else trying to use github with intellij that could answer this? how do i share an intellij project into an existing repo?

modern vigil
#

Is there another way to get an enchantment without using Enchantment#getByKey?

tender shard
modern vigil
#

No, I want to convert e.g SHARPNESS to Enchantment.DAMAGE_ALL

tender shard
#

you'll have to force push your stuff since the histories are unrelated. it would be a way better idea to just create a new repository

desert musk
#

alright

#

new to github as well so i’m not familiar with really what a repo is

#

but a new repo for each project seems a bit much to me ig

tender shard
#

a repository is like "your project". someone can clone (= "download") it, make changes on their PC, and then submit and push ("=upload") it. However git doesn't allow you to upload stuff if you haven't downloaded it from the same repository, in very easy words

desert musk
#

i see so it’s not really a database

#

or it is

tender shard
#

I'd just click on VCS -> Share on GitHub and create a new repo

desert musk
#

but just for a specific thing

#

meant to be downloaded

tender shard
#

it is a "database" for changes made to files

desert musk
#

it’s not like a “front page” rather

#

idk what im saying

tender shard
desert musk
#

but i was just trying to make a repo for my entire minecraft server to have all of its resources inside of it

#

but that’s not conventional from what i gather

modern vigil
#

I read the Javadoc and getByName is deprecated, back to getByKey

tender shard
desert musk
#

i see, ok

tender shard
#

git is a bit complicated at first

desert musk
#

lol

hasty prawn
#

I still don't really understand it

#

I can commit, push, pull, clone

#

and...

desert musk
#

lmao

#

yeah imma try to understand it

#

we’ll see…

quiet ice
hasty prawn
#

Oh yeah I could probably do that

#

"wdym there's a merge conflict"
deletes everything
"there fuk u now there's not"

desert musk
#

lol

quiet ice
#

My biggest fear is that I accidentally commit a merge conflict without git noticing

desert musk
#

it doesn’t notice sometimes?

#

shit

tender shard
#

well reverting stuff is easy though 😄

quiet ice
#

it never prevents you from commiting a merge conflict

tender shard
#

(although I don't know how it works in CLI - I can only revert commits with IntelliJ or github's website lol)

desert musk
quiet ice
#

I usually ammend

tender shard
quiet ice
#

I only rely on syntax errors to detect merge conflicts

vague swallow
desert musk
#

oh boy

tender shard
vague swallow
#

what's the different?

tender shard
#

that's basic java

#

?learnjava

undone axleBOT
hasty prawn
#

There's a new blog post for you alex

quiet ice
#

git status will still say that there is a conflict even if you resolved it - you can still git add no matter whether it was resolved

tender shard
hasty prawn
#

Difference between == and .equals()

tender shard
quiet ice
#

Perhaps with the advent of primitive objects this issue might get resolved

#

Or perhaps even worsened

desert musk
#

my understanding was just that .equals could be overloaded

tender shard
# vague swallow thanks

TL;DR: If we both buy the same tshirt, our tshirts are equals() but they aren't ==. although they look identical, they are two different objects

quiet ice
#

Probably latter

desert musk
#

cuz java’s pissy and wont let you operator overload

tender shard
#

== checks if it's the exact same tshirt, equals() checks if they are the same size, have the same print, are equally dirty, etc etc

desert musk
#

oh

#

weird

vague swallow
tender shard
vague swallow
#

yeah I'm still at the beginning

tender shard
desert musk
#

so == is about memory addresses??

tender shard
#

yes

desert musk
#

wow

tender shard
#

if you look at new Object().equals(), you'll see that it also only does ==

desert musk
#

that’s strange

tender shard
#

but now check what new ItemStack().equals() does

desert musk
#

right

#

makes sense

tender shard
#

here's the equals() of UUID:

    /**
     * Compares this object to the specified object.  The result is {@code
     * true} if and only if the argument is not {@code null}, is a {@code UUID}
     * object, has the same variant, and contains the same value, bit for bit,
     * as this {@code UUID}.
     *
     * @param  obj
     *         The object to be compared
     *
     * @return  {@code true} if the objects are the same; {@code false}
     *          otherwise
     */
    @Override
    public boolean equals(Object obj) {
        if ((null == obj) || (obj.getClass() != UUID.class))
            return false;
        UUID id = (UUID)obj;
        return (mostSigBits == id.mostSigBits &&
                leastSigBits == id.leastSigBits);
    }

desert musk
#

sheesh

quiet ice
tender shard
#

it simply compares whether the internal values (mostSigBits and leastSigBits) are equal, and if yes, two UUIDs are also considered equals() even if they are actually two different objects. but obviously both represent the same UUID so they are equals()

desert musk
quiet ice
#

it clones the item meta once or twice and noone has bothered to fix it

#

Not even the paper team

#

At this point I'm afraid to fix it myself

desert musk
#

lol

hasty prawn
quiet ice
#

?stash

undone axleBOT
tender shard
#

Does someone know how I can remove all those @ NotNull annotations from the generated javadocs? it looks like a mess

#

also they somehow appear twice in the description of each method

desert musk
#

lmao

chrome beacon
#

Appearing twice is a known bug

tender shard
#

yeah but why does noone fix it lmao

#

I'd rather not show them at all

desert musk
#

what in the world

hasty prawn
#

Oh huh

#

You should fix it then peepoGiggles

opal juniper
quiet ice
#

NNY talked about this ages ago, there is at least one PR that fixed this

opal juniper
#

miss that man

tender shard
#

but is that actually a problem?

#

I mean okay it's not nice but I'd rather see pull requests for new features instead of fixing stuff that's been working fine since 10 years 😄

quiet ice
#

imagine doing this with a shulker box full of fully written books. not sure if performance would be tanking but it could be

copper scaffold
#

i have a question how can i make a compass for manhunt that can track a player? can someone help me with that pls?

tender shard
quiet ice
#

I know that getItemMeta is a pretty expensive call either way - I improved the performance of my CE plugin drastically by removing/caching these calls

tender shard
#

You can use CompassMeta#setLodestone(Location)

copper scaffold
#

okay thx

opal juniper
#

doesnt that only work if there is a Lodestone at that location or something

tender shard
#

I highly doubt that

#

since it takes a Location and not a block

#

and that location could be in an unloaded chunk

#

I doubt that it actually loads the chunk just to check if there is actually a lodestone

#

but I also haven't tried it

quiet ice
quiet ice
#

no, false

tender shard
#

whut

opal juniper
vocal cloud
#

UwU

quiet ice
#

true means that there is a lodestone at that block - which is false

tender shard
#

you're right

opal juniper
#

^

tender shard
#

Gets if this compass is tracking a specific lodestone. If true the compass will only work if there is a lodestone at the tracked location.

quiet ice
#

false means that there is not a lodestone at that block

tender shard
#

that's very weird method names

#

why not just "setDestination"

opal juniper
#

mirrors the nms ig

tender shard
#

makes sense, NMS is always weird

quiet ice
#

It also confused me, but thankfully someone was fast to explain my mistake to me

opal juniper
#

that and they are swedish lol

#

bad translations upward_stonks

hasty prawn
#

D:

opal juniper
#

disagree

#

seems cool

quiet ice
#

Whoa, why so swedophobic?

vocal cloud
opal juniper
vocal cloud
#

Bruh move to Ukraine

quiet ice
#

It's not much better here in germany

#

Oh yeah, ukraine might be a fun place

#

"fun"

opal juniper
#

germany seems cool

#

honestly everywhere but england seems better

vocal cloud
#

Meh Canada is a pretty big disaster rn

quiet ice
#

I quite like my country, but man I wish the public transportation was better

tender shard
#

I'm freezing

sage dragon
#

Hey,

I have a schematic file.

I want it to be placed evenly spaced inside a newly generated void world.

Any idea how I can do this?

I have no idea about custom world generators

opal juniper
tender shard
quiet ice
#

this ~30 minute drive takes around 1.5 hours with public transportation

tender shard
tender shard
quiet ice
#

I sadly live there

opal juniper
#

geol

tender shard
#

RIP :<

hasty prawn
sage dragon
quiet ice
#

Okay, apparently the getItemMeta call serves a purpose

hasty prawn
#

I mean it makes sense that you'd have to call it twice

quiet ice
#

well my thought was that you could just go with the meta field, but CraftItemStack overrides the getItemMeta method to not make use of the meta field

hasty prawn
#

oh

#

welp

unique geyser
#

I have an issue
so my plugin works perfectly on my server but on another server, it doesnt work
both are paper 1.18.1

chrome beacon
#

Add some debug messages

hasty prawn
#

?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.

quiet ice
#

how does it not work?

unique geyser
#

it doesnt even show up on the other server

quiet ice
#

any exceptions?

unique geyser
quiet ice
#

Did you even copy the file?

unique geyser
#

yeah

quiet ice
chrome beacon
#

I've seen uploads fail to server hosts before. Try deleting the jar and uploading it again if you're using a host

unique geyser
#

there are 3 commands
/c
/s
/tpme

/c and /s show up but not the teleport command
but it does work on my personal servr

quiet ice
#

But /tpme works?

unique geyser
quiet ice
#

Do you have the perms for the command?

unique geyser
#

you dont need perms

#

you can use it without op

quiet ice
#

Sure? try to op yourself anyways

unique geyser
#

k

#

even with op it doesnt show up

#

on the server it doesnt work

vocal cloud
#

Gotta make a list of hosting providers to avoid

unique geyser
#

my server

vocal cloud
#

Does this provider give logs?

#

download one

quiet ice
#

And what happens if you use the cmd anyways?

unique geyser
unique geyser
quiet ice
#

What is the output of /pl?

vocal cloud
#

I'm assuming it's not loaded

valid solstice
#

how to make summoned falling blocks not fall?

quiet ice
#

disable physics

valid solstice
tender shard
quiet ice
#

oh

valid solstice
#

ty

quiet ice
#

Yeah I'm an idiot

unique geyser
vocal cloud
#

log please

quiet ice
#

Yeah, then log

unique geyser
#

alright
im not the owner
but i did ask the owner, he is gonna send soon

chrome beacon
#

Might want to remove that since it contains your ips

quiet ice
#
[11:49:50] [Server thread/ERROR]: Ambiguous plugin name `Prestige' for files `plugins/Prestige (2).jar' and `plugins/Prestige (1).jar' in `plugins'

here you have it, the plugin is loading an outdated version

unique geyser
quiet ice
#

yes, but only one is loaded I assume

#

whether that is really the cause is up in the air, but it explains it

unique geyser
#

alright

#

thanks

vocal cloud
#

I was going to assume an outdated version but having 2 is most likely the issue

onyx fjord
#

was PacketPlayOutChat removed? if yes what should i replace it with

topaz scroll
#

ah you were already answered

modern vigil
#

Is it item of material {material} or item of {material}?

#

Yes, I'm asking grammar questions in a minecraft dev server

tardy delta
#

make a sentence of that

modern vigil
#

Item metadata cannot be get for item of ${}

#

basically it has to error if no item meta could be resolved/get

tardy delta
#

lol

#

cannot get itemmeta for material <>

onyx fjord
#
[11:34:20 WARN]: java.lang.RuntimeException: Failed to find NMS class: PacketPlayOutChat
[11:34:20 WARN]:        at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$1(MinecraftReflection.java:2079)
[11:34:20 WARN]:        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
[11:34:20 WARN]:        at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:2079)
[11:34:20 WARN]:        at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.loadNMS(OverlordMsgRemover.java:135)
[11:34:20 WARN]:        at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.onEnable(OverlordMsgRemover.java:62)
[11:34:20 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[11:34:20 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)
[11:34:20 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501)
[11:34:20 WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559)
[11:34:20 WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473)
[11:34:20 WARN]:        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:669)
[11:34:20 WARN]:        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:436)
[11:34:20 WARN]:        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:352)
[11:34:20 WARN]:        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1179)
[11:34:20 WARN]:        at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:320)
[11:34:20 WARN]:        at java.base/java.lang.Thread.run(Thread.java:833)

this is the error i get

#

any ideas why?

tardy delta
#

whats at your OverlordMsgRemover class line 135?

onyx fjord
#

(this.posField = MinecraftReflection.getMinecraftClass("PacketPlayOutChat").getDeclaredField("pos")).setAccessible(true);

modern vigil
#

What items cannot have a persistent data container?

#

PacketPlayerOutChat ?

onyx fjord
#

where can i find the list of all packets?

onyx fjord
modern vigil
#

idk then

tardy delta
#

never used protocollib

onyx fjord
#

same o.o

tardy delta
#

never used packets either

#

nah only once for npc

modern vigil
#

also is it normal for Kotlin plugins to be 7+ MB

onyx fjord
#

yes

modern vigil
#

lib.jar is my plugin

onyx fjord
#

it is normal

modern vigil
#

why is it so much bigger?

tardy delta
#

because you're shading stuff?

valid solstice
#

does World#getHighestBlock also get the highest block of player placed blocks?

vocal cloud
#
  1. read the docs
  2. try it and see
valid solstice
#

it just says "Returns Highest non-empty block"

#

does this include player placed? idk

sage dragon
#

Hey,

I have a schematic file.

I want it to be placed evenly spaced inside a newly generated void world.

Any idea how I can do this?

I have no idea about custom world generators

nimble torrent
#

did not work sadly 😦

misty ingot
#
    public void createPlayerInDatabase(UUID uuid, String name) {
        try {
            PreparedStatement statement = plugin.getConnection()
                    .prepareStatement("SELECT * FROM villagerPark_players WHERE UUID=?");
            statement.setString(1, uuid.toString());
            ResultSet result = statement.executeQuery();
            if (!result.next()) {
                PreparedStatement statement2 = plugin.getConnection()
                        .prepareStatement("INSERT INTO villagerPark_players (UUID, NAME, ECO, STREAK) VALUES (?, ?, ?, ?)");
                statement2.setString(1, uuid.toString());
                statement2.setString(2, name);
                statement2.setInt(3, 0);
                statement2.setInt(4, 0);
                statement2.executeUpdate();
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }

anyone know why this is not working? the uuid and name are valid
and there is absolutely NO errors

(also the database table is valid and the connection is successful)

#

*the issue is that it is not inserting new players into the table

onyx fjord
kind hatch
buoyant viper
#

yeah its that

#

looked for it with minis mapping viewer

tardy delta
#

try with resources

#

shit wrong ping

manic furnace
#

When I run a command and get the player, everything works, but when I add nms, it triesto get the nms class and can't find it anymore.

#

What can I do?

#

Is it possible that it comes from this:

[19:23:41 ERROR]: [STDERR] [org.bukkit.craftbukkit.v1_18_R2.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
kind hatch
onyx fjord
#
[12:24:25 WARN]: java.lang.RuntimeException: Failed to find NMS class: ClientboundChatPacket
[12:24:25 WARN]:        at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$1(MinecraftReflection.java:2079)
[12:24:25 WARN]:        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
[12:24:25 WARN]:        at ProtocolLib(58).jar//com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:2079)
[12:24:25 WARN]:        at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.loadNMS(OverlordMsgRemover.java:135)
[12:24:25 WARN]:        at OverlordMsgRemover-1.0.jar//com.github.kaspiandev.overlordmsgremover.OverlordMsgRemover.onEnable(OverlordMsgRemover.java:62)
[12:24:25 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[12:24:25 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)
[12:24:25 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501)
[12:24:25 WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559)
[12:24:25 WARN]:        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473)
[12:24:25 WARN]:        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:669)
[12:24:25 WARN]:        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:436)
[12:24:25 WARN]:        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:352)
[12:24:25 WARN]:        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1179)
[12:24:25 WARN]:        at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:320)
[12:24:25 WARN]:        at java.base/java.lang.Thread.run(Thread.java:833)
#

i still get this

kind hatch
manic furnace
#
package at.theduggy.projekt;

import at.theduggy.projekt.Animation.Animation;
import at.theduggy.projekt.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.Random;
import java.util.UUID;

public class TestParticleCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
        NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
        return false;
    }

}
kind hatch
manic furnace
#

I know

#

And that is the strange thing

#

It says that the error is in line 23

buoyant viper
#

whats line 23

kind hatch
#

^

manic furnace
#
NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
kind hatch
#

So a dependency issue.

manic furnace
#

?paste

undone axleBOT
kind hatch
#

How are you managing your plugin? Maven, Gradle, manually?

manic furnace
kind hatch
#

Ok, now we have NMS code. Can you ?paste your stacktrace

manic furnace
buoyant viper
#

is it getting remapped properly

manic furnace
kind hatch
misty ingot
#
29.03 17:30:40 [Server] SEVERE java.sql.SQLException: Before start of result set
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.checkRowPos(ResultSetImpl.java:517)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1314)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:822)
29.03 17:30:40 [Server] SEVERE at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:843)
29.03 17:30:40 [Server] SEVERE at com.wonkypigs.villagerpark.commands.giveEco.execute(giveEco.java:35)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:207)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:157)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:74)
29.03 17:30:40 [Server] SEVERE at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)

anyone know why this is happening?
here is line 35

statement.setInt(1, playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1]));

the current database value for the column "ECO" for the player is 0 (integer) and it is not able to add 1 to it?

manic furnace
tardy delta
buoyant viper
#

somethings not lining up with the error and the command code

manic furnace
#

So how can I do that?

misty ingot
onyx fjord
misty ingot
#

isnt when you put a + between 2 integers, adding them?

tardy delta
#

playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1])

misty ingot
#

yeah, they are both integers

tardy delta
#

add those are ints

#

because of the parse

#

weird

misty ingot
#

I am... adding integers...?

#

one sec brb

buoyant viper
#

in the stacktrace ur command was erroring bc of a noclass error but the command code u sent doesnt reference that class at all @manic furnace

kind hatch
buoyant viper
#

is the stacktrace older than the commands current code

manic furnace
#

no

kind hatch
onyx fjord
#

uh sorry i dont quite understand

misty ingot
onyx fjord
#

do you wanna see my pretty code maybe?

kind hatch
#

Yes

hardy swan
#

Is there any common cause for a softdepend to load after the plugin?

vocal cloud
#

You spelt the name wrong

hardy swan
#

not it, definitely

onyx fjord
#

okay prepare

#

for madness

misty ingot
#

here is the full code

                    ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
                    try{
                        PreparedStatement check = plugin.getConnection()
                                .prepareStatement("SELECT ECO FROM villagerPark_players WHERE NAME=?");
                        check.setString(1, target.getName());
                        ResultSet playerEcoAmount = check.executeQuery();
                        PreparedStatement statement = plugin.getConnection()
                                .prepareStatement("UPDATE villagerPark_players SET ECO=? WHERE NAME=?");
                        statement.setInt(1, playerEcoAmount.getInt("ECO") + Integer.parseInt(args[1]));
                        statement.setString(2, target.getName());
                        statement.executeUpdate();
                    }
                    catch (SQLException e) {
                        e.printStackTrace();
somber sequoia
#

Is there any way to disable the vanilla ender pearl cooldown?

misty ingot
#

yes

#

I think

somber sequoia
#

You think?

#

That doesn't sound too good

river oracle
#

probably I think

misty ingot
#

well I did it once with skript...

river oracle
#

if you can do it with skript you can do it in java

#

and likely better

misty ingot
#

but what I actually did was add throw cooldown to snowballs

#

not sure about disabling it

manic furnace
#

Is the current Spigot-Version 1.18.2-R0.1-SNAPSHOT?

somber sequoia
#

If you can add it to any item you could probably set it to 0 and that would semi disable it

#

Thank you guys

kind hatch
river oracle
onyx fjord
onyx fjord
#

yes it is

manic furnace
#

Ok

tardy delta
#

static block meh

misty ingot
#

I just checked google, Integer.parseInt(args[1]) is changing args[1] from a string to an integer.
What I am not so sure about is if playerEcoAmount.getInt("ECO") is the right way to get the integer from the ECO column.

#

any sql experts in the chat?

tardy delta
#

is that a spigot event? @onyx fjord otherwise you forgot the @EventHandler

onyx fjord
#

its a protocollib event

tardy delta
#

ah ye i just looked up

#

ImmutableMap.builder kek

sacred mountain
#

how do i give a player a permission?

clever musk
#
        <dependency>
            <groupId>io.papermc.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>io.papermc.paper</groupId>
                    <artifactId>paper-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Is this correct for 1.18.2 mojang mappings?

vestal barn
#

why does my getInstance().getDataFolder() equal to serverpath\plugins\{pluginname}\plugins\{pluginname}\

visual tide
#

it shouldnt

tardy delta
#

isnt that what it's supposed to do?

vestal barn
#

well it does

#

isnt it supposed to be serverpath\plugins\{pluginname}\

tardy delta
#

whait wha plugins/name/plugins/name

vestal barn
#

its creating a very weird director structure

#

ik

#

ive fixed it now nevermind

#

i had a function that did this File folder = new File(getInstance().getDataFolder(), folderPath);

#

and i passed another getInstance().getDataFolder() as a argument

onyx fjord
#

plox halp

sacred mountain
#

what

tardy delta
#

you are trying to cast a chat modifier to a string

#

but that isnt possible

sacred mountain
#
        HashMap<UUID, PermissionAttachment> permissions = new PlayerConnection(plugin).getPermissions();
        if (permissions.containsKey(player.getUniqueId())) {
            PermissionAttachment attachment = permissions.get(player.getUniqueId());
            attachment.setPermission(name, value);
        }
    }``` wuld this work
onyx fjord
#

its kinda problematic for me to find that

tardy delta
#

ChatOutListener.java:39

#

line 39 in chatoutlistener class

misty ingot
#

how can I auto complete a certain argument in a command with names of all online players?

tardy delta
onyx fjord
#

try {
message = (String) this.plugin.getMessageMethod().invoke(chat.getHandle(), new Object[0]);

hash = ((message != null) ? message.hashCode() : -1);
}

sacred mountain
#

i never got lambdas

onyx fjord
#

this is the line 39

tardy delta
#

reflection goes brr

onyx fjord
#

😭

#

halp

sacred mountain
tardy delta
#

a

#

are you trying to put it in the map too?

sacred mountain
onyx fjord
tardy delta
tardy delta
onyx fjord
#

-.-

tender shard
#

does someone know why Player#isOnGround is deprecated? Because the explanation makes no sense, neither CraftPlayer nor CraftHumanEntity override that method

hasty prawn
#

The client controls if they're on the ground iirc

tender shard
#

yes that's what the docs say

hasty prawn
#

So it's unpredictable I think is why

#

In most cases it should probs work

tender shard
#

but from what I see, it uses the method from CraftEntity which uses some math to check it

#

CraftEntity calls the NMS entity isOnGround

hasty prawn
#

I always just use it anyways lol

tender shard
#

NMS Player doesn't have any isOnGround so it also uses the NMS entity one

#

and checks whether one is on the ground by some collisions etc

#

so I doubt that what the docs say is true

hasty prawn
#

Maybe Player had its own implementation at some point and then they fixed it and forgot to remove the docs?

#

Seems unlikely but idk

tender shard
#

well the whole impementation was ever only in NMS

vocal cloud
#

I assume it can be spoofed by the client somehow. Maybe that's changed

tender shard
#

so maybe mojang just changed it and noone at spigot noticed

hasty prawn
#

Maybe, I have no clue.

tender shard
#

yeah I'll just also use the deprecated method lol

native ruin
#

i'm trying to make milk not remove potion effects
would checking EntityPotionEffectEvent.Cause milk and then cancelling the event suffice?

tardy delta
#

uhh show code

grim ice
#

wow

#

static abuse

#

and no SQL conventions :O

tardy delta
#

prevent sql injection and use a preparedstatement

#

with setting parameters

tender shard
#

does someone know how can I listen to incoming packets WITHOUT protocollib or similar?

viral crag
#

wireshark

tender shard
#

using a plugin, obviously, to do plugin stuff

tardy delta
#

github doesnt seem to give a fuck about the formatting colors

#

uhh whats wrong with that

grim ice
#

@tardy delta I recommend

#

making a Database interface

#

with stuff like close connect etc

#

and a storage interface

#

with stuff related to your actual storage

#

like loadUser()

tardy delta
#

firing the event happens in the doesExist method

#

lol i have that

grim ice
#

then a class called SQLStorage implements Database, Storage

#

yeah

#

cuz this looks pretty uh

#

weird imo

#

why does init throw SQLException

#

why SQL?

#

why not something else

#

you have a design problem here probably

vocal cloud
#

Inserting in mongo be like db.insert(object) roffMET

tardy delta
#

because it initializes the tables

grim ice
#

not all storages throw SQLException

#

thats a database interface

#

not a storage one

#

so my YMLConfig implements Storage e.g

tardy delta
#

im only using h2 and mysql

grim ice
#

will throw SQLException?

tardy delta
#

so mye basically the interface is redundant

grim ice
#

I dont care (doesnt matter)

#

you want your project to be flexible

#

so you change add features without breaking code

tardy delta
#

i can add features without breaking things

grim ice
#

you prob need to learn ISP

tardy delta
#

just add a new method to the storage interface and make it implement

grim ice
#

(SOLID)

#
  1. Interface Segregation Principle: It states that “do not force any client
    to implement an interface which is irrelevant to them“. Here you should
    prefer many client interfaces rather than one general interface and
    each interface should have a specific responsibility.
tardy delta
#

whats isp?

#

ah

grim ice
#

youre having one general interface with 2 responsibilites

#

there should be 2

#

one Storage and the second Database

tardy delta
#

which responsabilities?

#

getting the stuff from the persistent storage and?

grim ice
#

Database for interacting with the database, e.g disconnect(), connect()

#

Storage for getting stuff like user data

#

like void createHome(Home home) throws SQLException;
too

tardy delta
#

would still have to implement both interfaces so makes no difference

grim ice
#

createHome should be in Storage, not in database

#

It does

#

better design

#

you will find ur project being a huge mess if you just "no difference, just design"

#

ask yourself

#

is it normal for a createHome function to throw SQLException

#

why doesnt it throw MongoDBException if that ever existed

#

It shouldnt be specific

#

Maybe you cant control that

#

but stuff are mixed

tardy delta
#

how should i handle throwing exception then?

grim ice
#

I mean for me

tardy delta
#

just an throws Exception instead of specific SQLException?

grim ice
#

I would just return an int value

#

and catch inside the method

tardy delta
#

then you cant print the stacktrace

grim ice
#

well you should handle it probably

#

not throw a stacktrace

tardy delta
#

atm the delegating storage is handling exceptions by giving them to the future

#

and the things that need it handle it in the way they want

grim ice
#

I would return an 1 if an error occured

lavish hemlock
#

I personally just use some kind of Result type

grim ice
#

and log an error message

tardy delta
#

look at the homecommand#createHome for example

grim ice
#

and 0 for success.etc

tardy delta
lavish hemlock
#

Ye :)

grim ice
#

i would return an int instead of having throws SQLException inside of a Storage interface

#

a storage can be something that doesnt use sql at all

#

so it doesnt make sense

tardy delta
#

well im not going to use things that are not a database

#

im not sure if mongo is actually a database or what it is

grim ice
#

make your design flexible

#

u dont know what happens later

nimble torrent
#

how would i detect if someone breaks a block and what the block is?? i tried the harvest event thing and it dodmt work

grim ice
#

BlockBreakEvent

nimble torrent
#

that isnt a thing

grim ice
#

Lmao?

#

💀

tardy delta
#

if those database method should return an int, that would work for all void methods but the others arent going to work

#

gl returning a Future<Kingdom, Integer>

nimble torrent
tardy delta
#

and pairs go brr

nimble torrent
#

thx

grim ice
#

then

#

a Storage<StorageType Enum>

#

maybe

#

actually nvm

#

alr its fine if u cant control that

#

its not that much of a deal

tardy delta
#

ahh you cant construct an enum value during runtime like in rust

#

that would be the thing

grim ice
#

but breaking ISP sucks

grim ice
#

StorageType.SQL.getException()

#

would return a sql exception

tardy delta
#

in rust i would have done

enum StorageResult<T> {
  Ok(T t),
  Err()
}```
#

even storing the exception in the err constant

tardy delta
grim ice
tardy delta
#

i mean from where does the exception come?

grim ice
#

ur method that throws SQLException

tardy delta
#

so the enum holds a storage inside

grim ice
#

the enum holds types of storages

#

and their exception

tardy delta
#

i would have store the enum constant which im working with somewhere

#

bcs on compiletime i dont know with what storage im working

nimble torrent
# grim ice BlockBreakEvent
    public void onBlockBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        Block block = event.getBlock();

        if(block.getType() == Material.DIAMOND_ORE) {
            player.sendMessage("mine diamonds");
        }
    }```
#

it doesnt do anything

tardy delta
#

so youre better off just storing the storage

#

@EventHandler and register it

nimble torrent
#

i did

tardy delta
#

weird

#

obviously not

#

nms is the implementation

#

dont ask me where to find it tho

nimble torrent
# tardy delta @EventHandler and register it

in my main class in the enabling function is this

getServer().getPluginManager().registerEvents(new events(), this);```

in my events

```java
public class events implements Listener {
    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        Block block = event.getBlock();

        if(block.getType() == Material.DIAMOND_ORE) {
            player.sendMessage("amogus");
        }
    }
}```
sacred mountain
#

amogus != funny

tardy delta
#

lol class name starting with lowercase

#

why is compiler even allowing that

nimble torrent
#

thats the problem?

grim ice
#

no

tardy delta
#

Events not events

#

no

nimble torrent
#

ok

tardy delta
#

something else

crisp steeple
#

then work from there

#

(also you should really change that class name)

modern vigil
#

What is a good way to approach this?

#

I have one class, ItemManager, but the paths to the item directory is hardcoded into a variable

#

But I want to change this

#

My ItemManager does too much atm

#

I was thinking of some kind of ConfigManager class

lavish hemlock
#

ooh Kotlin, hot

#

Also uh

#

You don't need to use stream in Kotlin

#

In fact

#

You shouldn't

#

Because Kotlin has sequence

#

(or whatever it's called)

modern vigil
#

o h

#

how do I check if it's empty tho

#

Do I call toList()?

lavish hemlock
#

Also wait

#

Doesn't walkBottomUp already return a stream/sequence...?

modern vigil
#

yeah it does

lavish hemlock
#

Oh wait it's a FileTreeWalk

modern vigil
#
        val itemFiles = file.walkBottomUp()
            .filter { it.name.endsWith(".json") }```
crisp steeple
nimble torrent
lavish hemlock
#

Which is a sequence of files

modern vigil
#

FileTreeWalk implements/extends Sequence<File>

crisp steeple
nimble torrent
#

no

lavish hemlock
#

Also

#

File has an extension property called extension

#

Which is just the file extension

#

So you can do it.extension == "json"

nimble torrent
lavish hemlock
#

(Even then, Path is preferable to File in modern Java)

modern vigil
#

wym by path?

lavish hemlock
#

java.nio.Path

#

nio is new IO/non-blocking IO

modern vigil
#

How would I read from that?

lavish hemlock
#

It was introduced in like, Java 7 as a replacement to some of the classes in java.io

modern vigil
#

ohh

#

.readText

lavish hemlock
#

It mainly exists as it more accurately represents filesystem paths

nimble torrent
crisp steeple
lavish hemlock
#

java.nio.Path is to java.io.File sort of like how java.time.LocalDate is to java.util.Date

modern vigil
#
        val itemsPath = "$dataFolder/items"
        val path = Path(itemsPath);
        if(!path.exists()) {
            plugin.logger.info("$itemsPath does not exist, creating directory")
            path.parent.createDirectories();
            path.createFile();
            return;
        }```So this is the better version?
#

Or is path.parent.createDirectores() not needed?

lavish hemlock
#

Oh no you absolutely need to make sure parents exist in nio

#

It's a little more strict

modern vigil
#

Ah alright

lavish hemlock
#

But yeah that looks good

modern vigil
#

What is the Path equivalent of walkBottomUp()?

lavish hemlock
#

Lemme see

#

Ah

modern vigil
#

?

lavish hemlock
#

Kotlin has no walk extension method, you'd have to use java.nio.Files#walk

#

Which you'd then have to either:
A. Use the stream it returns (which sucks bc Kotlin's type-safety doesn't work with streams)
B. Convert the stream to a sequence via toSequence

#

so basically
Files.walk(path).toSequence()

modern vigil
#

toSequence dosn't exist, do you mean asSequence?

lavish hemlock
#

Oh

#

Yeah sorry lol

modern vigil
#

It's alright

#

You know more than me about kotlin

lavish hemlock
#

Yeah I've used it for a while

lavish hemlock
#

Okay so createFile I think would actually create an empty file

#

Rather than a directory

modern vigil
#

createDirectory then?

#

I'll try that

lavish hemlock
#

Yeah

#

btw I should mention

#

You don't have to check that the directory is empty

#

A forEach with no elements will just do nothing

tender shard
#

is there an easy method to convert e.g. a Short[] to short[] ?

tardy delta
#

for loop

tender shard
#

yeah I mean a generic method

tardy delta
#

:)

tender shard
#

that works for all wrapper classes

lavish hemlock
#

You'll just have to write your own

modern vigil
#

I just want an message to show the person the directory is empty

lavish hemlock
#

Fair enough

modern vigil
#

btw should I use semicolons in Kotlin?

lavish hemlock
#

Nah

#

No need

crisp steeple
#

no

lavish hemlock
#

Kotlin's semicolons add nothing

#

Oh btw you should return in that empty check

#

Like after printing the "directory is empty" warning, you should return

#

Otherwise, there's a useless forEach and then it gives a misleading "loaded successfully" print

lavish hemlock
#

I actually recommend using a lib for this though

#

Like perhaps RedLib

modern vigil
#

I need to use a JSON serializer though

#

But guessing by this code, how long do you think I have been coding in Kotlin for?

crisp steeple
lavish hemlock
#

Ehh JSON isn't the best format for configs

modern vigil
#

I just find it more readable

lavish hemlock
#

Hmm

#

I'd say you're like, relatively new. Not so new that you've never had experience with Java, but new enough that you've not gotten used to Kotlin's additional utilities.

modern vigil
#

I have been using Java for like 2 months and Kotlin for like...3 days?

lavish hemlock
#

Sounds about right

modern vigil
#

Is there like a Kotlin book?

#

One comparable to the concept of the Rust book

lavish hemlock
#

Uhh maybe, but you should probably just use the online docs

modern vigil
#

alright

crisp steeple
#

the online tutorials are really nice

lavish hemlock
#

Kotlin's docs are a little confusing at times but they're not that bad

modern vigil
#

What are the concepts you have to know

lavish hemlock
#

Uhh well

#

I'd say shit like Kotlin's type system

modern vigil
#

OH yeah another thing

#

What's the difference between Array, List and ArrayList?

lavish hemlock
#

Oh wow that's a very beginner question lmao no offense

#

Alright so

tardy delta
#

List is an interface

#

if you are not talking about kotlin

#

arraylist is an implementation of it

lavish hemlock
#

Nah this is Kotlin

tardy delta
#

meh

lavish hemlock
#
  • Array represents a Java array, and is a fixed-size collection of values.
  • List is an immutable list, meaning it cannot be changed.
  • ArrayList is part of Java's standard library, but afaik you shouldn't really use it in Kotlin.
crisp steeple
lavish hemlock
#

Or actually

crisp steeple
#

especially the keywords since there was a lot of those

lavish hemlock
#

ArrayList is an implementation of MutableList

#

But it's not necessary to specifically use the ArrayList type

#

Since mutableListOf exists

sage dragon
crisp steeple
#

it’s pretty weird going from java where keywords are used pretty conservatively to where’s a keyword for anything you can think of

crisp steeple
spring minnow
#

how can i send more than 1 line action bar?

#

sending more than one action bar just replaces the other one

#

how can i make appear more line action bars?

#

\n only makes a strange code

#

doesn't work

sage dragon
# crisp steeple what are you doing to create them

Because I have no idea how custom World Generators work, I thought this would do the trick:

    @Override
    public void generateBedrock(WorldInfo worldInfo, Random random, int x, int z, ChunkData chunkData) {
        for (int iX = x; iX < x + 16; iX++)
            for (int iZ = z; iZ < z + 16; iZ++)
                chunkData.setBlock(iX, 201, iZ, Material.BARRIER);
    }

(I disabled every generation type except bedrock)

chrome beacon
spring minnow
#

What

#

really?

#

ohw

#

ok, thanks

crisp steeple
sage dragon
hybrid spoke
#

change the material and send a screenshot

sage dragon
hybrid spoke
#

what video

crisp steeple
sage dragon
sage dragon
crisp steeple
#

you could try just listening to chunkloadevent and then do it there

hybrid spoke
sage dragon
clear raptor
#

Does anyone have any idea how to delay plugin unload until my JSON file gets saved?

public void save(Object data, String fileName) {
    }
        ObjectMapper mapper = new ObjectMapper();
        File file = new File(plugin.getDataFolder(), fileName);

        try {
            if (!file.exists()) {
                file.createNewFile();
            }

            // Writing to a file
            mapper.writeValue(file, data);

        } catch (IOException e) {
            e.printStackTrace();
        }
#

When I run this inside onDisable(), it throws exception

grim ice
#

prob cant

clear raptor
#

So how am I supposed to do the save 😄

vocal cloud
#

By doing it on update rather than when the server is shutting down

clear raptor
#

Updates are very frequent...

grim ice
#

then do it every few minutes

#

on another thread

clear raptor
#

It is frequent + I must do it so I will be 100% sure that it gets saved on unload

sage dragon
clear raptor
#

It is list of holograms and if some will be missing, it will not get re-added after restart

sage dragon
hybrid spoke
clear raptor
#

onDisable

hybrid spoke
#

server disable?

#

plugin disable?

clear raptor
#

yes

hybrid spoke
#

both?

clear raptor
#

both

#

but server disable calls plugin disable am I right?

hybrid spoke
#

so either you lag out the entire server by doing it on sync

clear raptor
#

Who cares on unload

#

😄

hybrid spoke
#

or you send it to another thread if for example just the plugin gets disabled but the server still runs

grim ice
#

but its still not working

hybrid spoke
#

oh thought its a "how do i do it"

clear raptor
grim ice
#

update it every few minutes

clear raptor
#

But maybe it is not the problem of plugin unloading before it gets saved?

java.lang.VerifyError: (class: org/codehaus/jackson/impl/JsonGeneratorBase, method: getOutputContext signature: ()Lorg/codehaus/jackson/JsonStreamContext;) Wrong return type in function
    at org.codehaus.jackson.JsonFactory._createUTF8JsonGenerator(JsonFactory.java:865) ~[CustomDropHead-1.0.0.jar:?]
    at org.codehaus.jackson.JsonFactory.createJsonGenerator(JsonFactory.java:755) ~[CustomDropHead-1.0.0.jar:?]
    at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:2048) ~[CustomDropHead-1.0.0.jar:?]
    at me.baterka.drophead.utils.JsonDataStorage.save(JsonDataStorage.java:31) ~[CustomDropHead-1.0.0.jar:?]
clear raptor
#

Thats maybe additional protection against crashes so you not loose everything

#

But when server properly calls onDisable, it must get saved...

clear raptor
#

So it is not data problem

hybrid spoke
sage dragon
#

ChunkGenerator#generateBedrock

hybrid spoke
sage dragon
#

I mean... Without using the provided x and z, I don't know which chunk the server want to render?

#

Okay, nevermind, I'm just stupid.

It's not about coordinates

grim ice
#

Me and someone I know were arguing about how flawed java is because of it not having null safety

#

and that NPEs are a major problem

#

He ended up finishing it with "Eh, I'm not gonna argue further. One day you'll understand, if you're ever going to work as a programmer professionally", So I thought maybe I'm missing something

#

I had the opinion of NPEs not being a major problem if you have logic and design

#

he had the opposite

supple elk
#

Hey guys, does world.rayTrace() return null if there's no collisions, or will just getEntity() / getBlock() return null?

tender shard
#

I have a method ```java
<M extends Map<K,V>,K,V> stuff(Supplier<M> supplier, PersistentDataType<?,K> keyType, PersistentDataType<?,V> valueType);

Does someone know if I can somehow get the class the supplier supplies? So basically something like supplier.getClass().getGenericType() or sth like that
tardy delta
#

nope

tender shard
tardy delta
#

M gets erased to Object so nah

tender shard
#

I hate type erasure

supple elk
#

type erasure crinch