#help-development

1 messages · Page 1602 of 1

lost matrix
#

I mean SQL scales better than flat files.

#

Unless you memory map them...

proud basin
#

The things is I don’t like how long it actually takes to “receive” the item since it has to connect to db

eternal oxide
#

Yes, so decide if your timers need to persist over a server start?

lost matrix
#

Anyways. Databases are usually needed if you have multiple server instances running and every instance needs the same data as the other servers.

proud basin
#

By persist do you mean transfer over?

eternal oxide
#

yes, so someone is waiting on a timer. do they still need to be waiting after the server restarts

proud basin
#

be the same

lost matrix
proud basin
#

yes

#

It does

eternal oxide
#

ok it persists, so you need some form of database for it to persist

#

sql is slow

#

if timers are based on a single server the fastest would be flat file

proud basin
#

hm

#

ok

eternal oxide
#

well NBT-tags/PDC would be fastest. Next is flat file

#

also NBT tags means no database or file management for you

proud basin
#

was trying to understand the nbt api thing

eternal oxide
#

7smile7 explained it for ItemStacks. Its identical for Player objects

proud basin
#

yea

#

i would use entity

eternal oxide
#

yes, Player is an Entity

#
NBTEntity nbtent = new NBTEntity(player);

//set
nbtent.setInteger("kitCooldown", time);

//get
if (nbtent.hasKey("kitCooldown")
    return nbtent.getInteger("kitCooldown");
else
    return 0;```
#

very simple

proud basin
#

don't I want time as a long?

eternal oxide
#

yes, was just an example

proud basin
#

nvm

proud basin
somber hull
#

@lost matrix

lost matrix
#

F

somber hull
#

How do i give an item meta?

lost matrix
#

You cant

somber hull
#

Then how does it not have meta..

lost matrix
somber hull
#

But it doesnt, im getting an error saying the meta is null

lost matrix
#

Show the whole code and stack trace pls

somber hull
#

Ok

#

its a shit-show since i started this as my first project so a lot of it is unorganized, give me a minute

#

hmmm

#

hang on a sec

#

now its just not working since i added a check if its null, or air

lost matrix
#

Just show me the code section and ill give you some spots where you can add debug messages

somber hull
#

ok, i added a log to the thing and this is what i got

somber hull
#
blocks:
- null
- ==: org.bukkit.inventory.ItemStack
  v: 2730
  type: AIR
  amount: 0
- ==: org.bukkit.inventory.ItemStack
  v: 2730
  type: BIRCH_PLANKS
#

this was in my yaml file even though all i added was an itemstack

#

heres the code

#

?paste

undone axleBOT
eternal oxide
#

type: AIR

somber hull
eternal oxide
#

he told you earlier AIR has no ItemMeta

somber hull
#

but it shouldnt matter since air wasnt there when i was talking earlier

eternal oxide
#

line 12 will never be null, but the Item could be null

#

an ItemStack will always have a type

lost matrix
eternal oxide
#

but an ItemStack can be null

somber hull
#

i removed the .getType() == null

somber hull
#
            if (item == null)
                return;
            if (item.getType() == Material.AIR)
                return;
eternal oxide
#

line 33 if(i.getType() == Material.AIR) continue;

somber hull
#

Yea, i added that so if it is air, ignore it

eternal oxide
#

yep, just use == not .equals

somber hull
#

oh

#

i was told by multiple people to use .equals

#

i had a ton of issues with == for comparing objects'

eternal oxide
#

not to compare enums

lost matrix
#

Usually you would want to use .equals()
Just not for primitives and enums

eternal oxide
#

objects you compare with .equals

somber hull
#

Ok

lost matrix
#

There are some occasions where you would want to compare objects by == but they are quite rare

eternal oxide
#

like comparing Inventory instances use ==

somber hull
#

let me try it out rq

#

ok

#

so

#

it kind of works

#

but idk why its doing what its doing

#

gime a sec to explain

hardy swan
proud basin
#

Not sure if this is basic or not but was never taught this. Is there a way to call a object in 2 different methods but the objects getting the same values that was added from another method?

quaint mantle
#

Huh

lost matrix
proud basin
#

Figured that

#

lemme get a example

somber hull
#

I click with a block, and it gets the event.getCursor() then it runs these 2 lines

            plugin.reloadGuis();
            plugin.blocksGui.show(event.getWhoClicked());

this should reload the gui to allow it to have the new block, then show it to the player. but for some reason the block does not appear in the gui. But if i restart the serve or do /rl it does show up?? (plugin.reloadGuis is in the onEnable)

lost matrix
somber hull
#

but the thing is

#

its the same...

#

its just the reloadGuis

#

i have no idea where i would put the messages

lost matrix
#

In reloadGuis() for example.

eternal oxide
somber hull
#
    public void reloadGuis() {
        webhookGui = guiClass.createWebhookGui();
        commandsGui = guiClass.createCommandsGui();
        punishGui = guiClass.createPunishGui();
        adminGui = guiClass.createMainGui();
        settingsGui = guiClass.createSettingsGui();
        blocksGui = guiClass.createBlocksGui();
    }
somber hull
#

i never had to do this before and it worked fine

eternal oxide
#

Not if you are showign them a new Inventory

proud basin
#
MyClass myClass;

public void myMethod(String name) {
  myClass = new MyClass(name);
  myClass.setName(name);
}

public String getName(String name) {
  myClass = new MyClass(name);
  return myClass.getString(name);
}``` something like this idk if that makes sense haha
somber hull
eternal oxide
#

I assumed you were just updating it

somber hull
#

and if i close it

lost matrix
somber hull
#

and open it again

#

it still is missing

#

Thats why im confused

#

but if i reload the server

#

it shows up

#

the only thing affecting that

#

would be reloadGuis()

eternal oxide
#

then you are not creating a new inventory

somber hull
#

and that is in both spots

lost matrix
#

Then your methods use an old instance of your FileConfiguration

eternal oxide
#

^

#

could be

hardy swan
somber hull
#

hmm

somber hull
proud basin
somber hull
#

but when i take the item out it updates...

#

and when i add it it doesnt update

#

leme send the code for that

#
            navigationPane.addItem(new GuiItem(item, event -> {
                event.setCancelled(true);
                if (event.isRightClick()) {
                    List<ItemStack> items = (List<ItemStack>) plugin.getConfig().getList("blocks");
                    items.remove(i);
                    plugin.getConfig().set("blocks", items);
                    plugin.saveConfig();
                    plugin.reloadGuis();
                    plugin.blocksGui.show(event.getWhoClicked());
                }

removing an item

lost matrix
hardy swan
somber hull
#
        background.addItem(new GuiItem(backGroundItem, event -> {
            event.setCancelled(true);
            ItemStack item = event.getCursor();
            if (item == null)
                return;
            if (item.getType() == Material.AIR)
                return;
            List<ItemStack> items = (List<ItemStack>) plugin.getConfig().getList("blocks");
            items.add(item);
            plugin.getConfig().set("blocks", items);
            plugin.saveConfig();
            item.setAmount(0);
            plugin.reloadGuis();
            plugin.blocksGui.show(event.getWhoClicked());
        }));

adding an item (this one doesnt work)

#

I should clone the item first shouldnt i

proud basin
hardy swan
#

just dun make the new instance then

lost matrix
hardy swan
#

fk i misread

lost matrix
hardy swan
#

@proud basin ah I get what you mean

#

the answer is no

proud basin
hardy swan
#

yup it will, and you cant prevent that

lost matrix
#

Yes. Objects created inside a method are just thrown away as soon as the method is done.

hardy swan
#

the value has to be saved somewhere, and not in a method

proud basin
#

ugh

#

then my plan is ruined

lost matrix
#

This should never be a problem in an object oriented language

#

You can always pass one value from within a method to another by just calling it tho ^^

lean gull
#

anyone know a tutorial on easy to understand custom config files for newbies?

#

if you're gonna say i need to learn java basics first, just don't

hardy swan
lean gull
#

thanks but this is normal ones

#

i'm looking to learn custom ones

hardy swan
#

scroll down

lost matrix
lean gull
#

oh ok thank you

void haven
#

Hello I am using token manager as my token currency, anyway to link these across bungee servers?

lean gull
#

i'll try this, i might come back with some questions though

lost matrix
void haven
lost matrix
void haven
#

I can't find it hehe

lean gull
#

question: what's the difference between File variable type and FileConfiguration variable type?

lost matrix
#

for linux or windows?

hardy swan
void haven
hardy swan
#

FileConfiguration is from spigot

#

and is specialized in helping you manage configuration files as the name suggests

lost matrix
lost matrix
lean gull
#

so File is the directory in the hard-drive and FileConfiguration is what's in it?

hardy swan
#

it is abstracted

lost matrix
#

FileConfiguration is just a glorified HashMap that contains the content of the File

lean gull
#

alr i think i understand, thx

lost matrix
#

Do you know what a HashMap is?

lean gull
#

no sorry

#

isn't it a list of some sorts?

lost matrix
lean gull
#

how nice of you

hardy swan
#

well it is kind of basic

#

hashmap is a data structure that maps key to values using a hash function such that you can query its elements in O(1) time

lean gull
#

what

lost matrix
#

You can think of it like a simple table with one column being the keys and one column being the values.

lean gull
#

ohh right i remember now

lost matrix
#

And for each key you can store a specific value

#

To be fair, it seems like understanding maps is always a bit of a hustle for entry level devs

lean gull
#

ok can i ask line by line on what this means

hardy swan
#

it is more algorithmic based, which prob most of them isn't interested in

lean gull
#

on the custom config thingie article

hardy swan
#

You just have to understand how File works first

lean gull
#

file is a directory or a file

hardy swan
#

erm, i don't prefer that description but yea

#

a file can be a directory

lean gull
#

is there a more accurate one?

hardy swan
#

directory is also a file

lean gull
#

and a file can be a directory

paper viper
#

they are the same thing pretty much

#

for File

hardy swan
#

file as in java.io.File

lean gull
#

or you can get the directory from a file

#

correct?

paper viper
#

No you cant

lean gull
#

wat

paper viper
#

the File can be either a directory or a normal file

#

it has methods for both

#

like listFiles

#

isDirectory

#

stuff like that

#

so it can be both a directory and a normal file

#

at the same time

proud basin
lean gull
#

so you can get a file from a directory but you can't get a directory of a file?

quaint mantle
# lost matrix

i've been programming in different languages for many years, and as frustrating as it is to try and explain something to someone who has little experience using the language, in my experience the best way to learn a new language is by using it.

paper viper
#

that isnt what i even said

quaint mantle
#

I try to get in there and mess around

lost matrix
quaint mantle
#

Yes

paper viper
#

I am saying the File class can be used to represent a directory or a normal single file.

#

if it is a directory, it has its own methods such as listFiles which list the files of the directory

lean gull
#

you're saying or but also both

paper viper
#

sigh

hardy swan
#

lmao

#

figure it out yourself @lean gull

paper viper
#

i really want to say learn java

#

but yea no im just not gonan help rn

hardy swan
#

we are cursed with knowledge here

lean gull
#

if you don't want to help, don't. you don't have to be rude about it

quaint mantle
#

@lean gull I haven't been following this conversation at all really, but I can recommend a few great resources for you to help learn SOME of the basics

#

you really don't need more than an hour of work to learn the basics

#

the real basics

lean gull
#

the codeacademy one takes like 22 hours i think

quaint mantle
#

i thought codeacademy was paywalled

hardy swan
#

there are quite a lot of basics

quaint mantle
#

depends how dedicated you are

#

how consistent you are

#

and how quickly you can pick it up

hardy swan
#

if you learned other programming languages of course

#

transferable and analogous

lean gull
#

imma just ask questions about this article, if you don't want to help then just don't and don't be rude about it please

quaint mantle
#

I wouldn't recommend that someone start programming with Java

#

Python or even Lua is a good place to start for true beginners

hardy swan
#

I mean, I dunno python or how easy that is haha

quaint mantle
#

imo of course

#

python, lua, and JS are all very similar

#

so you get a lot of usage out of learning one of them

proud basin
#

With NBTEntity you need to do NBTEntity entity = new NBTEntity(Entity) but I wanna be able to use the object in multiple methods without making a new instance for each method.

lost matrix
#

Every python script ever:

import a_bunch_of_random_stuff as lib

lib.doTheThing()
lean gull
#

so this sets the variable customConfigFile to a file/directory that can later be set to something

    private File customConfigFile;```am i wrong?
lean gull
#

hence the "that can later be set to something"

lost matrix
quaint mantle
#

@lean gull my best advice to you: Find someone who knows Java well & is willing to give you their time to answer all your questions

lean gull
#

im finding people like that here

quaint mantle
#

you'll start picking stuff up, but if you don't want to go the traditional route that seems like the best idea

quaint mantle
#

yes

#

forget doing 1+1

#

use a math library

lean gull
#

ok and then this one declares without setting customConfig to what's inside the file

private FileConfiguration customConfig;```
hardy swan
#

inside what file?

lean gull
#

um

#

well it's not set yet

hardy swan
#

well then

lean gull
#

did i get that right

lost matrix
lean gull
#

hence the "declares without setting"

lost matrix
#

Yes. Its declared but not initialized.

lean gull
#

btw this thing has to be in the main file, right?

hardy swan
#

huh?

lean gull
#

this method

paper viper
#

what...

lean gull
#

or methods

hardy swan
#

wut?

lean gull
#

that's what i was told

hardy swan
#

method?

lost matrix
#

Nope. Nothing has to be anywhere. You can do whatever you want.

paper viper
hardy swan
#

hahaha

paper viper
#

tell us

lean gull
#

dunt remember

paper viper
#

we will beat them up

quaint mantle
#

!

hardy swan
#

wtf Im doubting my years of experience

lost matrix
hardy swan
lean gull
#

yes i know

#

fields are outside of functions and inside classes, correct?

#

i mean methods

hardy swan
#

fields have to belong to a class, yes

#

and methods too

lean gull
#

but if it belongs to a method then it's not a field?

#

afaik

lost matrix
#

On second thought... holding a hard reference to an Entity is not a good idea.

hardy swan
lean gull
#

what

hardy swan
#

it is a set of instructions on how to convert an input to output

lost matrix
# proud basin bump

Why do you want to use the same instance over again? For the nbt lib that makes no sense. You are meant to create a new instance of NBTEntity if you want to modify the nbt data of one.

lean gull
#

confused confusing confusion

proud basin
lost matrix
lean gull
#

ok so anyway this just starts a method on startup, correct?

#
    @Override
    public void onEnable(){
        createCustomConfig();
    ```
lost matrix
proud basin
lean gull
#

this lets you use the config from outside of the used class, correct?

    public FileConfiguration getCustomConfig() {
        return this.customConfig;
    }```
lost matrix
hardy swan
#

I think your problem is not knowing terminologies @lean gull

lost matrix
#

Well. You are on 1.8 anyways so good luck i guess...

proud basin
#

But the entity im using is Player

lost matrix
lean gull
#

what's terminologies

#

tried googling and didn't understand

proud basin
lost matrix
#

Just found this

proud basin
#

hm

#

ok

tawdry vine
#

How can I run a bit of code on a entity when it spawns?

paper viper
#

like modify it before it spawns?

#

for that you can consumer

tawdry vine
#

Just when a mob spawns, do x to it

hardy swan
#

there is EntitySpawnEvent and CreatureSpawnEvent

proud basin
wet jewel
hasty prawn
#

You're sending a String somewhere that's longer than the maximum (16)

#

I think that's what it is anyways

#

Doing anything with Scoreboards perhaps? I think it can happen there if you set a team prefix or something longer than 16 chars

static whale
#

Is there an event for a player setting their spawn? I know there is PlayerDeepSleep event but what I’m specifically trying to do is cancel the spawn set but still let night pass, plus a player doesn't need to sleep to set their spawn, it's just clicking the bed. One user directed me to use PlayerSpawnLocationEvent but that doesn't get fired on bed use.

tough zephyr
#

@wet jewel Most likely the username

#

Is too long

quaint mantle
tough zephyr
#

Bungee hard-limited usernames to 16 characters due to that being the protocol limit

#

So if you join with a (cracked username) with over 16 characters, it'll give you an exception

static whale
wet jewel
# tough zephyr <@!253205790259675137> Most likely the username

I don `t believe. On my Network, I never had this problem, until I updated my Bungee fork to 1.17 and ViaVersion.

Since then it started, but only in versions 1.8 - 1.12; any version 1.13+, does not throw this problem.

Also, I do not think that is what they comment, since the error occurs with practically any player, regardless of their name or prefix.

tough zephyr
#

@wet jewel At what stage do they get it?

#

While logging in?

#

The settings packet is also hard limited at 16

wet jewel
tough zephyr
#

Yeah no idea then. The only two packets I can think of with a hard limit of 16 on a string is the LoginRequest (name), and the Settings packet

#

But both of those would only cause a problem when you're connecting to the server

#

So maybe a plugin issue

wet jewel
#

Later, I was reading the possibility that it was the ScoreBoard; I tried taking it out and it persisted.

Besides that I use TAB and in that sense, it is friendly.

#

Now, I just updated ViaVersion from 4.0.1 (which is up to date); to beta version 4.0.2 and I think the incidents decreased; but they still exist.

#

I also tried updating LuckPerms (which in the past gave me some trouble adding support for new versions), and the problem has persisted.

tough zephyr
#

@wet jewel You don't have a stacktrace inside of Bungeecord's logs?

#

That'd be helpful

#

@wet jewel Oh you know what

#

That's actually a client error most likely. So you're probably sending too large of a string

#

Like a scoreboard or teams variable is over 16 characters long

#

Or the PlayerList entry is over 16

#

Or worldType

static whale
tough zephyr
#

@paper geyser Because it's not in the scope

#

U would have to put it as a field

paper geyser
#

OH

#

YOU'RE RIGHT

#

thank you!

tough zephyr
#

@paper geyser You should look into Objects. That way you can just have one map.

Like:

public class YourObjectWhatever {

private int maxMama;
private int currentMana;

methods....

}

#

Makes java a hell of a lot less tedious

paper geyser
#

alright I'll look into it

quaint mantle
#

How do you make the item not stand out? I wrote world#dropItem, but the item pops to the side. I've tried item#teleport, but it doesn't work.

#
        droppedItem2.teleport(new Location(Bukkit.getWorld("world"), 51.5, 69, -54.5));``` (Not work)
quaint mantle
#

hey im wondering how i can get all blocks between two points

#

obviously nothing huge

#

an area smaller than 50 blocks

#

i googeld a bit but the results i came with seemed to crash my server

near crypt
#

what is the easiest way to get the nearest block that is not air from a location?what is the easiest way to get the nearest block that is not air from a location?

near crypt
#

?

near crypt
quaint mantle
#

how can I spawn dropped item without world#dropItem?

#

How would i create a plugin that if i update one of the plugins in a list in the config, that it would see that and reload the server?

#

is it hard?

quaint mantle
quaint mantle
#

what?

#

item pops? sorry what?

#

hmm

quaint mantle
#

I want item to stop moving

#

when it dropped

paper geyser
dense goblet
# near crypt what is the easiest way to get the nearest block that is not air from a location...

Iterate outwards from a coordinate and stop the loop once currentBlock.isAir() is false. If your max range is high you might want to use chunk snapshots, but that's more work (in a similar case, I use a Map<ChunkCoordinate, ChunkSnapshot>, where chunk coordinate is a pair of ints x,y and the hash function hashes based on those variables. You can get a chunk coordinate from a block coordinate with a bitshift)

hardy swan
near crypt
dense goblet
#

Nah, probably not, depends how you define your distance

near crypt
#

and how can i do it?

dense goblet
#

Well what's your definition for distance

#

Which block is closer to X:
A X B

C

#

A B or C?

near crypt
#

AB obviously +

dense goblet
#

A or B

near crypt
#

both

dense goblet
#

Which one should your program pick

near crypt
#

it doesnt matter say A

dense goblet
#

You have to know in order to come up with the correct algorithm. More importantly for this case:
A B
C X

#

Is A equally close as B and C?

near crypt
#

yes

dense goblet
#

If yes then it's easy, if not it's gonna be harder

hardy swan
#

No hehe

dense goblet
#

What about:
A B C
D E F
G H X

Is A equally close to X as C is?

#

Wait my bad wrong example

near crypt
#

xD

dense goblet
#

Now

#

Are A and C the same distance from X

near crypt
#

yes it is

dense goblet
#

Okay then you can iterate outward in rings

#

Keep in mind this will favour corner blocks

#

Like A

near crypt
#

i just want to throw a snowball and where the snowball hits it should create a "blob" of red blocks around it

dense goblet
#

Ah so it needs to choose multiple blocks

hardy swan
#

It wouldnt be round

near crypt
hardy swan
#

Based on your definition of equally close

dense goblet
#

Does it matter if it colours blocks through walls

#

Like:
A B C X

C is air, X is snowball, A and B are solid

#

Should A be coloured too or only B

near crypt
#

A and B

dense goblet
#

Okay so through walls is fine

#

Should the blob be square or round

near crypt
#

oh sry then no

near crypt
dense goblet
#

Randomly needs a definition

#

e.g. the further out from the impact point the smaller chance to be coloured

near crypt
#

idk

dense goblet
#

This would give an effect like a spray can in MS Paint

near crypt
#

yeah

dense goblet
#

How big will the blob be

near crypt
#

it should be a paintball plugin

near crypt
dense goblet
#

But in what radius

near crypt
#

radius of 6 or 7 blocks

dense goblet
#

Ok let's say 7

near crypt
#

ye

dense goblet
#

Radius or diameter?

#

7 radius would be 14 diameter (or more likely 15 since you want it centered around the ball)

near crypt
#

yes

#

right

dense goblet
#

So maximum volume would be 15*15*15 = 3375 blocks, at most, to check

#

Which means you probably want to use chunk snapshots to reduce lag

near crypt
#

ye

cinder plume
#

any idea how to periodically allow certain mobs to spawn near the player ?

near crypt
dense goblet
#

Not in a place I can talk sorry

near crypt
#

okay

near crypt
tacit storm
#

Hey, I have a quick SQL Question;

I am trying to get every column in my Database using SELECT * FROM table_name WHERE user = 'user_name'
Checking the ResultSetMetaData, it returns every column.

Now going through the ResultSet with rs.next() in a while loop, only returns the first column though.
Any ideas ?

My table has 11 columns

hardy swan
#

You mean row or columns

#

Show code

vivid temple
#

can i copy a building and paste it through code?

hardy swan
#

Yes

#

Thats what worldedit is

vivid temple
#

true lol

cinder plume
#

Any idea how to periodically allow certain mobs to spawn near the player ?

vivid temple
#

so how do i do that

hardy swan
#

do you just want to copy the material?

#

and not its data

#

like texts on signs

#

items in containers

tacit storm
# hardy swan You mean row or columns

I mean Columns, here's the code:

            public void onFinish(ResultSet resultSet) {
                try {
                    ResultSetMetaData data = resultSet.getMetaData();

                    p.sendMessage(HexColor.UNIFORM_GREEN + "for Loop");
                    for (int i = 1; i <= data.getColumnCount(); i++){
                        p.sendMessage(HexColor.UNIFORM_BLUE + "Column found: " + HexColor.UNIFORM_MAGENTA + data.getColumnName(i));
                    }

                    p.sendMessage(HexColor.UNIFORM_GREEN + "while Loop");
                    while (resultSet.next()){
                        p.sendMessage(HexColor.UNIFORM_BLUE + "Data found: "
                                + HexColor.UNIFORM_MAGENTA + resultSet.getObject(resultSet.getRow())
                        + HexColor.UNIFORM_BLUE + " in Row: " + HexColor.UNIFORM_PURPLE + resultSet.getRow() + " (" + data.getColumnName(resultSet.getRow()) + ")");
                    }

                    resultSet.close();
                    resultSet.getStatement().close();
                    resultSet.getStatement().getConnection().close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }```

Output: https://i.imgur.com/WyoQUIQ.png
hardy swan
#

open or close doors

#

last line

#

Row

#

one sec

vivid temple
#

blocks and 1 door and a commandblock with pressure plate

tacit storm
#

Oh wow I just realized that it's Row and not Column, my brain did a massive game there LMAO

dense goblet
#

@near crypt So you need something like:
Triple nested for loop for delta x,y,z going from -7 to +7.
Using distance squared should be fine for controlling the random chance. So let's say dist = dx*dx + dy*dy + dz*dz.
Then your chance to colour that block is baseChance/(dist+1) (plus one to avoid dividing by zero).
Roll a random number and if it is greater than the chance, skip this block (using continue;).
Otherwise, you have to check if the block is air. The current block's position is the snowball's position plus dx, dy and dz. Use world.getBlockAt and then check if block.isAir(). If yes, skip the block. Otherwise keep going.
Then, you have to check if there is a block between the current block and the snowball or not. You can do a raycast from the block's position to the snowball and see if it hits something. If yes, skip the block.
Finally, you set the block to whatever the coloured block is supposed to be.

near crypt
#

okay thx brother

tacit storm
# hardy swan one sec

Okay yeah I had a massive brainfart, I was going into the next row trying to read out the Column haha

#

Fixed it now, thank you very much!

hardy swan
#

yea haha

vivid temple
hardy swan
#

is that all you want to copy?

#

why not use worldedit lol

vivid temple
#

nah i need something that can get copied with a trigger in my code

#

well basically i need to do it through code

hardy swan
#

then the simplest way is to have a list

cinder plume
#

Can someone please tell me

any idea how to periodically allow certain mobs to spawn near the player ?

hardy swan
#

iterate through all x, y, z between two blocks and add to the list

#

and that will be your clipboard

vivid temple
#

okay thanks

hardy swan
#

when you say allow, do you mean to spawn them manually?

cinder plume
#

like for example i want a zombie apocalypse

#

they keep spawning near the player , periodically

hardy swan
#

BukkitScheduler#runTaskTimerAsynchronously(Plugin,Runnable,long,long)

#

where you runnable would be a callback to server thread
Bukkit.getScheduler.runTask(Plugin, Runnable)

#

In this runnable will you then spawn entities around the player

cinder plume
#

bro im sort of new , i was thinking of doing something basic like

p.getLocation().getX() + new Random().nextInt(32)+1;

#

of this sort

hardy swan
#

yes all these are in the second runnable Im talking about

cinder plume
#

okay

hardy swan
#

you want to spawn periodically right

cinder plume
#

yes , in intervals

cinder plume
#

okay , will i find a guide online on what exactly entails this command

#

so i can learn

cinder plume
#

thanks

#

also , just out of curiosity

is threading and using sleep a valuable option

hardy swan
#

BukkitScheduler helps you solve it

#

avoid handling threads and sleep yourself unless specifically needed and you know exactly what is happening

summer scroll
#

I tried to spawn an armor stand with packets and set the armor stand invisible, but the armor stand is still visible, I'm using 1.16.5

cinder plume
#

@hardy swan so in long delay it should be 0 because the first run should be initiated instantly
and for long period , what is 1 tick = ?
like how many seconds or so.

hardy swan
#

0.05s

cinder plume
#

so 1 second = 20ticks

#

right

#

?

hardy swan
#

yes

cinder plume
#

alright bro thanks

#

helped a lot 😄

hardy swan
#

no problem

#

developers' greatest strength, googling

cinder plume
#

ahah thanks again 😛

hardy swan
#

is there anyway to set my plugin version in plugin.yml to project's version?

#

nvm think i found the solution

opal juniper
#

Some curly brackets shit

hardy swan
#

yea

#

${project.version}

queen niche
#

?paste

undone axleBOT
queen niche
#

Hi! Im making a command you can use as /attractie hub Hub

What it should do is output a message like [info] argument2 is opened click to warp

I have made it clickable and use the ClickEven.Action.RUN_COMMAND, "/warp" + args[1]))):

When using it gives me a internal error. Can someone look at my code and see what I did wrong?

gentle meteor
#

ive been banging my head at this for an h or so

i use this code to get Leafs

Leaves leaves = (Leaves) block.getBlockData();

But by some magic sometimes (usualy on a block break event) it returns craftblock and it meses up the casting. Any ideas on how to turn CraftBlockData into BlockData, and also what is the use of CraftBlock?

open lily
#

what is the MATERIAL name for enchanted golden apple

#

because IntelliJ is suggesting me only GOLDEN_APPLE

queen niche
# hardy swan which line is 36

Bukkit.broadcastMessage("§7[§dInfo§7] " + ChatColor.BLUE + "De " + ChatColor.DARK_GREEN + args[2] + ChatColor.BLUE + "Is geopend!" + ChatColor.DARK_AQUA + "[Klik hier om te warpen]");

stone sinew
open lily
gentle meteor
stone sinew
hardy swan
queen niche
hardy swan
#

that is args[1]

#

remember count from 0

queen niche
#

Oh wow.

#

Sorry

#

Thats stupid from me

hardy swan
#

/cmd args[0] args[1]

queen niche
#

Thank you! I'll try it out

hardy swan
#

np haha

open lily
#

because I have no idea, doing it for first time 😅

gentle meteor
stone sinew
hardy swan
open lily
#

sorry, i mean I'm making PlayerItemConsumeEvent and I want to apply some effects on player when the enchanted golden apple is eaten

hardy swan
#

dont you have a getItem()

gentle meteor
open lily
maiden briar
#
private Map<ServerInfo, Boolean> pingServers()
    {
        Map<ServerInfo, Boolean> servers = new HashMap<>();
        
        for(Map.Entry<String, ServerInfo> server : ProxyServer.getInstance().getServers().entrySet())
        {
            ServerInfo serverInfo = server.getValue();
            serverInfo.ping((serverPing, throwable) ->
            {
                if(throwable != null)
                    servers.put(serverInfo, true);
                else
                    servers.put(serverInfo, false);
            });
        }
        
        return servers;
    }

I am trying to reach servers in Bungee, but the problem is, if I return the servers map the CallBack won't be finished. This is to search a reachable gameserver or lobby

hardy swan
hardy swan
open lily
hardy swan
#

getType() to get its material

#

and ItemStack does have getDurability()

open lily
#

'getType()' in 'org.bukkit.inventory.ItemStack' cannot be applied to '(org.bukkit.Material)'

gentle meteor
hardy swan
#

e.getItem().getType() == Material.GOLDEN_APPLE

hybrid spoke
#

hell no

#

don't compare with equals

#

those are enums

hardy swan
#

my bad

hybrid spoke
#

much better

gentle meteor
#

I have literaly posted everything that ever tuches that instance in case i somehow turned it to CraftBlock by accident

hardy swan
#

did you check if the block in the argument is org.bukkit.block.Block

#

it should be

#

hmmm

gentle meteor
#

yep it is

open lily
hardy swan
#

you might have to add (short) in front of 1

open lily
#

ok, thanks 😅

hardy swan
#

java might not recognise it as a short, i forgot

gentle meteor
hardy swan
#

or you might not even need to add since getDurability's short can is subtype of int?

#

idk I'm just trolling

open lily
#

also how can I apply potion effect for X seconds and with X amplifier?

open lily
#

thx

hardy swan
sand rune
#

Guys , what's the sound that like ding ? In Spigot 1.8.8

hardy swan
#

one ding sound? or player level up sound?

sand rune
#

No ding @hardy swan

#

The player level up is not good

#

As u open in other server an GUI , ding sound plays , how ?

#

@hardy swan

hardy swan
#

try player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1); and see if that's the sound you want

dense goblet
#

@sand rune arrow hit player sound?

#

Idk if that was a vanilla thing tho

hardy swan
#

i dun think that is in 1.8.8 either

#

else it could be client side

gentle meteor
#

Just play with the sound for a bit untill you get it

#

Or you can make a small mod in fabric that writes sound input and then log into <server-of-choise> and yoink the valius

#

use the /playsound and have fun

maiden briar
#

How can I check if a bungee server is online?

hardy swan
hardy swan
#

im so good at googling

maiden briar
#

Ok thx

gentle meteor
#

Also may i ask what was the indended use of CraftBlock

#

That isnt just breaking deadlines

hardy swan
#

I don't even know how your Block can be a CraftBlock

#

eh wait CraftBlock implements Block

#

but somehow doesn't implement getBlockData()?? what version are you in lol

sand rune
#

Guys how to spawn particle in 1.8 using spigot

smoky oak
#

is bit shifting or dividing faster if you want to know how many powers of two are in a number and you dont care about the part after the column

#

IE integer divisions

sand rune
#

Bec the spawnParticle function don't show , how to spawn

ivory sleet
#

Probably bit shifting

ivory sleet
#

Nms

#

Also no need to bump your message after 30 seconds 👍

sand rune
#

How to spawn particles in spigot 1.8 ??? @ivory sleet

hardy swan
#

he just told you, with the use of nms

sand rune
#

What's nms

quaint mantle
#

good gui library?

sand rune
#

@hardy swan

#

What's nms

smoky oak
#

nms is the standard minecraft code

hardy swan
smoky oak
#

without bukkit or spigot atop it

ivory sleet
quaint mantle
#

which library is good for gui? any suggestions?

sand rune
#

Thx @ivory sleet

ivory sleet
#

Interfaces, mf-gui, inventoryframework, bkcommonlib, helper and canvas are just some of them.

smoky oak
#
public class RightClick implements Listener {
    @EventHandler
    public static void onInteract(PlayerInteractEvent e){
        if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
            e.getPlayer().sendMessage("Action.");
        }
    }
}```
That triggers twice. Why?
hardy swan
#

try filtering with right or left hand

smoky oak
#

um

#

im doing that?

hardy swan
#

i mean you can right click with left hand

open lily
#

How can I get EntityPotionEffectEvent cause by golden apple? Because when I do:
if (e.getCause().equals(Material.GOLDEN_APPLE)) {, Intellij says Condition 'e.getCause().equals(Material.GOLDEN_APPLE)' is always 'false'

#

or should I ignore this warn

hardy swan
#

are they even of the same type?

#

if not, it is always false

ivory sleet
#

because getCause() returns something completely else

smoky oak
#

figured out but thanks

#

having a ide is helpful at times lol

#

on another note what's the reach of a player? I want to make that interact thing work at the same range as block placement

hardy swan
#

5 for blocks

smoky oak
#

nevermind method only takes int

#

and thanks

#

but isnt it more than 5?

hardy swan
#

no

heavy void
hardy swan
smoky oak
#

neither of the methods take anythine else than int so imma settle for 5

gentle meteor
#

It implements get block data but it returns CraftBlockData for some godforsaken reason

smoky oak
#

cant you cast that? Sounds like one extends the other to me

gentle meteor
#

nope

#

you cant

ivory sleet
#

Nitidez yeah you should have a separate Command instance per command.

gentle meteor
# gentle meteor you cant

java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.type.Leaves (org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData and org.bukkit.block.data.type.Leaves are in unnamed module of loader 'app')

smoky oak
#

thats because youre casting to type

#

do ((BlockData) craftblockdata).equals(Material.<Leaves here>)

queen niche
#

Is it possible to make Bukkit.broadcastMessage("§7[§dInfo§7] " + ChatColor.BLUE + "De " + ChatColor.DARK_GREEN + args[1] + ChatColor.BLUE + " Is geopend!" + ChatColor.DARK_AQUA + " [Klik hier om te warpen]"); a clickable like I did with this line:

TextComponent message = new TextComponent(ChatColor.GRAY + "[" + ChatColor.LIGHT_PURPLE + "Info" + ChatColor.GRAY + "]" + ChatColor.RED + " Oh nee! Je hebt te weinig woorden gebruikt om de broadcast functie te gebruiken! /attractie [warpnaam] [attractienaam]"); message.setColor(ChatColor.RED); message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp " + args[0])); player.spigot().sendMessage(message);

#

since the one is a textcomponent but the other is a bukkit.broadcastmessage

ivory sleet
#

Bukkit.getServer().spigot().broadcast()

hardy swan
quaint mantle
hardy swan
#

just a different subtype than Leaves

open lily
#

if (e.getCause().equals(EntityPotionEffectEvent.Cause.FOOD) && (e.getModifiedType().equals(PotionEffectType.DAMAGE_RESISTANCE))){ how can I specify the material of food?

hardy swan
quaint mantle
#

yeah

quaint mantle
smoky oak
#

coordinats are the block corners

#
  • .5 places it in the midddle
heavy void
queen niche
ivory sleet
heavy void
#

I want to know why Main dont enable Commands, if i put Commands.setupCommands().

#

And it dont sends any error to me.

ivory sleet
ivory sleet
heavy void
# ivory sleet No thing is you’re never registering Commands.
try {
      SimpleCommandMap simpleCommandMap = (SimpleCommandMap) Bukkit.getServer().getClass().getDeclaredMethod("getCommandMap").invoke(Bukkit.getServer());
      simpleCommandMap.register(this.getName(), "mysterybox", this);
    } catch (ReflectiveOperationException ex) {
      Main.getInstance().getLogger().log(Level.SEVERE, "Cannot register command: ", ex);
    }
#

And it dont sends the "Cannot register" message in console.

ivory sleet
#

Which is called nowhere because you’re never instantiating a subtype of Commands

#

Just because you put something a class constructor won’t make it automatically calling itself

heavy void
#

uhh

ivory sleet
#

This is basic java. A class constructor is invoked when you instantiate the class.

hardy swan
#

you need to do sth like this

plugin.getCommand("").setExecutor(new ...);
ivory sleet
#

class A {
A() {

}
}
new A();

#

When the server meets the line new A(); then it will run the code inside the constructor which is the A() {...} part inside the class A

quaint mantle
hardy swan
quaint mantle
#

I spawned at void

heavy void
gentle meteor
hardy swan
#

at void?

quaint mantle
#

yea

hardy swan
#

under y = 0?

quaint mantle
#

nop

#

Bukkit.getWorld("world").dropItem(new Location(Bukkit.getWorld("world"), 33.5, 70, -54), new ItemStack(Material.STONE)); here is my code

hardy swan
#

ok then is 33.5, 70, -54 the location of the block

ivory sleet
#

No subclass of Commands is instantiated

#

Look at onEnable

hardy swan
#
new
ivory sleet
#

Do you see any new MysteBoxCommand();

quaint mantle
#

33.5, 70. -54's block type is air

hardy swan
#

try +0.5 to y too lmao

#

although I dun think that's the issue

heavy void
hardy swan
#

nowhere

#

it isn't assigned to anything

#

thrown into garbage collection

#

kiss it goodbye

heavy void
#

uhhhh

#

LOL, I FORGOT TO IMPORT

quaint mantle
hardy swan
#

then idk lol

#

dropItem works fine for me

ivory sleet
#

Anyways nitidez I missed that but you should probably clean up your code a little bit.

hardy swan
ivory sleet
#

I think he does register it in the Commands class

#

Anyways it’s hard to tell, inheritance relationships are the most coupled code designs you will ever encounter.

hardy swan
#

as in his setupCommands() doesn't do anything

#

does it

heavy void
#

Why ;-;

hardy swan
#

unless you do sth weird in the constructor, you have to assigned your newly instantiated instance to a variable

#

or return it

heavy void
#

Like making a variable to the MysteryBoxCommand class?

hardy swan
#

otherwise, this instance is lost if the reference to it is lost

#

you can

#

@heavy void I feel this is more of a basic OOP concept

ivory sleet
#

You should add some print statements and see where it stops

gentle meteor
#

by using basic oop (instanceof)

#

Even getting the block seperatly returns craftblock

ivory sleet
#

👍

heavy void
#

Im giving up, thanks you anyway, im so dumb for that.

hardy swan
#

it is weird that you would encounter instances of craftblock

ivory sleet
#

Did you add those print statements?

#

There might be so that your MysteryBoxCommand#perform is where it stops at

maiden briar
#
@EventHandler
public void playerJoin(PreLoginEvent e)

Can I cast the PendingConnection to ProxiedPlayer?

hidden delta
#

You can’t do that

#

because the event fired before the player is registered into the server

grim ice
#

?paste

undone axleBOT
grim ice
#

why

hidden delta
#

What is in line 14

grim ice
#

in main?

hidden delta
#

yup

grim ice
#

getCommand("startchallenge").setExecutor(new Setup());

hidden delta
#

did you add the startcommand in pluin yml

grim ice
#

NVM i misspeled startchallenegei n plugin yml

#

lmao im dumb

gentle meteor
#

ah channel back

#

pog

grim ice
#

wait

#

now it says

#

line 15

#

?paste

undone axleBOT
grim ice
#

getCommand("endchallenge").setExecutor(new Setup());

hidden delta
#

The same thing

#

You need to add the command in plugin yml

grim ice
#

I did

#

.

hidden delta
#

Send the plugin yml

grim ice
#

name: MCBDamagedFood
version: ${project.version}
main: me.hex.mcbdamagedfood.MCBDamagedFood
api-version: 1.16
authors: [ 2Hex ]
description: Minecraft But, Food damages you.
commands:
startchallenge:
description: start MCBDAMAGEDFOOD Challenge
aliases: [sch, startch]
endchallenge:
description: end MCBDAMAGEDFOOD Challenge
aliases: [ech, endch]

hidden delta
#

?paste

undone axleBOT
grim ice
#

i fixed it nvm

hidden delta
#

👍

open lily
#

Is it possible to get material of EntityPotionEffectEvent?

eternal oxide
#

Potion Effects do not have a Material

grim ice
#

there is prob a potion effect item meta

#

idk

rigid hazel
#
tptg:
    description: Teleportiert dich zu deiner Gilde, falls vorhanden.
    usage: "Usage: /tptg"
    permission: ccrp.default
    permission-message: Du besitzt keine Berechtigungen, um diesen Befehl auszuführen!```
#

Me with OP: /tptg

#

Ouput: Usage: /tptg

#

Why the command is not working correctly by adding it to the plugin.yml?

hidden delta
#

?paste

undone axleBOT
hidden delta
#

Wait

rigid hazel
#

Okay. Entwickler

hidden delta
#

Paste your command

rigid hazel
#

/tptg

hidden delta
#

i mean class

rigid hazel
#
public class TeleportToGuildCommand extends Command
{
    public TeleportToGuildCommand(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List<String> aliases)
    {
        super(name, description, usageMessage, aliases);
    }

    @Override
    public boolean execute(@NotNull CommandSender commandSender, @NotNull String label, @NotNull String[] args)
    {
        if(commandSender instanceof Player)
        {
            Player sender = (Player) commandSender;

            if(RolePlayer.getOnlineRolePlayer(sender).isTeleportingToGuild())
            {
                sender.teleport(RolePlayer.getOnlineRolePlayer(sender).getGuild().getGuildLocation().add(0, 1, 0));
            }
            else
            {
                sender.sendMessage("§cDu musst einen Teleportationspunkt nutzen, um dich zu teleportieren!");
            }
        }
        else
        {
            commandSender.sendMessage("§cNur Spieler können diesen Befehl ausführen!");
        }

        return true;
    }
}
#

Sorry

grim ice
#

?paste

undone axleBOT
grim ice
#

why is my code not working

#

no errors

rigid hazel
#

The pasting of this is as good, as paste

grim ice
#

nvm

#

no @EventHandler

hidden delta
#

I am in mobile

rigid hazel
hidden delta
#

return false

rigid hazel
#

Always?

hidden delta
#

when you use return true it means it will print the usage that in plugin yml

rigid hazel
#

I thought return false would do this.

lost matrix
rigid hazel
lost matrix
#

Returning false means the command failed

rigid hazel
#

Yes.

#

But why the usage is also shown returning true?

opal juniper
#

It shouldn't be unless there is an error

lost matrix
rigid hazel
#

I try remove the part from plugin.yml

lost matrix
#

So im suspecting that you are not running the code you have shown us

rigid hazel
#

Before I added it, it worked perfect

#

Now. The command works @lost matrix

#

I just removed commands: from plugin.yml

opal juniper
#

how does removing it from the plugin.yml make it work lmao

rigid hazel
#

I don't know.

opal juniper
#

surely it isn't registered anymore

rigid hazel
lost matrix
opal juniper
#

ohhhhh

lost matrix
opal juniper
#

you could have said

rigid hazel
#
commandMap.register("help", new TeleportToGuildCommand("tptg", "Teleportiert dich zu deiner Gilde, falls vorhanden.", "/tptg <player>", new ArrayList<String>()));
lost matrix
rigid hazel
#

How should I do it?

lost matrix
rigid hazel
#

I'm happy, when I learn to make things better.

opal juniper
#

ok

#

so

#

wait i should have probably prepared me question more - one sec

rigid hazel
#

Ähm. I have a little question.

#

If I want to run /guild create

#

How can i make that the player can complete the command with tab?

quaint mantle
#

Hey, is it possible to store some data within a block?

#

I'm looking for something like the PersistentDataAPI but for blocks

stone sinew
smoky oak
#

isnt it that entities lose nbt data on restart and you can store nbt in blocks?

#

i mean

#

if you give any block chest nbt and put a hopper below it

#

that block acts as if its a chest

stone sinew
#

Entities keep their data

smoky oak
#

ah sorry meant meta data

#

I remember that there was a glitch where a spawner had chest nbt

quaint mantle
#

Hmm so I would have to create something like a small database

hardy swan
quaint mantle
#

I am working on a furniture system where you can specify a list of barriers to use to simulate "hitbox"

#

If you only need one barrier, this is really easy because I can check if there is an invisible itemframe behind with the right persistent data

#

but if your furniture is made of 10 barriers, I would need to save the orientation and the root location in every block

#

so that if one of these blocks is broken, I can find the other ones

hardy swan
#

you said invisible itemframe

#

it is behind one of these barriers right

#

for every "furniture"

quaint mantle
#

yep right

#

so it's easy if your furniture is made with only one barrier, because you can easily find the item frame

#

but if this is a furniture with one item frame and 10 barrier blocks

#

then that's not easy

hardy swan
#

ah ok

quaint mantle
#

I would need to store the location of the item frame in these 10 blocks

#

or something like that

hardy swan
#

you may have to store it in a database

#

or

#

find entity within radius

maiden briar
#

Bungeecord I get Already connecting to this server, but I only call the connect method once

hardy swan
#

and if any is itemframe, it may tell you whether the block belongs to this furniture

quaint mantle
#

hmmm

hardy swan
#

itemframe can hold persistentdata

#

so it is almost as good

quaint mantle
#

yes as I said this is what I am already using

#

my problem is to find the itemframe when you break a block from a big furniture

#

currently it's easy because this can't be further than 1 block

quaint mantle
#

So I do something like that:

#
                    for (Entity entity : block.getWorld().getNearbyEntities(block.getLocation(), 1, 1, 1))
                        if (entity instanceof ItemFrame frame
                                && entity.getLocation().getBlockX() == block.getX()
                                && entity.getLocation().getBlockY() == block.getY()
                                && entity.getLocation().getBlockZ() == block.getZ()
                                && entity.getPersistentDataContainer().has(FURNITURE_KEY, PersistentDataType.STRING)) {
                            if (entity.getPersistentDataContainer().has(SEAT_KEY, PersistentDataType.STRING)) {
                                Entity stand = Bukkit.getEntity(UUID.fromString(entity.getPersistentDataContainer()
                                        .get(SEAT_KEY, PersistentDataType.STRING)));
                                for (Entity passenger : stand.getPassengers())
                                    stand.removePassenger(passenger);
                                stand.remove();
                            }```
hardy swan
#

finding entity in a radius is not difficult

quaint mantle
#

hmm I'll look into that

quaint mantle
#

if your furniture is 50 blocks long, it might not be a good idea to check it everytime someone breaks a barrier block

#

I'll check it out @summer scroll

#

it looks awesome, thank you very much! ❤️

hardy swan
quaint mantle
hardy swan
#

I don't know how getNearbyEntities is implemented, but it may not be slow

quaint mantle
#

Yeah may be

#

but this solution looks better

dense goblet
#

Is there a way to get an entity's projectile resistance or do I need to manually sum the enchantments

dense goblet
#

okay, is there anything else I need to consider

lost matrix
dense goblet
#

I'm damaging an entity with my own projectile

lost matrix
#

Because potion effects also can reduce the damage a projectile does. Same goes for normal protection.

dense goblet
#

yeah I tested and resistance is applied automatically

#

when doing entity.damage()

lost matrix
#

If you damage the entity with DamageType.PROJECTILE then the enchantment should also be applied automatically

dense goblet
#

how do you set the type?

#

do I need to call setLastDamageCause before?

lost matrix
#

I thought there was just a method for that. Let me investigate.

dense goblet
#

yeah I think forge had that but don't see it in spigot

lost matrix
smoky oak
#
getConfigurationSection(x+"-"+"-"+y+"-"+z)```
or
```java
getConfigurationSection(x+"."+"."+y+"."+z)```
when storing/accessing extra block data?
dense goblet
#

can I instantiate an EntityDamageEvent?

lost matrix
smoky oak
#

i meant

#

the forman

#

t

hardy swan
#

it is .

lost matrix
smoky oak
#

like should i make it in the style of

x:
  y:
    z: 'Seven'
#or
x_y_z: 'Seven'
lost matrix
dense goblet
dense goblet
lost matrix
# dense goblet Does firing the event actually apply the damage?

Something like that:

  public void damageWithProjectile(final LivingEntity target, final double damage) {
    final EntityDamageEvent entityDamageEvent = new EntityDamageEvent(target, DamageCause.PROJECTILE, damage);
    Bukkit.getPluginManager().callEvent(entityDamageEvent);
    final double finalDamage = entityDamageEvent.getDamage();
    target.setHealth(Math.max(0, target.getHealth() - finalDamage));
  }
lost matrix
#

I dont think so?

#

But you should test that

dense goblet
#

yeah will do thanks

dense goblet
#

either way it has getFinalDamage() so I can get that and manually apply

smoky oak
#

i need a config_section by coordinates

dense goblet
smoky oak
#

String key = x + "_"+y+"_"+z ?

lost matrix
smoky oak
#

yes

dense goblet
#

I use this:

public static final class BlockPosition implements Serializable {
        private static final long serialVersionUID = 100L;

        public final int x;
        public final short y;
        public final int z;

        public BlockPosition(Location location) {
            this(location.getBlockX(), (short)location.getBlockY(), location.getBlockZ());
        }
        public BlockPosition(int x, int y, int z) {
            this(x,(short)y,z);
        }
        public BlockPosition(int x, short y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public BlockPosition above() {
            return new BlockPosition(x,(short)(y+1),z);
        }
        public BlockPosition below() {
            return new BlockPosition(x,(short)(y-1),z);
        }
        public BlockPosition east() {
            return new BlockPosition(x+1,y,z);
        }
        public BlockPosition west() {
            return new BlockPosition(x-1,y,z);
        }
        public BlockPosition south() {
            return new BlockPosition(x,y,z+1);
        }
        public BlockPosition north() {
            return new BlockPosition(x,y,z-1);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            BlockPosition that = (BlockPosition) o;
            return x == that.x && y == that.y && z == that.z;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y, z);
        }

        @Override
        public String toString() {
            return "(" + x + "," + y + "," + z + ")";
        }
    }
#

there are some casts to short left-over from when I didn't have the second constructor so you can ignore those

smoky oak
#

how exactly would i use that in a hashmap? <Object, ConfigurationSection>

dense goblet
#

<BlockPosition, YourExtraData>

smoky oak
#

yea as said it changes hence configsection

dense goblet
#

changes?

#

just use polymorphism

smoky oak
#

depending on the block

lost matrix
# smoky oak yes

Then check this post out:
https://www.spigotmc.org/threads/tracking-blocks-that-were-placed-by-players.500216/

Saving such data in the PersistentDataContainer of a chunks is def a possibility. This way you dont need to think about where and when to save the data.

dense goblet
#

if you want it completely custom per-block (like nbt is completely custom per item) then you can use a Map<String, ConfigurationSerializable> or Map<String, Serializable> as the value

#

that would be most similar to a config section

#

then you could do YourCustomDataType.data.put("arbitraryDataName", arbitraryDataValue);

smoky oak
#

well i plan on storing it as a configuration section, do i have to cast it to configurationserializable ?

dense goblet
#

anything you serialise with bukkit's serialisation has to be either config serialisable or normal serialisable

smoky oak
#

but why would i use serializable in the first place

#

i mean

#

i get configsections from the file

#

and use configsections in my code

dense goblet
#

but that will be slower than having:
class ConcreteCustomBlockData extends YourAbstractCustomDataType {
private String someVar1;
private UUID someVar2;
private int someVar3;
}

#

config sections seem to be designed for config stuff not for arbitrary data serialisation

quaint mantle
#

hey ! I have a problem with a plugin in minecraft can someone help me or try to help me ?

dense goblet
#

also config sections are, I believe, configuration serialisable anyway

quaint mantle
#

Oh sorry

#

Im new lol

#

So

smoky oak
#

I just realized

#

loading that hashmap puts it in ram

quaint mantle
#

teams:
enabled: false
solo-item: "Oxey_Daisy"
solo-name: "&fSolo"
team-items:
- "BLUE_DYE"
- "RED_DYE"
team-names:
- "&1Blue"
- "&4Red"
teamlore: "&3Use this chest to choose a team!"

smoky oak
#

but i need my plugin to be cpu heavy instead of ram heavy

quaint mantle
#

here is my problem

#

i ran a bingo plugin

#

and i cant enable team

#

when i change false and true

#

the plugin doesnt work on my server

dense goblet
#

@quaint mantle ah, this channel is just for help with your own plugins

quaint mantle
#

oh and where can i redirect for my problem ?

dense goblet
#

the plugin should have a discussion section, faq or github issues page

smoky oak
quaint mantle
#

yes i know i tested

#

no problem

#

thanks

#

🙂

smoky oak
#

I also would rather not store that data in the chunk files as in the plugin linked so that there is no data leftovers after deleting the plugin and its files

dense goblet
smoky oak
#

no

dense goblet
#

then you will have big files on big worlds

smoky oak
#

I could but that would bring a whole other host of problems with it

dense goblet
#

that's what I do

#

then clear the files when necessary