#help-development

1 messages · Page 2006 of 1

waxen plinth
#

Oh wait

#

world.getEntitiesByClass(Item.class).stream().filter(i -> i.getItemStack().getType() == Material.SOME_TYPE).forEach(Item::remove)

#

Nice

jagged thicket
#

i have 16g Ram r5 3500 x and 2060 nd running 1 server and 3 mc is hard

waxen plinth
#

I didn't realize getEntitiesByClass existed

waxen plinth
#

Yes

#
for (ItemStack item : world.getEntitiesByClass(Item.class)) {
  if (item.getItemStack().getType() == Material.SOME_TYPE) {
    item.remove();
  }
}```
#

Simpler but longer

tall dragon
next fox
#

does anyone know how temporary players and sockets work using protocollib?

quaint mantle
#

I think I accidentally just deleted everything

#

Hold the fuck on

#

nvm it just bugged out

#

thank god

tall dragon
#

💀

fossil mural
#

How would i make it so all the enderchest have the open animation at all times? Have been on it a while and it is driving me crazy.

tall dragon
#

probably gonna have to use packets for that iirc

hybrid spoke
fossil mural
tardy delta
#

i see no god here

#

_<

hybrid spoke
tardy delta
#

oh 👉👈🤌

quaint mantle
#

okay well NOW its gone

#

horray

fickle frost
sterile token
#

Who need help? - Cuz i see a tag

lone remnant
#

ItemStack is deprecated. what to use instead?

eternal night
#

wat

#

ItemStack is definitely not deprecated

quaint mantle
#

It totally is

#

1.18+

fickle frost
#

Ouch

#

inb4 Player is deprecated

sterile token
#

ItemStack cannot be deprecated

eternal night
#

idk m8

#

like, maybe I went blind

sterile token
eternal night
#

but I cannot find a deprecation annotation or notice there

sterile token
#

Prob its your IDE

eternal night
#

Yea idk, whatever you are doing. ItemStack in the spigot API is not deprecated

sterile token
#

I rember that when using Eclipse i was always having warnings, etc. And them when i changed to Intellij Idea i started to enjoy more the pugin development

lone remnant
#

well, i might have seen something wrong, but thats what intellij decompiled from the maven sources for me ```java
/** @deprecated */
public ItemStack(@NotNull Material type, int amount, short damage) {
this(type, amount, damage, (Byte)null);
}

/** @deprecated */
@Deprecated
public ItemStack(@NotNull Material type, int amount, short damage, @Nullable Byte data) {
    this.type = Material.AIR;
    this.amount = 0;
    this.data = null;
    Validate.notNull(type, "Material cannot be null");
    this.type = type;
    this.amount = amount;
    if (damage != 0) {
        this.setDurability(damage);
    }

    if (data != null) {
        this.createData(data);
    }

}```
sterile token
eternal night
#

those are the constructors

#

not the entire class

#

the concept of damage is no longer applicable

#

this has been this way for a while

sterile token
lone remnant
#

ok

#

well, then why the heck did a tutorial that i had once set the damage and then 10 lines further not? ||(short) 15||

eternal night
#

because the tutorial is trash

sterile token
#

If it no trash, prob the tutorial its old

#

👍

eternal night
#

Well, an outdated tutorial either kept up to date or is useless

#

not all items have the concept of durability

sterile token
#

I didnt find any tutorial

eternal night
#

and what perms on bungee o.O ?

sterile token
#

Im done from Spigot side. Now i need bungee side

eternal night
#

I mean, on bungee you can only handle bungeecord permissions

sterile token
sterile token
#

Oh you do it via event?

misty current
#

can I replace a broken block in a blockbreakevent with another block? i was cancelling the event and setting the block, but that causes durability damage to not be taken for the tool

sterile token
misty current
#

or can I simulate tool damaging by calling a method or similar

waxen plinth
#

You could just wait a tick and then set the block to something else rather than cancelling the event

sterile token
misty current
sterile token
eternal night
#

like you can use the event

#

but the second method linked is probably preferred 😅

sterile token
#

kill05, try setting the block air and them replace it with what ever you want

waxen plinth
#

You really wouldn't be able to tell the difference

misty current
#

now that i think about it

fickle frost
#

You could try manually adjusting the damage of the player's tool.

misty current
#

what should i consider? unbreaking enchant and?

fickle frost
#

Ah, someone already suggested that.

misty current
#

unbreakable tag also i guess

#

anything im missing?

fickle frost
#

Pretty sure that's all, @misty current unless there's plugins adding custom enchants.

misty current
#

i guess i could call an itemdamageevent and see the outcome of it

#

or whatever the name is

fickle frost
#

That event wouldn't run if you cancel the blockbreakevent surely.

misty current
#

yes that's why i want to call it myself so if any plugin manipulates how much does an item get damaged, my plugin can adapt

fickle frost
#

Ah, you said call the event. Yep, sounds decent.

fickle frost
#

Don't forget to spawn block breaking particles!

lone remnant
misty current
sterile token
#

In doing my custom

#

Because i didnt find any plugin that allow me to have global groups, with bungeecord and spigot permissions at the same time

lone remnant
#

why bungeecord permissions though?

sterile token
#

Because we use bungee plugins

raw ibex
#

how to set a block on fire

quaint mantle
#

is getType deprecated in 1.18

raw ibex
#

no

quaint mantle
#
Enum<Material> itemType = event.getCurrentItem().getType(); //Method invocation 'getType' may produce 'NullPointerException' 
sterile token
quaint mantle
#

it states that the method will produce that

#

HOWEVER

#

If I fix it, or dont, it never works

raw ibex
#

what makes you think it's deprecated?

#

does intellij think it's deprecated?

sterile token
quaint mantle
#

The fact that now that ive migrated my plugin to 1.18, and my ClickEvent isnt working

lavish hemlock
#

That's just IDEA telling you that the return type is nullable

#

It's not deprecated

quaint mantle
#

But, clickDetection isnt working now

#
public class ClickEvent implements Listener {
    @EventHandler
    public void clickEvent(InventoryClickEvent event){
        Inventory inv = event.getClickedInventory();
        if(inv != null){
            String Title = inv.getType().getDefaultTitle();
            Player p = (Player) event.getWhoClicked();

            if(Title.equalsIgnoreCase(ChatColor.DARK_RED + "Challenges")) {
                Enum<Material> itemType = event.getCurrentItem().getType();
#

Did i do sometihng wrong here or

lavish hemlock
#

Also, you don't need to do Enum<Material> :p

raw ibex
#

Just do Material

lavish hemlock
#

Use Material

#

Yeah

tall dragon
raw ibex
#

true

lavish hemlock
#

Also you haven't given us your full code

sterile token
raw ibex
#

how to set a block on fire (like tnt)

sterile token
tall dragon
#

pretty sure there is a material for fire

quaint mantle
#

I need to send full code?

#

Uhh ok

tall dragon
raw ibex
#

ok

#

wait

quaint mantle
#
public class ClickEvent implements Listener {
    @EventHandler
    public void clickEvent(InventoryClickEvent event){
        Inventory inv = event.getClickedInventory();
        if(inv != null){
            String Title = inv.getType().getDefaultTitle();
            Player p = (Player) event.getWhoClicked();

            if(Title.equalsIgnoreCase(ChatColor.DARK_RED + "Challenges")) {
                Material itemType = event.getCurrentItem().getType();

                if(itemType == Material.POTION) {
                    if (EmeraldsPlugin.jp.getConfig().getBoolean("Challenges.BlockDamage")) {
                        EmeraldsPlugin.jp.getConfig().set("Challenges.BlockDamage", false);
                        PluginFuncs.sendGlobalMessage(ChatColor.GREEN + "The challenge, Block Damage, has ended.");
                    } else {
                        EmeraldsPlugin.jp.getConfig().set("Challenges.BlockDamage", true);
                        PluginFuncs.sendGlobalMessage(ChatColor.RED + "The challenge, Block Damage, has started!");
                    }
                    me.emerald.emeraldsplugin.ui.Challenges.getUi(p);
                }else if(itemType == Material.ROTTEN_FLESH) {
                    if (EmeraldsPlugin.jp.getConfig().getBoolean("Challenges.Hunger")) {
                        EmeraldsPlugin.jp.getConfig().set("Challenges.Hunger", false);
                        PluginFuncs.sendGlobalMessage(ChatColor.GREEN + "The challenge, Hunger, has ended.");
                    } else {
                        EmeraldsPlugin.jp.getConfig().set("Challenges.Hunger", true);
                        PluginFuncs.sendGlobalMessage(ChatColor.RED + "The challenge, Hunger, has started!");
                    }
                }
                me.emerald.emeraldsplugin.ui.Challenges.getUi(p);
            }
        }

        event.setCancelled(true);
    }

#

There

raw ibex
#

?paste

undone axleBOT
snow crow
#

Hello]

tall dragon
#

hello

snow crow
#

i need to know the registry changes in 1.18.2 idk where to check

next stratus
sterile token
quaint mantle
#

*sorry

sterile token
#

No problem just something to keep hen programming

lunar flax
quaint mantle
#

Oh, before I forget

#
getServer().getPluginManager().registerEvents(new ClickEvent(), this);
#

This is what is actually getting the event to register

lunar flax
next stratus
#

Schematic Iteration Problem

tall dragon
lunar flax
#

BukkitWorld weWorld = new BukkitWorld(p.getWorld());

raw ibex
#

how doi set block

tall dragon
tall dragon
raw ibex
#

it doesn't work

#

wait it works now

quaint mantle
#

Okay so my UI is working now.

#

... Except its not at the same time.

raw ibex
#

lol

tall dragon
next stratus
#

Orla, your class naming scares me

#

gameEvents

raw ibex
raw ibex
#

idk how to change it now

next stratus
#

right click and rename

lunar flax
tall dragon
raw ibex
#

i can't see where the rename button is lol

next stratus
#

refractor?

raw ibex
#

oh yea

tall dragon
raw ibex
#

thansk

#

@next stratus thanks for reminding lmao

next stratus
#

mhm

raw ibex
#

better?

lavish hemlock
#

Refactor is one of the most useful tools in IDEA

#

use it wisely

next stratus
#

looks better

#

I swear I'm dumb and it makes me sad

tall dragon
lavish hemlock
#

I dunno what that is

tall dragon
#

what!?

#

auto formatting, hello!?

sterile token
raw ibex
#

it's formatting

#

lmao

lavish hemlock
#

My formatting is already perfect, bruv

raw ibex
#

even i know that

tall dragon
#

cap

next stratus
#

I've been trying to work out where I'm going wrong with this code and I can't work out how to fix it but Idk where I'm going wrong 😔

raw ibex
#

send it

tall dragon
#

ctrl + alt + o pretty usefull too

next stratus
tall dragon
#

removes unused imports

raw ibex
#

alt f4 pretty useful as well

lavish hemlock
#

My imports are already perf- nah I'm kidding

next stratus
#

It makes me honestly angry that I get thrown by these stupid fucking things

lavish hemlock
raw ibex
#

it's sick

quaint mantle
#

Hey.. so how would I get the title of getClickedInventory?

#

its suppost to return Challanges

#

but returns Chest or CHEST

next stratus
#

I can learn the worldedit api ok-ish but i can't work out how to add these block vector 3 locations later on

misty current
#

can I get an instance of an item in a player's inventory so if I modify it it changes in the player inventory too? looking at the implementation of PlayerInventory, getting items returns a clone of the original itemstack

quaint mantle
#

Ive tried:

event.getClickedInventory().getType.name();
event.getClickedInventory().getType.getDefaultTitle();
#

None work however

#

Is there a way to actually get the name of the inventory? The name is Challenges.

misty current
#

you need to get the inventory view of the player

#

and get the title from that

quaint mantle
#

Wym?

#

How would I do that?

sterile token
raw ibex
#

*patient

next stratus
#

Sorry!

tall dragon
next stratus
#

I'm just going crazy 🥲

sterile token
torn badge
#

Can you show the name of a custom enchantment on the item?

torn badge
#

Or is that entirely client sided?

misty current
sterile token
misty current
#

gimme a sec jeez i had forgot the name of the method

misty current
#

probably it would be better to check for the actual object

quaint mantle
#

@misty current YES IT WORKS

#

THANK YOU SO MUCH

misty current
#

np

sterile token
#

Its not allowed

#

I rember i get muted for 1h for tag people

lavish hemlock
#

I'm pretty sure it's not disallowed

#

There's a chance you were just overdoing it

kind hatch
#

Who are you tagging?

quaint mantle
#

?

#

also, final question: How would I give a permisson to a person, and do permissions save?

kind hatch
#

Just use a permission plugin for that. (LuckPerms is the standard) It’s not worth the hassle to set permissions manually.

quaint mantle
ivory sleet
#

I mean LuckPerms has a good api in case you wanna have a good permission "library"

lavish hemlock
#

Just use Vault lol

kind hatch
# quaint mantle I prefer making my own personally

I get that, I really do, but if you don’t know how to register everything properly, it can cause big issues. Especially if you are creating a plugin for the general public. I’d at the very least look into the API LuckPerms provides as you can do a lot with it.

quaint mantle
#

How would I protect an item from being renamed to be used for malious purposes?

#

My thing is based on itemName

#

When right clicking to use

#

So how would I make it so that even if they renamed an item

#

They cant use it the same

chrome beacon
#

Don't use the name to detect your item

kind hatch
#

Use the PDC instead.

lunar flax
#

Also, world exists

#

apos1.getWorld().getName() returns world name aka world

tall dragon
#

then, idk. dont know much abt worldedit api

#

show

kind hatch
#

Share your code

#

I’m pretty sure the #save method requires a File object, not a String.

lavish hemlock
#

It wouldn't compile if that were the case

tall dragon
#

maybe it takes a file path too

#

tbh i would just use the #save method that takes a File

elfin steppe
#

If i have an armorstand class that runs a gui class (w events inside of it), am i still supposed to register the gui class in my main class?

tall dragon
#

that made zero sense

#

oh wasnt responding to you

#

oh, alright good

lone remnant
#

how do i need to do that now?

chrome beacon
#

Same thing just use your NamespacedKey

lone remnant
#

how do i get that?

chrome beacon
#

You can just make one

lone remnant
#

how?

chrome beacon
#

?jd-s

undone axleBOT
lunar flax
chrome beacon
lone remnant
#

new NamespacedKey(this, "whatever");?

elfin steppe
#

If i have an armorstand class that runs a gui class (w events inside of it) on right click, am i still supposed to register the gui class events in my main class?

lavish hemlock
#

It's because you're not verified

lone remnant
#

ok

#

for what do you need the ItemMeta.addEnchant b value?

brave sparrow
#

that’s whether it’s unsafe or not

#

Meaning can it go above the vanilla maximum and can it be applied to stuff it normally can’t

quaint mantle
#

Are there any tutorials on how to make a key crates?

lone remnant
#

true or false

deft helm
lone remnant
#

how do i get the item someone just clicked from InventoryClickEvent? tried to use getCurrentItem() but that returns null

lone remnant
lost matrix
torn shuttle
#

what's the fastest way to see if a plugin is running on bungeecord?

lone remnant
lost matrix
lone remnant
#

ok

lost matrix
torn shuttle
#

I tried isPluginEnabled, let me try that

#

It's made marginally harder by the fact that i don't know exactly what Geyser would even be called

sage dragon
#

Hey \o

I have no idea how hex colors work, but I'd like to iterate through most of them to achieve some color changing leather armor.

Does anyone have a tip for me?

prisma needle
#

NMS with gradle

tardy delta
#

i know how to translate them when they are in the format #ffffff

lost matrix
sage dragon
lone remnant
#

could you theoretically extend the piston push limit with a plugin?

#

without to much coding of moving the blocks manually of course

quiet ice
lost matrix
#

Just incrementing this int by 5 will look a bit weird. If you want to have smooth translations then you should
represent rgb as a 3D vector [r, g, b] and slowly change pitch, yaw (and length)

wooden fable
lost matrix
wooden fable
#

Ok ty

dire salmon
#

smile go particle thing plis?

waxen plinth
#

what

lost matrix
#

Could also be what you are searching for

waxen plinth
#

That could be really janky though

#

If they have sprint toggled on clientside it would just be choppy as hell wouldn't it

lone remnant
#

if i have a Custom Enchantment and then create a new instance, is that another instance than the instance created in onEnable when registering it?

waxen plinth
#

Huh

#

You should only create one instance

lost matrix
waxen plinth
#

It should be a singleton

lost matrix
#

^

waxen plinth
#

But doing it by extending the Enchantment class is clunky to say the least

#

Cannot recommend

lone remnant
#

yeah, but when i need it anywhere else, it is easier than getting it again from the main class

waxen plinth
#

No it's not lol

#

Just make it a singleton with a static getter or something if you must

sage patio
#

can i use switch case for item stacks? i mean insted of a long list of if else for checking item stacks, how can i use switch case ?

waxen plinth
#

No, you can't use a switch for that

lost matrix
waxen plinth
#

But you really shouldn't need to

quiet ice
#

You could do an instanceof but it is just a waste of memory imo

#

Try to minimise the amount of allocations

#

So yeah, you should use singletons

elfin steppe
#

Can someone tell me what i'm supposed to put in there

lost matrix
lone remnant
elfin steppe
#

yeah so how do i

quiet ice
#

Jesus, you coded that plugin, you should know what you are doing

elfin steppe
#

cos i cant j type player p or p or whatever

quiet ice
#

You should refractor your listener

#

I am almost certain that you should not pass a player there

sage patio
lone remnant
elfin steppe
#

my class code is right

#

alr

quiet ice
#

It may be right - but right now you have a player tied to an event which does not sound correct

elfin steppe
#

think its an inv tho

quiet ice
#

Especially because this appears to be the onEnable method

elfin steppe
#

its made to open an inv on armor stand right click

quiet ice
#

Then you shouldn't register you event listener in the onEnable method

solid cedar
#

just ping if answer to me

quiet ice
#

But it is more conventional to generalise event listeners to a point of it not being tied to a specific object

elfin steppe
#

?help

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

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

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

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

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

**__ModLog:__**

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

**__Permissions:__**

permissions Command permission management tools.

elfin steppe
#

whats the discord command to open like a

#

scratch file

quiet ice
#

?paste ?

undone axleBOT
elfin steppe
#

ty

#

thats the SpawnGUI class

#

i was doubting already if i had to register it or not in my main

#

But the events are j not working

#

the onlick event & dragevent

#

oh i got the same method name twice dumb

quiet ice
#

What are the callers of the constructor of your SpawnGUI class?

elfin steppe
#

Sorry, this is kinda new for me so i don't really know

#

Inventories etc r new for me

tardy delta
quiet ice
#

Eclipse or IntelliJ?

elfin steppe
#

Thats why i'm working w them

#

IntelliJ

quiet ice
#

Welp, then I do not know the shortcut to show the caller hierarchy

#

Anyways, my suggestion is to remove line 27 and to change line 23 to public SpawnGUI() {

#

If you have any compiler errors that pop up, let me know

elfin steppe
#

But then

#

It's not going to open the inventory

quiet ice
#

Shut, do as I say

elfin steppe
#

sure

#

as i said

#

its not opening

#

the inv

#

i tried

quiet ice
#

You can still call openInventory afterwards, but for that I need to see what compiler errors the change causes

elfin steppe
#

theres no errors

tender shard
#

does anyone know any shorter method of doing this?

        File file = new File(fileName);
        if(!file.exists()) {
            try (
                    InputStream inputStream = DiscordSpigotUpdateBot.class.getResourceAsStream("/" + fileName);
                    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                    BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
                ) {
                String line;
                while((line = bufferedReader.readLine()) != null) {
                    bufferedWriter.write(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
quiet ice
tender shard
elfin steppe
quiet ice
#

Call your openInventory method

lavish hemlock
lost matrix
#

Yes. Several.

elfin steppe
tender shard
#

it's a try with resource block

#

it auto closes them

quiet ice
lavish hemlock
#

Oh wait

#

That is terrible formatting lmao

quiet ice
#

Call the openInventory method where you want to open your inventory

#

Just not in the onEnable method and the constructor...

tender shard
eternal night
#

legacy people

quiet ice
#

Files#copy is J8

quiet ice
#

At least I think so...

tender shard
lavish hemlock
#

It is

tender shard
#

oh wait

#

lol

ivory sleet
#

Most of Files are since j7 iirc

eternal night
#

🙏

#

still, java 8 is depressing

lavish hemlock
#

90% of my projects are Java 8 lol

quiet ice
#

It is, and stupid android is holding us back

eternal night
digital haven
#

Maven Import Issue (Don't wanna interrupt convo)

tender shard
#

Files.copy is so weird

quiet ice
#

if it wasn't for android noone would use J8 ad there wouldn't be any libraries for J8

tender shard
#

it takes a CopyOption but that class doesn't have any public members

lavish hemlock
tender shard
#

I can never remember how the class is called

quiet ice
#

StandardCopyOptions

lavish hemlock
#

I don't like the module system

elfin steppe
#

How do i access an inv from another class in my current class

tender shard
#

I always try DefaultCopyOptions

quiet ice
#

You know that your IDE has a hotkey to show the class hierarchy?

undone axleBOT
lone remnant
quiet ice
eternal night
quiet ice
lavish hemlock
young knoll
#

That’s the spirit

lavish hemlock
#

Even when not using modules, you're still restricted by them

quiet ice
#

It doesn't use java anymore anyways

lost matrix
lavish hemlock
#

They went from DEX to ART iirc

elfin steppe
eternal night
#

The only time you are restricted by modules is if you fuck with jdk internals

lavish hemlock
#

Nowadays, they just recommend using Kotlin as the source lang since it better suits their API

quiet ice
eternal night
#

if you fuck with jdk internals you are doing something wrong

elfin steppe
eternal night
#

pretty often

lavish hemlock
#

There's a lot of features that JDK internals provide

quiet ice
#

In eclipse you can just press F3 on CopyOptions and it will show you the classes that implement copy options

lavish hemlock
#

e.g. the Javac Tree API, ConstantPool, CallerSensitive, etc.

lost matrix
quiet ice
#

not anymore

#

At least I think so? But who runs JREs?

lavish hemlock
lost matrix
#

"90% java 8"

eternal night
#

does the JRE bundle javac apis ??

lavish hemlock
#

JDK exclusive shit is JDK tools and APIs (Attach API, JVMTI, etc.)

lavish hemlock
#

With Oracle's pussy-ass public API, you can only do introspection

#

No modification

#

Problem is that, iirc, all JDK tool APIs are restricted by modules, even the public parts

tardy delta
#

does anyone knows what types of exceptions the exception handles catches?

#

the (t, e) ->

quiet ice
#

aby?

tardy delta
quiet ice
#

Except perhaps anything not instanceof Exception

quiet ice
lavish hemlock
#

\n

sterile token
#

LinkedList vs LinkedHashmap?

lost matrix
lavish hemlock
#

That

tardy delta
lavish hemlock
#

Those aren't comparable

sterile token
#

Now?

lavish hemlock
#

They're completely different data structures

sterile token
#

Arent Linked all the same thing?

lost matrix
quiet ice
tardy delta
#

oki

lone remnant
#

if i have a inventoryclickevent listener and check if that inventory is equal to another inventory, does it say its equal if the inventoryclickevent has removed or rearranged items in the inventory?

quiet ice
#

LinkedHashMap has almost the same runtime complexities as HashMap

sterile token
#

Oh Linked things are diff?

pliant oyster
#

I know this is a dumb question but how do u space messages out, like making them on different lines

quiet ice
#

LinkedList has almost the same runtime complexities as ArrayList

lavish hemlock
#

LinkedList is a doubly-linked list (dynamic array), LinkedHashMap is a map (dictionary) that retains insertion order

sterile token
pliant oyster
#

wait

#

what was the answer

sterile token
lost matrix
lavish hemlock
young knoll
#

Using a queue for queues?

#

Madness

lavish hemlock
#

afaik Queue is outdated or smthn

#

Deque is designed for both queues and stacks

sterile token
#

In conclusion Linked thing are diff?

lavish hemlock
#

Well, yeah

sterile token
#

Allright thanks

lost matrix
lavish hemlock
#

You can't fucking compare lists to maps

#

They're completely different

sterile token
#

I know but they have key Linked and i confuse them

lavish hemlock
#

Only similarity is that they're collection types (and even then, Map is not a Collection)

sterile token
#

😕

pliant oyster
quiet ice
young knoll
#

Java and JavaScript both have java in them

#

Do you confuse them?

lost matrix
tardy delta
#

thats car to carpet

sterile token
quiet ice
#

The only thing it has going for it is that it is easily resizeable

pliant oyster
young knoll
#

Yes

lost matrix
tender shard
tardy delta
#

many packets lol

quiet ice
#

Yes, that was what I meant

unreal quartz
lavish hemlock
quiet ice
lavish hemlock
#

Since most C programmers are on crack

tardy delta
#

oh

lavish hemlock
#

Otherwise, why would they be coding C?

sterile token
tender shard
#

you only realize how convenient the builtin config methods in spigot are when you only have plain SnakeYaml in a discord bot

lavish hemlock
#

This is why you just

#

don't use SnakeYAML

#

or YAML

quiet ice
#

why the hell did you use snakeyaml

lavish hemlock
#

Here's an easier solution:

#

TOML or JSON

pliant oyster
tender shard
quiet ice
#

just use org.json:json but not snakeyaml

lost matrix
#

Just throw everything into Gson or Jackson. Latter even supports yml

young knoll
#

Json configs 🤡

lavish hemlock
tender shard
unreal quartz
#

Here's an even easier solution:
Just hardcode it 🙂

eternal night
#

🙏

tender shard
#

awesome idea!

tardy delta
#

the hell is toml?

sterile token
#

For everything i use SnakeyYAML its not so difficult lmao

lavish hemlock
quiet ice
tender shard
#

[Something]
something = something

#

that's TOML

lavish hemlock
sterile token
tender shard
#

e.g. systemd files are toml

quiet ice
#

SimpleJSON is though afaik

lavish hemlock
#

Lies

lavish hemlock
lost matrix
#

u wanna start a fite?

young knoll
#

The best language is LUA

sterile token
sterile token
tardy delta
#

is this like json or something kek

quiet ice
tardy delta
lost matrix
sullen pendant
#

I cant use any bungee commands even though I have * perms on bungee, till yesterday I could

sterile token
#

haha

#

FiveM its GTA?

#

Or what

lavish hemlock
#

yes

sterile token
#

I have a friend that its develoer of FiveM

lavish hemlock
#

FiveM is modded GTA 5 multiplayer

sullen pendant
#

I mean I do have the perms set to true for my plugin as well

lavish hemlock
sullen pendant
#

Did a luckperms perm check as well

#

returns true

tardy delta
#

true

sterile token
#

I agree

#

php its the best shity things

#

Idk why the still mention to learn it

#

They should be taken out from the world

lost matrix
sullen pendant
#

I added setPermissionMessage("test") to the command but its still saying unknown command

#

bruh

sterile token
lavish hemlock
#

I am currently learning the actual worst language

#

x86_64

sterile token
lost matrix
lavish hemlock
#

Sorry but VB is not as bad as Assembly lol

sterile token
#

VB is better than C?

young knoll
#

Why doesn’t java have goto implemented

#

Smh my head

lavish hemlock
#

No I can understand it lol

lost matrix
lavish hemlock
#

I just understand that it's awful

golden turret
#

what happens to the client if i sent an uknown packet by him

sterile token
#

Visual Basic isnt before C?

#

Isnt it a new implemen t?

lavish hemlock
#

It's filled to the brim with terrible historic decisions

quiet ice
lavish hemlock
#

ARM would be easier to learn but I can't really run ARM

quiet ice
#

An goto statement complicates computing the stack table attribute by a lot

young knoll
#

Excuses

lost matrix
young knoll
#

Excuses!

quiet ice
#

Well, it'd be harder to track which locals may not be initialised and which are

lavish hemlock
#

Actually

sterile token
#

I would love to use C# for doing plugins

lavish hemlock
#

The JVM has a jsr instruction

#

Which is basically goto

sterile token
lavish hemlock
#

But

quiet ice
lavish hemlock
#

It no longer does anything

young knoll
#

goto is reserved but unusable

lost matrix
quiet ice
#

It was replaced with invokedynamic

young knoll
#

Which means I can't name my variables goto

#

Gosh

lavish hemlock
#

No

quiet ice
#

Goto is usable at a bytecode layer

unreal quartz
lavish hemlock
#

jsr was for finally blocks

golden turret
quiet ice
#

Ah

golden turret
#

using spigot and fabric

young knoll
#

Why use custom packets

lavish hemlock
#

invokedynamic just came out of nowhere lol

lost matrix
young knoll
#

Use that one packet mojang added for this purpose

quiet ice
#

Technically you can emulate goto statements with while (true) loops and break; and continue;

lavish hemlock
sterile token
lavish hemlock
#

They eventually made it so that finally blocks are now just inlined wherever they're used

young knoll
#

I mean

#

I do like C#

#

C+#

solid cedar
# tardy delta whats your sql statement?
                        .prepareStatement("SELECT * FROM es WHERE something=?");
                statement.setString(1, getConfig().getString("example"));
                ResultSet results = statement.executeQuery();
                results.next();```
quiet ice
#

I haven't figured out how to compile C# on my system yet, so I cannot comment on that yet

young knoll
#

It's C++ and C#

#

It's both memory managed and garbage collected

#

Don't question it

lost matrix
#

Maybe he is a linux only user

golden turret
solid cedar
#

Somebody help?

young knoll
#

You can easily communicate with client mods using Plugin messaging channels

sterile token
quaint mantle
#

How would I find a public function based on a string?

#

EX: String is named BasicKey, and im looking for public static ItemStack BasicKey

young knoll
#

Reflection

quaint mantle
#

k

young knoll
#

Imagine updating your plugin to support 1.18.2 and then not releasing it

#

smh

dire salmon
#

how do i check for players in the server?

sterile token
#

google common is included inside spigot jar?

lost matrix
lavish hemlock
sterile token
sterile token
quaint mantle
#

Should I send my code?

lavish hemlock
#

?learnjava

undone axleBOT
sterile token
solid cedar
quaint mantle
lost matrix
quaint mantle
#
public class Items {
    public static ItemStack BasicKey(){
        ItemStack item = new ItemStack(Material.TRIPWIRE, 1);
        ItemMeta iMeta = item.getItemMeta();
        iMeta.setDisplayName(ChatColor.GREEN + "Basic Key");
        iMeta.addEnchant(Enchantment.DURABILITY, 1, true);
        ArrayList<String> iLore = new ArrayList<>();
        iLore.add(ChatColor.GOLD + "A key! can open a basic crate.");
        iMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);

        return item;
    }
}

Im trying to find "BasicKey" based on a command argument.

#

Thats the issue.

sterile token
#

But why use reflections when you are just starting?

young knoll
#

I mean

quaint mantle
young knoll
#

Generally you just avoid them altogether

lavish hemlock
#

Reflection is quite slow

young knoll
#

Use a map

quaint mantle
#

Ah

young knoll
#

Or whatever

lavish hemlock
#

And

#

Honestly pretty verbose

lost matrix
lavish hemlock
#

It's only really for when you need to do something dynamically

young knoll
#

ur verbose

lavish hemlock
tardy delta
#

you never add lore

sterile token
lavish hemlock
#

Yes

sterile token
#

Im looking my spigot maven dependencies and doesnt contain Guava

#

Contains google common

lavish hemlock
#

Because it's a transitive dependency

sterile token
#

transitive?

lavish hemlock
#

It's a dependency of a dependency

sterile token
#

oH

#

Thanks

#

Im really dumb

#

....

somber hull
#

Yea lol

sterile token
lavish hemlock
#

HyperLink

#

You are a worse programmer than him

#

Stop lying to yourself

somber hull
#

What

young knoll
#

Nerd fight!

somber hull
#

No I meant

lost matrix
somber hull
wet breach
somber hull
#

My b

lavish hemlock
#

lmao

somber hull
#

I don’t reply to the message, I see the confusion there

somber hull
sterile token
young knoll
#

Md4 is the best programmer

#

md5 is washed up

lavish hemlock
#

No, I am

#

Well

somber hull
#

Wait

solid cedar
lavish hemlock
#

Conclure is better than me tbh

wet breach
lavish hemlock
#

But I'm still like 2nd or 3rd

young knoll
#

u

#

succ

sterile token
lavish hemlock
#

Yes

#

I think

wet breach
#

sometimes

#

but generally yes

#

in this case it should put Guava there, in fact running buildtools should have done it

solid cedar
wet breach
#

that is why I am surprised it isn't installed in your maven local XD

#

Guava does have some handy utilities though

#

like it has mechanisms already for caching stuff

lavish hemlock
#

Althooough

#

You should probably just use Caffeine

wet breach
#

haven't used that

#

so wouldn't know

sterile token
#

And if you wanna get all the results when doing a "SELECT * from table WHERE something=?", you should do it inside a "while" if not, only first result will be catched.

public void query(String query) {
  PreparedStatement statement = getConnection().prepareStatement(query);
  ResultSet result = statement.executeQuery();
  while (result.next()) {
    logger.log(Level.INFO, result.getString("field-1"));
    logger.log(Level.INFO, result.getString("field-2"));
  }
}
lavish hemlock
#

It's based off of Guava's caching, it's supposed to be better

lost matrix
quaint mantle
#
public static Function getItem(String item){
        HashMap<String, ItemStack> itemList = new HashMap<>();
        itemList.put("BasicKey", BasicKey());
        
        if(itemList.get(item) != null){
            return (Function) itemList.get(item);
        }else{
            return null;
        }
    }

Any way I can make this more efficient?

young knoll
#

Don't make a new map each time

lost matrix
#

Raw typed even

young knoll
#

ItemStack = Function

#

mhm

quaint mantle
#

oh my god im an idiot

#

ty

quaint mantle
young knoll
#

If you're a developer, you can contribute to the QuickShop code! Just make a fork and install the Lombok plugin

#

God dammit lombok

lost matrix
quaint mantle
#
public class Items {
    public static ItemStack getItem(String item){
        HashMap<String, ItemStack> itemList = new HashMap<>();
        itemList.put("BasicKey", BasicKey());

        if(itemList.get(item) != null){
            return itemList.get(item);
        }else{
            return null;
        }
    }

    private static ItemStack BasicKey(){
        ItemStack item = new ItemStack(Material.TRIPWIRE, 1);
        ItemMeta iMeta = item.getItemMeta();
        iMeta.setDisplayName(ChatColor.GREEN + "Basic Key");
        iMeta.addEnchant(Enchantment.DURABILITY, 1, true);
        ArrayList<String> iLore = new ArrayList<>();
        iLore.add(ChatColor.GOLD + "A key! can open a basic crate.");
        iMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        iMeta.setLore(iLore);
        item.setItemMeta(iMeta);

        return item;
    }
}
#

Can someone explain to me how do I use vectors to spawn block on top of location of event block?

young knoll
#

Block.getRelative

lost matrix
quaint mantle
young knoll
#

You need to learn about scope

quaint mantle
#

Scope..?

lost matrix
quaint mantle
lost matrix
#

Wait

quaint mantle
#

I want to be able to return the correct function based on the item String.

#

So that I can get the item requested

wet breach
young knoll
#

I smell a learnjava coming

young knoll
quaint mantle
#

I have been learning java thats the thing lol

vocal cloud
#

How else will that entry level position open

lavish hemlock
#

I am overqualified for an entry level position ;)

#

Still

#

I will take it

lavish hemlock
#

because I do not want to work hard

vocal cloud
#

Yeah but you wanna get paid good

lost matrix
#

you need to be 25 with 30 years of experience to be overqualified

young knoll
#

Looking for java developer, must have experience with java 8 thru java 26

#

Paying $3

lavish hemlock
#

I spent 3 years building knowledge, and I have 5 days of experience.

young knoll
#

Fuck I'm only 23 with 13 seconds of experience

tender shard
#

hm since yaml supports anchors, etc... does it also allow to concat strings? lol

lavish hemlock
#

Oh ye fun fact

tender shard
#

sth like

prefix: &prefix "https://something/"
something: *prefix + "something"
lavish hemlock
#

There's this thing you can do called a YAML bomb

next stratus
#

I am legit so confused how I'm going so wrong lol

tender shard
#

but what's the syntax for it

lavish hemlock
#
a: &a ["lol","lol","lol","lol","lol","lol","lol","lol","lol"]
b: &b [*a,*a,*a,*a,*a,*a,*a,*a,*a]
c: &c [*b,*b,*b,*b,*b,*b,*b,*b,*b]
d: &d [*c,*c,*c,*c,*c,*c,*c,*c,*c]
e: &e [*d,*d,*d,*d,*d,*d,*d,*d,*d]
f: &f [*e,*e,*e,*e,*e,*e,*e,*e,*e]
g: &g [*f,*f,*f,*f,*f,*f,*f,*f,*f]
h: &h [*g,*g,*g,*g,*g,*g,*g,*g,*g]
i: &i [*h,*h,*h,*h,*h,*h,*h,*h,*h]
tender shard
#

hm seems like simply concatting strings is not possible with yaml

lavish hemlock
misty current
#

can you listen for block stripping?

lavish hemlock
#

It's also possible in XML

misty current
#

or do you have to check it urself with interact events

lavish hemlock
#
<?xml version="1.0"?>
<!DOCTYPE lolz [
 <!ENTITY lol "lol">
 <!ELEMENT lolz (#PCDATA)>
 <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
 <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
 <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
 <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
 <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
 <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
 <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
 <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
 <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
young knoll
#

Interact events I imagine

wet breach
tender shard
#

I need it for plain strings though, not lists or anything

tender shard
#

I'll just use a regular %placeholder% or sth

misty current
lavish hemlock
misty current
#

can you check if an item is an axe or do i just check for the name of the material

young knoll
#

Hmm

misty current
#

same for logs

young knoll
#

Lesse

lavish hemlock
young knoll
#

Logs have a tag

wet breach
tender shard
#

I normally just do name().endsWith("_AXE")

young knoll
#

No tag for axe

#

sadly

misty current
#

aight thanks

misty current
tender shard
#

no there's only tags for MINEABLE_AXE

young knoll
#

I would use the namespaced key

#

Over the enum name

lost matrix
misty current
#

probably you could use nms to check for that but its pointless

young knoll
tender shard
lost matrix
tender shard
#

e.g. when you have 1.15 users and cannot use Material.NETHERITE_AXE

young knoll
#

Delete them

tender shard
#

of course one could just create a set at startup

pliant oyster
#

How can I set a players health to maximum using attributes

sacred mountain
#

hey im having trouble setting a value to my config.

im trying to do

player.getUserFile().set("cooldowntoggle", !player.getUserFile().getBoolean("cooldowntoggle"))

player.getuserfile returns a yamlconfiguration

my problem: it doesnt set it. i know that my other code functionality works because i can set the value manually through the file

young knoll
#

setHealth(getAttribute(maxhealthything).getValue)

pliant oyster
#

alr

#

lemmie test it

pliant oyster
quaint mantle
#
p.getInventory().addItem(foundItem);
#

This correct to give a person an item?

#

Note: fundItem is an ItemStack

#

*found

tender shard
#

do java records support clone() ?

quaint mantle
#

Seems to just.. not work

#

When doing it

pliant oyster
#

wait nvm it is

#

but

lost matrix
#
    private static final EnumSet<Material> AXES = EnumSet.copyOf(Arrays.stream(Material.values())
            .filter(material -> material.toString().endsWith("_AXE"))
            .toSet());

This would be version agnostic, no?

pliant oyster
#

it doesnt work for some reason

kindred valley
#

hello guys how can i take money(TNE) by using CommandExecutor

young knoll
#

what

lost matrix
quaint mantle
#

Its returning correctly

#

Its just not giving it for some reason

pliant oyster
#

player.setHealth(getAttribute(GENERIC_MAX_HEALTH).getValue); isn't working

iron tundra
#

I am trying to get a villager to open another gui but for some reason this isn't opening the new gui, the openNewGUI() work with another method of opening it up but this specifically doesn't work. If you can explain why this isn't working I would appreciate it!

    @EventHandler
    public void OpenGUi(TradeSelectEvent event) {
        event.setCancelled(true);
        openNewGUI((Player) event.getWhoClicked());
    }
kindred valley
kindred valley
lost matrix
pliant oyster
kindred valley
lost matrix
quaint mantle
#
String item = args[0];
if(Items.getItem(item) != null){
    ItemStack foundItem = Items.getItem(item);
    p.getInventory().addItem(foundItem);
}

Any reason why the player isnt receiving the item? Before you ask, no, getItem is working, I tested that out.

#

Its just the giving that isnt working for some reason.

tender shard
quaint mantle
#

And yes, it does reach the getInventory part

#

cause i tested that as well

tender shard
tender shard
lost matrix
young knoll
kindred valley
lost matrix
kindred valley
quaint mantle
#

I did sysout checks n everything.

#

Its reaching it, just not running.

#
if (sender instanceof Player p){
pliant oyster
lost matrix
quaint mantle
#

Unless thats incorrectly done

lost matrix
#

?jd

lost matrix
young knoll
#

So there is an open PR for this, but it was made in 2016 and had changes requested in 2021

quaint mantle
#

@lost matrix Just a note: p.getInventory().addItem(foundItem) when using in system, returns: "{}"

young knoll
#

So uhh... it may be a bit dead

young knoll
#

The return map is the items that failed to add

quaint mantle
#

*item

lost matrix
quaint mantle
#

Here is the item im trying to get:

#
private static ItemStack BasicKey(){
        ItemStack item = new ItemStack(Material.TRIPWIRE, 1);
        ItemMeta iMeta = item.getItemMeta();
        iMeta.setDisplayName(ChatColor.GREEN + "Basic Key");
        iMeta.addEnchant(Enchantment.DURABILITY, 1, true);
        ArrayList<String> iLore = new ArrayList<>();
        iLore.add(ChatColor.GOLD + "A key! can open a basic crate.");
        iMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        iMeta.setLore(iLore);
        item.setItemMeta(iMeta);

        return item;
    }
#

Here is the command:

package me.emerald.emeraldsplugin.commands;

import me.emerald.emeraldsplugin.EmeraldsPlugin;
import me.emerald.emeraldsplugin.Items;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class SpecialGiveCommand implements CommandExecutor{
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
        if (sender instanceof Player p){
            if(p.getName().equalsIgnoreCase("AnEmerald")){
                if(args.length > 0){
                     String item = args[0];
                     if(Items.getItem(item) != null){
                         ItemStack foundItem = Items.getItem(item);
                         System.out.println(p.getInventory().addItem(foundItem));
                         p.getInventory().addItem(foundItem);
                    }
                }
            }else{
                p.sendMessage(ChatColor.DARK_RED + "Invalid permissions to use this. You must be an administrator to use this.");
            }
        }

        return true;
    }
}
#

Also, I tested getItem, it works

#

As it DOES return the item

#

Oh, and here is the setExecutor

#
getCommand("specialgive").setExecutor(new SpecialGiveCommand());
young knoll
#

Is the itemstack amount 0

#

It doesn't seem like it, but that's the only real guess I've got

quaint mantle
#

shouldnt be

smoky oak
#

wait does the command run at all?

tender shard
#

what exactly is the problem?

smoky oak
#

^

quaint mantle
#

The problem: Its not giving me the item.

#

Does the command run: Yes

smoky oak
#

yea bu

lost matrix
quaint mantle
tender shard
#

add debug statements

#

is the players name equal to AnEmerald?

#

is Items.getItem(item) != null ?

quaint mantle
#

Yes, Yes

#

Ive tested those

tender shard
#

what does your System.out.println print?

quaint mantle
#

hold on, im testing 7smile7's thing..

tender shard
#

I am like 99% sure it doesn't even get to the System.out.println

kindred valley
#

i mean

#

i want command line to execute the command

quaint mantle
#

@lost matrix ```java
ItemStack{TRIPWIRE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"Basic Key"}],"text":""}, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"A key! can open a basic crate."}],"text":""}], enchants={DURABILITY=1}, ItemFlags=[HIDE_ENCHANTS]}}
10.03 21:24:19 [Server] Server thread/INFO ItemStack{TRIPWIRE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"green","text":"Basic Key"}],"text":""}, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gold","text":"A key! can open a basic crate."}],"text":""}], enchants={DURABILITY=1}, ItemFlags=[HIDE_ENCHANTS]}}

#

Prints this sucessfully

tender shard
#

Bukkit.getConsoleSender() or sth

tender shard
#

depends on where he is printing that out

smoky oak
quaint mantle
#

At all

#

Which is the weird thing

#

Cause it should be right?

tender shard
#
                         System.out.println(p.getInventory().addItem(foundItem));

#

what does this print?

#

the sout you already had included

quaint mantle
#

I already told 7smile7 that

lost matrix
#

That means that i got added

tender shard
#

yeah exactly

quaint mantle
#

So then where is it being placed? In the void?

smoky oak
#

you said you have checked all the if() clauses right?

quaint mantle
#

Yes

lost matrix
smoky oak
#

what's the exact command you're typing in the chat

tender shard
#

print out all contents of the player's inventory after it was added

quaint mantle
#

/specialgive BasicKey

tender shard
#

just to be double sure it actually got added and if yes, into which slot

young knoll
#

I mean if it is sysouting the result of addItem

#

Then obviously the if statements aren't the issue

quaint mantle
#

How do I send images?

young knoll
#

verify

quaint mantle
#

Im trying to send the fact, that my inventory is empty.

tender shard
#

just do for int i = 0; i < inv size; sout(i +" -> " + inv.getItem(i))

#

sth like that

smoky oak
#

wait a sec does sender instanceof Player p initialize Player p = (Player) sender ?

young knoll
#

yes

tender shard
#

obviously that wasn't meant to be valid java 😄

smoky oak
quaint mantle
#

Is it just me or am I blind

#

But that item isnt there

lost matrix
#

I would use

    public void printInventoryContent(Player player) {
        System.out.println(Arrays.toString(player.getInventory().getContents()));
    }

instead