#help-development

1 messages · Page 222 of 1

sterile token
#

fourte

#

I refactored

#

Now main, only start the FakeClient and opens the connection

tardy delta
#

ok

sterile token
tardy delta
#

what was the problem anyways lol

sterile token
#

I dont know how to send the packet back

tardy delta
#

what packet

#

the long being read?

eternal oxide
#

change the while in the keepAlive() to if

sterile token
#

k

#

Done

#

Still being disconnected

frail spire
eternal oxide
#

you need to write to a ByteArrayOutputStream

#

to build the keepAlive packet

sterile token
eternal oxide
#

then send it once built

sterile token
eternal oxide
#

yes

sterile token
#

Shity mc packets

#

😡

#

I dont catch how the fuck they works

eternal oxide
#

looks good

sterile token
#

I test and fails

#

Just disconnect me

#

I will send you the zip file

eternal oxide
#

instantly or after a time?

sterile token
#

Yeah sever disconnect me out instantly

#

So packet is not sent or smth like that

eternal oxide
#

um exit code 0 means your process finished

sterile token
#

yeah ik

frail spire
#

It ended itself

eternal oxide
#

did you forget to loop in your main?

sterile token
#

I removed thw while tho

eternal oxide
#

in teh keepAlive, yes

#

you shoudl still be looping in your main

sterile token
#

That why i dont like shity java.net sockets

eternal oxide
#

move your keepAlive call back to yoru main, after the connect

#

in a while loop

sterile token
#

I mean i wouldnt like to have it like that tho

#

But for testing no problem

kind hatch
#

But that's how keepalive works. It needs to be constantly sent on a frequent basis.

eternal oxide
#

you have to loop to keep reading new packets

sterile token
#

I need to compact tha tinto the lib

#

Not doing it on program main class which uses the library

#

[20:43:04 INFO]: FakeClient lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Badly compressed packet - size of 20 is below server threshold of 256

#

Still having that shity error

#

😂

sterile token
#

Hmnn

#

I dont even understand the shity exceptions

#

Because the protocol is so well designed

#

😡

frail spire
frail spire
sterile token
#

There is no other class

frail spire
#

Wtf

sterile token
#

There 3 methods only on tha class, Handshake, Login and keepAlive()

#

It must because im not sending correctly the packet

frail spire
sterile token
#

It just the fkng keepAlive()

#

Its really diff, because there is no fkc example about sending packets

#

Just tell what ** to use in the packet itself, but not how do to send it🤡

frail spire
#

It's just like last time I tried discord websocket
Sent a keepalive but they boot me off instead

sterile token
#

Discord?

#

Im working with mc ptcol

#

😂

frail spire
#

Sometimes it's hard to use something without libs

sterile token
#

ok

#

So what i can do?

frail spire
sterile token
#

hmn ok

rigid loom
sterile token
#

Does your plugin have 2 classes extending javaPlugin?

rigid loom
#

public final class Kingdoms extends JavaPlugin implements Listener is where it says its at

#

no

sterile token
#

Its saying that your pluign is already initialized

vocal cloud
#

You're reiniting your plugin somewhere

sterile token
#
FakeClient lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Badly compressed packet - size of 32 is below server threshold of 256
#

Loving shity mc prtcol

#

🤣

eternal oxide
#

I'm going to guess you are in offline mode

#

change the min packet size in server.properties to 32

sterile token
#

Im testing it in offline mode

#

Is that the problem

#

LMAo too much problems

eternal oxide
#

you could change it to 0 for no compression

sterile token
#

ok

#

[21:08:09 INFO]: FakeClient lost connection: Internal Exception: io.netty.handler.codec.DecoderException: java.util.zip.DataFormatException: inflate data is bad

#

Hahaha

#

Errors, erros and more erros, shity protocol that doesn thav a lib

eternal oxide
#

try -1 then

#

else I have no clue

sterile token
#

maybe the mc version?

#

Sever runs spigot 1.19.2

#

No bruh

#

I will send code

#

Because im really stressed with this

#

[21:10:02 INFO]: FakeClient lost connection: Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(2) + length(1) exceeds writerIndex(2): PooledUnsafeDirectByteBuf(ridx: 2, widx: 2, cap: 256)

#

shity protocols

#

😡 😡 😡 😡 😡

tardy delta
#

🤡

sterile token
#

Yeah

#

Why dont the fuck just make a library

#

Instead of making us devs to have headaches trying to figure how their shit works

mental frigate
#

hello

#

could anyone help me?

#
                Utils.getConfig().getInt("Elves.player-avoid-distance"),
                Utils.getConfig().getDouble("Elves.player-avoid-speed"),
                Utils.getConfig().getDouble("Elves.player-avoid-speed")));```
#

but my mob isnt running away from player, can anyone tell me what i am doing wrong?

mental frigate
tardy delta
#

obfuscation

mental frigate
wet breach
#

protocol is quite well documented for the most part

tardy delta
mental frigate
wet breach
#

also of note, obfuscation can make the overall binary smaller too

mental frigate
#

but they are making things so difficult 😭

remote swallow
#

thats the point im pretty sure

mental frigate
vocal cloud
#

The point is both to make reverse-engineering harder and to make the binary smaller. Removing long variable/method names helps reduce the binary size by quite a lot.

mental frigate
#

*that

#

but i am dying inside

#

and i can't find a way to fix my problem 😫

sterile token
vocal cloud
#

What version of MC

sterile token
vocal cloud
#

Not you

sterile token
#

ok

#

Reply so

#

Because if not its a mess

vocal cloud
#

I thought it was a reply KEKLEO

sterile token
#

oh haha

wet breach
sterile token
#

Yeah i dont understand how they serialize

tardy delta
#

as a bytearray ig

sterile token
wet breach
sterile token
#

I mean i would not use the full library i will definitly try take from it the things i need

#

Because its like 8mb library

atomic swift
#

how do i get all files within a directory

eternal oxide
#

Files.listfiles or soemthgin close

atomic swift
#

does anyone know if Path#getFileName() returns the file extension bc the jdoc just says

Returns the name of the file or directory denoted by this path as a Path object. The file name is the farthest element fromthe root in the directory hierarchy.

   Returns:   a path representing the name of the file or directory, or null if this path has zero elements
wet breach
atomic swift
#

not really

#

[file-name].[extension]

wet breach
#

alright don't listen to me then

orchid gazelle
#

It does include the extension

wet breach
#

extension is part of the filename, and the OS only makes that distinction for viewing purposes, but from a programming perspective it isn't separate

atomic swift
orchid gazelle
#

But to answer their question: yes, this method does include giving you the extension

#

For sure you basicly answered, but just to make it clear

wet breach
#

it is why I provided that last bit before you said I was correct 😛

orchid gazelle
#

Ok

sterile token
#

File#listFiles()

File dir = new File("path/to/dir");
File[] files = dir.listFiles();

hazy parrot
#

Any idea how can I exclude sqlite jdbc dep natives (am I even able ? ) because its like 23mb

vocal cloud
#

Isn't it a provided library?

sterile token
#

SQLite lib is not 23mb

hazy parrot
vocal cloud
#

Then just set the scope to provided?

hazy parrot
hazy parrot
sterile token
#

sqlite-jdbc

#

it not more than 1mb

#

🤔

chrome beacon
#

Sqlite is already bundled with Spigot

hazy parrot
chrome beacon
#

Ah

vocal cloud
#

Sqlite jdbc is a 12mb jar

sterile token
#

🤔

hazy parrot
#

why tf is it 23 here then

#
<dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.39.3.0</version>
        </dependency>

using this

vocal cloud
#

Oh lmfao you're reading it wrong

#

The packed size is 12.5

#

The unpacked is 23

hazy parrot
#

🤦‍♂️

plain sandal
#

does anyone know a good plugin for random kit pvp servers?

orchid gazelle
#

Wrong channel

sterile token
vocal cloud
plain sandal
#

ok

#

ty

sterile token
plain sandal
#

np

smoky widget
#
OfflinePlayer p = Bukkit.getOfflinePlayer(name);
        ItemStack is = new ItemStack(Material.PLAYER_HEAD);
        SkullMeta m = (SkullMeta) is.getItemMeta();
        m.setOwningPlayer(p);
        is.setItemMeta(m);

why with this code i got a steve head ?

#

but when i place it, it work

#

(and also i saw the data of the head is by value and when i place it, it's by skull owner)

fluid river
#

have you tried picking the head up after you place it

smoky widget
#

yes and it work

#

when i give it i have a value and when i pickup it i have skull owner (in nbt with data command)

fluid river
#

i mean skin on the head

#

when you place it and break it and pick it up

#

it has the skin you want

#

but when you give it with command it doesn't(until you place)

smoky widget
#

no

#

(when i pickup it with middle mousse button and ctrl)

fluid river
#

hmm

smoky widget
#

huh i inverted

#

when i give it i dont have texture property and when i place it i have

wet breach
#

however sometimes this breaks libs especially ones that are also plugins, but proper libs like sqlite however it generally doesn't cause issues

#

just add <minimizeJar>true</minimizeJar> to maven shade configuration

#

as I said, sometimes breaks libs so do some testing first with the final jar to see if it still works lol

quaint mantle
#
// COMMAND CLASS
public class Msg implements CommandExecutor {
    
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {

        System.out.println("works");

        return false;
    }
}

// also added it into the onEnable and in the plugin.yml```
#

Is there a new way to override the /msg command ?

wet breach
#

the size you see, is the size on disk and the reason this may be different is because it is dependent on block sector size for the disk

#

for example, lets say the block sector size is set to 5mb per block, the size on disk will be 15mb because it will use 3, 5mb block sectors to store 12mb

river oracle
quaint mantle
#

Ohh okay.

humble tulip
#

@quaint mantle alternatively you can unregister the vanilla command from the command map

valid basin
#

Does anyone know a way to make a player completely blind? I'm creating a gamemode that requires flashes (like in FPS games)

#

I need a way to make someone completely blind, not with effects tho

river oracle
#

Why not with effects that's likely the easiest way

#

U can remove the particles

valid basin
#

Because they're not completely blind

#

They can still see the player if he comes close

river oracle
#

You could do that and hide all players in their radius closely than unhide them once it wears off

#

Otherwise ull need packet fuckery

valid basin
#

or maybe spawn particles per player

#

with packets yea

#

that covers his vision completely

wet breach
#

You don't necessarily need packets to hide players.

river oracle
fluid river
#

has

#

Player#hidePlayer()

#

and Player#showPlayer()

boreal temple
#

hey how do i allow default players to use tm commands

#

tp

fluid river
#

add permissions?

#

and how is this related to development

echo basalt
#

You can then color it with rgb n such

vocal cloud
#

A player could cheat by not using it though

#

Give them blindness

stuck flax
#

What is the default reason is none is provided in the inventory#closeInventory method?

vocal cloud
#

Where are you seeing a reason for closeInventory?

stuck flax
#

InventoryClickEvent.closeInventory(Reason)

vocal cloud
#

Sigh, Paper moment

remote swallow
#

?paperdev

undone axleBOT
#

Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)

stuck flax
#

Ah didn't realise it was Paper-only

#

myb

worldly ingot
#

fwiw, if you're compiling against the Paper API, you should probably be asking your question in the Paper Discord/forums anyways

vocal cloud
#

Easy way to find out is to read the docs hes_UwU

fluid river
#

no "reason" provided, but it's an alternative anyways

vocal cloud
#

With paper the reason is probably 'unknown' by default

frail gale
#

is it possible to save Objects into ItemStack’s NBT Data? Objects like: List and HashMap

vocal cloud
#

Big question is: why

frail gale
#

but is it possible?

wet breach
#

?pdc

wet breach
#

If you serialize the data into base64 pretty sure you could easily store it into pdc

vocal cloud
#

Possible? Yes. Do you want to? Probably not.

wet breach
#

Yeah considering items can sometimes magically disappear

#

If that happens well there goes your data lol

frail gale
#

well my idea is just to make Inventories from the Item’s NBT Data

#

and continue with sub inventories

wet breach
#

You are better off using something similar to schematic files except with inventories. Items are subject to just being removed.

#

If the item drops, you will lose all the data with it

frail gale
#

the items will be in a GUI so they are not gonna be droppable

#

but I’m thinking for other possible ways too

#

like what’s the best way to make a GUI which will list some folders and then you can open each one close it create new folders

wet breach
#

Since you are already going to have a custom inventory you might as well just use file storage or db storage for the data.

frail gale
#

like windows file explorer

frail gale
frail gale
pine forge
#

@kind hatch Did you test this yet?

quaint mantle
#

How do I spawn a vanilla mob in a different biome

#

Ive got some nms code setup but it's not working

#

I ended up just creating dirty by sometimes replacing animals with the mob I want on chunk load

cobalt marlin
#

i think you can change spawning rules with datapacks

cerulean lynx
#

is there any good website for learning java

#

i tried w3 but dont understand methods

jagged monolith
#

?learnjava

undone axleBOT
jagged monolith
#

Another one that isn't on the list is Udemy. It has really good java courses, but they aren't free

cerulean lynx
#

do you know someone on udemy?

#

cost doesnt matter

jagged monolith
#

Tim Buchalka Is a really good instructor for it

cerulean lynx
#

thanks

#

and another question

#

where should i reach

#

for plugin developing

jagged monolith
#

All the basics would be a good start. As well as things like inheritance, try and catch, abstract

rough drift
#

That's just a java course lol

cerulean lynx
#

thanks

jagged monolith
#

?di

undone axleBOT
jagged monolith
#

That's also good info to have @cerulean lynx

cerulean lynx
#

understand other things but what is this doing

rough drift
# cerulean lynx

this. tells Java that you are setting one of the class's properties rather than a property in the current scope

#

so since you have two variables both named plugin (on in the class, one as a parameter) you use this. to set the one in the class

#
public class Test {
  private final Plugin plugin; // <- This is indicated by this.plugin

  public Test(Plugin plugin) {
    this.plugin = plugin; // "plugin" is the variable in the constructor
  }
}
cerulean lynx
#

alright thank you

molten hearth
humble tulip
#

ServerConnectEvent is called before the connection is even being made. What is called if that cinnection fails?

#

Eg. Player does /server test1

#

Test1 is down however so bungee tells them that it's down

#

What even is called when a connection isn't made?

fluid river
soft viper
#

can i use ClickEvent.Action.RUN_COMMAND not from player

#

from cmd

hazy parrot
#

What

soft viper
#

ClickEvent.Action.RUN_COMMAND executes a command from the player, can it execute command from cmd?

eternal night
#

No

#

The client just sends the command to the server

#

It's executed as if the player typed that command into the chat and sent it

trim creek
humble tulip
trim creek
#

could be many reasons

soft viper
humble tulip
#

If they click it twice itll run the console command twice

trim creek
#

then make a command that executes the correct command from the console

humble tulip
#

But if you wanna be more secure

#

You can make the command something like /<uuid here>

trim creek
#

like /playercommand, which will make console execute your required command

humble tulip
#

And check the command pre process event

trim creek
#

HashMap

soft viper
humble tulip
#

And use uuid to match up the commands

trim creek
humble tulip
#

So let say you'd like to use the command /eco give steve 200

#

But you don't want them spamming it

#

Assign a random uuid to the command and put it in a map

trim creek
#

instead of UUID, do a HashMap. .-.
More easier and can be set whatever they want to. Just make sure not to make it spam any errors after the execution of the command

humble tulip
#

It works

#

But it's not concrete

valid basin
trim creek
#

both should work, but HashMap is probably better

humble tulip
#

Personally I'd use the uuid method

trim creek
#

well, depends on everyone's mind

humble tulip
#

Uuid with a hashmap

trim creek
#

Perfect

#

xd

humble tulip
#

If the player gets sent two msgs with 2 diff commands

#

What happens there

trim creek
#

they either execute one, or both 😹

humble tulip
#

You'll need a new hashmap for every new command you'd like to excute

ionic dagger
#

What’s the correct way to check if a player clicked in a specific inventory

flint coyote
#

Comparing the InventoryHolder

ionic dagger
#

Could you give me an example of that?

flint coyote
#

and creating your Inventory with a specific one

#

Let me find the project I used this in 😅

ionic dagger
#

Yea I checked if the player that triggered the oninventoryclick event clicked in an inventory with the name equal to the name of the inventory I created

#

I think by using getWhoClicked() but I did it last night at like 3am so that’s probably not the right method call

flint coyote
#

Anvils can be renamed which also renames the inventory iirc. So that's not the most secure way

ionic dagger
#

What??

#

Oh

#

I see

flint coyote
#

If you rename an anvil inside an anvil (or might also work for chests) and you place it. I think it keeps the name

ionic dagger
#

Maybe I can make an inventory class and j check if it’s in an instance of that class

#

But that seems super complicated for a simple task so they’re definitely a better way at going about this

flint coyote
#

yeah you check the inventory holders instance usually

#

Bukkit.createInventory(new MyOwnHolder(), size, name)

#
...
}
#

And in the InventoryClickEvent you just check

if (!(inv.getHolder() instanceof MyOwnHolder)) return;
ionic dagger
#

Oh

#

So there’s no easy way?😞

flint coyote
#

how is that not easy? o.o

#

Why would implementing InventoryHolder be a problem?

#

So you'd rather implement or extend your own Inventory class?

#

But then you have to keep track of each inventory that you open for a player. This way the holder (which is stored inside the inventory) is used to keep track of it

#

It just seems overkill if you can use the holder. Especially since it would be null if you don't use it for that

ionic dagger
#

How would u do it w maps

ivory sleet
#

You can use InventoryView right?

ionic dagger
#

That’s what I did

flint coyote
#

I see, alright. I'll keep it in mind

#

You mean a custom Anvil inventory?

#

yeah that would make sense. So far I only did normal inventories

#

Wait but would you set Anvil as the InventoryHolder for a custom anvil inventory?

#

Oh so it's done in createInventory I suppose

white root
#

Is there an easy way (or any way) to listen for a shrieker shrieking? I thought that I might find a ShriekerShriekingEvent or something similar, but I wasn't able to find anything?

fallow violet
#

where can i report bugs?

flint coyote
#

As usual. What seems to be the problem?

flint coyote
#

Well then you are in a static context. That's not the schedulers fault tho.

hybrid turret
#

Can I give the player an item with which he can click on e.g. an iron door to lock it and then give him a key to open said door?

mighty pier
#

you can

hybrid turret
#

ooo

flint coyote
#

Welcome to the world of coding 👋

hybrid turret
#

i have searched for a while now and i figured i'd ask :D

white root
#

Thats probably something you would have to make yourself via a plugin

#

or have someone make for you

hybrid turret
#

yk, i've been developing a large server-system (currently on 1.16.4 but i'm planning on migrating to 1.19.2 once i figure out how easy that is) and this is just a thing that popped into my mind a while ago but i haven't found a solution

hybrid turret
#

wdym by that?

worn tundra
#

:D

molten hearth
#

lmao

hybrid turret
#

am i not getting jokes rn? sorry lmao

#

my brain has been dead for the last couple days

flint coyote
hybrid turret
#

or did you try that already?

mighty pier
flint coyote
mighty pier
#

thats what developers do

worn tundra
hybrid turret
#

hm

#

mb

hybrid turret
#

fair enough

worn tundra
flint coyote
dim bronze
worn tundra
#

Try blockphysicsevent or similar

white root
hybrid turret
flint coyote
#

Yes you don't want static unless it actually makes sense

flint coyote
hybrid turret
#

i hate static so much lmao

white root
dim bronze
#

You could also listen for when a sound is played to the player

#

I imagine there is a way to get the block source of the sound

#

and only then do you have to check whether its a skulk sensor

flint coyote
worn tundra
#

We're probably not seeing smth very obvious for the shrieker lol

#

Must be some interact / change event or something

flint coyote
dim bronze
#

I don't know whether the shrieking is handled client side though

white root
flint coyote
dim bronze
#

I'm thinking purely off the playsound command here but don't sounds that are played to the player have a source?

#

you'd just have to check the sound source block

flint coyote
#

You remove static and use either DI or an actual object?

dim bronze
#

I assume the shrieker isn't client side since the warden spawns after x number of shrieks

flint coyote
#

Then do it

dire marsh
dim bronze
#

That's a lot simpler 😆

hybrid turret
#
  public void onUseKeyInteractable(PlayerInteractAtEntityEvent e) {
    Player p = e.getPlayer();
    ItemStack item = e.getPlayer().getItemInHand();
    if (item.getType() == Material.NAME_TAG && item.containsEnchantment(Enchantment.LUCK)) {
      e.setCancelled(true);
    }
  }```

Can someone explain why tf this code won't work? I don't get it (yes, the if-statement is reached)
worn tundra
#

What doesn't work?

#

It doesn't get cancelled?

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.

hybrid turret
#

i'm sorry

#

oh really?

white root
#

<player>.inventory.getItemInMainHand

dire marsh
hybrid turret
#

welp, that's probably the issue

#

ty

white root
hybrid turret
#

not?

dim bronze
#

that's definitely the proper way of doing it. No idea that event existed

dire marsh
#

i found it by searching for shriek on the papermc discord xd

white root
#

Uh, another thing, how do you listen to a/the GenericGameEvent?

dire marsh
#

i think it's the new event system mojang added

dire marsh
white root
dire marsh
#

1.9.2
hmmm

#

think you meant to type 1.19.2

white root
#

I might be dumb, one second

#

ah, yep, I was using 1.9.2 lmao

#

ok nvm

dim bronze
#

1.9.2?

white root
#

yeah, typo in my build.gradle lol

worn tundra
#

💀 howd you get it lol

dim bronze
#

OMG

#

OMG

#

A kotlin user!!!

white root
#

A bit like a unicorn am I?

dim bronze
#

been a while since I've seen another in the wild

worn tundra
#

kotlin user when

dim bronze
#

didn't even clock in the screenshot, it took me till you said you were using gradle

#

I thought this doesn't sound like a java developer

flint coyote
#

We still use maven with kotlin tho 💀

dim bronze
#

💀

twin venture
#

Hi is there any good tutorial on how to use packets to spawn , and munplate entites?

wet breach
dim bronze
#

once you use gradle there's no going back to maven

white root
#

Can confirm

flint coyote
#

Not much of a wonder considering how painful maven multi module builds are

dim bronze
#

and there's no need to rely on plugins for everything. If you want something to happen during your build you just code it rather than getting a plugin that does it

#

just makes sense

wet breach
#

there really isn't anything maven can't do

#

majority of people who see or complain of maven going slow is due to the fact they haven't learnt maven or bothered to configure it properly

wet breach
#

making a custom maven plugin is no more difficult then making a plugin for spigot

#

you can even have maven execute build scripts too if you really dislike maven that much or you can combine maven with ant as well

wet breach
#

in either case which you want to use is mostly preference. The majority here will most likely never see any differences between the two because you really need super large projects to really see the difference.

#

maven by default is configured to be conservative with resources

#

you need to modify the maven config or add it to your pom to allow maven to use more resources. As well as concurrent building

dim bronze
#

Yeah totally it’s preference

#

I don’t really have any massive projects, but the small things that I do utilise are much easier to make in gradle than maven from my experience

#

And not sure if this is just a kotlin thing, but by default gradle is definitely slower than maven

wet breach
#

well ease of use is mostly down to what makes sense to you. For some gradle makes sense, for others maven does. I prefer maven because literally there isn't a problem I can't solve with it build wise. I can either find a plugin to resolve whatever issue or provide some functionality or I can make one.

wet breach
ionic dagger
#

Got me giggling n shit

dim bronze
#

Oh yeah I definitely don’t use gradle to it’s full potential

wet breach
#

well at least you know you are 😛

dim bronze
#

But I was definitely worse with maven

#

I would do so much manually

#

And maven is a joke for kotlin development

wet breach
#

I don't use kotlin so I can't really say

dim bronze
#

I’ve never had a problem with maven using Java

hasty prawn
#

Does anyone use gradle to its full potential? Seems like its so jam packed with stuff that'd be near impossible

echo basalt
#

gradle is complicated

wet breach
#

Well unless you are using a kotlin JVM, kotlin compiles to java bytecode

wet breach
#

like builds that can take hours or even a day or so

hasty prawn
#

oh hell nah KEKW

hybrid spoke
#

gradle's onl advantage for me is for big ass projects

#

other than that it only causes problems

hasty prawn
#

I get impatient when my build takes 30 seconds

wet breach
#

For example, compiling something like Firefox

dim bronze
wet breach
#

Firefox literally can take you half a day or more to compile XD

dim bronze
#

I used to use brave-git from the arch AUR and rather than use their binaries it recompiled the browser

#

Every

#

Fucking

#

Update

wet breach
#

lol

dim bronze
#

Took forever

#

Of course that wasn’t using a JVM language but gives you an idea of how long a build actually can take

hybrid spoke
wet breach
#

when I had a dual core it took me something like 18-20 hours to compile firefox I think it was

dim bronze
#

That’s why you don’t push to main

wet breach
hybrid spoke
dim bronze
#

They knew what they were doing when they made that command

wet breach
#

svn is alright until someone messes up the history

dim bronze
#

Blame

hasty prawn
#

Reminds me of OBS change logs where they blame the person for bugs directly

dim bronze
#

Haven’t ever used a source control other than git and don’t plan to

hybrid spoke
wet breach
hasty prawn
#

Still pretty funny

wet breach
dim bronze
#

Probably, but I haven’t had issues

wet breach
#

svn is really easy to use and doesn't take much to set up, where it becomes a hassle is when you want to rollback something

dim bronze
#

If it ain’t broke don’t fix it

wet breach
#

or when you need to change the history

#

this is where git actually excels over svn

dim bronze
#

git push -f

wet breach
#

ah yeah, just force the commit because you don't want to actually fix the problem 😂

#

but even some people do what you would do on SVN to fix problems with git

#

for example, on svn instead of trying to rollback a change, you would just commit again with the changes reverted

#

and you just pretend the history is all fine and dandy XD

#

people who use git kind of do the same thing and don't bother with the rollback features

#

the other advantage of git is that everyone has a local copy, where as in svn you don't and thus you can't have multiple people checkout the same thing so file locking can be an issue sometimes

#

especially if someone forgets to checked in what they checkouted

dim bronze
#

what?

#

how does that work

#

so everyone just stays on separate branches?

wet breach
#

no, you are all on the same branch most of the time. But with SVN there is a server that maintains file locks

#

so if someone checks out a file

#

someone else can't check it out

dim bronze
#

yeah, but that sounds very limiting

#

especially on large projects

wet breach
#

so you have to wait for that person to make their changes, so you can make yours

dim bronze
#

i guess that stops conflicts but that just doesn't sound very productive

wet breach
#

git does alright with this, but even git has its limitations when it comes to merging

dim bronze
#

does it follow the same general workflow of new feature -> new branch?

#

for large projects I guess that's followed more closely

glossy venture
#

in 2008 ppl thought git was too new appereantly

wet breach
wet breach
#

every branch is a directory inside of the repo

#

also svn is more performant when it comes to large files as well or super large projects

#

also when it comes to permissions, git is very limiting. SVN allows you to set permissions all the way down to per file permissions and per directory

dim bronze
#

yeah I've had to deal with incompetent developers before me pushing gigabytes of data to a repo and of course when you clone or create a new branch the entire history goes with it

wet breach
#

so svn is still used, just its has its strenghts and weaknesses like git has its strengths and weaknesses

dim bronze
#

as everything will

wet breach
#

for small to medium projects git is probably the best especially if you don't have too many people working on it

#

medium to large projects with quite a lot of people probably best to use svn

wet breach
#

you need access to the central server itself to change the history

#

with git, all it takes is someone to push the history to mess it all up for everyone else

red sedge
#

wait so uh if i do smth like HashMap<String, int>

would i need to have that identical string object to be able to match it

#

cuz like

#

yk how you cant use ==

eternal oxide
#

no

red sedge
#

because if my issue aint that i dont know what it is

eternal oxide
#

String keys are not compared by instance

red sedge
#

are string arrays compared by instance

eternal oxide
#

No clue, but probably

red sedge
#

fuck..

eternal oxide
#

it simple to test

red sedge
#

kk

#

ill brb

ivory sleet
red sedge
#

mmm yeah

#

string arrays check by instance

red sedge
ivory sleet
#

For any a and b, a and b are considered to be the same key if and only if a == b

red sedge
#

ah

#

yeah no thats not what i need

#

i have like a custom recipe system where I have a String[] of keys for items and a Recipe object for recipes in a hashmap so like Hashmap<String[], Recipe> and I need to make it so that String[] matches with any identical string array

#
        HashMap<String[], Integer> map = new HashMap();

        String[] str1 = new String[] {"a", "b", "c"};
        map.put(str1, 5);

        System.out.println(map.get(new String[] {"a", "b", "c"})); // so like this should also return 5 instead of null
        System.out.println(map.get(str1)); // returns 5
tardy delta
#

You might just make a record around that arr

red sedge
#

so instead of a string array i'd have a record that has 9 variables for each key?

red sedge
#

not really?

wet breach
#

because you can totally use a hashmap inside of a hashmap

red sedge
#

but i dont see how that would help?

robust sinew
#

how do I delete a World? Like if I want to delete the world's file on the server disabling what method do I use to delete it?

wet breach
#

the file delete method

wet breach
red sedge
#

yeah but then how would i find the recipe?

#

this hashmap is to like uh find the recipe from the items in the gui

#

so i get the item id of each item in the gui

#

make an array

#

and then look up in the hashmap to find if there is a recipe for that specific combination of items

wet breach
robust sinew
#

thanks btw

red sedge
#

i might be overcomplicating it

wet breach
#

there is a reason why I mentioned using two hashmaps

red sedge
#

ya but i still dont see how id do it

#

feel like im missing smth really obvious sorry

wet breach
#

HashMap<String, CustomObject> CustomObjectMap inside of customObject is another HashMap<ItemStack, Recipe> RecipeMap. Now all you have to do is just do this
CustomObjectMap.get(String).RecipeMap.get(ItemStack) or something to that effect anyways

#

you could even do it without a custom object

robust sinew
#

ah nvm I figured it out

wet breach
#

HashMap<String, HashMap<ItemStack, Recipe>>

red sedge
#

wha-

#
  1. what is the first string? huh
wet breach
#

the name or some identifier

#

anything really

red sedge
#

okayy

#

and um, how am i suppose to figure out what that is from 9 items in an inventory

wet breach
#

because you can decide on the names or make it use the names of the items

red sedge
#

okay so arent we doing the same thing?

wet breach
#

who cares how many recipes or combinations you have, just toss them all into the hashmap....not like the hashmap is going to break

red sedge
#

i am so confused right now im so sorry

wet breach
#

but the way I am suggesting is instead of trying to group them all together just keep it all separate

#

no need to really worry about if item a is the same recipe as item b if they are both in the hashmap anyways

#

anyways I am tired so I am going to bed, you are making it harder then it needs to be

#

or more like over thinking it

red sedge
#

extremely possible

#

alright

#

thank you

untold patio
#

Hello guys c; hope you're all fine

#

I'm compiling this code but when I run this command in the server, the console says "Null pointer exception"

hazy parrot
untold patio
#

Ok, gimme a sec

vocal cloud
#

I assume the map or array aren't initialized

tardy delta
#

make your main final pls

#

you better call it 'plugin' tho

white root
#

Or be a rebel and call it plugout

vocal cloud
#

private static final Main main

vocal cloud
#

Called it

untold patio
#

This is what happens :c

vocal cloud
#

Did you initialize the array you're adding it to?

tardy delta
#

Main line 36

untold patio
vocal cloud
#

Yup

#

Called it

dim bronze
#

Homes and homes ahh

tardy delta
#

lul

vocal cloud
#

Ugh I'm still writing my State Manager tutorial. Guess my next one is going to be a "how to read an error"

tardy delta
#

private final Map<UUID, List<Home>> homes = new HashMap<>(); 🥺

dim bronze
#

Most beginners definitely don't try to understand the error

#

purely because theres so much text that they won't understand

vocal cloud
#

Understand your error

#

Because otherwise any error you get you'll just come back

untold patio
#

You're right

hard ether
#

Does anyone know how I could make a region and get the center block of that region?

#

ive been stuck on this for a couple hours

eternal oxide
#

region?

hard ether
#

ty

hard ether
icy beacon
#
final String[] args = getCondition().split(" ");
final String[] arguments = new String[args.length - 1];
System.arraycopy(args, 1, arguments, 0, arguments.length);

Any way to simplify this? Basically want to create an array that is a split string, but pop the first argument

patent fox
#

how can i get the location to the right of the player depending on the perspective?

smoky oak
icy beacon
patent fox
smoky oak
#

should be part of javas math packages

#

i recall doing some vector math

#

i can check the package

#

ah

#

i substituted my math with doing it directly oops

#

just check the vector3d class

#

it should have functions to flatten to a plane

untold patio
#

Ok guys, this seems to be working nicely, the only thing I see is that it's listing all the homes for all the players and not the ones a specific user creates

#

Should I add an UUID to the home class and check if that home has the sender UUID?

tardy delta
#

do you have a Map<UUID, List<Home>> in your main?

untold patio
#

Yes

tall dragon
dim bronze
#

theres no need to keep two collections, you can just use the values() of the map

tardy delta
#

well youre iterating over some kind of collection that is not a map

red sedge
#

in an inventoryclickevent do i need to just wait a tick to have the updated inventory

#

or is there anyway to force update it

untold patio
tardy delta
#

or you ensure youre the latest one that applied changes

untold patio
#

I mean I'm not sure if I used it or not

tall dragon
#

res += obj.getName() + " ";

tardy delta
#

== checks for the memory location of a variable, ::equals compares the actual content of an object and can be self defined

untold patio
tall dragon
#

not even sure why ur comparing it there

#

without an if statement

tardy delta
#

we learnt loops in college today 💀

untold patio
#

Hmmm I'm not comparing

smoky oak
untold patio
#

I'm just adding to the same variablew

red sedge
tall dragon
#

its not needed to add

red sedge
#

do i need to wait for that change to affect the inventory in e.getInventory

tardy delta
#

you can get the changes with the appropriate event method?

untold patio
tardy delta
#

=+

tall dragon
#

what is obj.getname ?

tardy delta
#

+= fuck

smoky oak
#

yea was bout to say that

untold patio
#

x'd

tardy delta
#

atleast add a comma smh

untold patio
#

In the arraylist

tall dragon
#

works fine for me

smoky oak
# untold patio Ok guys, this seems to be working nicely, the only thing I see is that it's list...

the issue with this is that you're not checking if a player owns that home. youre checking if a player has a home at all, then you concatrinate all home names and return them. you need a check in the loop, or better yet, iterate over the homes of that player only.
If you're using configuration, if you try to get a configuration section it returns an empty configsection if the player has no home

#

so you wont get a NPE when iterating thta

untold patio
smoky oak
#

also

#

it might be an issue that youre typing homes once 'Homes' and once 'homes'

vocal cloud
#

There's so much wrong with it.

tall dragon
#

like intellij suggests you

vocal cloud
#

There shouldn't even be a loop or an arraylist

tall dragon
#

true

smoky oak
tardy delta
#

exposing collections go brr

tall dragon
#

well here it is

#

and he has it too

smoky oak
#

hm

tardy delta
#

foo = ""

smoky oak
#

bar

tardy delta
#

shut

smoky oak
#

sorry reflex

tall dragon
tardy delta
#

always wondering what foobar even meant

icy beacon
#

wait wtf since when is "yield" an operator in java

tardy delta
#

since the fancy switch

smoky oak
#

java 9 then

icy beacon
#

damn

#

i love it

tall dragon
#

what does yield even do

#

never heard of it

smoky oak
#

idk i use the new switch not the new operator

icy beacon
#

my copilot

tardy delta
#
return switch (state) {
  case BRRR -> {
    System.out.println("I'm outta here");
    yield -1;
  }
  default -> 2;
}```
smoky oak
#

bleh

icy beacon
smoky oak
#

somehow that looks wrong

tall dragon
#

isnt that just the same as return -1 ?

smoky oak
#

and cant you just do -> to give a return value from a switch

icy beacon
#

return is in the return switch

tardy delta
#

ye

icy beacon
smoky oak
#

ah

#

yea logging wont be possible then

tardy delta
smoky oak
#

unless you call a function exactly for that returning the value but that sounds like a bad idea

smoky oak
tardy delta
#

how do i know lmfao

#

damn pink

vocal cloud
#

They usually pick for you

#

just sudo reboot now

tardy delta
#

long time since i did updates lol

vocal cloud
#

sudo apt-get update && sudo apt-get upgrade && sudo reboot now

tardy delta
#

ill probably start dualbooting again

icy beacon
#

this is SO fancy omg

tardy delta
#

switch in a case 💀

icy beacon
#

i feel like i am coding in not java

icy beacon
#

that's.. that

icy beacon
#

xD

smoky oak
#

y'al should update if youre running any sort of SSH cuz there's been a massive vulnerability that's been fixed in newer updates but is about to be disclosed

#

or downpatch to 1.x

tardy delta
#

im only using pi on my local network so dont really care lol

#

mf why am i pi@pi

icy beacon
#

me trying not to make an unfunny 3.14 joke

smoky oak
#

im gonna do it

untold patio
#

😄

tardy delta
#

programmers: Math.PI

hybrid spoke
chrome beacon
eternal night
#

wtf

peak depot
#

for what would you need that

tardy delta
#

Math.pow(5, Math.PI)

naive bolt
#

how can i do an if statment where i have a bool true or false and in the if statment if the bool is true then i pass a condition in the if statmnet

tardy delta
#

probably doesnt accept a double as 2nd param

naive bolt
#

can i nest that in an existing if statment tho

summer agate
#

You'll have to elaborate

naive bolt
#

if bool false then have
if (blockData.getMaterial() != Material.AIR && blockData.getMaterial() != block.getLocation().getBlock().getBlockData().getMaterial()) {
else if true have
if (blockData.getMaterial() != block.getLocation().getBlock().getBlockData().getMaterial()) {

#

like a double if statment in one

#

idk im in a sleep wreck trying to do this

#

it probably doesnt make much sense its hard to explain

summer agate
#

You can probably find your answer in ?learnjava

#

Huh guess that didnt work

#

?learnjava

undone axleBOT
serene sigil
#

how do u check if a player doesnt have a shulker box with a dragon egg inside (shulker box yes, but not with egg)

vocal cloud
#

Probably by fetching any shulkers they have in their inventory and checking if they contain dragon eggs?

radiant cedar
#

how can i count all stone blocks in a players inventory just to have the number
then remove all of them

#

but thats for single itemstack no?

#

i need how many they have in whole inventory

#

or should i iterate through each slot

native ruin
#

oh wasn't to you

#

sorry

radiant cedar
#

ohoh

serene sigil
#

i know how to check if they have, but idk how to do the opposite

native ruin
native ruin
serene sigil
#

my current code

native ruin
#

put an ! before the if statement

#

if(!condition)

radiant cedar
#

should i iterate through all contents

#

or is there a better function

#

that will give how many cobblestones they have in inventory

native ruin
#

oh yea probably

radiant cedar
#

i couldnt find in docs

#

found one called getMaxStack or smthng

#

but idk if it returns largest stack

chrome beacon
robust sinew
#

does onDisable() run when the server closes, or how could I run something on the server closing?

chrome beacon
#

Yeah your plugin gets disabled when the server is closed

robust sinew
#

for some reason the thing I'm doing isn't running

#
    public void onDisable() {
        getServer().getWorld("CustomCoolWorld").getWorldFolder().delete();
        super.onDisable();
    }``` I'm trying to delete my world file when the server closes
#

is there another way to do this?

chrome beacon
#

The world probably isn't unloaded yet

robust sinew
#

ah

#

how do I unload it?

#

I'll google it ig

#

I tried unloading the world but it didn't work

#

the world still didn't delete

serene sigil
#

(so it triggers for the first shulker which doesnt have anything and then doesnt triggers the shulker with the egg)

severe marsh
#

How can I check if the attacked entity is dead in the EntityDamageByEntityEvent event?

tall dragon
#

check if the victim's health - the final damage is lower than 0

severe marsh
#

Like this? if (e.getDamage() > ((Zombie) e.getEntity()).getHealth()) {}

tall dragon
#

not really

severe marsh
#

Because it doesn't let me do the e#getEntity()#getHealth() if it's not casted. And I already did Zombie check earlier

tall dragon
#

and i would do it exactly as i said victimHealth - final damage <= 0

severe marsh
#

ait, thanks

summer agate
naive loom
#
        int entityId = player.getEntityId();

        PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityId);
        EntityCreature creature = null;
        WorldServer ws = ((CraftWorld) player.getWorld()).getHandle();

        String kitName = kit.name().toLowerCase();
        switch (kitName) {
            case "creeper" -> creature = new EntityCreeper(EntityTypes.q, ws);
            case "enderman" -> creature = new EntityEnderman(EntityTypes.y, ws);
            case "snowgolem" -> creature = new EntitySnowman(EntityTypes.aI, ws);
            case "chicken" -> creature = new EntityChicken(EntityTypes.n, ws);
        }

        player.setMetadata("spleef-kit", new FixedMetadataValue(spleef, kitName));

        assert creature != null;
        PacketPlayOutSpawnEntity spawnPacket = new PacketPlayOutSpawnEntity(creature);
        try {
            // c field

            Field entityIdField = spawnPacket.getClass().getDeclaredField("c");
            entityIdField.setAccessible(true);
            entityIdField.set(spawnPacket, entityId);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }

        Bukkit.getLogger().info("A little bit of magic for these dumb ass packets!");
        Bukkit.getLogger().info("Player Entity Id = " + entityId);
        Bukkit.getLogger().info("Spawn Packet Entity Id = " + spawnPacket.b());

        for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
            CraftPlayer craftPlayer = (CraftPlayer) onlinePlayer;
            EntityPlayer entityPlayer = craftPlayer.getHandle();

            entityPlayer.b.a(destroyPacket);
            entityPlayer.b.a(spawnPacket);
        }
#

Could someone shine some insight on why this isn't working. (Isn't working by I cannot see my own skin, and can't move after these packets are sent)

peak depot
#

?paste

undone axleBOT
peak depot
river oracle
#

asynchronous access

#

shouldn't be doing what your doing async

peak depot
#

let me try

river oracle
#

you can only read data async

#

generally thats the rule with spigot api

#

writing is not really going to possible on 99% of the api asynchronously

peak depot
#

works thanks

hazy parrot
#

You tested that pretty fast ngl

river oracle
#

he has super powers

#

i need that work flow though tell me

peak depot
#

I just replaced runTaskLaterAsynchronously with runTaskLater compiled put on server reload /debug (start the game) get some items 2nd account killed me looked in chest and done

#

1min job

river oracle
#

💀 you are just productive

peak depot
#

well gota get the plugin finish someday

stone dust
#

How
Do
You
Fix
Null Pointer Exception
???

Im sooo tired of searching the web for answers of how i can fix this problem, and i guess you guys fix it in your sleep (or just doesnt do it)

I have a List which i want accessible from another class, but im getting a null pointer exception.

"Code:"
public List<String> onCooldown = new ArrayList<>();

hazy parrot
peak depot
tardy delta
#

?di

undone axleBOT
tardy delta
#

probably want to have an object wrapping that collection with appropriate methods for crud operations tho

tardy delta
#

because passing mutable collections around goes brr

stone dust
#

Wait, do you have a pastebin?

#

?pastebin

tardy delta
#

youll ever fuck it up

peak depot
#

?paste

undone axleBOT
rotund ravine
tardy delta
#

wrapping logic with your object would be much cleaner

stone dust
rotund ravine
tardy delta
#

this can be refactored to if plugin.collection.remove()

#

if it will remove it and return true if it was able too

rotund ravine
#

It returns true if he was removed

#

Not added

tardy delta
#

you were using t as param before

#
if (plugin.selectedPlayers.contains(t)) {
                plugin.selectedPlayers.remove(t);```
=>
#
if (plugin.selectedPlayers.remove(t)) {}```
sterile token
#

selectedPlayers must be used only for field or variables declarations

#

That its speciifed on Chapter 6, article 1 of Java programming book, "Conventions"

rotund ravine
#

He’s talking about getters and setters for variables. Encapsulation

tardy delta
#

getters exist for a reason yes

sterile token
#

Yeah, you should be using encapsulation instead of working directly over the things

stone dust
sterile token
#

Code messy == hard understand when needing to fix up issues, not even talking it about scalability terms

stone dust
rotund ravine
#

One thing i learned about spigot is it’s pointless to point anything out.

#

I don’t see you using your field in your code @stone dust so please point to where the error occurs

#

With a stacktrace and the updated code.

sterile token
#

Yeah that its called basically

#

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

sterile token
#

Learn how to ask about code

#

Not wondering to sound rude, but doesnt make sense asking for help without explaning the problem itself "just sayin doesnt work" and not sending any code/code "not working" ho you call it

rotund ravine
#

He did send code and said his problem

sterile token
#

If you wont help dont do it

#

Its simply

#

Dont disturb on the channel saying not necessary things

#

🤔🤪

rotund ravine
#

Stop being weird.

#

I literally asked him for further information so i could help him properly.

rotund ravine
torn badge
#

Dude Verano chill

sterile token
rotund ravine
#

Please provide the stacktrace and the code in which you use the variable. @stone dust just ignore the others.

stone dust
#

The error occurs where it searches if selectedPlayers has p (Line 32 in the pastebin)
And here is the stacktrace: Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.contains(Object)" because "this.plugin.selectedPlayers" is null at live.supeer.twitchplugin.TwitchCommands.onCommand(TwitchCommands.java:31) ~[twitchplugin-1.0-SNAPSHOT.jar:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] ... 23 more

tardy delta
#

that list is null

stone dust
#

?conventions

sterile token
#

You should use a getter

#

I mean it is part of Chapter 6, Article 1 "Conventions" of the book of basic fundamentals and advanced programming for Java

tardy delta
#

noone knows what book youre talking about 💀

echo basalt
#

💀

rotund ravine
#

The variable should not be null. @stone dust

echo basalt
#

Just follow the 4 principles of OOP + java naming conventions

rotund ravine
#

Are you setting it somewhere?

echo basalt
#

and proper design patterns like Dependency Injection & Dependency Inversion

#

Might as well apply SOLID principles

glossy venture
#

bro verano in this case it really doesnt matter, its not professional production code

echo basalt
#

and while you're at it, use JNI to achieve better performance by writing your code in c++

sterile token
tardy delta
#

never heard of dependency inversion lol

glossy venture
#

jni calls are slower right

torn badge
echo basalt
#

yeah

#

actuall

#

y

stone dust
tardy delta
#

actually bytecode

echo basalt
#

make it with something more native to minecraft - redsotne