#help-development

1 messages Β· Page 2147 of 1

granite owl
#

dude the eventhandler isnt hooking static functions lmao

crisp steeple
#

oml

crisp steeple
#

you literally made a static listener

#

i saw it with my own eyes

granite owl
#

okay so please explain to me why not to pass the event as function parameter?

river oracle
#

I have methods where I pass events as a parameter

granite owl
river oracle
#

solid layer of abstraction

granite owl
river oracle
#

works well with some interfaces I have set up

granite owl
#

xD

river oracle
#

amazing for gui clicks and such

crisp steeple
river oracle
#

oh bruh has a static event handler

granite owl
#

main.class

crisp steeple
granite owl
#
    @EventHandler
    public void onPlayerRespawn(PlayerRespawnEvent event)
    {
        User.onPlayerRespawn(event);
    }
#

User.class

#
    public static void onPlayerRespawn(PlayerRespawnEvent event)
    {
        if (!event.isBedSpawn() && !event.isAnchorSpawn())
        {
            event.setRespawnLocation(spawn);
        }
    }
waxen plinth
#

But why

granite owl
#

because having this

waxen plinth
#

And why do you put your braces on the next line

#

😭

crisp steeple
granite owl
#
public void onEnable()
    {
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        
        Callbacks.init(this);
        Ranks.init(this); 
        Admin.init(this);
        User.init(this);
    }
``` otherwise this is getting messy af
opal juniper
#

so that i vomit

river oracle
#

what

crisp steeple
#

??

#

lmao

#

second deleted message

opal juniper
#

thats not the point

crisp steeple
river oracle
#

a user shouldn't be singleton

#

or just rename the class to be better descriptive of its contents

crisp steeple
#

yeah

#

something like UserHandler would maybe make more sense

#

no one knows, this class just came out of nowhere

opal juniper
#

use sounds to me like it should be instantiated

river oracle
#

ASakashrug maybe it makes sense given his codebase

crisp steeple
opal juniper
#

as like a Player would be

waxen plinth
#

Just split it up

#

Make an initializeUtils method or something like that where all the init happens

#

But all of that stuff is static and probably shouldn't be

granite owl
#

its 3 distinct systems that interact with each other but operate independent

crisp steeple
#

depends what it does ig

granite owl
crisp steeple
#

if its just removing the player removePlayer probably makes more sense

waxen plinth
#

How could it be messy

#

It's just a sequence of init calls

#

And you can make it more branching if needed

#

Like one call to initialize all of the systems for one thing, then a call to initialize all of the systems for another thing

crisp steeple
granite owl
crisp steeple
#

bruh

crisp steeple
granite owl
#

if i aint getting u wrong here

shadow gazelle
#

Do I have to make a new enchanted book to modify the stored enchantments or something? Just remove/adding them doesn't seem to work.

waxen plinth
#

I dunno I just got here

waxen plinth
#

You have to get the ItemMeta, cast it to EnchantmentStorageMeta, and then add/remove stored enchantments

shadow gazelle
#

That's what I'm doing

#

it isn't saving or something

waxen plinth
#

Can you show the code

#

^

shadow gazelle
#

ffs

granite owl
shadow gazelle
#

forgot I had to do that with meta

waxen plinth
granite owl
#

and fully operational

crisp steeple
waxen plinth
#

Have you ever used nucleus

#

It's like essentials but for sponge

#

And my god it is so much better

shadow gazelle
waxen plinth
#

I kinda hate essentials

daring lark
#

i have a quick question. Did spigot overrides equals method, like if i would like to compare chests or sth. Did i need to override them on my own?

opal juniper
#

it overrides somethings

#

depends

waxen plinth
#

Why would two different chests ever be equal

crisp steeple
#

chests as in the blocks or inventory?

daring lark
waxen plinth
#

ItemStack overrides equals

#

I can't even really think of much else that would need to

#

Different entities, blocks, and such will never be equal

#

BlockData overrides equals

#

ItemStack#equals?

#

Yes

granite owl
waxen plinth
#

It only returns true if the items are identical

#

Yes

#

Oh my god it is not that complicated nor does it matter that much

#

Just pick something lol

#

Both the names sound fine

#

Leave a comment/javadocs if you really think it's unclear what the method does

crisp steeple
shadow gazelle
#

lol

trail oriole
#

currency.get(player.getName()) -= helmetP[helmet];
Currency is a hashmap having the player as a key and an int associated and helmetP is an array containing integers, yet i can't do this operation

opal juniper
#

well u need to re-set it

trail oriole
#

so set instead of get ?

#

is that all ?

opal juniper
#

but you cant -= cause that is reassigning to something that isnt a var

trail oriole
#

oh

#

i'm so confused on how to do that

quiet ice
#

map.put(key, value)

opal juniper
#

^

quiet ice
#

(you could use map.merge or something like that but eh)

trail oriole
#

but how do I get the previous value associated to the key

#

I still need to do an operation

quiet ice
#

just get it?

#

Also, you should always store data based on the player's UUID, not by name

trail oriole
#

currency.put(player.getName(), currency.get(player.getName() )- helmetP[helmet]); ?

quiet ice
#

close

trail oriole
#

no need for data, the hashmap is deleted when the player opens an inventory and a new one is created so no need to use uuid, i'll nver have two players with the same name online

quiet ice
#

But you probably meant the right thing, it's just a stray bracket

trail oriole
#

no wait

#

it works

#

i'm just dumb and used player's name instead of the player itself

quiet ice
#

oh

#

I sense a memory leak

trail oriole
#

yeah ^^'

sterile token
#

What better for comparing ItemStack, equals() or isSimilar()?

humble tulip
#

Similar doesn't check amount

#

Equals does

sterile token
#

Oh allright good point i didnt think that

granite owl
#

iirc equals converts the objects into their sha hash and then compares the two so they must be absoloutly identical to return true

#

but i bet if im wrong here someone will be happy to enlighten

ivory sleet
#

at some point I believe equals cloned the stack 3 times

sterile token
#

So for ItemStack equls() is memory lost right?

sterile token
#

Because when you compare ItemStack you dont care about the amount for example

ivory sleet
#

then isSimilar

sterile token
#

Allright thanks

#

I dont know why the fuck, interface doesnt allow to use their implementation methods of a class

#

For me its so engorrous

granite owl
#

because thats what a class is for

#

and why u inherit objects

ivory sleet
#

default?

#

private methods?

sterile token
#

I explain

#

So you told me if correct

#

I use interface when need to have the same methods in multiple class

granite owl
#

i mean im prob just dumb but iirc an interface just tells the class it must have a method

ivory sleet
#

thats one way to use them

granite owl
#

but the method must be defined in ur class

#

like a placeholder

sterile token
#

So in my case i have a Menu interface with getName(), getSize(), getInventory(), bla bla.

So i have 2 diff types of menu, Inventory (normal one) and Paginated.

So in paginated i want to use there the methods from interface and the methods from the class

#

I cannot, because for tracking my inventories i have a Map<UUID, Menu> because as i have diff menu types

ivory sleet
#

that sounds extremely like an impl detail

#

good thing it isnt exposed in your interface

sterile token
#

I would love to do that lmao

#

setPage() its specific from the PaginatedMenu

#

My main problem come when i need to get the inventory, into the diff types

#

Because if i cast it, them i get issue

#

πŸ€”

ivory sleet
#

I mean expose the type then?

sterile token
#

I cannot because the Menus will be saved in 1 map only

#

I dont want to have them separated

ivory sleet
#

I mean

#

the map can still consume the type Menu

#

but you should have a separate type which is paginated

#

as it seems to expose further api functionality

sterile token
#

Conclure i dont understand sorry im dumb :(

#

Ajam, and how you track them?

#

Allright, so you have a class for normal menus and one for paginated right? And you track uuid and BaseGUI

#

Yeah i do that for dont killing myself

#

So what i can do? explan what you mean Conclure by doing further api functionality

#

Yeah you keep the full player object losting memory

#

That what i avoid using UUID instead of whole object

#

But iin fact is the same

grim ice
#

which has a static factory

#

to make its implementation (PaginatedMenuImpl/SimplePaginatedMenu)

sterile token
#

Yeah

grim ice
#

thats what i would do

sterile token
#

A factory right?

grim ice
#

yeah, factory pattern

sterile token
#

ok

granite owl
#

hows the event called thats fired when the beacon is activated?

#

when the effect is chosen for an emerald, diamond etc

sterile token
#

So its organized good in this way:

Menu interface - For the menus implementations
InventoryMenu - For working with normal inventory
PaginatedMenu - For working with paginated menus
MenuButton - For managing the item and the action it run
MenuAction and ActionEvent - For managing the actions
MenuHandler - Keep tracks of menus

#

For looks organized, maybe im wrong

grim ice
#

i mean that sounds fine

sterile token
#

Yeah but i need to take care because its open source api

grim ice
#

not really

#

Majority ==> Correct

#

Minority ==> Incorrect

sterile token
#

2Hex factory are usually singleton classes right?

grim ice
#

they can be interfaces

#

It does

sterile token
grim ice
#

majority is the correct

#

by correct I mean that you cant suppress it

#

if you cant suppress an opinion, society calls it correct

#

like it or not lol

#

It will become correct

#

Well

#

the new born babies will be taught that it is correct, if chosen so by the majority

#

therefore the next generation will think its correct, even though it actually was not

#

so the fact that it is incorrect will be forgotten

sterile token
grim ice
#

and democracy is just the definition of what im saying

#

the representative that assigns law, is elected by the majority

#

meaning correct or incorrect heavily depends on the majority

#

lol

#

it does

#

Yes.

sterile token
#

If majority dont agree, you will get literally fucked

#

As said Hex

grim ice
#

oh yeah whatever

#

your friends are family are nothing in this society lol

brisk acorn
#

can some one help me

grim ice
#

i can bet none of you have that high of a social status that your opinion matters in society

#

its the sad truth lol

brisk acorn
#

@grim ice

grim ice
#

what

sterile token
#

And if need help follow this ?ask

#

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

brisk acorn
#

can some one explain this is confuing is it just a sever with mods installed for that version of mc?

chilly pagoda
#

hello Im totally new to java & spigot, is there any resource I can learn how to implement adding new tool/weapon types? (scythes daggers)

#

obv with variants such as wooden, stone, iron etc.

#

I thought of giving them an NBT tag so I can get the item type and execute code for all material types, but I couldnt find much help on that online

quaint mantle
#

you can do that with resource packs and pdc

#

?pdc

granite owl
#

isnt there a bukkit implementation for the beacon activate event?

chilly pagoda
#

I tried looking for github repos that would have something similar but no luck there

quaint mantle
#

there's other ways like checking for specific lore but I would recommend learning pdc

chilly pagoda
#

yea no lore checking would be dogshit for what Im trynna do

#

is there some fully-working example available so I can have something that works and learn from that?

#

Im real shit at theory I need something practical to learn how stuff works

#

prolly worded taht wrong tired asf soz, all I'd need to learn this is to have 1 example of someone reading any custom nbt tag off an item

hexed hatch
#

Not even remotely

chilly pagoda
#

yea its prolly not

#

jsut too much information in the post my ape brain gets overloaded

sterile token
grim ice
#

@chilly pagoda listen

#

so what it does is

#

every item has a container okay?

chilly pagoda
#

yes

grim ice
#

and in that container u caan add a section

#

and that section has a valie

#

value

chilly pagoda
#

yes

grim ice
#

so for example

#

section "name" with value "Osama"

#

name: Osama

chilly pagoda
#

{tag:{ape:1b}}

#

I did datapacks for years

grim ice
#

yeah

lost matrix
#

?pdc

chilly pagoda
#

I just never did Java :p

#

Ill try to find a vid tho dw

#

im le special

grim ice
#

so in this case

#

the section

#

is a "namespacedkey"

#

namespacedkey is nothing complicated

#

its just a word

#

(string)

#

attached to your plugin

#

ItemStack itemStack = ...;
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI);
itemStack.setItemMeta(itemMeta);

#

here

#

u have the itemstack from somewhere

#

and a namespacedkey, which is ourcustomkey

#

u get the container of the item, and write

#

our-custom-key: Math.PI

#

in it

#

which is 3.14 ofc

#

so this is how it looks like

limpid junco
#

I'm not sure if it is in the rules of this server, but can we ask questions about the installation of Third party spigot libraries?
because I'm having trouble with the installation of https://github.com/IPVP-MC/canvas
I went through to instructions and the
mvn clean install
is just not working for me
It says that mvn is not a command in the terminal

grim ice
#
item:
|__ container:
    |__ our-custom-key: 3.14
    |__ something-else: hello
#

@chilly pagoda

#

its just a hashmap if u know what that is

sterile token
#

a PDC its easy to understand its literally a key-value pair

grim ice
#

yeah

#

i didnt understand it at all when i was starting out though

sterile token
#

where key can be a name to indentify and the value can be a object, string, integer, etc

#

Hex im burning my head trying to do the paginated menu - hahaha

twilit wharf
#

I have a biome provider, and when I set a biome to deep ocean, it sets it in f3, but still generates land there. The land has shipwrecks and ocean monuments on it, yet no water.

grim ice
#

(thats why i dislike guis)

sterile token
#

2Hex its correcta List<PaginatedMenu>?

grim ice
#

yea ig

mortal hare
#
public interface HandleableUIContainer<T extends HandleableUIContainerView<? extends HandleableUIContainer<T, V>, V>, V> extends UIContainer<T, V>, HandleableUI<T, V> {}

my generics best record

sterile token
mortal hare
#

abstraction shit

#

im doing an experimental lib, where toasts, container inventory uis, and holograms could be implemented using the same couple interfaces

sterile token
#

dovidas can i get your gth profile please

mortal hare
#
UI<?> hologramUI = HologramFactory.getInstance().createHologram("Hello world!", loc).display(player);

UI<?> inventoryUI = ContainerUIFactory.getInstance().createGUI(Component.text("Title"), ....).display(player);

UI<?> toastUI = ToastsFactory.getInstance().createToast(IconType.STONE, Component.text("Title"), Component.text("Detailed info")).display(player); 
#

it theory it should work similiar to adventure api

mortal hare
sterile token
#

Thanks

#

i watn to check menu apis

#

But on github i only find shity ones

mortal hare
#

There's no git repo there

#

containing this

#

its on my pc currently since its very experimental

#

and not complete yet

sterile token
#

Oh ok

#

Because my brains burns trying to create paginated one

mortal hare
#

have you tried using SpiGUI

sterile token
#

Shity

#

I dont like the design

mortal hare
#

My Inventory UI implementation currently doesnt use InventoryHolder

sterile token
#

no one use that

#

hahaha

mortal hare
#

InventoryFramework afaik use that

sterile token
#

why?

mortal hare
#

to detect if the inventory is gui

sterile token
#

I dont understand the need of that

mortal hare
#

you can store instances of objects there

#

but there are some consequences of doing that

sterile token
#

I just check the top inventory

#

πŸ˜‚

#

dovidas

#

How can i design the paginated part?

mortal hare
#

well chest inventory is 6*9 = 54

#

right

sterile token
#

ajam

#

In my PaginatedMenu i keep track of List<Menu>

radiant cedar
#

what is the difference between Bukkit.getWorld and Bukkit.getServer().getWorld()

radiant cedar
#

lmaoo

#

ok ty

mortal hare
#

I bet Bukkit.getWorld() internally just calls Bukkit.getServer().getWorld()

#

so Bukkit.getServer().getWorld() should be with a pinch of salt faster to call since you are calling only one method you need, and not two methods instead

#

but that's premature optimization

#

JIT would take care of that, I bet.

grim ice
#

Uh

#

How do i make some sort of

#

communicating from a client and a server (not in spigot or minecraft)

#

so it cant be replicated

#

by others

#

cuz if i wanna make a point system for example

#

i will want to tell the server to add me a point when i do something

eternal oxide
#

end-to-end authentication or a token system

grim ice
#

wat

#

oooo

eternal oxide
#

however you will never write anythign that is 100% secure

grim ice
#

that sounds hard

eternal oxide
#

You have to decide how much work you really want to put into making it secure

grim ice
#

i guess not that secure

#

but not extremely easy to bypass

#

do u know some tutorial

#

or guide

eternal oxide
#

Nothing up to date. I've not done anything with encryption in 10 years

grim ice
#

doesnt need t o be up to date

mortal hare
#

I like how I despised using generics and now im abusing the shit out of them lol

quaint mantle
#
void transferMoney(
            Player sender,
            Player recipient,
            Connection connection,
            Statement statement,
            String amount
    ) throws SQLException {
        float senderBalance = 0;
        float recipientBalance = 0;

        ResultSet result = statement.executeQuery("SELECT * FROM currencies;");
        while(result.next()){
            if(result.getString("uuid").equalsIgnoreCase(sender.getUniqueId().toString())) senderBalance = result.getFloat("money");
            if(result.getString("uuid").equalsIgnoreCase(recipient.getUniqueId().toString())) recipientBalance = result.getFloat("money");
        }

        statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());
        statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());

        recipient.sendMessage(MetricCraft.prefix + ChatColor.WHITE + "You've received " + amount + "$ from " + ChatColor.GREEN + sender.getName() + ChatColor.WHITE + ".");
        sender.sendMessage(MetricCraft.prefix + ChatColor.WHITE + "You sent " + ChatColor.GREEN + recipient.getName() + " " + amount + ChatColor.WHITE + "$.");
    }```
#

This should work, right ?

mortal hare
#

this seems vulnerable to sql injection exploits

quaint mantle
#

I just started with sql today

mortal hare
#

if people managed to inject some sql related query text into those variables (like recipientBalance), they can literally wipe your SQL table or make infinite amounts of cash

quaint mantle
#

Is it possible ?

mortal hare
#

it could be impossible

#

but you shouldnt trust your senses

#

of what's possible

#

its just not worth it

quaint mantle
#

You're right.

#

Can you help me in DMs, if you want to, and if you're free ofc.

mortal hare
#

Its late for me (1AM) and its alr monday so I'm gonna probs sleep soon since i need to get up at 7 AM

#

so can't really help much

quaint mantle
#

so do i just replace the normal statements with prepared ones ?

mortal hare
random kestrel
#

Hey quick question, does someone know how to retrieve a list of all ids and those that are usable for BlockData?

mortal hare
#

instead of using string appending for your queries you create query format string, for example:

statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());

would turn into

PreparedStatement statement = con.prepareStatement("UPDATE currencies SET money = ? WHERE uuid IS ?");
statement.setInt(1, Integer.parseInt(amount);
statement.setString(2, recipient.getUniqueId().toString());

#

by doing that you're letting the SQL implementation classes to clear your variable data if they contain malicious SQL query code, leaving harmless data in place

sterile token
#

isnt executeUpdate()

mortal hare
sterile token
#

dont worry

#

executeUpdate() => for update
executeQuery() => for getting data

#

hich?

#

Also what means blame?

mortal hare
#

nvm wrong source

#

you should call execute(), executeUpdate() or executeQuery(), in this case executeUpdate()

quaint mantle
#

I'm getting an error from the uuid

#

coz it has -

#
if(result.getString("uuid").equalsIgnoreCase("\"" + recipient.getUniqueId().toString())) recipientBalance = result.getFloat("money");```
#

How do I implement it in here?

civic dagger
#

so whats the best way to store some data on a item? for example when you wanna create a custom item that triggers when you right click you check if its the custom item or not with ItemMeta but they arent always a good solution and now i need another way i think i can use NBT data but i dont think its the best way to do it

eternal oxide
#

?pdc

civic dagger
#

thanks

quaint mantle
#

@eternal oxide

#

would be able to help me please ?

eternal oxide
#

That wiki is fine

crisp steeple
#

you just use that to avoid sql injections

kind hatch
#

When you use it depends on what you need. If you need "metadata" or even just extra data on an item, it's recommend to use the pdc.

crisp steeple
#

but you shouldnt really use \" either

#

because then they could just inject with a "

quaint mantle
#

Then how do I inject he uuid?

crisp steeple
#

use a parameter

#

the ?

quaint mantle
#

how would you do it ?

eternal oxide
#

always use prepared statements and it will prevent injection attacks

quaint mantle
#

Could you give me a small code snippet ?

radiant cedar
#

how can I make in blockbreakevent the breaker of the block is the owner of the item that drops

eternal oxide
#

it correctly wraps and parses the values

crisp steeple
#

statement.setInt(1, int)

radiant cedar
radiant cedar
crisp steeple
#

use pdc most likely

kind hatch
crisp steeple
#

#setDrops

radiant cedar
crisp steeple
#

that isnt a thing

quaint mantle
radiant cedar
#

it is bro

eternal oxide
#

String concatenation is not to be used with sql

quaint mantle
#

so if I use the prepared statements it will automatically do it for me, right ?

eternal oxide
#

yes

quaint mantle
#

So I won't have a problem with the - anymore ?

eternal oxide
#

teh - in a UUID is always there

crisp steeple
quaint mantle
#

Well yes.

eternal oxide
#

unless you are querying mojang or something

quaint mantle
#

But there's a problem with normaly storing it.

crisp steeple
#

well then yeah just make a new itemstack and set its owner to the uuid you want

#

then setDrops

eternal oxide
quaint mantle
#

Well time to learn it then, thank you for the recomentation man!

crisp steeple
radiant cedar
#

Items can

crisp steeple
#

oh

#

uh

#

im not sure then tbh

#

what you could do

eternal oxide
#

Yep, prepared statement and adding the UUID using statement#setString

crisp steeple
#

is just cancel the event and then set the blocks type to air

#

then spawn an item naturally at that spot

radiant cedar
#

yes but u cant make ur own Item i think

#

u can make ItemStack

#

atleast im trying and cant seem to figure out

crisp steeple
#

World#dropItemNaturally

#

then in the consumer give the the item the owner

radiant cedar
#

right now i have this

#

but u cant make new Item

#

i think

crisp steeple
eternal oxide
#

you don't create Items

#

you do create ItemStacks

radiant cedar
#

ye thas what im saying

#

but then I cant set owner for itemstack

#

i can set for Item

eternal oxide
#

How you do it all depends on how nice you want it.

crisp steeple
eternal oxide
#

eg, you could just insert all the drops into teh block breaking players inventory

radiant cedar
#

ye but eh want it drop

eternal oxide
#

then stop any drops happening

radiant cedar
eternal oxide
#

if you want it to drop you have to modify each item in teh drop item event or in teh block break event and mark the item with the players UUID

#

then in teh pickup event you check each item tht tries to be picked up

#

Quite complex if you are at the level of being unsure how to create ItemStacks

sharp flare
#

#setOwner does the job of preventing others from picking up the item unless the uuid is equal to that dropped item

radiant cedar
#

cus u cant get Item of the block but u cant setOwner for ItemStack

sharp flare
#

After breaking the block, get the dropped entity item, and do setOwner

radiant cedar
crisp steeple
sharp flare
eternal oxide
#

I didn;t know they had added a setOwner on Items

shadow gazelle
#

So now I have an issue of not being able to actually apply the higher level enchantments with my plugin

#

Is there anything in the anvil event to get rid of the limit of 40 levels, or increase it?

#

I see you can remove the limit

#

But what about increasing it?

#

Nevermind, found it

quaint mantle
#

interesting

torn shuttle
#

before I go out of my way to do it is there an easy way to get all the enums from the api for a given page without me having to write a parser or doing it manually?

quaint mantle
#

Does anyone know how to import another project I made with gradle into my current gradle project?

eternal oxide
#

page?

torn shuttle
#

I need to get the api values for a webapp I'm making and uh

#

there's a lot

crisp steeple
#

are you just trying to get a json list of all the materials?

torn shuttle
#

and when I say get I mean hardcode, I'm not going to be accessing that page every time that would just be mean of me

torn shuttle
quaint mantle
crisp steeple
#

i made something a while ago that parsed an entire enum into json

#

although now that i think about it using gson probably wouldve been simpler

torn shuttle
#

oh actually let me check something

crisp steeple
#

or an actual project

quaint mantle
#

an actual project

#

its another gradle project

crisp steeple
#

hm

torn shuttle
#

ah damn it decompiled materials also don't give me a clean list

radiant cedar
#

How can I change the ItemMeta of an ItemStack if the amount of the ItemStack changes (ItemStack in inventory)

eternal oxide
#

Too many actions can affect a stack size

radiant cedar
#

when pickup lets say

eternal oxide
#

Tell us what you are trying to do and we can probably tell you a better method

radiant cedar
#

and an itemstack size changes

#

I have a yml of set materials and prices for them

#

so I wanna update the itemmeta

#

to the total price of that stack

#

but it can be siz 9 or 64 or whateverf

eternal oxide
#

calculate the total when you need to, not every time the size changes

radiant cedar
#

which is when u open inventory... OOHHH

#

ty ❀️

torn shuttle
#
(function() {
    'use strict';
    const values = document.getElementsByClassName("member-name-link");
    let parsedStrings = [];

    for (var element in values) {
       parsedStrings.push(values[element]['innerHTML'])
    }
    console.log(parsedStrings);
})();

Because I'm lazy I worked around parsing the api with tampermonkey, feel free to steal this. It outputs all enums on the page to console in a way that can be used elsewhere pretty easily.

#

oh oops looks like it has a little bit of contamination lol

radiant cedar
#

anyone know why this wont trigger?

#

the system prints

#

i press E to open INV but it never actually gets triggered

ebon coral
#

How do I replace a string with a component in a component?

solemn gulch
#

why does getKiller exist on the player and not the playerdeathevent

delicate lynx
#

good question

torn shuttle
#

?paste

undone axleBOT
torn shuttle
#

alright if anyone cares to this script on greasemonkey / tampermonkey will add a download button to the top of the spigot api page which you can click to download a yml file containing all of the enum values, excluding things tagged as "LEGACY" because I don't want that
https://paste.md-5.net/jejasomuda.js
a very specific tool for an issue that I've had more than once tbh

ebon coral
#

How do I use the component's showItem hover?

crisp steeple
# radiant cedar

you cant check when a player opens their own inventory unfortunately

#

that's client side

crisp steeple
limpid junco
#

Code: ```java
package hello.ello;

import hello.commands.GUICommand;
import hello.events.ClickEvent;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class Ello extends JavaPlugin {

@Override
public void onEnable() {
    this.getCommand("spacepowers").setExecutor(new GUICommand());
    getServer().getPluginManager().registerEvents(new ClickEvent(), this);



}

}```

dusk flicker
#

use a paste

#

?paste

undone axleBOT
limpid junco
#

ok

#

idk how this thing works anymore

#

it used to make sense

crisp steeple
#

not exactly sure what you want us to do with this but sure

limpid junco
#

umm

#

Did you read the error?

#

I mean

#

it was in the link

crisp steeple
#

ah

#

didnt realize there was a deleted message

limpid junco
#

o

eternal oxide
#

spacepowers command is not in your plugin.yml

crisp steeple
#

^

limpid junco
#

ummm

#

wait

#

one sec

#

thats my plugin .yml

eternal oxide
#

then thats not the same plugin.yml that is actually in the jar you are testing

limpid junco
#

Thats wierd

#

both of those files are in the main directory

eternal oxide
#

open the jar you are testing with any archive program (7-zip)

#

check teh actual plugin.yml that is inside the jar

limpid junco
#

ok

#

its in there

#

I openned it too

#

its the exact same thing

eternal oxide
#

drop your jar in here

limpid junco
#

ok

#

wait

#

do I need to be verified for that?

eternal oxide
#

yes

limpid junco
#

oof

#

ok

radiant cedar
#

@crisp steeple is it normal for the server to be around 4-6gb memory use

dusk flicker
#

what ver, with what plugins

crisp steeple
#

sounds like a bit much but im not really an expert on ram usage

radiant cedar
dusk flicker
#

so descriptive

radiant cedar
#

my plugin

#

made multiverses

#

maybe us of that

dusk flicker
#

what ver

radiant cedar
#

what

dusk flicker
#

minecraft version

radiant cedar
#

1.18.2

dusk flicker
eternal oxide
# limpid junco there

looks fine to me. It shoudl work fine with a 2 space indent. change it to the standard 4 to be sure

limpid junco
#

What line should have a two space indent?

ivory flume
#

How do I turn off people from using a locked in the off hand?

eternal oxide
#

the indentation on commands and all after

limpid junco
#

ok

eternal oxide
#

multiples of 4

ivory flume
#

theres certain items i put on inventories that can't be moved, and i want to fix a bug where they move it via using the off hand

wraith marsh
#

heya im trying to make a plugin that includes a PlayerBedEnterEvent but it doesnt seem to be listening, i have the eventhandler annotation, implemented listener and registered the class

dry forum
#

does a task automatically delete once its done executing? like if i had a runnable execute 2 seconds later would it delete itself once it runs everything?

wind tulip
#

Hey, if I'm using a scheduler inside of a library, do I pass the library's plugin for the parameter or do I pass the main project's?

eternal oxide
#

a library doesn;t have a Plugin instance. You pass yours

eternal oxide
dry forum
#

so once its run once they wont run again? and the variable it was stored in is cleared/deleted?

eternal oxide
#

yes, Tasks are cleaned up once done (with GC)

dry forum
#

ight ty

eternal oxide
wraith marsh
#

i tried that

#

didnt work

wind tulip
eternal oxide
#

your plugin instance is this as the code is in your main class

wind tulip
#

it needs to be static

eternal oxide
#

You can;t initialise your static plugin like that.

wraith marsh
wind tulip
#

well "this" on its own is not static apparently

#

oh

eternal oxide
#

on your last line, change the plugin to this

wind tulip
#

yeah, that gives a syntax error

#

'me.wonk2.DFSpigotLib.this' cannot be referenced from a static context

eternal oxide
#

because yoru method is static it wants a static reference

wraith marsh
eternal oxide
#

is this a library? as you have no onEnable or anything

wind tulip
wraith marsh
#

oh

eternal oxide
#

then you shoudl not be extending JavaPlugin as this is not a plugin

wind tulip
#

so I guess it's not needed then

eternal oxide
#

no, your library shoudl not care who is accessing it. They should provide their plugin instance in any method calls which require one

#

This playSounds method seems more appropriate for a utility class rather than a library

dusk flicker
#

also

#

?conventions

undone axleBOT
wind tulip
#

oh

dusk flicker
#

yeah thats the issue

wind tulip
#

nvm

eternal oxide
#

he's commenting on your TreeMaps

dusk flicker
#

i was commenting on all of it tbh lol

eternal oxide
#

lol

eternal oxide
dusk flicker
#

should be camelCase rather than PascalCase

wraith marsh
eternal oxide
#

and?

wraith marsh
#

it doesnt register the listener

#

well it just doesnt listen

wind tulip
eternal oxide
#

then we'll need to see some code

wind tulip
#

naming conventions are just practices for most people

dusk flicker
#

aka how to never get a job in industry

wind tulip
#

You really think they're gonna care that I capitalize the first letter in a method's name

#

pfft

dusk flicker
#

yes

#

If what you are doing is only for you; sure I understand that, but being that is is a library and others will be using it you should follow the standard conventions

eternal oxide
#

Don't get a job in "the Industry". Everyone becomes a dick when theyr ego inflates.

wraith marsh
dusk flicker
#

get verified and you can, or just send it in a paste

#

?paste

undone axleBOT
eternal oxide
#

ah embed

wraith marsh
#

ye

eternal oxide
#

use the paste link or verify

shadow gazelle
#

Never mind, my idea doesn't work. Is there any other way to change the maximum enchantment cost? I just get this and can't take the complete sword when I set the maximum to a higher value.

wraith marsh
dusk flicker
#

yeah, up to you

wraith marsh
#

alr

dusk flicker
shadow gazelle
#

There's a plugin that somehow allows it, but I'm looking for a specific usage and it can't do that

wind tulip
wraith marsh
dusk flicker
#

decompile that plugin then lol

#

toptal murdered my boy

eternal oxide
wind tulip
eternal oxide
#

yes

dusk flicker
#

what a plugin name lmao

eternal oxide
#

just not how you are doing it

dusk flicker
eternal oxide
#

all static items in a class are initialized at class load. Which is before teh plugin loads

shadow gazelle
#

bruh

#

It's not like anyone can even do anything with your IP

dusk flicker
#

I cant see a reason that it wouldent work

shadow gazelle
#

DoSing or DDoSing is illegal and you'd get banned from pretty much every ISP you try to get

dusk flicker
kind hatch
#

You should care more about your IP being leaked. Just because it's illegal doesn't mean that people are going to stop doing it.

#

It's a pain in the ass to get your IP changed sometimes.

shadow gazelle
#

What reason does anyone have to DDoS you, though?

dusk flicker
#

people are weird

wind tulip
shadow gazelle
#

that's true

#

But unless you're going around pissing people off, pretty much no one's going to

kind hatch
#

Me personally, none. At least to my knowledge, but even then. Why ignore best practices? Just because you may not be a target doesn't mean that you might not be in the future.

eternal oxide
#

I've been a dev as long as Spigot has existed. They have never ddos'd me.

shadow gazelle
#

Any websites you go to gets it too Β―_(ツ)_/Β―

kind hatch
#

Besides, it becomes more than just your IP at a certain point. If you aren't careful, you could become part of a botnet without realizing it.

#

Or install something unknowingly.

wind tulip
eternal oxide
#

Yes, if you have a plugin of that name

wind tulip
#

that is the library name

eternal oxide
#

then no, its not a plugin

kind hatch
#

Any reason you can't call JavaPlugin#getPlugin()

wind tulip
kind hatch
#

Oh, it's not a plugin.

eternal oxide
#

It requires a plugin instance. Your library is not a plugin

dusk flicker
#

you could just, being an api, get it through a method var

wind tulip
eternal oxide
#

as it is a library you could use teh SheduledExecutorService

#

yes util method

#

the code you currently have is not really apropriate for its own lib

wind tulip
eternal oxide
#

then your methods need to ask them for a plugin instance (when required) or use Javas ScheduledExecutorService instead of BukkitRunnables

wind tulip
eternal oxide
#

yes

wind tulip
wraith marsh
#

@eternal oxide i sent the files

#

or hastebin links*

wraith marsh
eternal oxide
#

Yes, Rack told you to add sysouts before each if statement

waxen plinth
#

"it didn't work"

#

What happened

wraith marsh
#

i removed the whole code after the method and only added sysout

waxen plinth
#

Don't say "it didn't work" say what happened vs what you expected to happen

wraith marsh
#

it just doesnt show up

waxen plinth
#

Ok so your event listener is not being called

eternal oxide
#

if you got absolutely no output then chect your startup log for errors. your plugin doesn;t sound like it's even running

wraith marsh
#

no errors nothing

#

it is the other listener works

#

its just that specific listener that gives no output

eternal oxide
#

show us the listener with your debug in it

eternal oxide
#

I see no debug messaging

wraith marsh
#

uh wdym?

kind hatch
#

No souts or getLogger()

wraith marsh
#

yeah but the bedevent is the only listener thats not doing anything

kind hatch
#

Well that probably means that the criteria for this line of code isn't being met.
e.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK

eternal oxide
#

use dependency injection instead of trying to import a static reference

#

new PlayerSleepListener(this)

golden kelp
#

Staaaatic abooze

wraith marsh
#

oh ive never done that

#

ill watch a tutorial on it

#

thanks

eternal oxide
#

?di

undone axleBOT
wraith marsh
#

ah

#

but on what line?

#

im not really understanding

#

im using static reference on the task scheduler

eternal oxide
#

read teh basic concept from that wiki link

wraith marsh
#

alright

#

on both listeners or only the bed enter event?

eternal oxide
#

only your bed enter uses a plugin reference

wraith marsh
#

you mean the getPlugin method?

#
public void onPlayerSleep(PlayerBedEnterEvent e) {
  System.out.println("a");
}
#

ive tried this

#

with the static reference

eternal oxide
#

and you see the a?

wraith marsh
#

nope

eternal oxide
#

yep

wraith marsh
#

?

eternal oxide
#

use Dependency Injection to pass a reference of yoru plugin

wraith marsh
#

k

fallow violet
#

i need help

#

How can i save a bukkitrunnable for later?

drowsy helm
#

can make it a class

#

that extends BukkitRunnable

fallow violet
#

an then?

#

the basic stuff?

drowsy helm
#

whats the context

#

you could always just store it as a variable

fallow violet
#

I mean i can just write the methd then?

round agate
#

make a class extends the runnable then store it somewhere else. when you want to run it just call the run method

eternal oxide
#

What do you mean by "save it for later"?

fallow violet
#

like this?

eternal oxide
#

when you start a task you shoudl get an id returned

#

using that id you can cancel the task using the scheduler

fallow violet
#

yes but no

#

xd

#

but it works thanks

wraith marsh
#

i cant get it to work

#

ill watch a tutorial instead and see if i can follow that instead lol

fallow violet
#

wdym?

wraith marsh
#

still nothing

eternal oxide
#

show what you did

eternal oxide
#

looks fine

wraith marsh
#

the other listeners are working as intended

eternal oxide
#

I see nothing wrong in that code

solemn gulch
#

is there a way to check if a creature is undead (like if smite affects them)

wraith marsh
#

should i screenshare to make sure?

eternal oxide
#

No real point. Theres nothing wrong in that code. The sleep listner has no reason not to work

wraith marsh
#

so what do i do?

eternal oxide
#

I assume you get your custom enabled message at startup

#

and your custom join message

wraith marsh
#

yup

eternal oxide
#

does yoru consume listener do anything?

wraith marsh
#

wanna see config.yml?

#

yes

#

its questionable for what it does but yes it works as intended

eternal oxide
#

Then I see absolutely nothing wrong. unless you failed to build the new jar or didn't correctly update the version on your test server

wraith marsh
#

oh right

#

ill see if somethings wrong with that

#

does reload confirm make a difference?

eternal oxide
#

it may. Restart

wraith marsh
#

okay see you when the sun explodes

#

wait what

#

that was the issue all along

#

no way lmao

#

LMAOO i was uploading the file to the host but i wasnt deleting the old one so it doesnt replace it

random kestrel
#

classic

wraith marsh
#

welp im just glad i got to resolve the issue and learn constructor injection
thanks elgarl see ya next time

cinder thistle
#

that's a vibe

golden kelp
#

zhe vibe

dry reef
kindred valley
#

I fixed all the prob by using scanner.nextLine(); before inputting

#

scanner.nextInt(); does not creating a new line

drowsy helm
dry reef
drowsy helm
#

yeah the actual resource pack only has to be white

#

chat colour will colour it for you

dry reef
#

Then we'll have to add 64 Unicode to the resource pack

#

8*8

drowsy helm
#

realistically you only need 1 unicode charcater and 8 negatively spaced characters

drowsy helm
#

you just need 1 unicode character which is 1x1 white pixel

dry reef
#

yeap

drowsy helm
#

then 8 negative spaced characters, (-8, -7, -6 etc)

dry reef
#

hmm okay i try

drowsy helm
#

to position the pixel

#

but its really inefficient

#

and uses up chat length

leaden nebula
#

Hi, I would like to manage the nms well and I wonder if anyone knows of a mapping viewer site

echo granite
#

This is actually what you should do

glossy venture
#

you cant use method sfrom the class in a lambda

#

so youd have to make it an anonymous inner class

golden kelp
#

hi guys, i am making a plugin rn for 1.18. Id also like to run it in 1.8 if that possible. Do i need to make the same plugin twice or is there some hacky workaroud

glossy venture
#

you could use multple modules

#

have a

plugin-base
``` with the code
#

using a

VersionProxy
``` interface or whatever
#

and then implement that in different modules for different versions

golden kelp
#

can you elaborate

#

also, how does one make an array of objects in YAML

#
myRootObj:
  - objOne:
      objData: "never gonna give you up"
      objDataSecond: "rick astley"
  - objTwo:
      objData: "never gonna give you up"
      objDataSecond: "rick astley"

smth like dis?

crimson terrace
#

you could theoretically use json

#

just to give another option

golden kelp
#

i mean, i dont think anyone would want to use json for spigot plugins, as YAML is what a lot of server owners are comfortable with

glossy venture
# golden kelp can you elaborate

so, lets say youre making a plugin to spawn an entity or something and in 1.8 you want to use armor stands, and in 1.18 you use area effect clouds

you have a structure like

plugin-base
  - src/main/java/me/myplugin
    - Bootstrap.java
    - VersionProxy.java
plugin-v1_8_8
  - src/main/java/*
plugin-v_1_18_2
  - src/main/java
``` in this case, the `Bootstrap.java` file contains a class extending `JavaPlugin`, and has a method to get the version proxy, like so:
```java
public abstract class Boostrap extends JavaPlugin {
  public abstract VersionProxy getVersionProxy();

  // all of your other logic
  // you can implement the rest here
}

since we want entity spawning,, we create a class

public interface VersionProxy {
  Entity spawnMarker(Location loc);
}

then, in each version module, you shade/shadow the base into the jar and implement the plugin using the Boostrap class. this is also where you would define your plugin.yml, this is so you can implement the VersionProxy class and pass it, like so:

public class Boostrap_1_8_8 extends Bootstrap {
  public static class Version_1_8_8 implements VersionProxy {
    @Override
    public Entity spawnEntity(Location loc) {
      // do logic
    }
  }

  @Override
  public Version_1_8_8 getVersionProxy() {
    return new Version_1_8_8();
  }
}
#

lol long af

golden kelp
#

bruh u did that πŸ’€

#

thanks <3

glossy venture
#

lmao

#

np

golden kelp
#

i was like, what is this guy doing

echo granite
#

The lambda is an instance of Runnable and not BukkitRunnable, which you need an instance of in order to cancel itself during running

#

That's why I'm proposing an anonymous class

unique spoke
#

hey guys
i have a question, how to add gravity to EntityPlayer? (npc) with nms

#

can anyone help ?

radiant cedar
#

guys how can I make it so that when I press Install in maven

#

I can save these

#

ymls to a specified folder

lost matrix
lost matrix
#

*Unless they are packet based.

unique spoke
#

and i dont wanna use any npc library

lost matrix
golden kelp
#
portals:
  - startCords:
      x: 69
      'y': 69
      z: 69
  - startCords:
      x: 79
      'y': 79
      z: 79

how can I get all the portals?

radiant cedar
earnest forum
#

make a new Location(x,y,z)

radiant cedar
golden kelp
#

No no, I know that, I mean how can I read them from the config

lost matrix
radiant cedar
lost matrix
earnest forum
#

for y and z as well

#

FileConfiguration#getInt

radiant cedar
golden kelp
golden kelp
#

How can I get each startCord section then?

#

like an array of all of them

lost matrix
golden kelp
#

f u c k

#

then?

lost matrix
earnest forum
#

get the config section of "portals" and then loop through

#

using ConfigurationSection#getKeys

golden kelp
#

wait a second

#

ill show my whole config

lost matrix
golden kelp
#

that will help us

#
portals:
  - startCords:
      x: 69
      'y': 69
      z: 69
    endCords:
      x: 169
      'y': 69
      z: 169
    replace: true
    block: STONE
    rewards:
      commands:
        - /give %p% dumbItem
        - /kill %p%
      items:
        - GOLDEN_SWORD
        - DIAMOND_SWORD
      potionEffects:
        - name: FIRE_RESISTANCE
          duration: 69
          level: 4
          particles: true
        - name: FIRE_RESISTANCE
          duration: 69
          level: 4
          particles: true
  - startCords:
      x: 69
      'y': 69
      z: 69
    endCords:
      x: 169
      'y': 69
      z: 169
    replace: true
    block: STONE
    rewards:
      commands:
        - /give %p% dumbItem
        - /kill %p%
      items:
        - GOLDEN_SWORD
        - DIAMOND_SWORD
      potionEffects:
        - name: FIRE_RESISTANCE
          duration: 69
          level: 4
        - name: FIRE_RESISTANCE
          duration: 69
          level: 4
#

thats my whole config

earnest forum
#

what are the dashes for?

lost matrix
earnest forum
#

this part is incorrect

golden kelp
radiant cedar
golden kelp
radiant cedar
#

What is the path to them

golden kelp
#

how should I make an array of objects then?

earnest forum
#

FileConfiguration#getList()?

#

i think thats a thing

golden kelp
#

O

#

ty

lost matrix
#

Alright do what you want... sigh

golden kelp
#

that returns an ArrayList<ConfigurationSection?

golden kelp
radiant cedar
#

Bro just do like
Portals
portal1:
whatever info for portal 1
portal2:
whatever info for portal 2

#

No?

golden kelp
#

Aight

#

yaml is pretty confusing xd

earnest forum
#

im not sure if you can do lists like that

#

with their own info

radiant cedar
#

No u dont

earnest forum
#

dont quote me on that tho

radiant cedar
#

But u can get each info

#

For each portal

earnest forum
#

yea if u use config sections like that

radiant cedar
#

And then create the objects

earnest forum
#

and THEN you can use getKeys

radiant cedar
#

And place them in list after

golden kelp
#
portals:
  - portalOne:
      startCords:
        x: 69
        'y': 69
        z: 69
      endCords:
        x: 169
        'y': 69
        z: 169
      replace: true
      block: STONE
      rewards:
        commands:
          - "/give %p% dumbItem"
          - "/kill %p%"
        items:
          - GOLDEN_SWORD
          - DIAMOND_SWORD
        potionEffects:
          - name: FIRE_RESISTANCE
            duration: 69
            level: 4
            particles: true
          - name: FIRE_RESISTANCE
            duration: 69
            level: 4
            particles: true
  - portalTwo:
      startCords:
        x: 69
        'y': 69
        z: 69
      endCords:
        x: 169
        'y': 69
        z: 169
      replace: true
      block: STONE
      rewards:
        commands:
          - /give %p% dumbItem
          - /kill %p%
        items:
          - GOLDEN_SWORD
          - DIAMOND_SWORD
        potionEffects:
          - name: FIRE_RESISTANCE
            duration: 69
            level: 4
          - name: FIRE_RESISTANCE
            duration: 69
            level: 4

radiant cedar
#

U dont need -

#

I think

golden kelp
#

o

#

i m so dumb

radiant cedar
#

Idk myself I started using them yesterday

#

But I have like 13 ranks with name, bounding box, cost and whatnot

#

All saved and works perfeclty

earnest forum
#
portals:
  portal1:
    coords:
      x: 111
  portal2:
    coords:
      x: 112

for (ConfigurationSection section : config.getConfigurationSection("portals").getKeys(false)){
  player.sendMessage(section.getInt("coords.x");
}


returns:

111

112
radiant cedar
#

Also of u dont mind me asking why is it β€˜y’

earnest forum
#

getKeys returns all the keys inside of the config section

#

so that returns a list of "portal1" and "portal2"

radiant cedar
#

Ye so then u can do for each portal

#

Get keys

#

Which u get the info for each portal

earnest forum
#

yea

golden kelp
#

but i am not sure, i saw it in an online formatter

radiant cedar
#

Isnt it just y location

earnest forum
#

just do y

#

you don't need the quotations

lost matrix
#

This is your general structure.
Now before we can give you any meaningful advise you should answer my question:
How do you generate your yml data?

golden kelp
#

I just wrote it myself

earnest forum
#

i think he's just typed it in

#

yeah

golden kelp
#

and then the server owner can change it for their needs

earnest forum
#

a program can't write that

#

look at my example vinesh

golden kelp
#

oo

#

ty

earnest forum
#

i reckon its easier than lists

lost matrix
#

Then the memory representation of "portals" is a List<ConfigurationSection>

golden kelp
#

ty

radiant cedar
#

@lost matrix i am still very confused on how to open the ymls insid the jar

earnest forum
#

look at a tutorial

radiant cedar
#

Cus rn I have them all in a folder in my computer and

earnest forum
#

for custom yaml files

radiant cedar
#

Thats where I take data from

lost matrix
golden kelp
#
ArrayList<ConfigurationSection> portals = (ArrayList<ConfigurationSection>) vClasses.getConfig()
    .getConfigurationSection("portals")
    .getValues(false);