#help-development

1 messages · Page 50 of 1

lost matrix
#

I personally are at a point where i just pipe everything into one uber Gson instance that can serializer literally anything.
No annotations needed and no need to register any serializer or implement interfaces.

echo basalt
#

I don't use annotations

#

only an interface that's basically a tag

severe oak
#

same, I don't know how to use annotations all like that yet

echo basalt
#

although you can override the save and load default methods to add additional data

#

I can skip the interface directly

severe oak
#

also, same lol.

echo basalt
#

An easier way to do this would be to serialize the class to a json object and then convert all the fields into database params

#

but who wants fancy stuff that gets updated when you can make your ghetto version of it

ivory sleet
lost matrix
#

I feel like json is the serialization gateway to anything

echo basalt
#

who needs unit testing

#

other than actual projects

ivory sleet
#

Integration tests are not unit tests

echo basalt
#

as for integration tests

#

I make sure to save crucial data

ivory sleet
#

But yeah Ig unit tests can be a bit too much sometimes

echo basalt
#

and then see if my game or server crashes

#

and by crucial data I mean stuff like world and chunk data 👍

ivory sleet
#

Hmm I presume that could work, fair

echo basalt
#

if things crash, we fix

#

or another way to do this is to just copypaste this system (it's self-contained, doesn't depend on bukkit or anything) into another project

#

make like 5 sample classes

ivory sleet
#

Yeah tho that sounds like mere unit testing

echo basalt
#

then serialize and deserialize

#

example

#
MyObject object = new MyObject(1, "two", true);

Map<String, Object> map = StorageUtils.save(object);
MyObject deserialized = StorageUtils.load(map);

assert object.equals(deserialized);
#

I mean this will fail for transient data

#

but rest is fine

#

I even make ghetto unit testing

#

and maybe I might toss a
String query = new DynamicTable("data").getWriteQuery(map);

#

obviously I'd cache the table

tender shard
#

just to add: "assert" doesn't do anything, usually

#

assert in normal code is useless

#

it only does stuff when you tell java to enable assertions, which are normally disabled

ornate patio
#

Hello, I would like to know what format to put in mysql. I would like to get all the items with this line [Lorg.bukkit.inventory.ItemStack;@7a80ba30 in a setContents please ?

tender shard
#

whut

#

that's just some generic toString() thing

#

do you want to store an itemstack in a database?

#

I dont really understand your question

tender shard
#

ah okay. you can turn an itemstack to base64 or similar to store it

#

one sec

#

this turns an ItemStack into a base64 string that you can store

#

then just do fromBase64(...) to turn it into an itemstack again

ornate patio
#

Ok, Thank you

severe oak
#

Does anyone know how to remove the annoying mongodb logs in console? I've been trying to for a while to no avail

noble lantern
#

everyone knows im the grammar king

#

how are your all doing today

echo basalt
#

burch

#

remember that project I talked about?

noble lantern
#

crazy frog

echo basalt
#

no

#

the one where I outsourced

noble lantern
#

or the punch punch one

#

uhhmmm

echo basalt
#

for the punch punch guys

noble lantern
#

ah so yes punch punch

#

i do remember

echo basalt
#

so yeah the old dev failed to do his job

noble lantern
#

figures kekw

echo basalt
#

I'm looking for alternatives

#

if you want to write some gangsta backend

#

hmu

tender shard
#

hbu?

noble lantern
noble lantern
tender shard
#

and haven't eaten anything

#

so yeah

echo basalt
#

sounds like you're a developer

tender shard
#

that will change soon though

obsidian drift
#

How does hypixel have this second line above the players head?

eternal oxide
#

armorstands

echo basalt
#

invisible armorstand above head

obsidian drift
#

Would they add the armor stand as a passenger?

eternal oxide
#

no

echo basalt
#

technically they can but it wouldn't allow for much flexibility

obsidian drift
#

so what do they do instead?

echo basalt
#

summon an armorstand and move it equally to the player

#

I wonder if there's a way to do it with packets so there's no 50ms offset

obsidian drift
#

There is no delay when the player moves

quaint mantle
echo basalt
#

yeah that

feral whale
#

Is there any plugin Reduces spawn mop the mops respawning too much that make lag in the server!

echo basalt
#

I swear if I see one more stupid "is there any plugin that ..." question in this channel

feral whale
#

what are you going to do

quaint mantle
#

I'm gonna die ok

echo basalt
#

go after your kneecaps

quaint mantle
#

that as well

echo basalt
feral whale
#

It seems you do it so much that you even ask about it to me

quaint mantle
#

Quick question: I have a custom item plugin, when a player uses a give command, it gives an item stack with an ID in the nbt and lore, name, attributes of that custom item. Now I want to add stack instance specific data, for example, a player can modify the name color per item, or upgrade something about the item.
I first thought of extending ItemStack, but like this isn't Forge lol (This doesn't work because minecraft doesn't know how to deal with it and makes it a normal itemStack again)
Do I really have to keep track of every CustomItemStack instance in every inventory, or is there a better way?

echo basalt
#

uhh

#

Can't you like

#

use PDC or store the custom data within NBT

quaint mantle
#

PDC?

echo basalt
#

PersistentDataContainer

#

it's the native nbt api implemented in 1.14

#

?pdc

quaint mantle
#

I've used it in Fabric, didn't know I could use that in spigot ok

#

Wait

#

I literally forgor about this

#

lmfao im so dumb

#

ok

#

thanks mate

echo basalt
#

No worries

quaint mantle
#

btw, do persistentDataContainer entries show in the nbt idk

#

or can you remove nbt with packets?

#

I don't want the users to be able to extract data from the PDC

#

except the visible part of course

shadow zinc
#

Maven is having a spaz attack trying to download from it and I cant connect

#

ffs it just worked, nvm

#

after 10 minutes

slate trail
#

can sombody help me here

shadow zinc
#

don't ask to ask, just ask your question with full detail

slate trail
#

i cant tho

#

it dosent let me show it

shadow zinc
#

?paste

undone axleBOT
shadow zinc
#

is that what you need?

slate trail
#

can i message you it

shadow zinc
#

what cant you show?

quaint mantle
slate trail
#

oh

#

can i message you so i can show you guys

shadow zinc
#

just verify yourself

quaint mantle
#

also, are you sure you are using the correct channel? You asked for help in #help-server as well..

slate trail
#

how do i verify

shadow zinc
#

no

#

isnt there a channel called verify?

slate trail
#

yay

quaint mantle
#

idk there was

slate trail
#

check help-server

earnest forum
#

!verify

undone axleBOT
#

Usage: !verify <forums username>

earnest forum
#

is the command

slate trail
noble forge
#

I am spawning in a packet entity. When I move away from it it does not unload. However when I spawn in a normal entity and move away from it after a certain distance it is unloaded. Do I need to explicitly despawn the packet entity to remove it from the client or does the client handle it by itself?

slate trail
#

can somebody help me

noble forge
#

but from my experiences right now that doesnt seem to be the case

shadow zinc
#

How can I get all the files inside a folder inside my plugin that hasn't been created yet?

#

like in my resources folder

noble forge
#

you're asking how to get files from a folder that hasnt been created yet?

shadow zinc
#

yeah but its inside the plugin

#

so it does exist

noble forge
#

so how to get files from this folder?

shadow zinc
#

or resources/x

shadow zinc
#

the thing is, they are getting a specific file

#

I need to get the folder and list the files

eternal oxide
#

iyou need to read the package

#

well zip as resources don;t have a package

noble forge
#

What exactly do you mean by reading a folder?

shadow zinc
#

trying it now

azure dirge
#

is there possible way to copy one class to multiple directories in IntelliJ?

shadow zinc
#
            File[] files;
            InputStream inputStream = getClass().getResourceAsStream("/translations");
            if (inputStream != null) {
                try (OutputStream outputStream = new FileOutputStream(files)) {
                    IOUtils.copy(inputStream, outputStream);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                    return;
                }```
#

I got this

#

however

#

whats the way with file output stream with folders?

quaint mantle
#
private void init(){
        ItemStack item;
        item = createItem(" ", Material.BLACK_STAINED_GLASS_PANE, null);

        // item ui setter
        for(int i = 0; i < 27; i++){

            //info
            if(i == 8 || i == 26){
                switch (i){
                    case 8: {
                        List<String> lore = new ArrayList<>();
                        lore.add("§7 Click on the offers to §a§lBuy");
                        lore.add("§7 from the Trader.");
                        item = createItem("§b§l Make a selection", Material.BOOK, lore);
                        inv.setItem(i, item);
                    }
                    case 26: {
                        List<String> lore = new ArrayList<>();
                        lore.add("§7 Click on the offers to §c§lSell");
                        lore.add("§7 to the Trader.");
                        item = createItem("§b§l Make a selection", Material.BOOK, lore);
                        inv.setItem(i, item);
                    }
                }
            }

            // items to trade
            else if (i == 2 || i == 4 || i == 6 || i == 20 || i == 22 || i == 24){
                List<String> lore = new ArrayList<>();
                lore.add("§7 Click on the offers to §c§lSell");
                lore.add("§7 to the Trader.");
                item = createItem("§b§l Make a selection", Material.BOOK, lore);
                inv.setItem(i, item);
            }
            
            // pane decoration
            else {
                inv.setItem(i, item);
            }
        }

    }

no errors just wondering if this is coded efficiently

shadow zinc
#

please use ?paste

sacred scaffold
#

What coding language do you need to know in order to code plugins?

#

Is it JavaScript

tall dragon
#

Java

sacred scaffold
#

Ok

tall dragon
#

or Kotlin

sacred scaffold
#

Okay I’m thinking of learning one I already know python

shadow zinc
#

who tf is making plugins in kotlin?

#
    public static File getFileFromURL(String folder) {
        URL url = ResourceFolder.class.getClassLoader().getResource(folder);
        File file = null;
        try {
            if (url != null) {
                file = new File(url.toURI());
            }
        } catch (URISyntaxException e) {
            file = new File(url.getPath());
        }
return file;
    }```
tall dragon
#

well coulnt be me either

shadow zinc
#

I got this code, but it keeps giving java.lang.IllegalArgumentException: URI is not hierarchical

#

ffs I'll just manually input the files

#

too much bother

eternal oxide
#

what exactly are you trying to do?

#

get a list of resources to extract from your jar?

drowsy helm
#

how does ClientboundTeleportEntityPacket work? the constructor only takes Entity

shadow zinc
#

it was bad tbh

eternal oxide
#

I'd guess its to update teh client of the entities position

drowsy helm
#

ah thats probably it

#

ill give ita try

onyx fjord
#

does protocollib have a skill issue?

#

SERVER_DATA is supossed to have 2 booleans

#

but plib thinks its only one

drowsy helm
#

lmao

#

i gave up on plib a while ago

severe oak
onyx fjord
#

there should be one for enforce secure profile and one for previews chat

drowsy helm
#

is this for your popup canceller?

onyx fjord
#

im testing it on plib

#

to prove someone wrong

#

whatever

drowsy helm
#

i tried to recreate it in plib and couldnt find out how

#

idk if its just not updated or what

onyx fjord
#

my kod

#
        protocolManager.addPacketListener(
                new PacketAdapter(this, ListenerPriority.NORMAL,
                        PacketType.Play.Server.SERVER_DATA) {
                    @Override
                    public void onPacketSending(PacketEvent event) {
                        if (event.getPacketType() ==
                                PacketType.Play.Server.SERVER_DATA) {
                            PacketContainer packet = event.getPacket();
                            packet.getBooleans().modify(1, aBoolean -> true);
                        }
                    }
                });
#

and error ima send in a min

#

btw im on latest 5.0 build

drowsy helm
#

looks like spigot doesnt like setPos for ServerPlayer

onyx fjord
#

long error

#

ima

#

?paste

undone axleBOT
onyx fjord
drowsy helm
#

index of the boolean?

onyx fjord
#

or maybe via being dumb

drowsy helm
#

could be a byte possibly??

onyx fjord
#

in packet events its just a boolean

#

ah

#

viaversion skill issue

chrome beacon
vivid cave
#

hello 🙂 Some questions regarding PlayerInteractEntityEvent & ItemFrames

  1. Is it the correct event to track when some player add or remove item from itemframe
  2. In the event handler body, after verifying that the event.getRightClicked() is indeed instanceof ItemFrame, and casting it to ItemFrame, and then retrieving the item with itemframe.getItem(), this item will be the one BEFORE the player interaction, correct? If I want to get the state of the itemframe (with the updated item) i have to schedule a bukkit runnable to run next tick, and execute itemframe.getItem() once again, am i correct?
chrome beacon
#

Since it's an npc it doesn't have one

drowsy helm
#

yeah

#

it only gives the error after i instantiate it

onyx fjord
drowsy helm
#

i can teleport it wherever beforehand

chrome beacon
#

Override the methods where it tries to use the connection

spark pagoda
#

Why do CB packages include a version number?

chrome beacon
#

🤷‍♂️ Someone decided to do that

#

It was like that for the regular nms package too in older versions

spark pagoda
#

yeah, but nowadays those seem to be under mojang mappings too

eternal oxide
#

as there is no client

drowsy helm
eternal oxide
#

no

#

do you have an NPC class that extends ServerPlayer?

drowsy helm
#

yeah

#

it says ServerGamePacketListener is public but i cant access it

eternal oxide
#

then add to yoru constructor this.connection = new NetworkHandler(minecraftServer, new NetworkManager(PacketFlow.CLIENTBOUND), this);

drowsy helm
#

oh im dumb

#

thanks

eternal oxide
#
public class NetworkHandler extends ServerGamePacketListenerImpl {
    
    public NetworkHandler(MinecraftServer minecraftserver, Connection networkmanager, ServerPlayer entityplayer) {
        super(minecraftserver, networkmanager, entityplayer);
    }
    
    @Override
    public void send(Packet<?> packet) {
        // Empty as we never want to try an send packets to a fake player.
    }
}``````java
public class NetworkManager extends Connection {
    
    public NetworkManager(PacketFlow enumprotocoldirection) {
        
        super(enumprotocoldirection);
    }
}```
drowsy helm
#

oh thats super easy then

#

thanks

obsidian drift
#

The packet ClientboundSetEntityMotionPacket has xa, ya, za integers in it. I assume this is where the entity is moving to but these are integers. Is there any way to turn these values into doubles to get an accurate idea of where the entity is moving to?

#

Nevermind, found out it is velocity not location

glossy scroll
round finch
#

yo how do I get the title of a Inventory

#

i want to compare the name

chrome beacon
#

Why do you want to compare the name

#

I hope you're not planning on using that to detect your inventory

round finch
#

shit you right..

severe oak
chrome beacon
#

I recommend comparing inventories by their InventoryHolder or even better the inventory instance

round finch
#

i could just take the inventory and compare them

ignore the entire name thing

severe oak
#

Anyone know how to remove mongodb console logging?

opal juniper
#

i assume you have to set the level

sterile token
#

Also a small research on google tells that

#

There are some questions that can be found on stackoverflow with small research

drowsy helm
#

pretty sure mongo logger is funky with spigot

#

most of the stuff on google doesnt work

severe oak
sterile token
#

Oh yeah I agree that

#

Im using mongo with spigot and i have data loading errores

#

For example all data works perfects during first sever starting and on second it doesnt

severe oak
#

Note to self to never use reflections again. This shit gives me headaches

magic raptor
#

Hi, how am i supposed to get deep in bungeecord?

eternal oxide
#

keep diggin?

magic raptor
#

Be serious, i can't find anything related on it

#

Since getKeys(true) doesn't exist

eternal oxide
#

what is "get deep"?

#

oh you are talking about the config

magic raptor
#

Let's suppose i have this

section:
test1:
- value1
- value2
test2:
- value1
- value2

i need to get that values under keys

severe oak
#

nested values?

eternal oxide
#

yeah, bungee config is a pain

#

it doesn;t give you access to teh backing map

severe oak
#

iirrc, getNested?

magic raptor
#

what's getnested?

severe oak
#

or its getConfigurationSection, lemme look at docs rq

magic raptor
#

i need to do a task that automatically adds the values into a list

#

that's why i'm asking, i can't do like on spigot using getKeys(true)

quaint mantle
#

I need help with making a plugin dm me

magic raptor
#

why md5 didn't put the same methods as spigot on bungee, just why, anyway, any solution?

eternal oxide
#

I made a PR to bungee to addjava public Map<String, Object> getSection() { return Collections.unmodifiableMap( self ); }But it was rejected

eternal night
#

at least you got the format down

magic raptor
eternal oxide
#

all you can do is getSection(String path)

#

I myself use a modified bungee config code to implement my own method

magic raptor
#

i just wanted to make a task that every X seconds picks those values and adds them into a list

eternal oxide
#

The only easy way is use getKeys and iterate it

#

as it returns return new LinkedHashSet<>( self.keySet() );

magic raptor
#

show me an example if you can and want

#

i'm thinking something meanwhile, i hate bungee config

eternal oxide
#

I can;t at the mo, too busy RL

magic raptor
#

no problem

eternal oxide
#

or just mod Configuration.java as I did

magic raptor
#

can't, the plugin isn't for me

eternal oxide
#

yes you can

#

you literally import 4 classes from Bungee

#

include them in yoru code and thats it

magic raptor
#

ah i tought you wanted to make me mod bungee itself

supple elk
#

are gamerules universal or do they only apply to a single world?

tender shard
#

I'll totally accept this deal

alpine urchin
#

@quaint mantle I'll accept 500

tender shard
#

I mean

alpine urchin
#

if you pay beforehand

tender shard
#

this is sooo much money

quaint mantle
ivory sleet
#

This is not the channel for services and recruitment

#

?services

undone axleBOT
quaint mantle
#

I cant open it says and error

tender shard
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

ivory sleet
#

Thats not really an excuse though

tender shard
#

@ivory sleet You haven't read their extremely detailled error message

#

obiouvlsy they said it has "error"

ivory sleet
#

Mustve missed sth then, goes w/o saying looked like it turned into a topic that doesnt belong here

tender shard
#

haha yeah

#

I tried to compile this in my java IDE but it keeps saying Error

quiet ice
#

what the hell is this

peak depot
severe oak
#

Going insane rn

eternal night
ebon stratus
#

do mixins work in spigot? or any way to modify nms?

eternal night
#

no spigot does not support mixins

ebon stratus
#

any way to modify nms then?

eternal night
#

beyond reflection ?

worldly ingot
#

Bukkit's goal is to try and prevent you from doing that by providing API

#

What are you aiming to achieve here?

ebon stratus
#

a lot..

chrome beacon
#

There are projects to load Mixins on your server

eternal night
#

ignition or smth

chrome beacon
#

Ignite

worldly ingot
#

Yeah, I mean you can make use of Mixins if you want, they're just... not really supported

chrome beacon
worldly ingot
#

You're inevitably going to break something

errant narwhal
#

i think this looks crazy but can we make a plugin that can play cutscene in resource pack file to player? like make player see mp4 file inside game without mod?

chrome beacon
#

You can use maps to play video

errant narwhal
errant narwhal
ebon stratus
#

is it ok to make a fork of spigot ? and if it is, do i need to set some kind of license or anything?

chrome beacon
quiet ice
#

I'd especially advise against forking spigot as the toolchain was not meant to be used as a fork

ebon stratus
#

ok

quiet ice
#

Plus bukkit's API is pretty good for many things, but if you want to do some things such as adding blocks I wouldn't even recommend daring to attempt it in the first place

round finch
#

||Custom Models is always a option just saying||

alpine urchin
#

there's no LGPL

#

there was a mistake in the commit name, but the LICENSE.txt was GPLv3

quiet ice
#

Yes, de-facto it is GPL given that it depends on a GPL license, but I was sure that it was LGPL...
Lemme check

#

?stash

undone axleBOT
quiet ice
desert frigate
chrome beacon
#

I think it's the default stone break sound

#

Could be wrong

desert frigate
#

the BLOCK_STONE_BREAK sound is the sound of it broken

#

wait it might be BLOCK_STONE_HIT

round finch
#

SPAM HIT Stone Sound

simple turtle
#

How do I get hints such as the vanilla /time command? I tried using commodore to leverage the brigadier command parser and dispatcher, but couldn't get the hints to show on my paper server (both 1.19 and 1.19.2), I've asked in their discord, but looks like there might be an already open issue on the problem, so I'm looking for alternatives. In the screenshot I'm looking to get the <time> to show, but without it being in the tab to complete options.

chrome beacon
#

Yeah Commodore or using Brigadier directly is how you do it

quaint mantle
#

Fuck you too ❤️

round finch
#

tru luv

simple turtle
sacred basin
#

Hello, I have a question.

If I don't remove many registered event listeners, will they remain in handler list and cause a memory leak?

desert frigate
#

i slowed it by 7 ticks and now it sounds good

#

is is possible to make mobs AI follow another entity?

wide coyote
sacred basin
tardy delta
#

how is this null :/

wide coyote
#

because it is not something you should do, handling events and listeners is spigot's (bukkit's) job and just let it do its job
still, you can remove your listeners if you want to but you don't have to, they get deleted after restart anyways

severe oak
wide coyote
#

your listeners also gets removed when your plugin is disabled

real blaze
#

alright, how do i get when an item is destroyed by fire/lava?

#

because entitydamagedevent wont cut it

#

because there is a way of triggering the entitydamagedevent with an item and not have the item get destroyed

civic apex
#

when compiling my mojang mapped nms pluggin using SpecialSource I dont get the -remapped.jar (i get the 3 other jars tho). If i look at the output of running package I see that specialsource tried making it

[INFO] Replacing .../target/plugin-1.0-SNAPSHOT.jar with .../target/plugin-1.0-SNAPSHOT-remapped.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------```(btw there are no more errors after that and the `.../target/plugin-1.0-SNAPSHOT-remapped.jar` simply does not exist)
desert frigate
#

how can i make it so specific items cannot burn in lava or be destroyed?

tardy delta
#

mmmyes here bossbar is not null and suddenly it becomes null :/

#

tf this is weird

sacred basin
# wide coyote your listeners also gets removed when your plugin is disabled

That means the registered listeners are not removed periodically but removed when the server disabled?

I'm in a position to choose between two options

  1. Register event listeners in every new instance. This code will be simple.
  2. Register listeners once and pass event to the every new instance. But code becomes complex.
wide coyote
#

what are you trying to do exactly

#

because one of us got it wrong

vivid cave
#

PlayerInteractEntityEvent & ItemFrames

#

if someone can help me on that^ 🙂

sacred basin
#

I'm making a minigame framework plugin.

So if new minigame is created then must be removed. And it needs event handlers.

wide coyote
#
  1. you can do some checks in your event listener about the game status and etc
  2. you can remove and register the event listener
    it is up to you but I would go with the option 1 since it is simple and second way may get you in trouble with your code
tardy delta
#

dont implement a new listener for each minigame objects pls

wide coyote
#

^

real blaze
tardy delta
#

tf this doesnt give me any errors but it prints out null

#

does it make any difference that it is a transient variable?

quaint mantle
tardy delta
#

yes hes a girl

sacred basin
errant narwhal
quaint mantle
errant narwhal
#

No

real blaze
#

where's the outdated build tools pin?

dry forum
#

is it possible to add methods to existing spigot classes? its kinda hard to explain but my plugin is made in 1.15 but i want to support 1.12+, but im using .getLocation which was added in 1.15, so when i try to use the plugin in 1.12 it gives an error saying .getLocation doesnt exist, so i want to know if theres a way i could extend a class and make my own getLocation method?

eternal night
#

no

#

kotlin has extensions

#

in java, no

#

and in kotlin it is only syntactic sugar anyway

dry forum
#

ah thats anoying is there any other way around this?

civic apex
#

where does .getLocation() not exist

dry forum
#

im talking about the file configuration one

civic apex
#

oh, I wrote my own Location parser

eternal night
#

easiest way to do this is to depend on the 1.12 api

dry forum
desert frigate
#

how can i set the state of a wheat seed?

civic apex
desert frigate
dry forum
civic apex
#

Location <-> String

civic apex
dry forum
#

yeah but with that id need to redo all of my code involving setting and getting locations though

civic apex
#

"redo all my code" as in changing .getLocation to parseLocation(.getString())

dry forum
#

yeah

civic apex
#

well yes

#

shouldnt be too much of an issue

dry forum
#

80% of my plugin relies on that

#

and its quite a big plugin

fiery prairie
#

so umm i deleted my project file accidentaly, brought it back from github but since it is now a new project, i am not able to publish the project changes i just made on the same github repository as the old project, cause the repository already exists. how can i upload my changes to github now, to the same repository?

civic apex
#

whats the problem

dry forum
#

id be copy pasting stuff for hours

civic apex
#

bruh

fiery prairie
#

visual studio code

dry forum
#

uhh no?

civic apex
#

you are looking for a solution that involves not changing anything then

dry forum
fiery prairie
#

cause you could copy all the code into vscode, and click ctrl+f and get an option to replace all "text" with "newtext"

civic apex
#

this is also an easy way

fiery prairie
#

do you at least have notepad++

dry forum
civic apex
#

you could ctrlf it

fiery prairie
#

well yea thats the problem

desert frigate
#

which one isnt deprecated? lol

fiery prairie
#

intellij doesnt allow replacing using ctrl+f

civic apex
#

also you could change your fileconfiguration implementation

civic apex
dry forum
#

alright ill try it thanks

fiery prairie
civic apex
#

how do you not know how to replace text and you have a big plugin

fiery prairie
#

idk, also it doesnt work for me

dry forum
#

who me?

civic apex
#

yes

dry forum
#

idk i dont rly pay attention to ide controls and stuff

severe oak
civic apex
#

since its a mess to mantain

fiery prairie
desert frigate
#

i cant seem to find a way to change the stage of a seed crop

dry forum
#

1 class in my plugin has 2k lines :p

severe oak
civic apex
#

how many classes does your plugin have

dry forum
civic apex
#

bruh.

dry forum
civic apex
#

why dont you split more

#

on files

dry forum
#

i do

civic apex
#

no you dont

dry forum
#

i do

civic apex
#

you got a 2k line file

dry forum
#

thats 1 file and its for the main library

civic apex
#

still 20 are few classes

#

for one of them to be so big

dry forum
#

meh

severe oak
dry forum
#

just counted them and its 28 classes

severe oak
#

nothing close to yall 2k lines

civic apex
#

2k is just too much

dry forum
#

started this plugin like 1 1/2 years ago on and off so some it could be reduced

civic apex
#

do you have copy pasted code?

dry forum
#

wdym

civic apex
#

same code in 2 different places

dry forum
#

no not rly

civic apex
#

(same as in basically the same)

fiery prairie
#

so umm i deleted my project file accidentaly, brought it back from github but since it is now a new project, i am not able to publish the project changes i just made on the same github repository as the old project, cause the repository already exists. how can i upload my changes to github now, to the same repository?

desert frigate
#

how can i check if a block is a wheat?

#

like if a player put wheat seeds there

tardy delta
#

check the block type

severe oak
desert frigate
#

yeah it works

#

ty

#
                            org.bukkit.block.data.Ageable ag = (Ageable) blockData;
                            ag.setAge(1);
                                ``` why doesnt this code work? it doesnt have errors but it just doesnt change the age of it
severe oak
#

block.setBlockData(ag); according to docs.

desert frigate
#

ah im stupid, i was looking at docs and didnt see the last line

#

thanks

severe oak
#

No worries, you'll get it.

desert frigate
#

since Crops is deprecated, what else do i use?

#

Crops crop = (Crops) e.getBlock().getState();
if(crop.getState().equals(CropState.RIPE)) {
}

eternal oxide
#

ageable

desert frigate
#

ah thanls

real blaze
severe oak
real blaze
severe oak
#

"not have the item get destroyed"

real blaze
#

oh read the rest of the pretense above that lol

#

the issue was that it wasnt getting destroyed

#

essentially if you:

  • put a block over a hopper minecart
  • throw item at block
  • just before it gets sucked up, set it on fire
    this triggers the EntityDamagedEvent and has a chance of the item not getting destroyed due to getting picked up
#

solution was to set the itemstack to 0 after the check to force it to no longer exist

craggy plover
#

how do you register a gui in the main class?

chrome beacon
#

Depends on what you mean by register

craggy plover
#

like its in a seperate class how do i make it work

severe oak
chrome beacon
#

?learnjava

undone axleBOT
hybrid spoke
#

does any1 know a resource for "scrollable" inventories?

#

otherwise i will have to make one

supple elk
#

Does anyone know why the worldfile isn't deleting? It's worldfile.delete() which is not working

#

I'm guessing the server may still be accessing it?

#

but which part

#

I've already unloaded the world

fiery prairie
#

what should I choose here to compile the plugin into projectfolder -> target -> ?

severe oak
supple elk
#

returns false

#

hence why I think it's the issue

#

unloadWorld returned true

#

I printed this before

#

got that

#

oops didn't show the full thing

#

there was another print of b1 at the end

#

basically false is the result of delete()

severe oak
#

SecurityManager.checkDelete() log this before you delete the world

supple elk
#

ok thx

severe oak
#

it just checks if you're allowed to delete the file

supple elk
#

How do I know what's stopping it from being deleted?

#

if that is the issue

#

it's depracated

#

but I'll try anyway

severe oak
#

lol ofc its deprecated

#

Bukkit.unloadWorld(world, true); should fix your issues

supple elk
#

doesn't that just make it save?

eternal oxide
supple elk
#

a clone of a world which I no longer want

#

not the main world

eternal oxide
#

k

#

I do a task to delete it

severe oak
supple elk
#

I see

eternal oxide
#

one sec

#

ide opening

#
    private void deleteWorld(String worldName) {

        World world = Bukkit.getWorld(worldName);
        File worldFile = world.getWorldFolder();

        if (Bukkit.unloadWorld(world, true)) {
            new BukkitRunnable() {

                int maxAttempts = 50;

                @Override
                public void run() {

                    try {
                        FileUtils.deleteDirectory(worldFile);
                        maxAttempts = 0;
                        createWorld();
                    } catch (IOException e) {
                        Bukkit.getLogger().log(Level.SEVERE, e.getMessage());
                        maxAttempts--;
                    }
                    if (maxAttempts <= 0) {
                        this.cancel();
                    }
                }

            }.runTaskTimerAsynchronously(plugin, 20, 20);
        }
    }```
tardy delta
#

got some weird issue lol

#

this seems to work but when i access the bossbar later on, its null :/

#

no errors on this code

severe oak
#

skillProgressBar?

tardy delta
#

ye shut up 🙄

#

jk

severe oak
#

Is it null when you construct the instance? or just later on?

#

actually nvm

#

make sure you're not overriding the field

tardy delta
#

i added debug code in the constructor but its not triggering lol

severe oak
#

Did you make a new instance of the class?

opal juniper
tardy delta
#

i'm makign a new instance when loading the player and currently the loading code works :/

opal juniper
#

what’s the purpose of transient there @tardy delta ?

tardy delta
#

damn gson

#

the stuff would try to serialize the bossbar lol

opal juniper
#

ah ok

#

i didn’t realise that you were using gson

tardy delta
#

nice debug code doesnt get printed

#

gson calls the constructor i hope 🥺

#

actually....

severe oak
#

I don’t see any usages

#

It should say at least 1 usage above your constructor

#

Right click and press “Find Usages” (on the constructor)

opal juniper
#

if it’s internal to gson it wouldn’t find then

tardy delta
#

so gson doesnt give a fuck bout my constructor 🤔

severe oak
#

Also, this is kinda nitpick but if iirc doesn’t Bukkit.broadcastMessage() send the message to every player? I’d recommend Bukkit.getConsoleSender().sendMessage()

#

(It only sends the message to console)

opal juniper
#

they are just debugging

#

lol

tardy delta
#

lets try liek this

#

my old code is hitting me with a knife in my back lol

#

delayed removal cache smh

supple elk
#

Getting this

severe oak
misty ingot
#

is there a way to make a loop which will take a value from a database every x seconds and then set a player's level to that value? (bungee) I just need help with the loop part, I need to start the loop when the player joins and stop it when they leave

supple elk
#

That's with saving too

severe oak
daring lark
#
        dataPath = plugin.getDataFolder() + File.separator + "data" + File.separator + "playerMenuUtility";
        File folder = new File(dataPath);
        if(!folder.exists()) folder.mkdirs();
        for(PlayerMenuUtility utility : utilities) {
            File file = new File(dataPath, utility.getOwnerId() + ".yml");
            Utils.createFile(file);
            FileConfiguration config = YamlConfiguration.loadConfiguration(file);
            config.set("menuMode", utility.getMenuMode().toString());
        }
    }``` am i need to do something more to write stuff to file? cause my file is empty but it's created
misty ingot
chrome beacon
supple elk
eternal oxide
#

then do it on startup instead, in onLoad() if Bukkit.getWorlds().isEmpty()

#

means no worlds have been loaded yet, so you can delete any you want

tardy delta
#

lets implement a proper database instead of using gson 🥺

severe oak
# misty ingot .

Bungee has an task scheduler that you can use or you can use Timers

misty ingot
#

well I cant find the bungee task scheduler

severe oak
#

Either way, I’d advise not to implement what you’re asking

misty ingot
#

well I just want to show a custom value on the player's exp bar which is kept up-to-date

#

how would you recommend I do it?

tardy delta
#

just reloading your shit instead of querying it every time3

severe oak
#

^

#

Only update when you need to

misty ingot
#

hmm I guess I could just connect up all the points at which the value can change and just make the level bar change then

tardy delta
#

ah yes it not even working

vocal cloud
#

That's gross

tardy delta
#

in other words: i was too lazy to write a db impl

fervent prawn
#

How can I get this name?

tardy delta
#

isnt there an ItemStack#getLocalizedName or smth?

tardy delta
#

idk lol

#

ah ask godcipher

#

😈

vocal cloud
#

Probably by getting the brewing stand from the event and reading the inventory

desert frigate
#

what do i use since event.setCursor is deprecated

opal juniper
#

whats the screaming sandals nms repo

desert frigate
#

u need a Location

cold tartan
#

how would i create a map that worked like Map<Class<? extends Event>, functioToDoWithEvent> mapThing?
So if I did mapThing.put(playerEventClass, getPlayerFunction)
then mapThing.get(playerEventClass) i would get the player from that event back

#

is it through consumers?

rapid hill
#

How to setup and use Hikari Pool Connection?

cold tartan
#

something like this:

Map<Class<? extends Event>, Function<Event, Player>> test = new HashMap<>();
            test.put(PlayerEvent.class, ev -> ((PlayerEvent) ev).getPlayer());
eternal oxide
#

why store under a class? you can only have one instance then

tender shard
#

SecurityManager ?!

tender shard
chrome beacon
#

They might just be the vanilla translation of the inventory

#

Not a custom title

#

Which mean they have to include the translation file in their plugin to get the name

vivid cave
#

server starts up, i want to retrieve all the entities that were loaded for some reason, in what event should i do that?

#

Does EntitiesLoadEvent covers startup too?

chrome beacon
#

It should yeah

rotund pond
#

Hello everyone 👋
I have a question about spigot custom events.
What are handlers exactly ? What are they supposed to do ? How can they be useful ?
Do you have a comparison to understand this ?

Thank you ^^'

chrome beacon
#

Do you mean the HandlerList?

eternal oxide
#

anyone listening to the event is in the Handlers list

vivid cave
#

is there a builtin set containing all the blocks that we can SEE through (not fully opaque), such as glass, cobweb, water, etc

eternal oxide
#

yes

#

somethign like Material#isTransparent()

vivid cave
#

damn really thats making it a lot more easyier for me :d

#

making custom ray tracing (i don't like the RayTrace classes of bukkit)

rotund pond
rotund pond
eternal oxide
rotund pond
eternal oxide
#

no, its not for you to do anything with

#

well, you could see every plugin thats listening to your event

formal bear
#

Whats wrong?

eternal oxide
#

java version

formal bear
#

okay i fixed it

#

shade version

simple shale
#

Hi are you allowed to request plugins lol

eternal oxide
#

?services

undone axleBOT
round finch
#

yo what is the proper way to get Inventory from config?

#

or should i save items?

river oracle
round finch
tender shard
round finch
#

Custom Inventory

tender shard
#

inventories aren't seriazable

#

they are basically only an array of itemstacks + a title anyway

#

so just recreate your inventory

iron glade
#

I'm trying to make some methods < 1.18 compatible, would this be a good method to get the max build heigth?

    public int getMaxBuildHeight(World w) {

        if(w.getEnvironment() == World.Environment.NORMAL) {

            return Bukkit.getVersion().contains("1.18") || Bukkit.getVersion().contains("1.19") ? 319 : 255;
        }
        return 255;
    }```
lime moat
#

What would the best GUI library be?

iron glade
lime moat
#

I'll take a look :)

iron glade
chrome beacon
iron glade
chrome beacon
#

Yeah

#

What about ir

iron glade
#

I wanna get the max build heigth, means the last block you can place a block

chrome beacon
#

Yeah it's that

iron glade
#

doesn't sound like that

ancient plank
#

but it is

#

how does it not sound like that

iron glade
#

wouldn't that return like 120 if the highest block is at 119?

chrome beacon
#

Then just use - 1 on it?

iron glade
#

but i dont wanna get 119

#

i wanna get the maximum allowed building height

#

256 or 320 since 1.18

chrome beacon
#

Which is what that method does

ancient plank
#

-1

iron glade
chrome beacon
#

No

#

It's just an example

#

You can lower the max height

ancient plank
#

^ in the properties file

iron glade
#

ahhh now we talking

#

didn't know that

#

so since this method is also available in 1.19 I can just always use it I guess

atomic violet
#
        scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                
                for (Player players: Bukkit.getOnlinePlayers()) {
                    System.out.println(players);
                    List ents = (players.getNearbyEntities(500,50,500));

                    for (int i = 0; i <= ents.size(); ++i) {
                        if (ents.get(i) instanceof ArmorStand) {
                            System.out.println(ents.get(i));
                        }
                    }
                }
            }
        }, 0L, 100L);
    }```
#

any reason why this code would only be printing the result of 1 player in the server (the first person on the list for Bukkit.getOnlinePlayers)

#

cause even if my friend joins the server, it only prints my name, and the two armor stands i have placed down, and stops there, it doesnt do my friend at all

#

and if i leave it switches to printing his name and the stands every 5 seconds instead

#

even if i join back

#

i also screenshotted my server console if you need that but theres no errors

iron glade
#

why you print players

#

and not players.getName()

atomic violet
#

to figure out the issue

waxen plinth
#

You don't need the longhand syntax for runnable

iron glade
#

also lambdas are a thing

waxen plinth
#

Yep

#
() -> {
  // Your code here
}```
atomic violet
#

ah okay

waxen plinth
#

Instead of

ancient plank
#

lambda cring

waxen plinth
#
new Runnable() {

  @Override
  public void run() {
    // Your code here
  }

}```
#

The two are identical in this context

iron glade
#

lambda is love

atomic violet
#

and about the for loops? i still dont know why theyre broken and not printing right

#

i have code i want to run and stripped it all to figure out why its not iterating through all players

iron glade
waxen plinth
#

It's running every 5 seconds

atomic violet
#

ik

ancient plank
#

?jd

atomic violet
#

i did that to figure out why its not printing all players

waxen plinth
#

Why don't you just do System.out.println(Bukkit.getOnlinePlayers());

#

Oh wait a second

#

I know why it's only printing one

#

You get an exception, don't you?

atomic violet
#

because i want it to print the first player, list the nearby entities, and then print the next one, etc

ancient plank
#

redempt brain moment

sterile token
waxen plinth
#

for (int i = 0; i <= ents.size(); ++i) {

#

You do <=

sterile token
#

Oh no bruh dont use shities index for

waxen plinth
#

Since indices start at 0

#

The last valid index of a list is one less than its size

tender shard
waxen plinth
#

Meaning you're trying to access an invalid index at the end of this iteration

tender shard
#

sorry but thats the best thing I could come up with

iron glade
#

You can also replace the online players for loop with

                             Bukkit.getOnlinePlayers().forEach(player -> {

                                    getLogger().info(player.getName());
                                    //do more stuff
                                    

                                });```
waxen plinth
#

So your code prints one player, runs into this exception, and exits

atomic violet
#

oh wait

#

so if there was 3 players, it would do 2 players and stop?

waxen plinth
#

No

#

It prints the player before attempting this loop

#

But this loop always fails

#

So it only ever gets one player in before throwing an error

#

For future reference, if an error is being shown in console you should always include it with your code

#

It's pretty vital information that would have made debugging this easier

#

Seeing <= vs < is a pretty minor difference and many people here will only skim the code, not read it that closely

#

I would have missed it if I didn't read it extra closely

#

But if you had shown the resulting exception, we'd have all been able to immediately identify where the issue is

atomic violet
#

well i screenshotted it but i cant add images for some reason :/

#

i wouldve added it

waxen plinth
#

You can just copy-paste the text

atomic violet
#

oh yeah thats true

ancient plank
#

screenshots are cringe

iron glade
#

?paste

waxen plinth
#

To post images you have to verify your spigot account

undone axleBOT
atomic violet
#

thanks for the help

waxen plinth
#

As in, link it to your discord

#
Bukkit.getOnlinePlayers().stream().peek(System.out::println).flatMap(p -> p.getNearbyEntities(500, 50, 500).stream()).forEach(System.out::println);```
atomic violet
iron glade
#

As I haven't touched it in years, are there built in commands to change a server's motd?

#

Or is it like in some configuration file?

vivid cave
round finch
waxen plinth
tender shard
#

Bukkit and Server have a method "getMotd" but no "setMotd"

#

so, yes, you need to change it using NMS, there's no other way

ancient plank
tender shard
ancient plank
#

Ye but it exists

tender shard
#

well, I mean

#

of course it would change it, for the player who just "pinged"

#

which is probably what they are looking for lol

#

so

#

yeah

#

What are you trying to do exactly @iron glade

grim ice
#

ServerListPingEvent

quaint mantle
#

hello. i am trying to code a simple /discord command. i am extremely new to this stuff and a lot of times, i have no clue what im doing. everything worked perfectly until i tried to make it configurable. i watched around 2 or 3 tutorials however all of them said different things. what im trying to do is grab text from the config and add it on to a message that im sending to the player. whenever i load into my test server and do /discord, nothing shows up. not even in the console. i am very confused about what i did wrong. if anyone could help me in the right direction, that would be amazing. i can provide my code if needed

grim ice
#

.setMotd

vivid skiff
#

How can i make wait a player from right clicking another player, for example i click another player with a stick and i have to wait 10 secondo to re click the player

delicate lynx
#

save the time in milliseconds on first right click, check if it's been 10 seconds if they click again

vivid skiff
#

Ok, thanks

tender shard
#

just do ?paste

#

then paste your code there

iron glade
tender shard
iron glade
#

aight, will do so, thx

tender shard
round finch
#

why do one get a win error on creating yaml configuration

round finch
#

gimme sec tired

tender shard
#

ok 😄

round finch
#

/paste

#

!pastebin

#

i forgor

#

@tender shard how i get the md5 paste

#

i forgor command

undone axleBOT
round finch
#

ty!

#

wtf is java.io.WinNTFileSystem error

#

sorry i just came back after so long to code

#

i had similer problem before

vivid cave
#

Is there a way to report sth without going through JIRA?
I'm lazy as fuck
Well if anyone wants, i think that Material.BARRIER.isOccluding() should return False (it's a block & we can see through) and that Material.GLASS.isTransparent() should return true (light can go through)

azure hawk
#

How can i open an inventory, then the player puts some items in it and on close it gets saved. After the close a message get send with all the items so like "1: Grass Block, 2: Stone 3....". Do you guys have any idea how that could work?

desert frigate
#

Is it possible to use persistentDataContainer on a player?

#

or another way of saving data on a player without the use of external databases

quaint mantle
undone axleBOT
quaint mantle
#

the message in that code is not sending at all and im not getting anything in the console

round finch
#

OH a player
message link

lime moat
#

I can send the wild code if needed too.

lime moat
#

Huh

#

Oh, wait, I may be dumb

#

One second

#

Yep, I just forgot Teleport teleUtil = new Teleport(this); :P

#

Fair enough, I'll do that, thank you!

sterile token
#

Abusing static methods make you looks a bit unexperienced also

#

We are not swearing you, just given recommendations that you learnt from experience

tender shard
#

did you already get it fixed?

quaint mantle
#

its perfectly fine. i did not. ive been at it all day haha

tender shard
#

what exactly is the problem?

#

any error messages in console?

#

btw why are you using a list for the discord command?

#

I assume that you only have one discord link, right?

#

and not like 20

quaint mantle
quaint mantle
tender shard
quaint mantle
#

?paste

undone axleBOT
quaint mantle
#

i went off of a youtube tutorial so it might be a little odd

tender shard
quaint mantle
#

im on 1.19

tender shard
#

try to wrap your whole onCommand method into a try/catch block

onyx fjord
#

Dumb why did they do that

tender shard
#

like this:

public boolean onCommand(....) {
  try {
    doYourStuffHere();
  } catch (Throwable t) {
    t.printStackTrace();
  }
}
tender shard
#

but it's really like that

#

you now have to manually try/catch all your onCommand stuff

#

otherwise it simply ignores any exceptions

tender shard
quaint mantle
quaint mantle
#

okay ill try that and hopefully ill get something in console

tender shard
#

basically everything you already coded goes into "doYourStuffHere()"

quaint mantle
#

alright. ill attempt that

cunning canopy
#

if I have a private class hashmap and a public getter. if I do class.get("bleh").replace("bleh", "blah") will the private change too?

tender shard
#

erm

#

I dont really understand this question

#

can you try to explain it again

cunning canopy
#

is it the same object

#

if I have a private var in a class

#

and a public class.getPrivateVar

ornate patio
#

is spigot for 1.19.2 released?

#

or is it compatible with 1.19.1

tender shard
#

it would normally return the exact object

cunning canopy
#

If I change something in the .getPrivateVar() will it change

tender shard
cunning canopy
tender shard
cunning canopy
#

nice, thanks

ornate patio
tender shard
#

np

sterile token
cunning canopy
quaint mantle
sterile token
#

I think its something:

Map<Key, Value> bla = new HashMap<>();

public Map<Key, Value> getMap() { return new HashMap<this.map>()}  ```
sterile token
#

I dont want to sound rude

onyx fjord
#

Just add }

tender shard
tender shard
quaint mantle
onyx fjord
#

It'll tell him to return

#

In ij

#

And will quick fix

tender shard
#

the onCommand method WANTS YOU to return a boolean. So yeah, add "return true;" at the end, and then add the missing closing } bracket

#

if it still doesn't work, show your whole class please

quaint mantle
#

i fixed it

sterile token
# quaint mantle i dont mind lmao. im extremely new

Oh ok, nice to hear that i will say some useful recomendations:

  1. Learn about the IDE you are using

  2. Is to learn java like correctly (Watching tutorials or reading about it features, etc and by coding project practicising what you have learnt)

  3. Start learning about apis and libraries (Database ones, utilities ones, etc)

quaint mantle
quaint mantle
torn shuttle
#

There's a guy who has seemingly taken upon himself to go around asking devs to tag Russian translations of plugins with [terrorist state] on spigot

tender shard
#

do you get NO RESPONSE AT ALL?

#

not even the plugin sending it's usage string?

torn shuttle
tender shard
#

lol

torn shuttle
#

Who knows maybe Mr Putin really loves elitemobs and upon reading that I tagged the Russian translation would immediately stop the war and see the error in his ways

acoustic oak
#

Not sure if this is the right channel, I lost access to my paid resources? It says I have none but i definitely purchased some

dusk flicker
#

Not really anything we can do; Contact the plugin author, if not, contact the Staff Team

#

?email

undone axleBOT
acoustic oak
#

Thank you

compact haven
worldly ingot
floral drum
#

uwu hi mr chocolate

dusk flicker
#

lol

#

oml I didnt even realize you said mr. chocolate lmao

floral drum
#

I used to say it all the time

torn shuttle
worldly ingot
#

Lol

floral drum
#

uwu

ornate patio
#

idk if my question belongs in here or in #help-server but I posted it in help-server so if anyone could that'd be great

tender shard
#

i really dont get the hate on russian people

#

it's not their fault if the government does shitty things

#

but yeah probably not the right channel to discuss this haha

torn shuttle
#

I mean I had half a mind to say he was spamming people but it's really just two messages from what I see , the only messages he ever sent as far as i can tell

#

Just doesn't feel appropriate to bring that to spigot plugins, it's not like the people in Russia can go protest against this or vote Putin out, that's about as good as an idea as asking Chinese users to stand up against their government at this point

#

And even if they could it's just not the place for politics imo, that has always been my stance

eternal oxide
#

I don't know enough about either side so I'd not comment

worldly ingot
#

when the invasion first happened, people were asking us to block Russian users lol

#

I was like ??????

torn shuttle
real blaze
river oracle
compact haven
#

what lol

worldly ingot
#

(/s) ^

torn shuttle
dusk flicker
#

horrible

#

speaking of skyblock. the ONE server I actually liked that the owners ran into the ground, CosmicSky(block)

quaint mantle
stuck flax
#
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;

public class BlockPhysics implements Listener {
    @EventHandler
    public void onBlockPhysics(BlockPhysicsEvent event) {
        Bukkit.getConsoleSender().sendMessage(event.getBlock().getType().toString());
        if (event.getBlock().getType().equals(Material.SAND) || event.getBlock().getType().equals(Material.GRAVEL) || event.getBlock().getType().toString().contains("CONCRETE_POWDER")) {
            event.setCancelled(true);
            Bukkit.getConsoleSender().sendMessage("Cancelled a block fall");
            Bukkit.getConsoleSender().sendMessage(Boolean.toString(event.isCancelled()));
        }
    }
}

Gray Concrete Powder falls, sends all proper messages to console but block still falls. Anyone know why?

shadow gazelle
#

Am I doing something wrong here? I'm trying to store a list of item stacks, but nothing in the config ever changes.

    @Override
    public boolean saveChanges(ConfigurationSection groupSection) {
        ArrayList<ItemStack> list = Lists.newArrayList(Arrays.stream(this.inventory.getContents()).iterator());

        if (Storage.get().isConfigurationSection(groupSection.getCurrentPath())) {
            Storage.get().set(groupSection.getCurrentPath() + ".items", list);
            Storage.save();
            return Storage.reload();
        } else {
            logger.warning("Group \"" + groupSection.getName() + "\" was not found, unable to save contents");
            return false;
        }
    }
#

These are my save and reload methods

    public static void save() {
        try {
            storage.save(storageFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static boolean reload() {
        storageFile = new File(plugin.getDataFolder(), "storage.yml");
        if (storageFile.exists()) {
            plugin.saveResource("storage.yml", false);
            storage = YamlConfiguration.loadConfiguration(storageFile);
            return true;
        } else {
            logger.warning("Could not reload storage, file was not found");
            return false;
        }
    }
#

get just returns the FileConfiguration

iron glade
#

I need to know when a thread is done to start some other code, how would I achieve this?

eternal oxide
#

this code is never going to execute on teh first run. It will only work when the file already exists, which means saving from resource will do nothing.

#
        if (storageFile.exists()) {
            plugin.saveResource("storage.yml", false);```
shadow gazelle
#

that's why it's in the reload method lol

eternal oxide
#

it shoudl be if (!storageFile.exists())

shadow gazelle
#

no, it shouldn't

#

Read the method name

eternal oxide
#

teh file will not exist before you create it

#

File is only a pointer to a location. Ther may be something at that location, or there may not

shadow gazelle
#

bro

#

the method is literally called reload

eternal oxide
#

.exists() will only be true if there is a file or a directory at teh location

shadow gazelle
#

no shit

eternal oxide
#

Your code is saying, If there is a file here (be it an actual file or a directory) copy the resource, but don;t overwrite

#

So nothign gets copied

shadow gazelle
#

why the hell am I event running saveResource there

#

that's not supposed to be there

eternal oxide
#

No clue, thats what I'm saying. it will do nothing

shadow gazelle
#

still isn't saving, nice

eternal oxide
#

add some debug to see if you are even calling save

lime moat
#

I specify my GUI items like this: java GuiItem guiItem = ItemBuilder.from(Material.STONE).asGuiItem(event -> { event.setCancelled(true); String test_message = main.getConfig().getString("test-message"); player.sendMessage(MiniMessage.miniMessage().deserialize(test_message)); }); How could I add a certain CustomModelData/nbt to it?

rapid aspen
#

Hi

#

can someone help me please?

iron glade
#

Just ask ur question

rapid aspen
#
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (sender instanceof Player p) {
        if(((Player) sender).getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;

        if(((Player) sender).getGameMode() == GameMode.SURVIVAL) {
            ItemStack heart = new ItemStack(Material.NETHER_STAR);

            ItemMeta heartMeta = heart.getItemMeta();

            heartMeta.setDisplayName(ChatColor.RED + "Coração");

            heart.setItemMeta(heartMeta);

            p.getInventory().addItem(heart);

            double pHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();

                  p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(Bukkit.getServer().getPlayer(args[1]).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + Integer.parseInt(args[0]) * 2);
            }
        }
        return true;
    }
iron glade
#

why all that casting

#

you checked if the sender is a player, no need to cast

compact haven
#

he doesn't realize that ... instanceof Player p gives him a Player variable that he can use xd

#

@rapid aspen just use p.getGameMode() etc, in place of ((Player) sender)

rapid aspen
#

ok

iron glade
#

That's just code, is there a problem with it or why did you send it?

rapid aspen
#

im doing a lifesteal plugin

#

and now im doing a /withdraw command