#help-development

1 messages · Page 2033 of 1

fast path
#

So you want check it every tick?

kind hatch
#

The problem is that he created a while loop that checks for true instead of the boolean breakFree

tender shard
#

no it changes the whole logic

#

your current code only sets it to true once

#

and once it once gets set to false, it stays false forever

pliant oyster
#

I did if(e.getInventory().equals(mainGui)){ e.setCancelled(true) }

fast path
#

Wait what

tender shard
lime jolt
fast path
#

How can block equal material

kind hatch
#

@tender shard Read my last post.

tender shard
fast path
#

So that breakFree never true.

tender shard
#

you set it to true once and then once it gets set to false once, it stays false FOREVER

lime jolt
fast path
#

Then It stucked

tender shard
#

because you refuse to move the breakFree = true into your loop

tender shard
#

no

#

you don't

lime jolt
tender shard
#

it will never run

#

because you are stuck in your while loop

lime jolt
#

brb

tender shard
#

also you can't change it from your main class, it's a local variable

fast path
#

Hey… organize your thoughts

tender shard
#

ngl the whole code is a huge mess

fast path
#

@lime jolt you know how can’t your code break?

tender shard
#

I've never seen so many duplicated lines

lime jolt
#

🙂

fast path
#

Because breakFree won’t be true

#

block.equals(material)

#

There’re different type

lime jolt
#

ohhh

#

I seee

tender shard
#

yes, that's another thing

lime jolt
#

that is big problemo

tender shard
#

a block will never be equal to a material enum

fast path
#

But that’s important

lime jolt
#

what would I change that to then?

kind hatch
#

You all are missing the basics here.

He wrote this

boolean breakFree = true;

while (true) {
// Code Inside
}
```He made a while loop that checks **true**. This will **always** be running. 

He should have instead done this:
```java
boolean breakFree = true;

while (breakFree) {
// Code Inside
}
fast path
#

getType().equal

lime jolt
#

getBlock().getMaterial?

lime jolt
#

cool

fast path
#

Yeah

lime jolt
#

I will try that

viscid girder
#

getBlock().getType()

lime jolt
#

aright I will try

fast path
#

And.

#

You should use material.isAir

#

Not equal air

lime jolt
#

so

#

getBlock().getType().isAir

fast path
#

I’ll check your code angin and find where problem is.

#

Yeha

lime jolt
#

aright thanks I will try that

tender shard
#

he wants to loop while breakfree is NOT true

unique eagle
#

Hello ! i use Player#sendBlockChange and i want to rotate a furnace with block data

BlockData furnace = Bukkit.createBlockData(Material.FURNACE);
player.sendBlockChange(new Location(Bukkit.getWorld("world"),1386 ,4 ,1513),furnace);```

furnace spawn with blockFace to the north
kind hatch
viscid girder
tender shard
fast path
#

Hm

fast path
unique eagle
#

okay 🙂

tender shard
fast path
#

And change blockface

pliant oyster
#

I added the debugs and for some reason it's not detecting that I clicked something in the inventory

tender shard
fast path
#

Send it.

tender shard
#

did you register your listener?

fast path
#

You need to detect name of gui

#

Not detect gui

pliant oyster
pliant oyster
tender shard
pliant oyster
tender shard
#

does this get printed when you click?

fast path
#

Hm

kind hatch
fast path
#

The eventhandler is ready I think

viscid girder
kind hatch
#

If you can compare something smaller in value, why wouldn't you?

fast path
#

So problem is check

kind hatch
#

Also, a direct object comparison would be far more accurate than a string comparison.

pliant oyster
tender shard
fast path
tender shard
#

System.out.println(e.getInventory());

fast path
#

If you only check inventory equal

tender shard
#

and also print out the other inventory you're comparing to

fast path
#

What if you add something to inventory

kind hatch
tender shard
tender shard
kind hatch
#

It's an instance of an Inventory. The inventory instance doesn't change.

tender shard
#

exactly

fast path
#

Oh you’re right

tender shard
#

it's the same as this:

Person a = new Person("mfnalex");
Person b = a;
b.setName("TangJin");

b is still == a now

pliant oyster
fast path
#

My fault

tender shard
#

?paste

undone axleBOT
pliant oyster
#

oh

#

full code

#

ok

#

it's a big big one

tender shard
fast path
#

Hm

fast path
#

In this image he did correct

tender shard
pliant oyster
fast path
#

Uh

tender shard
#

add this in your listener ad the very top:

System.out.println(e.getInventory());
System.out.println(e.getClickedInventory());
System.out.println(mainGui);
fast path
#

Show me where you register your eventlistener

pliant oyster
#

ok

tender shard
#

I guess you have to use getClickedInventory instead of getInventory

fast path
#

Yes

kind hatch
#

Do you think that's due to the Inventories being split into views?

#

Like top and bottom inventory?

#

Cause that used to work like that.

tender shard
#

maybe, we know it when they send the output of the sout's

fast path
#

Just use clickinventory

#

And use equals instead of ==

tender shard
#

that makes no difference

fast path
#

== only work when memory location is same

lime jolt
#

thx

tender shard
fast path
#

np

#

Maybe

pliant oyster
# tender shard add this in your listener ad the very top: ```java System.out.println(e.getInven...
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1c28b366
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1c28b366
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@23996f3f
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1c28b366
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryPlayer@45ab0f42
[16:43:53] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@23996f3f
``` it logs this idek what it is
fast path
#

But I will always use it

#

Why not?

kind hatch
#

Remember the inventory click event fires for every inventory.

fast path
#

Why there are 6 inventory

#

Can’t you just click once?

#

It should only log 3 inventory right?

pliant oyster
#

Idk

fast path
#

Paste your code and send here angin

#

I need see new code

pliant oyster
#

?paste

undone axleBOT
pliant oyster
fast path
#

@tender shard did you see that?

pliant oyster
#

I'll try wat mfnalex said

fast path
#

That not same memory location.

pliant oyster
#

I'll use getClickedInventory instead

fast path
#

In this case
getInventory is same with getClicked

#

But different with mainGui

#

That’s weird.

pliant oyster
#

yeah

#

my code is just broken

#

lemmie check if there's something wrong outside of this class

#

maybe it's not registered correctly

tender shard
#

check the event's getView().getTopInventory() instead of the clicked inventory

fast path
#

hm

tender shard
pliant oyster
#

oh true

fast path
#

If clicked is on top then it just output same

fast path
tender shard
pliant oyster
#

the thing is

fast path
pliant oyster
#

breh im so confused

#

nothing inside if (e.getClickedInventory().equals(mainGui)) is working

kind hatch
#

Because you are using .equals instead of ==

pliant oyster
kind hatch
#

Since when?

tender shard
#

equals() or == makes no difference

pliant oyster
#

I mean im so stuck rn so Ima try what shadow said rq

pliant oyster
kind hatch
#

😛

fast path
#

If some object overwritten equal method then it works

tender shard
kind hatch
#

Ok, so @tender shard you were right about the top inventory. It's the correct instance.

fast path
#

Like string

tender shard
#

yes but Inventory doesn't override it. CraftInventory does override it, but it's basically also the exact same thing

kind hatch
#

@pliant oyster Compare your mainGUI to the top inventory using InventoryClickEvent#getView().getTopInventory()

fast path
#

hm

pliant oyster
#

alr

tender shard
fast path
#

You know? CraftInventory extended Inventory

tender shard
#

it's the implementation of the Inventory interface

#

same as with CraftPlayer and Player

#

and basically anything in Spigot

fast path
#

And if you use getInventory I think it returned a CraftInv

#

so the equals still works

tender shard
lime jolt
#

does anyone know how to "sendTitle" to everyone on server

fast path
#

That’s easy

#

just foreach player and do

kind hatch
#

Iterate over Bukkit#getOnlinePlayers() and use the built in sendTitle method in the player object.

fast path
#

.spigot().sendTitle

lime jolt
#

aright thanks

#

wait

lime jolt
#

Bukkit.getOnlinePlayers().sendTitle

fast path
lime jolt
#

u sure that works?

fast path
#

No

#

Foreach

lime jolt
#

oh

#

for(Player player: Bukkit.getOnlinePlayers()){}

fast path
#

Bukkit.getOnlinePlayers().forEach(p->p.spigot().sendTitle(…))

#

thats work too

lime jolt
#

aright

#

thx

#

idk how the --> arrow stuff works

fast path
#

That’s lambda

kind hatch
fast path
#

Oh

#

Sorry we’re in different timespace

kind hatch
fast path
#

I uses spigot because I working on old version and newer too.

pliant oyster
#

I'm using a command to run that function

fast path
#

I want to go sleep

#

If you can dm me the full code

#

@pliant oyster

pliant oyster
#

tangjin

lime jolt
#

does anyone know how to see if someone died?

fast path
#

Or you can still try use title to check

kind hatch
pliant oyster
#

the class that runs the function is in a different class

fast path
#

Hm

kind hatch
fast path
#

Uh no

pliant oyster
fast path
#

There is a isDead method

kind hatch
pliant oyster
#
@Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

        if(sender instanceof Player){

            Player player = (Player) sender;

            CrateSystem crateSystem = new CrateSystem();
            crateSystem.openCratesMenuGui(player);


        } else {

            sender.sendMessage("You must be a player to use this command!");

        }

        return true;
    }```
fast path
#

@kind hatch looks normal

#

Byebye gtg

kind hatch
pliant oyster
kind hatch
#

Did you register the command?

pliant oyster
#

Yea

#

the command works

kind hatch
#

Can you share the CrateSystem class?

pliant oyster
#

yes

fluid nacelle
#

So I am looking to get a spiral projectile trail with 2 particles opposite to each other, I've managed to do it but it's only horizontal and I want to make it change as the projectile changes, so I'll somehow need to account for the yaw and pitch. Any trigonometry experts have any ideas? xD

pliant oyster
#

?paste

undone axleBOT
lime jolt
wooden fable
#

Is there any Packet for setting the player's pose? (Stop crawling/swimming)

kind hatch
pliant oyster
#

the inventory is opening

#

but everything inside the if (e.getInventory().equals(mainGui)) isnt

sacred mountain
#

how do i pass a variable type as an argument in a method? I want to make it so i can use the same method but with different types

kind hatch
pliant oyster
#

what

kind hatch
#

Change your comparison. Compare your mainGUI to the topInventory using InventoryClickEvent#getView().getTopInventory().

pliant oyster
#

idk how to do that lmao

kind hatch
#

You don't know how to write an if statement?

pliant oyster
#

I do

#

just that I have no idea wym

#

ohh

#

if (e.getView().getTopInventory().equals(mainGui))

#

like this

kind hatch
#

Yes

tardy delta
#

the InventoryClickEvent#getView returns an InventoryView which basically consists of two inventories

#

like when you right click a chest, the upper one will be the chest and the lower one the player's inv

kind hatch
#

Try the == comparison.

pliant oyster
#

k

#

ye samething

#

I'm honestly so confused

kind hatch
#

What's the output of your debug messages? Because they should be the same at that point.

System.out.println(event.getInventory());
System.out.println(event.getClickedInventory());
System.out.println(event.getView().getTopInventory());
tender shard
#

there is no real situation in which equals will be false while == will be true

kind hatch
#

What about if it's overriden?

pliant oyster
#
[17:14:12] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@755d3550
[17:14:12] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@755d3550
[17:14:12] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@755d3550
tender shard
#

now it's working

pliant oyster
#

what

tender shard
pliant oyster
#

my brain is not wokring rn

kind hatch
#

System.out.println(mainGUI);

#

Or whatever the name of it is.

lime jolt
#

anyone know how to clear everyones inv

pliant oyster
kind hatch
pliant oyster
#

it prnts

[17:18:09] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1cdb1a55
[17:18:09] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1cdb1a55
[17:18:09] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@1cdb1a55
[17:18:09] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@7f019c5
``` now
lime jolt
kind hatch
#

@tender shard You got any insight on this? His inventories should be comparing properly now, but aren't for some reason.

lime jolt
tender shard
#

if they return the same hashcode (e.g. if sout is the same) it should be equal()

kind hatch
tender shard
lime jolt
#

wait

lime jolt
#

I am blind

#

thx

#

the capital

kind hatch
pliant oyster
#

what

kind hatch
#

Cause in my testing, I'm setting a size and getting the proper comparisons.

pliant oyster
#

I don't think that would be the issue

tender shard
#

wanna see something funny?

        double nan = Double.NaN;
        if(nan != nan) {
            System.out.println("This actually gets printed! Wtf!");
        }
smoky oak
#

just

#

dont

#

also can you get the bounding box/hitbox of a raised shield?

kind hatch
#

Then again, I'm storing the instance of the inventory in a map.

lime jolt
quasi patrol
#

Top.gg vote event basically cause Top.gg sends a webhook request and not like doing an actual event in an api.

kind hatch
pliant oyster
pliant oyster
#

honestly wtf is wrong with the code

smoky oak
#

can you show ur code?

pliant oyster
#

?paste

undone axleBOT
pliant oyster
frigid rock
#

hello! i'm trying to make a verification plugin and i need to store some data in a database (username, uuid, password etc..) I tried by doing this but it stores each "value" in a different row, how can i put those values in one row? (i made 3 methods for the username and the uuid and the password). ```java
public void setName(String name){
this.name = name;
PreparedStatement namePs = null;
try {
namePs = conn.prepareStatement("INSERT INTO users (username) VALUES (?)");
namePs.setString(1, name);
namePs.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}

}```
tender shard
frigid rock
#

yeah but i want 3 different methods

tender shard
#

then setString(1, ame);
setString(2,uuid);
setString(3,password);

frigid rock
tender shard
frigid rock
#

oh okay, thank you! imma try that

tender shard
#

INSERT obviously creates a whole new entry 🙂

frigid rock
#

bruhh yeah

elfin atlas
#

Does someone know how can I'll make a effect like this when I'll go over a Armorstand with my view?

smoky oak
#

fairly sure that's a mod only thing

lavish hemlock
#

what mod is that

elfin atlas
#

Its not a mod

frigid rock
lavish hemlock
#

hmm

#

what

#

what is that

smoky oak
elfin atlas
#

I mean this is also not a mod

frigid rock
#

that's a texture pack

elfin atlas
#

Yeah

lavish hemlock
#

yeah but that's more explainable

elfin atlas
#

I can say its not a Mod

frigid rock
#

mhmm idk

tardy delta
lavish hemlock
#

what server is that

frigid rock
tardy delta
#

origin realms does such hover-over things too

brave sparrow
elfin atlas
lavish hemlock
#

Also you're supposed to cache PreparedStatements lol

tardy delta
#

idk how to send the thing

elfin atlas
frigid rock
brave sparrow
#

You don’t manually cache them yourself

lavish hemlock
#

Isn't the point of a PreparedStatement that it precompiles the SQL statement or smthn?

brave sparrow
#

A prepared statement is associated with a Connection, it doesn’t stand alone

kindred valley
#

?learnjava

undone axleBOT
brave sparrow
#

The database driver can do the prepared statement caching but you’re not supposed to do it yourself

quasi patrol
#

So uhh?

brave sparrow
brave sparrow
kind hatch
#

@pliant oyster @tender shard I figured out why the inventory instances were different.

quasi patrol
tardy delta
#

didnt know you could call methods on an array

brave sparrow
brave sparrow
tardy delta
brave sparrow
#

Well I mean yeah

quasi patrol
brave sparrow
#

An array is just an Object

golden turret
#

how can i get the server name in bungeecord config from a spigot plugin? something like Bukkit.getBungeeServerName()

quasi patrol
brave sparrow
quasi patrol
#

So use a different dedicated port than?

brave sparrow
brave sparrow
elfin atlas
kind hatch
#

@pliant oyster To solve your problem, you need to stop creating new instances of your GUI and instead use one instance of it instead.

tardy delta
#

i thought arrays were primitives

elfin atlas
#

I see

lavish hemlock
tardy delta
kind hatch
#

Keep in mind that's done with a resource pack.

tardy delta
#

ye but i mean the price thing

quasi patrol
#

Same error.

kind hatch
#

@tender shard I can't believe I didn't realize this earlier. If you have Inventories that you are creating in a class like that and then register events for that class using a new instance of that class. The listener will be tied to those instances. Of course it wouldn't have worked. You need the initial instance in the first place.

Think of it like this.
You need three things for a custom inventory to work. (In this specific setup.)

  • The class
  • The inventory
  • The listener

Think of this as a sort of metaphorical "bundle".

So, now what happens when you create a new instance of the class? You get the following.

  • The new class
  • The new inventories

The bundle is incomplete because you don't get the new listener. That's why there is mismatches between instances.

brave sparrow
#

I don’t know anything about the library you’re using

quasi patrol
#

Well do you know what packet id 79 is?

chrome beacon
#

What version

brave sparrow
#

^

#

Better question though

#

Why is your web socket using minecraft packets

west oxide
#

hey so i know this isnt a discord bots help but i need help making a discord bot that works with my plugin
this is my code :

  var sqlId = "'"+id+"'";

  connection.query("SELECT UUID FROM " + linkTable + " WHERE linkID = " + sqlId, function (err, result, fields) {
    if (err) throw err;
    if(result.length == 0){
      console.log("not found");
    }else{
      console.log(result[0]);
      return result[0];
    }
  });
}````
and it returns this :
```{ UUID: '3e8eac9d-c886-47a1-937c-5f0dfdf6114b' }```

how can i make it only return the uuid value ...
kind hatch
#

Cast it to a UUID?

west oxide
kind hatch
#

A result set can return multiple things right? So you need to cast the result to the proper object type.

pliant oyster
#

me or him

kind hatch
#

you. My bad

pliant oyster
#

ok I have no idea wym

kind hatch
# pliant oyster ok I have no idea wym

To put it simply. You need to change your current approach. You have a simple solution and a slightly more complex solution.
The simple solution is to create on instance of your custom inventory class and pass it around to wherever you need.
OR
The complex solution is to create an inventory manager that handles creating inventories and can keep better track of instances.

#

There is technically a third solution, but I think it's frowned upon.

pliant oyster
#

listen man, does it seem like my brain is big enough to comprehend what you said?

kind hatch
#

Not the solution I was talking about, but that's how the manger would handle things.

kind hatch
pliant oyster
#

I'm bad at translating verbal stuff into code if yk what I mean

kind hatch
pliant oyster
#

ye

#

spoonfeeding is how I learn xD

patent horizon
#

would someone be able to help me with this

pliant oyster
#

I don't copy and paste it tho

#

if I don't know what it means

kind hatch
#

Ok. You know how instances work correct?

Inventory inv1 = Bukkit.createInventory();
Inventory inv2 = Bukkit.createInventory();
Inventory inv3 = Bukkit.createInventory();

All three of those are separate instances of the same class. They all have the same methods, but are different based on content and the memory address that's assigned to them.

pliant oyster
#

yeah

fluid nacelle
#

You could always include your own equals method though if you make an abstract class or something

kind hatch
#

Think about what happens when you create an instance of something inside an instance of another object.
In your case, you are creating an instance of Inventory inside your CrateSystem class.

#

Let's say you did this multiple times.

kind hatch
#

Instance one of CrateSystem will have an inventory instance with it's own ID.
Then in another it will have another instance with another ID.

pliant oyster
#

according to console

#
[17:53:56] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@22e1f12d
[17:53:56] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@22e1f12d
[17:53:56] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@22e1f12d
[17:53:56] [Server thread/INFO]: org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryCustom@6cbecd29
kind hatch
#
CrateSystem crateSystem1 = new CrateSystem();
CrateSystem crateSystem2 = new CrateSystem();
CrateSystem crateSystem3 = new CrateSystem();
pliant oyster
#

something I am doing is changing mainGui right when I click it

kind hatch
#

Yes, do you see how the last one is different?

pliant oyster
#

yeah

kind hatch
#

Why do you think that is?

pliant oyster
#

it was changed

kind hatch
#

Not quite

#

That instance wasn't changed. Instead you are now dealing with a new instance.

pliant oyster
#

maybe cuz I did

mainGui.setItem(10, emeraldOreItem);
mainGui.setItem(12, diamondOreItem);
mainGui.setItem(14, goldOreItem);
mainGui.setItem(16, ironOreItem);
``` right before the player opens it
kind hatch
#

Which is because you created a new instance of the CrateSystem class to open the GUI to the player.

#

That new instance will have different instances of the Inventories created inside.

#

Which is what you see in console

#

Now, how do you solve this?

#

The simplest solution is to just have one instance of CrateSystem.

pliant oyster
#

I have to brb

#

gimmie 5 mins

kind hatch
frigid rock
#

yo, does anyone know what this means? java com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Illegal double '23e516' value found during parsing

kind hatch
#

Exactly what it says. A double can only contain numbers.

#

Likely an issue with whatever method is parsing the data.

#

Or the way it was implemented into your project.

frigid rock
#

but i'm not using doubles

kind hatch
#

What are you using then?

frigid rock
#

just strings

#

that's a uuid that i turned into a string

pliant oyster
#

since when did playerupdate inventory exist

#

never heard of that

#

I thought it automatically updates bruhhh

kind hatch
#

It does for the most part, but there are times when it needs to be called.

#

Just depends on what you are doing.

pliant oyster
#

so when I set an item in there

#

?

kind hatch
#

If you set the items first, then open the inventory, you don't need to call updateInventory().

#

You would want to call it if the inventory is already open and you want to change items inside it.

pliant oyster
#

so this should fix it?

patent horizon
#

would anyone know why warped fungus isn't registering as a material?

kind hatch
kind hatch
patent horizon
#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>remapped-mojang</scope>
        </dependency>```
kind hatch
patent horizon
#

yup

kind hatch
#

And you ran BuildTools normally?

patent horizon
#

yup

patent horizon
#

all there

kind hatch
# patent horizon yup

Only thing I can think of is an issue with maven. Have you tried restarting intelliJ? Or invalidating caches and restarting?

pliant oyster
#

oh

#

so when I use cratesystem outside of the class

patent horizon
#

i've restarted multiple times, don't know how to do the latter

pliant oyster
#

it is different?

kind hatch
patent horizon
#

which of these do i check

kind hatch
#

I normally clear these.

elfin atlas
patent horizon
#

resource packs

kind hatch
elfin atlas
tardy delta
#

i know now now

#

aah

elfin atlas
#

Kinda hard todo

pliant oyster
pliant oyster
#

inside the InventoryClickEvent

kind hatch
#

Not unless you are changing the contents of the GUI when they click an item.

pliant oyster
#

breh

#

ok so

#

I'ma try to use my brain here

#

for a moment

#

the first 3 logs is the inventory that the player has opened

#

and the 4th log is the mainGui inventory

#

are they not the same inventories?

kind hatch
#

What does the output say? If they do not have the same output. Then no, they are not the same.

elfin atlas
#

Does someone here knows how raytracing is working with spigot?

pliant oyster
#

the first 3 are the same and the 4th one is different numbers

#

but why arent they the same?

#

the inventory that the player opens is the mainGui

kind hatch
pliant oyster
#

if u ?jd me after I say this

pliant oyster
#

That is not a bleb-friendly word!

kind hatch
#

I thought you knew what they were. I even asked that at the start.

#

And you said yes.

#

Also, no I can't ?jd you because instances are a basic concept of Java itself.

pliant oyster
#

Yeah I knew what they were now I have no idea wtf u mean by that

#

?jd @pliant oyster

pliant oyster
#

oh wait

#

I thought jd is learn java

#

LMDFAO

#

well either way

#

dont do either one on me

#

speak in bleb friendly language

kind hatch
#

So, you do understand that every time you create a class like this:

MyClass clazz = new MyClass();

You are creating a new instance of that object.

pliant oyster
#

yes

#

and I use that in a command

kind hatch
#

Ok, now. You understand that applies to EVERY single thing in Java correct?
It also applies to this:

Inventory mainGUI = Bukkit.createInventory();
pliant oyster
#

Yeah

#

I just called them variables

#

bcuz my brain is not that big

kind hatch
#

Well yes. You create variables for those instances.

#

So that you can modify them.

golden turret
#

my english is asking what is bounce

lavish hemlock
#

A variable refers to an instance of a type.

kind hatch
lavish hemlock
#

(Alternatively, it can also refer to a primitive value, AKA a number like int i = 0)

golden turret
#

thanks

pliant oyster
#

I never called them instances or stuff like that tho so I didnt know what he meant when he said that lmao

kind hatch
#

Ok, that clears some of my confusion up. 😛

pliant oyster
#

ok so

#

what about the variable

lavish hemlock
kind hatch
#

That's what I was trying to think of .-.

#

The variable is just used to access the internals of the object.

lavish hemlock
#

It's more correct to say the members of the object.

#

A member is any element that is nested within a class.

#

i.e. fields, methods, and inner classes.

#

Although, you don't need a variable to refer to an inner class, just an instance of an inner class.
Actually, you do if you're using a non-static inner class.

kind hatch
#

True

#

Anyways. Referring back to my original statement. What happens when you have instances inside of instances?

#

Potential for mismatch.

pliant oyster
#

idfk

kind hatch
#

So, every time you call Bukkit.createInventory() you have an instance.

#

It's unique.

pliant oyster
#

yes.

kind hatch
#

Now, every time you create an instance of CrateSystem, it is also unique.

pliant oyster
#

oh

kind hatch
#

Combining the two together will create something even more unique.

pliant oyster
#

so it opens a different inventory

kind hatch
#

Yes

pliant oyster
#

bcuz it's not the same cratesystem

#

as the other one

kind hatch
#

Yes!

pliant oyster
#

well how do I get it to be the same one lmfao

kind hatch
#

Just use one instance.

#

The common way to do this is with Dependency Injection.

pliant oyster
lavish hemlock
#

DI isn't very complicated

pliant oyster
#

Either way

lavish hemlock
#

The easiest way I can explain it is that

pliant oyster
#

it's not a bleb-friendly word

lavish hemlock
#

Instead of having your objects create instances of other classes

kind hatch
#

You create an instance in your main class, then create a getter for it. Use your main class to call that getter in other classes.

lavish hemlock
#

Here's a code example

kind hatch
#
public class ReallyCoolCommand implements CommandExecutor {
  
  // The instance of your main class.
  private MainClass plugin;

  // The constructor
  // Require the constructor to take whatever class you need as a pramenter.
  public ReallyCoolCommand(MainClass plugin) {
    this.plugin = plugin;
  }
  
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    plugin.whateverMethodsExistInThatClass();
  }
}
rough drift
#

eh

lavish hemlock
#

w/o DI

public class Example {
    public Example() {}

    public void announceExplosion() {
        // The problem here is that we might not want a Bomb, we might want a Nuke or Dynamite instead!
        Explosive exp = new Bomb();
        exp.explode();
        System.out.println("kaboom");
    }
}

w/ DI

public class Example {
    private final Explosive exp;

    // This will now allow us to use any kind of explosive.
    public Example(Explosive exp) {
        this.exp = exp;
    }

    public void announceExplosion() {
        exp.explode();
        System.out.println("kaboom");
    }
}

And this is how you would use the DI version:

new Example(new Bomb()).announceExplosion();
new Example(new Nuke()).announceExplosion();
rough drift
#

ig that works?

lavish hemlock
#

Basically, DI helps us to untether our code

quaint mantle
#

Does anyone know what plugin or how they configure in the anarchy so that people start transfer in a separate place and then fall into the overworld?

lavish hemlock
#

We depend upon the superclass (Explosive) rather than the concrete type/implementation (Bomb)

pliant oyster
lavish hemlock
kind hatch
#

Cause you are chaotic neutral.

lavish hemlock
#

Another example of DI is what Shadow mentioned, which is using DI over something like a Static Singleton.

lavish hemlock
lavish hemlock
#

Just, anything really

#

A service

kind hatch
#

That's the benefit of DI. It can be anything you need.

patent horizon
#

my friend is downloading intellij for the first time and is getting harassed by this window saying they have to get a jetbrains license

kind hatch
#

Use the community edition instead.

patent horizon
#

ah ok

pliant oyster
kind hatch
# patent horizon ah ok

Unless he has a school email, then the community edition will work just fine. It has like 92% of what the Ultimate Edition has.

lavish hemlock
#

Yeah but it's unpreferable. DI is the cleanest, most maintainable way to do it.

pliant oyster
#

DI is confusing me

#

idk what to do lmao

pliant oyster
lavish hemlock
#

Static singletons :p

pliant oyster
#

fuck sake

lavish hemlock
#

I'm gonna write a blog post on dependency injection just so I have something to copy-paste :p

kind hatch
#

That's the developer mindset baby!

#

LETS GO

pliant oyster
#

I need shadow masters version

hexed hatch
#

Dependency inject these nuts in your mouth

pliant oyster
#

shadow idk how to call the method without create a new instance of it

pliant oyster
sterile token
# pliant oyster what are the other ways lol

A simple DI example:


public class InjectedClass {

    public InjectedClass(App app) {
      // Do staff with app
    }
}

public class App {

  private InjectedClass injected;

  public static void main(String[] args) {
    this.injected = new InjectedClass(this);
  }  
  
  public InjectedClass getInjected() { return this.injected; }
}

#

Correct me if im wrong

lavish hemlock
#

No that would just be a getter

#

For it to be DI, you'd have to pass InjectedClass to something else

sterile token
#

Oh ok

#

That maow its correct?

kind hatch
#

It's just an example though.

sterile token
simple anvil
lavish hemlock
lavish hemlock
kind hatch
simple anvil
#

NMS?

lavish hemlock
#

net.minecraft.server

#

Internal Mojang code

simple anvil
#

its a head. so the player would not join

#

so what should i use?

kind hatch
#

It also depends on what value you are taking from that link. If it's the mojang link, use GameProfile, if it's the base64 value, use NMS.

simple anvil
#

im not taking any valuse from the link

sterile token
#

What are you doing?

simple anvil
#

`

#

`

#
/give @p minecraft:player_head{display:{Name:"{\"text\":\"Stack of Newspaper\"}"},SkullOwner:{Id:[I;-963021313,-1681963191,-1745649695,-970650732],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmQ1YjU4ZDZlN2Q0Y2Q5ODdkMDgxYjkxZWZlMDllZTBkMjA3OGYwZGI0M2Y1MGQwYTZjZjNiMzI3NzBhZWE0ZiJ9fX0="}]}}} 1
#

this is the command to get the head

#

it need a command block

sterile token
#

You can do it via command too

simple anvil
#

this is a command block

sterile token
#

just exeucte __ /give @p minecraft:player_head{display:{Name:"{"text":"Stack of Newspaper"}"},SkullOwner:{Id:[I;-963021313,-1681963191,-1745649695,-970650732],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmQ1YjU4ZDZlN2Q0Y2Q5ODdkMDgxYjkxZWZlMDllZTBkMjA3OGYwZGI0M2Y1MGQwYTZjZjNiMzI3NzBhZWE0ZiJ9fX0="}]}}} 1__ directly on game...

simple anvil
#

i want it so. if a player places a player head on a diamond block it changes to the newpaper head

#

how would i do thjat

sterile token
#

newpaper head? what that

simple anvil
#

newspapter head

kind hatch
#

You need to apply the texture to the block when they place it down.

simple anvil
sterile token
#

?jd

kind hatch
#

Listen for the BlockPlaceEvent, create the player head with the custom texture, and then update the blockstate.

simple anvil
#

create the player head with the custom texture
that is what i dont know

simple anvil
#

yea, i know how to make a player head

sterile token
#

So??

simple anvil
#

but i dont know how to set a texture

sterile token
#

I dont udnerstand you lmao

simple anvil
#

or update the block data

sterile token
#

That its from the documentations

#

You cannot have everything served on the table. You have most of the time to read the docs

simple anvil
#

public static final Material PLAYER_HEAD
BlockData: Rotatable

#

im still lost

#

Deprecated.
all usage of MaterialData is deprecated and subject to removal. Use BlockData.

#

but if the only block data is rotation

#

then how do i do it

young knoll
#

Use the block state

simple anvil
#

ok

#

thanks

golden turret
#

how can i set the break stage of a block?

young knoll
#

It’s client side

#

But there’s a method for it in Player

golden turret
#

where

pliant oyster
young knoll
golden turret
#

thansk!

#

will i need to send it each tick?

#

because the player can be far from the block

sterile token
pliant oyster
#

ok so I'm trying to call a method from a different class without creating a new instance of it

#

the thing shadow told me idk how to do

sterile token
#

Send your classes on ?paste please

kind hatch
#

Make the constructor take an instance of whatever class you need as it's parameter.

sterile token
#

?paste

undone axleBOT
pliant oyster
sterile token
pliant oyster
#

wait

kind hatch
sterile token
#

Like this you have to do it


public class InjectedClass {

    public InjectedClass(App app) {
      // Do staff with app
    }
}

public class App {

  private InjectedClass injected;

  public static void main(String[] args) {
    this.injected = new InjectedClass(this);
  }  
  
  public InjectedClass getInjected() { return this.injected; }
}

sterile token
#

Ble look at my example

kind hatch
pliant oyster
sterile token
#

I dont think you can pass constructors params without creating a new instance?

pliant oyster
#

thats the thing

kind hatch
#

You can

pliant oyster
#

I need to do that without creating a new instance

sterile token
kind hatch
#

Yes

#

The point of the parameter is to tell the class what it needs to work.

sterile token
#

Because you cannot declare static constructor

kind hatch
#

If you already have an instance somewhere, pass it through

golden turret
sterile token
#

The main problem is that i cannot help if i dont see his code. I dont understand what he is doing

golden turret
#

1 pitch = 16 blocks, right?

eternal oxide
#

You can only use teh sendBlockDamage on one block at a time

pliant oyster
kind hatch
#

What's it asking for?

pliant oyster
#

it says I need crateSystem

golden turret
eternal oxide
#

You would have to handle packets yourself

pliant oyster
#

so now I create a variable of CrateSystem?

golden turret
#

np then

kind hatch
tender shard
pliant oyster
trail pilot
#

instance

kind hatch
pliant oyster
#

alr

unreal quartz
tender shard
trail pilot
#

i wanna do something crazy but i dont know what😭

#
  • i lost my nitro
tender shard
kind hatch
# pliant oyster so I have to create a new instance?

I think we need to cover the basics again.

// Declaration of an object.
// The object is null at this point.
private Object obj; //This is an example. This object can literally be anything.

// Object instantiation.
// At this point, the object is no longer null.
obj = new Object();
```The name you give the object is your **reference** to that object. It also acts as your reference to it's specific instance.
So when you call obj.whateverMethod(), you are accessing a method within the object.

Now, what if you need multiple objects? Java allows you to do that. You just need to create a new instance with a different name.
```java
Object obj1 = new Object();
Object obj2 = new Object();

Now, you have two separate instances of the same class. What you do with each one now is up to you. Whatever you change in obj1 with it's internal methods will not affect obj2.

Another neat perk of java is the ability to pass object instances into methods.

So if you have a method like this:

public void myCustomMethod(Object object, int value) {
  object.whateverMethod(value);
}

You would call the method and pass in your instance that you created earlier.

myCustomMethod(obj1, 12) //The number I chose is arbitrary.
pliant oyster
#

what do I put inside the parameters tho bcuz I have to but a cratesystem in there and I cant do that without creating a new instance of it

young vine
kind hatch
tender shard
kind hatch
pliant oyster
kind hatch
pliant oyster
shadow night
#

Is there something to register permissions?

kind hatch
quaint mantle
#

registerPermission?

pliant oyster
#

I didn't expect it to be this complicated to just use a method without creating an instance of it

kind hatch
#

Well, therein lies the problem. You don't actually know java. :3

pliant oyster
#

Lmao I don't need to fully know it

shadow night
pliant oyster
#

to do stuff like this

kind hatch
#

The basics cover things like this.

quaint mantle
#

?learnjava

undone axleBOT
young knoll
#

You can define custom perms in plugin.yml

pliant oyster
#

I'm like one of those ppl who learn by spoonfeeding

young knoll
#

And the check them anywhere with gasPermission

kind hatch
pliant oyster
#

yes

#

bcuz I understand how it works when I get the answer

#

ofc I can learn java and use my time on that but it would take much longer for me to learn

kind hatch
#

But there are multiple ways to achieve the same result when it comes to programming. How will you differentiate between them if you don't actually understand the concepts behind what you are writing?

pliant oyster
#

I only write stuff that I understand

kind hatch
#

You've demonstrated that you don't actually know the terminology though. I've been trying to explain to you that the issue you are having doesn't require a complicated fix. However, I'm also using some of the basic jargon. Don't you think it would be far more beneficial for you to at least learn that before just jumping straight in?

pliant oyster
#

No

wooden fable
#

Is there any Packet for setting the player's pose? (Stop crawling/swimming)

pliant oyster
#

It will take much longer to learn the entire language it self

#

I would have to use something once and then I learn how to do it

#

Idk how to create getters and setters bcuz I never did it before

kind hatch
#

I'm not saying you need to learn the entire language. You just need to learn the basics.

#

No one here knows the entire language.

#

Not to mention that it's constantly changing.

pliant oyster
#

I would have to use it once to learn how to do it

simple anvil
#

how to i apply a texture onto a player head

mortal hare
#

why havent i found this before

#

perfect hashing of two integers with no collisions

#

so cool!

fossil lily
#

Am I doing anything wrong here? Im just trying to get discord-token, but when I change the config it still gets the old token

mortal hare
#

you need to save the config

tender shard
kind hatch
#

You need to reload the config if you make changes manually.

mortal hare
#

if you're changing it inside code

#

or reload it inside the code if the changes were made externally

fossil lily
#

Can I just add reloadConfig at the beginning?

tender shard
fossil lily
#

k

#

thanks

tender shard
#

but normally you want to have a reload command

mortal hare
#

that's why commands like /<command> reload exist

#

just to trigger the reload of the configuration files and other thingies

tender shard
mortal hare
#

is there any perfect hash method of hashing a three int values

tender shard
mortal hare
#

hash which has no collisions

quaint mantle
#

How can I get the text from the anvil that I entered?

fossil lily
#

It still doesnt work with configReload :(

mortal hare
#

this does perfectly hash two integers

#

into unique one

#

but i need to hash three

tender shard
#

the first answer puts three ints between 0.255 into one int

mortal hare
#

thing is i have one number which could reach int limit

#

and i don't know

tender shard
#

if your numbers are larger, you can probably do the same thing with longs

#

what's the largest number you'd have to store?

mortal hare
#

i thought i could do some arithmetic like a * 100 + b * 10 + c but i don't know the limits of c

#

that's the problem

tender shard
#

well are they integers?

mortal hare
#

yes

#

its 32 bit int limit

tender shard
#

an int is 4 bytes, a long has 8 bytes so that'd only work for 2 ints

mortal hare
#

but that wouldnt work

tender shard
#

can't you just use a string to represent them

mortal hare
#

and you would need to use longs

quaint mantle
#

How can I get the text from the anvil that I entered?

tender shard
#

String.format("%d,%d,%d",a,b,c); lmao

mortal hare
#

i don't care if they're reversible or not

tender shard
mortal hare
#

im preparing for an exam, and its in c++, you can't use STD libraries there so i need to design how to do this as fast as i can

#

i have bunch of values that are tied together, map would be great in this case

tender shard
#

2 or 4 byte ints?

#

if it's 2 bytes, they'd fit into a long

little panther
#

hey, im new and trying to get into spigot coding. Is there any way for me to figure out where a flying entity hits the ground?

mortal hare
#

lemme try bitshifting

tender shard
mortal hare
little panther
tender shard
# mortal hare lemme try bitshifting

as said, if you have 2 byte ints, it'll fit into a double with bitshifting. if it's 4 bytes, you'll have to use a byte array or sth but obviously that won't reuslt in "a number"

tender shard
#

what do you need it for?

little panther
#

was thinking about that i could check when it stops moving on the y-axis if that is possible

tender shard
#

pig.isOnGround()

little panther
tender shard
#

I thought you had a pig flying through the world and want to know the location where it will eventually touch the ground like 20 seconds later or sth lol

mortal hare
#

but that would involve more than that probs

little panther
mortal hare
tender shard
#

but that won't work when a pig hits a wall while still going upwards

#

does "air restistance" exist in mc? like does an object get slower automatically, or not?

mortal hare
#

i don't think so

tender shard
#

if it doesn't exist, then it's easy - just wait until either X or Z velocity changes and kaboom

mortal hare
#

well

#

maybe

#

because chickens

#

float slower

#

in air

tender shard
#

yeah but that's something else I guess 😄

mortal hare
#

probs

#

im bad at physics

tender shard
#

i'd just print out the velocity of my pigs in every tick and then see if there's a certain pattern in X or Z velocity decrease

#

or alternatively simply get the nearby blocks of the pig

#

if they are all air, it's proooobably still flying lol

tender shard
#

unless you're using an outdated MC version

#

Material.WARPED_FUNGUS works fine on 1.16+

mortal hare
#

that's probably why

tender shard
#

yeah the api-version must be at least 1.13

mortal hare
#

having no api-version inside the plugin.yml results in material type compatibility mode for older versions of minecraft (specifically for supporting older plugins)

patent horizon
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>remapped-mojang</scope>
        </dependency>```
tender shard
kind hatch
#

scope should be classifier

mortal hare
#

that's pom.xml

tender shard
kind hatch
#

no?

tender shard
#

oh yeah

#

that's what you mean

#

I thought you said he should do <scope>classifier lol

#

yeah the scope should be "provided"

kind hatch
#

^

patent horizon
tender shard
#

and remapped-mojang belon gs into <classifier>

tender shard
little panther
patent horizon
#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
        </dependency>```
tender shard
patent horizon
#

i have

tender shard
#

you haven't run it to get the remapped jar

#

run the command from the blog post

#

(replacing 1.18.2 with 1.18.1)

little panther
young knoll
#

Delay the check from starting for a tick

sacred mountain
#

whats the correct way of getting maven nms

#

ive been told my way is illegal

young knoll
#

Wat

quiet ice
#

maven as in maven?

sacred mountain
#

mb

quiet ice
#

Or maven as in spigot?

sacred mountain
#

missed a word

#

read it again

tender shard
#

can a ConfigurationSection be cast to a Map<String,Object> somehow?

#

simply casting it throws a CastExc

quiet ice
#

The only "legal" way of obtaining it is via mavenLocal

sacred mountain
quiet ice
#

If you obtain nms from a repository it is probably not legal

tender shard
quiet ice
sacred mountain
#

oh woops

young knoll
#

There actually is a repo for it too

#

Very sus

sacred mountain
#

is this

patent horizon
#

the code from this dudes solution doesn't seem to be valid anymore. would anyone know the work around

patent horizon
#

yes

tender shard
#

what version exactly?

patent horizon
#

it works now

#

1.18.1

tender shard
#

you already got it?

patent horizon
#

yup

tender shard
#

kk

pliant oyster
#

mfnalex can u help me with something, just don't ?learnjava me lmfao

young knoll
#

Temptations rising

winged anvil
#

?lj

#

?learnjava

undone axleBOT
winged anvil
#

ah

pliant oyster
winged anvil
#

lmao

#

dont L me you just learned what an instance was today

sacred mountain
#

people bullied me until i switched to java 17

winged anvil
#

@pliant oyster what you need help with

pliant oyster
#

ur just gonna ?learnjava me lmfao

patent horizon
tender shard
#
package de.jeff_media.jefflib.internal.nms.v1_18_R1;

import lombok.experimental.UtilityClass;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.Packet;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;

@UtilityClass
class NMSPacketUtils {

    private static Connection getPlayerConnection(final Player player) {
        return ((CraftPlayer)player).getHandle().connection.connection;
    }

    public static void sendPacket(final Player player, final Object packet) {
        if(!(packet instanceof Packet<?>)) {
            throw new IllegalArgumentException(packet + " is not instanceof " + Packet.class.getName());
        }
        getPlayerConnection(player).send((Packet<?>) packet);
    }

#

this is what I'm using to send packets to a player, so yeah instead of playerConnection, call connection.connection

patent horizon
#

im just trying to get the player's client version

winged anvil
pliant oyster
#

well do u still jet lj'ed?

winged anvil
#

still hella stuff i dont know either so

#

i probably would but i dont do much with spigot anymore so

pliant oyster
#

ye then u prob will get lj'ed while trying to help me as well xD

winged anvil
#

ask your question

pliant oyster
#

nrn

winged anvil
#

just dm me

#

the question

young knoll
#

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

young knoll
#

It’s not ?learnjava :p

ivory sleet
patent horizon
#

java

#

kotlin does things with my feelings

pliant oyster
#

?paste

undone axleBOT
tender shard
#

oh my god I am literally so stupid

#
    public static Map<String,Object> asMap(final @NotNull ConfigurationSection section) {
        final Map<String,Object> map = new HashMap<>();
        section.getKeys(false).forEach(key -> {
            map.put(key,section.get("key"));
        });
        return map;
    }
#

find the error

#

lmao

ivory sleet
#

okay

#

not the null obv

#

but ye

young knoll
#

Well yeah, you are String.valueOfing the components

tender shard
#

at least not in the Connection object

ivory sleet
#

oh well if you use mojmaps

#

idk what it might be called else wise

tender shard
#

I'm using remapped

young knoll
#

new ComponentBuilder().append(blah).append(blah)

tender shard
#

otherwise it also wouldn't be called "connection.connection" but "d.a"

#

or similaaaah