#help-development

1 messages · Page 445 of 1

icy beacon
#

i'm scared to open it

pseudo hazel
#

its only 350 lines

tardy swift
#

?

icy beacon
#

the code randomly interrupts

#

??????????????????????????????????????????????

#

@tardy swift

pseudo hazel
#

where is the rest of it

icy beacon
#

why is everyhthing in one class as well 😭

#

i give up

#

steaf you deal with it

#

i believe in you

pseudo hazel
#

I have dinner ready xD

icy beacon
#

have a good meal

river oracle
#

He forgot about the new class button

#

Or they are a python dev

icy beacon
#

bro forgot about all keyboard buttons

young knoll
#

I wonder where this code came from

icy beacon
#

seeing as the code abruptly ends

pseudo hazel
#

ty lol

icy beacon
#

but it's hard

river oracle
#

A certain AI anyone??

icy beacon
#

this ai is bad at indenting for sure

tardy swift
#

i send something

river oracle
#

That still cuts off

icy beacon
#

bro just sent his entire fucking project

river oracle
#

Also what's with the random xml at the top

hybrid spoke
#

i wanted to scroll this shit

icy beacon
#

what is this witchcraft

#

@tardy swift you said that somebody told you that this code is valid\

#

make sure to punch them in the face next time you see them

ancient plank
#

dont be mean

icy beacon
#

sorry :3

daring lark
#

how can i check if entity can reproduce?

river oracle
#

AIs don't have feelings

ancient plank
#

I don't care how bad the code is, but there's no value in insulting someone because their code isn't what you consider great

icy beacon
daring lark
icy beacon
#

because bad code compiles

young knoll
#

Iirc it’s Entity instanceOf breedable

tardy swift
#

whats problem ???

#

it will never work ?

river oracle
#

By chance

icy beacon
#

well if you manage to compile java code with random xml gibberish in its header i'll be pretty impressed

tardy swift
icy beacon
#

your friend probably used an ai

tardy swift
#

why

river oracle
#

Idk ask your friend

icy beacon
#

because this code looks mighty weird and inconsistent and well

icy beacon
tardy swift
#

what it mean

icy beacon
#

i cannot start to comprehend this code enough to explain it to you

#

i'm sorry

daring lark
river oracle
#

You need to learn to code before coding

icy beacon
river oracle
#

I'd be more apt to help but it seems like you have 0 knowledge of java

tardy swift
icy beacon
#

yes.

daring lark
tardy swift
#

like

icy beacon
#

i think "canBreed" means generally

#

can breed at all

tardy swift
#

it will not event be detect by mc

icy beacon
river oracle
twilit roost
#

does this look valid?
or do I need to create POST_PARAMETERS?

#

oh lord
this site offers the code this
sorry :D

tardy swift
daring lark
river oracle
#

It takes time but it's a very useful skill

terse ore
#

wait what

#

tiwitters algorithm is open source

mint nova
#

Hello i have a question. Can i somehow create an items in 1 inventory.setItem(index, ItemStack)?

#

To get out of this

fluid river
#

umm

icy beacon
fluid river
#
for (int i = 0; i < 54; i++) {
    if (i > 19 && i < 17) continue;
    inventory.setItem(i, glass);
}```
icy beacon
#

i don't know an elegant approach but i'd do smth like

Set<Int> of (0,1,2...)
set.forEach(slot -> inventory...
fluid river
#

yup

mint nova
#

Thanks you guys

icy beacon
mint nova
#

for helping

icy beacon
#

anytime

fluid river
#

actually interesting

#

what's gonna be faster

#

for loop with ifs

#

or forEach

#

cuz forEach is kinda sus

icy beacon
#

benchmark it

#

yours is probably faster but it can hurt readability imo

fluid river
#

but it doesn't have ifs cuz the set is predefined

icy beacon
#

i prefer readability over minor optimization

pseudo hazel
#

why not both

#

make the set and loop over it

#

probably just as fast as forEach but whatever

viral temple
#

?paste

undone axleBOT
icy beacon
#

what material would i use in a gui to represent a list of players? like, i click the button and a gui with all online players opens for example

#

this isn't a code question, it's an opinion question

#

a player head is out of the question

#

i need a glowable item

pseudo hazel
#

ender eye?

icy beacon
#

for some reason it refuses to glow

icy beacon
pseudo hazel
#

tf is glow

#

you mean enchant?

icy beacon
#

like an enchantment glow

#

alr i'll use an ender eye perhaps

pseudo hazel
#

paper

#

filled map

#

book

#

idk

icy beacon
#

book i use for culture upgrades

#

filled map i use for stats

#

perhaps an ender eye works well

pseudo hazel
#

there is not really a good item for it

icy beacon
#

yeah

pseudo hazel
#

just make a resource pack 🤷

icy beacon
#

haha nah i don't care THAT much

pseudo hazel
#

lol

icy beacon
#

it's fine

#

ty

terse ore
#

does anyone know what's wrong with my sql?

pliant blaze
#

Hlo

#

how to stop griefing in server

icy beacon
viral temple
#

https://paste.md-5.net/vujomeciwa.coffeescript
So, the story goes like this: the first method where the UUID is supplied works, the second method where it should return everything, it doesn't work...
This is for MySQL, because for SQLite is working just fine (with other implementation)
Can anyone find wth is not working?
for me sout is not even showing....

pseudo hazel
terse ore
#

think of it like a variable

#

in my java code I set those

pseudo hazel
#

okay

terse ore
#

but the problem is with the WHERE NOT EXISTS

icy beacon
pseudo hazel
#

i cant help srry xD

icy beacon
#

maybe select * would work?

terse ore
#

doesnt seem to be that

#

it is related to WHERE NOT EXISTS

pseudo hazel
#

are the red lines relevant?

terse ore
#

I am getting an error at the red lines

tender shard
#

what's that supposed to mean

icy beacon
#

good point

pseudo hazel
#

xD

icy beacon
#

select from .. where ..

#

maybe that'd work

pseudo hazel
#

insert where there is this data 😛

icy beacon
#

but insert i doubt

#

update?

#

maybe you're looking for update

tender shard
#

what is it supposed to do

terse ore
#

insert into participants where not exists(check here if something exists)

tender shard
#

that makes no sense

terse ore
#

I think I just found an example

icy beacon
#

i think you're looking for update yeah

terse ore
#

let me try it

icy beacon
#

UPDATE table SET ... WHERE condition

#

i th ink

pseudo hazel
#

you wouldnt be able to insert somewhere where something exists

icy beacon
#

true

pseudo hazel
#

because then it wouldnt be inserting

terse ore
#

it would insert

#

it will be duplicate

icy beacon
#

into where

terse ore
#

wait what happens if I make the primary key unique

icy beacon
#

can you tell us in plain english what you want to do

terse ore
#

insert something if it doesn't exist

pseudo hazel
#

thats always

icy beacon
#

EXACTLY what you want to do

pseudo hazel
#

you cant insert something that already exists

icy beacon
#

please

terse ore
icy beacon
#

..

pseudo hazel
#

what this is supposed to save

icy beacon
#

"I want to change a player's world"

pseudo hazel
#

like whats in the database

#

whats the purpose

icy beacon
#

"I want to commit manslaughter"

#

(via the tools of, for example, somerthing)

#

And you want to do what via the tools of sql?

terse ore
#

yes

icy beacon
#

what the fuck is yes

icy beacon
#

And you want to do W H A T via the tools of sql?

#

in PLAIN english

terse ore
icy beacon
#

not in SQL

#

insert W HAT???????

pseudo hazel
#

zbll is going bananas please respond with what you want to use the database for

icy beacon
#

WHY??

terse ore
icy beacon
#

insert if it doesn't exist

terse ore
#

yeah

pseudo hazel
#

I guess you dont want help then xD

icy beacon
#

because it doesn't exist

#

is it what you are trying to do

#

i assume not

pseudo hazel
#

wtf is some values

icy beacon
#

then what the fuck ARE you trying to do

terse ore
#

man you're confusing th out of me

pseudo hazel
#

the solution always depends on the context

icy beacon
#

?xy

undone axleBOT
pseudo hazel
#

what do you want to store in the database?

icy beacon
regal scaffold
#

Hey

#

?gui

icy beacon
#

?guis

undone axleBOT
regal scaffold
#

Looking for smile7 implementation

tender shard
icy beacon
#

^

terse ore
icy beacon
#

are we speaking the same english

pseudo hazel
#

so those lines are unrelated?

tender shard
#

okay anyway, there is no WHERE in INSERT. Because it makes no sense

regal scaffold
#

Ok I have a question with this implementation,

Currently if I want to have a sub-gui open from the GUI, What I do is I create a new GUI instance from a item button.

But I'm wondering, I want to do a multi-page system. How can I change the implementation to allow me to have a previous/next or is the approach just to create a new instance of each page every time and keep track of what page the current one is?

tender shard
#

WHERE is the table on insert

terse ore
#

I asked, how could I insert into the table only if the values I tried to insert do not exist

regal scaffold
#

I could have a private int pageNumber on each menu and use that in the manager to figure out what page is currently on and what next and back should do

tender shard
#

what you are trying to do is probably INSERT … ON DUPLICATE KEY UPDATE

pseudo hazel
#

just insert it regardless

terse ore
pseudo hazel
#

why do you need to know if its already there

tender shard
terse ore
#

then I would have duplicates

icy beacon
pseudo hazel
#

xD

pseudo hazel
#

i sense youve gone mad from the people asking for help this past hour

icy beacon
#

i want to commit blanket

terse ore
pseudo hazel
#

well if instead or repeating "insert into where" you could explain what the purpose of your database is

regal scaffold
#

@lost matrix I have a question with your GUI implementation.

Currently if I want to have a sub-gui open from the GUI, What I do is I create a new GUI instance from a item button.

But I'm wondering, I want to do a multi-page system. How can I change the implementation to allow me to have a previous/next or is the approach just to create a new instance of each page every time and keep track of what page the current one is? Is creating a new instance of the desired page every single time the right way? I could keep track of the current page used and then do stuff accordingly

pseudo hazel
#

thats the wrong smile

regal scaffold
#

Indeed lol

pseudo hazel
#

btw @regal scaffold editing the message isnt gonna ping him retroactively i dont think

icy beacon
#

just mention acf and smile will wake up automatically from his long hibernation

#

at least that worked a couple times

regal scaffold
#

I think you're right

#

But I left the message there

#

Maybe he'll answer

#

Not gonna spam ping him

pseudo hazel
#

fair

twilit roost
terse ore
#

@tender shard INSERT OR IGNORE works for me

#

with unique keys

young knoll
#

The only slightly annoying thing about it is that it triggers auto increment rows

terse ore
#

wth

#

why would it do that

young knoll
#

Because it tries to insert first

terse ore
young knoll
#

I mean it doesn’t really matter

vocal cloud
#

You can always check if it exists first

twilit roost
ocean hollow
#

Guys, how to change the description of all items on the server? For example, the player receives an oak, and it is renamed to a different name

mint nova
#

How i can turn this code, so in config,yml i can use & to color instead this idk symbol

#

because idk

ocean hollow
wise mesa
#

what'

pseudo hazel
wise mesa
#

oops

#

hit enter by accident

mint nova
pseudo hazel
#

before what

mint nova
#

Because i need to do a prefix only

young knoll
#

The best way to change the item names would be with a resource pack

mint nova
#

wait

#

i just...

#

i dont say this word

young knoll
#

Or with a packet listener

wise mesa
#

what's a good way to go about making an unbreakable block breakable

#

or any way at all

#

i was thinking something with playerinteractevent?

#

but then idk how to do the delay

#

and is it possible to have the block breaking effect

young knoll
#

You can make a full custom breaking system like hypixel has

echo basalt
#

^

wise mesa
#

i have no clue where to start

echo basalt
#

well

young knoll
#

I actually have one that’s mostly functional

echo basalt
#

the player sends an arm swing animation packet every tick

#
  • a Start Dig, Stop dig, Abort dig packets
#

you can then calculate time

pseudo hazel
#

or you can make a resourcepack if you are dedicated and lazy

echo basalt
#

and send block break animation packets

wise mesa
#

i see

#

that works

young knoll
#

There is a method for sending the break effect in the api

ocean hollow
young knoll
#

But you can only have one at a time

pseudo hazel
#

sure, but why?

young knoll
#

Until Chocos pr gets merged

mint nova
echo basalt
#

well you're already intercepting packets

#

so at this stage you're limitless

young knoll
#

You don’t have to

pseudo hazel
pseudo hazel
wise mesa
#

well id love to see all the options

#

so i still wanna take a look at it

young knoll
#

sendBlockDamage

mint nova
wise mesa
#

ah i see

young knoll
#

?paste

undone axleBOT
young knoll
#

That's the bulk of what I did for custom block breaking

mint nova
#

can anyone help? I reload my config and the change color didnt work.

This is my code:

     if(player.hasPermission("wiadomosc.reload")){
            player.sendMessage(ChatColor.GREEN + "Pomyślnie przeładowano plik config.yml");

            plugin.reloadConfig();
        }
``` reload command

```java
        String prefix = config.getString("prefix");
        prefix = ChatColor.translateAlternateColorCodes('&', prefix);
``` this is convert color, in sent message command

```yml
prefix: '[Wiadomosc] '
``` and simple config file
tardy delta
#

bruh moment, now i both have a getValue() and value()

pseudo hazel
tranquil dome
#

My main class looks like this:

class Main: JavaPlugin(), DiscordoPlugin { ... }

It extends JavaPlugin and it implements my interface, DiscordoPlugin. This interface contains a method to access DiscordoAPI. In another plugin, I get the plugin instance of Discordo using the following:

DiscordoPlugin dp = (DiscordoPlugin) Bukkit.getServer().getPluginManager().getPlugin("Discordo");

Since my main class implements DiscordoPlugin, this cast should work, however, I get the exception:

java.lang.ClassCastException: dev.bloedarend.discordo.plugin.Main cannot be cast to dev.bloedarend.discordo.api.DiscordoPlugin

What am I doing wrong?

subtle folio
#

General theory question, how would I go about making a plot system? Would I great a new world? Or like space out each plot by 100 blocks?

pseudo hazel
tranquil dome
pseudo hazel
#

wel judging from the error you clearly have access to Main

#

or maybe I am misunderstanding

tranquil dome
#

This returns the Main instance of my plugin, but the return type is Plugin

Bukkit.getServer().getPluginManager().getPlugin("Discordo")
pseudo hazel
#

I see

#

I think you have to wait for someone more experienced with object juggling like this xD

tranquil dome
#

Alright, nw :)

eternal oxide
tranquil dome
#
[19:50:59 ERROR]: Error occurred while enabling TestPlugin v1.0-SNAPSHOT (Is it up to date?)
java.lang.ClassCastException: dev.bloedarend.discordo.plugin.Main cannot be cast to dev.bloedarend.discordo.api.DiscordoPlugin
        at test.dont.matter.testplugin.TestPlugin.onEnable(TestPlugin.java:18) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_321]
#

Wait hold on

eternal oxide
#

did you make a mistake and shade your plugin into your other one?

tranquil dome
#

I'm not sure, but I don't think so

eternal oxide
#

?paste your pom

undone axleBOT
tranquil dome
eternal oxide
#

yep your last dependency needs a provided scope

quaint mantle
#

what argument does it expect from me

worldly ingot
#

The constructor is right in the tooltip

#

In fact, it's your constructor lol

delicate lynx
#

show us the base class....?

#

it needs an argument so put one

worldly ingot
#

Base(Player target)

tranquil dome
delicate lynx
#

I am blind, didn't see the constructor there oops

quaint mantle
young knoll
#

It wants a player

quaint mantle
#

got it

young knoll
#

It's not doing anything with it though

quaint mantle
#

yh i got it

tardy delta
#

effects of doing too much python heehee

quaint mantle
#

or well it doesnt work

#

it doesnt trow errors anymore but the listiner also doesnt work

sage patio
#

how i can find that sound from the code?

#

is there any way?

#

(i want to change the sound in my resourcepack, but i don't know to change & play what)

terse ore
torn shuttle
#

@tender shard you lurking?

young knoll
#

That's not a PR :p

torn shuttle
#

you mean for spigot?

young knoll
#

yes

torn shuttle
#

I'll do a spigot PR for this if I ever actually get comfortable with the inner workings of it

#

there's a lot of weird shit in here

#

the two AI systems is a shame, if they stuck to goalmanager it would be an easy addition

young knoll
#

Yeah smh mojang

torn shuttle
#

the fact that it uses goalmanager and brains and memories and per-entity AI is just a nightmare

young knoll
#

Choco did a PR for a goal API a while back

#

But he got stuck on how to abstract all the vanilla goals so a plugin can make instances of them

torn shuttle
#

brains do not expose enough to work with just through mappings, I will probably have to work around them to actually extend functionality

#

like you can't by default just remove a goal in a brain

#

it's not an accessible field

#

you can remove all goals or you can go eat shit

young knoll
#

Not as much of an issue for an API

#

We can modify access

torn shuttle
#

yeah not the worst thing, it's just compounding nuisances

#

what was choco stuck with?

young knoll
#

This pull request IS a work in progress as of creating it because feedback is absolutely required before moving forwards. There are a few issues to address before this can get merged and they are as follows:

Vanilla pathfinder goals are unsupported
    a. I cannot think of a sane way to interface with all vanilla pathfinder goals without creating 57 interfaces for every vanilla pathfinder goal. That's a little bit messy
    b. If the approach above is used, there is no sane way to let developers create new instances of said interfaces because... well... they're interfaces
Navigation is really inconsistent. If the entity is focused on some entity other than the one to which it should navigate (i.e. #setTarget()), it will not navigate at all rendering the method pretty useless. I'm not sure of any alternative because this is just vanilla behaviour.
torn shuttle
#

that second one sounds like a sort of misunderstanding of how the system is meant to work

#

from what I read the target, if any, is just where the entity will go

young knoll
#

(Keep in mind this is from 2017)

torn shuttle
#

the only workaround is to feed it a different target and force the entity to hold it via goals

#

though

#

navigation is confirmed to be shit

#

like I don't know if I still have some setting not quite right but it looks like it's barely able to pathfinding using the default methods, the next thing I'm adding is my own A* pathing

young knoll
#

I mean it certainly works fine for Mojang

torn shuttle
#

if you can't extend goal to create your own goal there really isn't much of a reason to have the system in the first place

torn shuttle
quaint mantle
#

ive added the listener under the command now but how exactly can i accsess the target

young knoll
#

I guess not being able to extend vanilla goals would be annoying yeah

torn shuttle
#

are bats still committing suicide in caves?

#

also even 57 interfaces wouldn't cut it as much as you might think, there is a lot of hardcoded stuff in here

#

like slime movement

#

that's just hardcoded jumps

young knoll
#

The idea bounced around in the PR was factory methods

#

But that wouldn't let you extend the vanilla ones

torn shuttle
young knoll
#

Making instances of the vanilla goals

torn shuttle
#

ah

#

imo unextendable vanilla goals are fine so long as you can modify them to some extent, the main thing is I think you still need to be able to extend Goal in the first place

young knoll
#

You could always delegate to them

torn shuttle
#

was that PR before brains were added to the game?

young knoll
#

Not sure

#

There was an extendable goal in it

torn shuttle
#

pr would've been worth it just to have that one

young knoll
#

Yeah sadly it died

#

Could definitely revive it to that point fairly quickly though

#

Might do that

torn shuttle
#

at this stage I wouldn't bother unless you have something solid for brains, all new entities use them and I wouldn't be surprised if some soonish update gets rid of goalsmanager entirely

young knoll
#

I'll have a look at them

#

They can't be that complimicated

torn shuttle
#

nah main thing is they hold states

#

instead of the old manager which only did priorities

young knoll
#

Hmm

#

It is annoying they are split tho, I agree with that

#

What even uses brains

#

Villagers, Camel, Sniffer, ?

torn shuttle
#

everything since the nether revamp update

#

not villagers

#

afaik

young knoll
#

Pretty sure they do

torn shuttle
#

might be wrong though

young knoll
#

Iirc they were the debut of brains

torn shuttle
#

uh

echo basalt
#

villagers use brains

#

and I kinda hate the brain system

#

because well... it's not that well abstracted

young knoll
#

But you know what we can do

torn shuttle
#

no you're right

young knoll
#

We can add a hasBrain method :p

torn shuttle
#

they use brains

#

surprising

#

first one I've seen retrofitted

young knoll
#

They got brains in 1.14

#

I wonder if the pillagers use them

#

Nope

torn shuttle
#

1.14?

#

that long ago?

#

weird

#

most of all I just wish there was just the one system

young knoll
#
Brain<Villager> behaviorcontroller = this.getBrain();
behaviorcontroller.stopAll(world, this);
#

Lobotomy method

torn shuttle
#

because rn I have to replicate AI across two different systems and for however many versions I want to support

#

if you remove the brain do they magically start using the goals? That would be funny

young knoll
#

Alright so we have Activities

#

Which are a registry item

torn shuttle
#

states

#

within them you have priorities

#

though everything seems to mostly have the same priority because why not

#

then you have behaviors

#

behaviours are basically goals 2.0, even the method layout is similar

young knoll
#

Memories, Sensors, Behaviors, and Schedule

torn shuttle
#

yeah

young knoll
#

I'm going to guess memories save things, sensors are for finding targets, behaviors are for actual movement

#

And schedule is idk

torn shuttle
#

uh sorta

#

I haven't really delved beyond behaviors thus far

#

I do wonder if there is a way to just set a dude to pathfind without setting a goal

#

I'm not trying to send body parts flying, I could teleport mobs to do that, I'm trying to use the navigation to send the pathfinding entity on its way without having to register a permanent goal

young knoll
#

PathNavigation has a moveTo method

torn shuttle
#

it sure does

weak meteor
#

Does enchantments have order that applies to all items?
Like:
First Sharpness
Second Protection

torn shuttle
#

maybe I did it wrong before but it looked like any goal would override that @young knoll

#

so effectively useless unless I lobotomize them

young knoll
#

I see

torn shuttle
#

I'll have to retest it but I am decently sure I got it right in 1

#

it's real easy to do it for entities managed by goals because you can just remove a goal instance, brains are clearly way more annoying

tawny remnant
#

Why can't I import ServerPlayer to my maven project? It's not suggesting it in the import net.minecraft.server.level

eternal oxide
#

?nms

mystic terrace
#

Hello! First of all I want to say that I'm new coding, and I learned today how to make custom config file, but I don't know how to create a realod method for them to use "/maincommand reload".

Code:

    public static void createFiles(SimplePortalPermissions files){
        if (!files.getDataFolder().exists()) {
            files.getDataFolder().mkdirs();
        }

        //Creates messages.yml
        messagesFile = new File(files.getDataFolder(), "messages.yml");
        if (!messagesFile.exists()) {
            files.saveResource("messages.yml", false);
        }
        messages = YamlConfiguration.loadConfiguration(messagesFile);
    }
terse ore
#

How would be a good approach on making a gui?

#

(any resources?)

tawny remnant
# eternal oxide ?nms

Thank you good sir, i found the problem. I didn't have the remapped in the dependencies!

terse ore
mystic terrace
#

It's custom config

terse ore
#

@young knoll do you recommend me using some inventory APIs or handle it by myself?

young knoll
#

Up to you

terse ore
#
    @Override
    public void reloadConfig() {
        newConfig = YamlConfiguration.loadConfiguration(configFile);

        final InputStream defConfigStream = getResource("config.yml");
        if (defConfigStream == null) {
            return;
        }

        newConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
    }```
That's the code for reloadConfig();
terse ore
young knoll
#

My own

mystic terrace
terse ore
#

you can adapt it to reload your custom config

quaint mantle
#

Hi , guys , help please

#

Who know write mods

#

1.16.5 Forge

terse ore
terse ore
#

idk why I can't invite to the proper one

quaint mantle
#

How to import 3D armor into Minecraft?

terse ore
#

@quaint mantle

quaint mantle
#

Thank

terse ore
pure dagger
#

Can anyone explain how to do that? i dont know how to use world generator

#

is this hard?

chrome beacon
#

You could just use PlotSquared

pure dagger
#

i want to write it

#

i dont think its that hard

terse ore
#

custom chunk generator

mystic terrace
terse ore
terse ore
#

remember to use saveConfig if you have cached changes

pure dagger
#

oh ok

terse ore
terse ore
#

can you send code of how you manage custom config

#

?paste

undone axleBOT
mystic terrace
terse ore
#

I would actually make a class per config file

#

(possibly an interface and implement it in each class)

mystic terrace
#

I'm gonna keep it like this atm, i don't wanna suffer again xd

terse ore
#

it will free you of future headaches

mystic terrace
#

It's just for learning purposes, I will do it

#

but can you help me with that?

terse ore
#

for sure

mystic terrace
#

I mean, what happen if I don't put it?

terse ore
#

let me give you an example

#
public class ConfigMessage {
  private final File configFile;
  private FileConfiguration config;
  
  public ConfigMessage() {
    File file = ...;
    handle file existance
    
    this.config = new YamlConfiguration();
    try {
      this.config.load(file);
    catch (IOException e) {
      e.printStackTrace();
    }
  
    this.configFile = file;
  }

  public void reload() {
    do reload stuff
  }
}  
#

so in that case you can construct that class on your JavaPlugin class

#

and then you can create methods inside it

#

so you will be able to do configMessage.reload()

mystic terrace
#

perfect

#

thanks!

terse ore
#

np

quaint mantle
#

how can i use the target from the command in the listener

tardy delta
#

probably put them in some collection

#

whats that doing tho, its way too small

rotund ravine
#

wasn't much better haha

tardy delta
#

lets rephrase that im too lazy to read all of it

#

just use some kind of collection ye

quaint mantle
#

i have no idea what im doing half of the time

rotund ravine
#

?paste

undone axleBOT
rotund ravine
#

thank you

quaint mantle
#

i dont really know where else to run it from then the listener cause the reuest is only supposed to be send when they click a certain item in the gui

sharp bough
#

for sqlite querys should i use

Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
            @Override
            public void run() {
     
            }
        });

or something else?

tardy delta
#

i use a CompletableFuture

#

so forkjoinpool, it just needs to be async

regal scaffold
#

I'm using Smile GUI Implementation

#

But I'm wondering, is there a way I can make it so that when a user presses "esc" it goes to a specific GUI but when a user clicks a icon it creates a new instance of the current GUI

tardy delta
#

sec is just inv close event

#

esc

regal scaffold
#
                .consumer(event -> {
                    Bukkit.getScheduler().runTaskLater(plugin, () -> {
                        plugin.guiManager.openGUI(new SpeedUpgradeInventory(ultraChest), player);
                    }, 1L);
                });

Item click

#

The problem is

#
    @Override
    public void onClose(InventoryCloseEvent event) {
        super.onClose(event);
        Bukkit.getScheduler().runTaskLater(plugin, () -> {
            plugin.guiManager.openGUI(new MainMenuInventory(ultraChest), (Player) event.getPlayer());
        }, 1L);
    }

Overrides the previous one

tardy delta
#

are you closing the prev one?

#

the current one i mean

regal scaffold
#

I am not

regal scaffold
tardy delta
#

ah its in the close event

regal scaffold
#

So it thinks it is closing

#

What shall be my workaround

tardy delta
#

id say delay it a bit more but if it gets over 5 ticks or something then it just doesnt work

regal scaffold
#

I see it

#

work

#

It opens the same one first, then instantly opens the onClose() one

#

But how can I have both functionality, if escape go to old menu, if click item open same menu

lyric berry
#

If anyone know how to setup vault api that can help I'd appriciate it. I followed the vault api github page and my plugin has depend: [Vault] but it keeps saying it can not find Vault :(

terse ore
#

Just by checking if inventoryholder is null I make sure that players don't "imitate" my inventory right?

weak meteor
#

does the return statment matters?

#

Like, in some tutorials and codes i see it is return true;

#

but this is the default i get from the interface

rotund ravine
#

it returns the "usage" from the plugin.yml if you return false.

terse ore
#

?nms

tardy delta
regal scaffold
#

I'm using Smile GUI Implementation
But I'm wondering, is there a way I can make it so that when a user presses "esc" it goes to a specific GUI but when a user clicks a icon it creates a new instance of the current GUI.

What happens rn is that upon clicking an item it reopens the current inventory but then it activates the close event which opens the menu inventory.

How can I have both functionality?

lyric berry
tardy delta
#

show code

lyric berry
# tardy delta show code
    private boolean setupEconomy() 
    {
        if (getServer().getPluginManager().getPlugin("Vault") == null)
        {
            return false;
        }

        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        
        if (rsp == null) 
        {
            return false;
        }

        econ = rsp.getProvider();
        return econ != null;
    }
tardy delta
#

also got an economy plugin?

lyric berry
#

and the onEnable just checks this method

lyric berry
young knoll
#

Well

#

This isn't going to work then

tardy delta
#

not sure if vault knows to load yours

young knoll
#

RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);

young knoll
#

Exactly

#

You won't get anything in return, you need to be the one registering the service

regal scaffold
#

java.lang.IllegalArgumentException: The embedded resource 'phoneData/db49723f-afd0-439c-9c32-7487e06b16d7.yml' cannot be found in plugins\rpphones-1.0-SNAPSHOT.jar

#

I'm saving a resource using plugin.saveResource("phoneData/" + phone.phoneUUID + ".yml", true);

#

Clearly doing something wrong

tardy delta
#

that wont work

#

saveResource gets an embedded resource from within your jar and exports it to the plugins/plugin folder

regal scaffold
#

new File()

#

Oh

tardy delta
#

just call save on the fileconfig

regal scaffold
#

I'm dumb

tardy delta
#

or file, i forgot

regal scaffold
#

Wait but If I'm creating a new file

#

I assume I need to create the file first

#

Then attach the FileConfiguration

#

Then save it

tardy delta
#

ye

lyric berry
tardy delta
#

thats how it works

#

if you depend on it, the server ensures its loaded

regal scaffold
#

Perfect

#

So then, last question. getDataFolder gives me the entire folder

#

What if I want to make a subfolder

#

Do I create it once on first startup?

tardy delta
#

new File(dataFolder, "subfolder")

#

uhh id do it on first save

regal scaffold
#

Perfect!

#

Thanks

#

If the subfolder isn't there

#

Don't matter because if subfolder is subfolder/file.yml

#

It'll save it correctly

tardy delta
#

file.mkdirs()

#

on file.yml

regal scaffold
#

Oh

#

I thought it would still save it correctly

tardy delta
#

that will ensure its parent folders exist

regal scaffold
#

Gotcha

#

Thanks

#

Now gotta figure out how to correctly overwrite

#

On save

tardy delta
#

doesnt FileConfiguration#save do that?

#

its FileWriter related and im not aware of the impl

regal scaffold
#

Still need to pass it a file

tardy delta
#

ye that file may or may not exist on your disk

regal scaffold
#

Yup

#

Got it!

#

It's my first time using config as a "database"

#

I've always just serialized and store in pdc or sql

#

This is so cool

tardy delta
#

you are better than the dude that saved json in a sql db

regal scaffold
#

I saw

#

I wanted to cry

#

I'm way past that, gotta admit

#

loll

young knoll
#

Why did you go from SQL to configs?

grave lagoon
#
    @EventHandler
    public void PlayerDamaged(EntityDamageByEntityEvent event) {
        if (!((event.getDamager() instanceof Player)) && !((event.getEntity() instanceof Player))) return;

        Player player = (Player)event.getEntity();
        Player target = (Player)event.getDamager();

        String playerUUID = player.getUniqueId().toString();
        String targetUUID = target.getUniqueId().toString();

        if ((!playersInCombat.contains(playerUUID)) && (!playersInCombat.contains(targetUUID))) {
            playersInCombat.add(playerUUID);
            playersInCombat.add(targetUUID);
            player.sendMessage(ChatColor.RED + "You're now in Combat!");
            target.sendMessage(ChatColor.RED + "You're now in Combat!");
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
                public void run() {
                    if ((playersInCombat.contains(playerUUID)) && (playersInCombat.contains(targetUUID))) {
                        playersInCombat.remove(playerUUID);
                        playersInCombat.remove(targetUUID);
                        target.sendMessage(ChatColor.GREEN + "You can now log out safely.");
                        player.sendMessage(ChatColor.GREEN + "You can now log out safely.");
                    }
                }
            },200L);
        }
    }

#

why does it send it 4 times??

regal scaffold
#

Since I'm using 1 file per object, there is no performance downside

#

I can save/update stuff individually and I use a cache anyways

torn shuttle
#

what's the underlying structure for hosting a maven repo of a multimodule project? Do I need to make a module that handles publishing and have that one stay close sourced to protect credentials?

grave lagoon
#

so how am i suppoesd to fix it and it sends it to both players

#

there arent duplicates

lyric berry
#

id also check make sure player is not the target

grave lagoon
#

yes but id like to send it to both players

tiny atlas
#

?paste

undone axleBOT
grave lagoon
lyric berry
#

a player can be both by hurting themself

young knoll
#

Don't think so

#

The only way to hurt yourself is with a projectile, in which case the damager will be the projectile

lyric berry
#

with a bow and arrow. no?

compact haven
#

The damager is any Entity not just a Player

grave lagoon
compact haven
#

You mistakingly just cast it ash such

#

otherwise if you confirmed then yeah ur good

grave lagoon
#

thats not a real thing

#

even if i scroll down

terse ore
#

you can set any object with FileConfiguration#set ?

grave lagoon
terse ore
grave lagoon
#

wait but will it still detect even if it isnt a shooter, eg. a sword

young knoll
#

You can set any object that is primative or ConfigurationSeralizable

grave lagoon
#

im confused

#

i just want to fix the 4 messages

young knoll
#

Projectiles do in fact call the EntityDamageByEntityEvent

grave lagoon
#

ok guys all i want to do is fix it outputting 4 messages

#

for both players

mortal pollen
#

how can I change the file from file is read only

#

?

#

thank you

grave lagoon
#

huh i reloaded the plugin and the 4 messages were fixed, what event do u use for the projectiles

#

thx

#

whats the public void EntityDamageEvent(EntityDamageEvent event) for

#

do i need it?

#

okay thankss then

terse ore
#

python joined the chat

grave lagoon
#

getHitEntity isnt a thing in projectile hit event

#
    public void ProjectileHit(ProjectileHitEvent event) {
        if (!((event.getEntity().getShooter() instanceof Player)) && !((event.getEntity() instanceof Player))) return;

        Player player = (Player) event.getHitEntity();
        Player target = (Player) event.getEntity().getShooter();

        player.sendMessage("eeeeeeee");

        String playerUUID = player.getUniqueId().toString();
        String targetUUID = target.getUniqueId().toString();

        if ((!playersInCombat.contains(playerUUID)) && (!playersInCombat.contains(targetUUID))) {
            playersInCombat.add(playerUUID);
            playersInCombat.add(targetUUID);
            player.sendMessage(ChatColor.RED + "You're now in Combat!");
            target.sendMessage(ChatColor.RED + "You're now in Combat!");
            Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getPlugin(), new Runnable() {
                public void run() {
                    if ((playersInCombat.contains(playerUUID)) && (playersInCombat.contains(targetUUID))) {
                        playersInCombat.remove(playerUUID);
                        playersInCombat.remove(targetUUID);
                        target.sendMessage(ChatColor.GREEN + "You can now log out safely.");
                        player.sendMessage(ChatColor.GREEN + "You can now log out safely.");
                    }
                }
            }, 200L);
        }
    }```
terse ore
#

Why does InventoryClick event doesn't have a getPlayer()?

grave lagoon
terse ore
#

thx

grave lagoon
#

nope

#

im using 1.19.2 shaded\

signal kettle
#

Okay so I want to make that when player click with book in hand on to any block then the block will be put on that block but when player again click on that block with book in hand then this exact block will be changed to another one, unfornutly it change the one that I click but also put another one on the block face of the first one ;/

    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void BookPlace(final PlayerInteractEvent event) {
        ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
        Player player = event.getPlayer();
        Block targetBlockLocation = player.getTargetBlock(null, 100).getRelative(event.getBlockFace());

        if (event.getHand().equals(EquipmentSlot.HAND)) {
            if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                if (targetBlockLocation.getType().equals(Material.BARRIER)) {
                    if (item.getType() != Material.BOOK) {
                        if (item.getAmount() == 1) {
                            item.setAmount(0);
                        } else {
                            item.setAmount(item.getAmount() - 1);
                        }
                    }
                    OraxenFurniture.place(targetBlockLocation.getLocation(), "leather_book_1", Rotation.NONE, BlockFace.UP, null);
                }
            }
        }
    }

    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void BookPlaceAdd(final PlayerInteractEvent event) {
        ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
        Block block = event.getClickedBlock();

        if (event.getHand().equals(EquipmentSlot.HAND) && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
        if (item.getType() != Material.BOOK) return;
        if (block == null || block.getType() != Material.BARRIER) return;
        if (!Objects.equals(OraxenFurniture.getFurnitureMechanic(block).getItemID(), "leather_book_1"))
            return;

        if (item.getAmount() == 1) {
            item.setAmount(0);
        } else {
            item.setAmount(item.getAmount() - 1);
        }
        OraxenFurniture.remove(block.getLocation(), event.getPlayer());
        OraxenFurniture.place(block.getLocation(), "leather_book_2", Rotation.NONE, BlockFace.UP, null);
    }
}
paper viper
#

@grave lagoon what is the problem

terse ore
young knoll
terse ore
#

or I need to check for something

grave lagoon
grave lagoon
#

so yea

paper viper
#

for bow shots?

grave lagoon
#

ye

young knoll
#

What

#

CraftTippedArrow is an entity

weak meteor
#

Someone has a guide or tutorial about permissions?

young knoll
#

I never said it was

#

I simply said projectiles do call the event

weak meteor
#

Im not talking about player.hasPermission("lol.lol");

#

Like, ive seen stuff too much complicated

#

but does the same

paper viper
#

@grave lagoon


@EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
    {
        if(event.getEntity() instanceof Player)
        {
            Player player = (Player) event.getEntity();
        }
        if (event.getDamager() instanceof Arrow)
        {
            if(((Arrow) event.getDamager()).getShooter() instanceof Player)
            {
                Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
            }
        }
    }
weak meteor
#

what's that

terse ore
#

does setslot start at 1 or at 0

young knoll
#

0

weak meteor
#

No im not asking about plugin.yml

terse ore
weak meteor
#

lol

#

just my message delayed

paper viper
#

@grave lagoon

@EventHandler
    public void onEntityDamageByEntity(ProjectileHitEvent event)
    {
        if(event.getHitEntity() instanceof Player && event.getEntity() instanceof Arrow && ((Arrow) event.getEntity()).getShooter() instanceof Player)
        {
            Player hittedPlayer = (Player) event.getHitEntity();
            Player shooter = (Player) ((Arrow) event.getEntity()).getShooter();
        }
    }

or this

weak meteor
#

Hmm

#

But a permission node is what?

#

the string "lol.command"?

#

Okay

#

Thanks

#

Bukkit is the love of my life then

#

i thought i needed to code stuff

#

lol

#

How should i manage a sub command?

terse ore
young knoll
#

You’ll have to check permissions manually for that

#

It’s only one line though so it’s not that bad

weak meteor
#

Yes, but that's obvious

#

like a list, nothing complicated?

versed canyon
terse ore
#

@weak meteor

grave lagoon
# paper viper <@414637770892378112> ```java @EventHandler public void onEntityDamageByEnt...

will something like this work?

        if (!(event.getDamager() instanceof Player)) return;
        if (!(event.getEntity() instanceof Arrow) && !(((Arrow) event.getEntity()).getShooter() instanceof Player) || !(event.getEntity() instanceof Player)) return;

        Player player = (Player) event.getEntity();
        Player target;
        if (event.getEntity() instanceof Arrow) {
            target = (Player) ((Arrow) event.getEntity()).getShooter();
        } else {
            target = (Player) event.getDamager();
        }```
weak meteor
#

Lemme see if there's any post

terse ore
#

use that post

#

and check for arguments

#

String[] args parameter

grave lagoon
grave lagoon
terse ore
#

when using

#

Player#performCommand

#

if I use "/say 1"

#

it will execute "//say 1" or "/say 1"

young knoll
#

Uhh

#

I don’t remember

#

Best just to test it

terse ore
#

let me try then

versed canyon
#

Make sure when you pass the args to the subcommand, you also pass the index of where to start parsing the subcommand's arguments

terse ore
#

why doesn't player.performcommand get logged?

young knoll
#

It should

grave lagoon
weak meteor
#

i was used to that

#

but never find something useful

terse ore
#

let's debug

#

yay

paper viper
# grave lagoon will something like this work? ```java if (!(event.getDamager() instanc...
@EventHandler
    public void onEntityDamageByEntity(ProjectileHitEvent event)
    {
        if(event.getHitEntity() instanceof Player && event.getEntity() instanceof Arrow && ((Arrow) event.getEntity()).getShooter() instanceof Player)
        {
            Player hittedPlayer = (Player) event.getHitEntity();
            Player shooter = (Player) ((Arrow) event.getEntity()).getShooter();
        }
    }
``` use this
grave lagoon
#

for proj hit event

versed canyon
#

That's odd naming too, onEntityDamageByEntity for ProjectileHitEvent

paper viper
#

which version of spigot?

grave lagoon
young knoll
#

I’d just use EntityDamageByEntityEvent for all of it

#

Saves having 2 events

versed canyon
#

What are you trying to do exactly @grave lagoon

paper viper
#

works fine for me

grave lagoon
#

its good for normal damage

#

but doesnt work for projectiles yet

versed canyon
#

Yeah you want entitydamagebyentity event

terse ore
#

yeah @young knoll performcommand adds a / before

grave lagoon
# versed canyon Yeah you want entitydamagebyentity event

would smt like this work?

        if (!(event.getDamager() instanceof Player)) return;
        if (!(event.getEntity() instanceof Arrow) && !(((Arrow) event.getEntity()).getShooter() instanceof Player) || !(event.getEntity() instanceof Player)) return;

        Player player = (Player) event.getEntity();
        Player target;
        if (event.getEntity() instanceof Arrow) {
            target = (Player) ((Arrow) event.getEntity()).getShooter();
        } else {
            target = (Player) event.getDamager();
        }
young knoll
#

You should change Arrow to Projectile

grave lagoon
paper viper
#

@grave lagoon are you shure that the event is imported?

#

import org.bukkit.event.entity.ProjectileHitEvent;

terse ore
#

one question guys, if I want to make a couple of inventories should I make an interface and implement it in those I need to?

paper viper
#

gui menus?

terse ore
#

yeah

#

mb didn't explain correctly

paper viper
versed canyon
#

?paste

undone axleBOT
grave lagoon
#

oh im stupid

#

1 sec

versed canyon
terse ore
lyric berry
#

i got my vault to work i just redownloaded vault so I don't know what was wrong thanks all.

versed canyon
#

In that snippet of code, attackingPlayer will be the player that attacked regardless of whether they hit directly or with an arrow. It will be null if the attacker wasn't a player. You may also want to check if the Entity victim is an instanceof Player, if both are Players it is a PVP event and you should log it.

weak meteor
#

how can i reload config if im not in main class?

#

nvm

weak meteor
#

the strings stuff in onCommand includes the command?

#

like

#

/command arg1 arg2 arg3

#

and strings.length() = 3 or 4?

sullen marlin
#

The array? Doesn't include

weak meteor
sage patio
#

How i can finish a BukkitTask?

rotund ravine
#

Finish in what sense

sage patio
#

before the time i set

#
BukkitTask task = new BukkitRunnable() {
                        @Override
                        public void run() {
                            // code
                        }
                    }.runTaskLater(Main.getInstance(), 6000);
#

before the 6000 tick

echo basalt
#

pretty sure you can call cancel() within the runnable

sage patio
#

i want it to run the codes too

#

Bukkit.getScheduler().runTask(plugin, (Runnable) task); is this correct for that?

#

or this starts that timer twice

wary harness
#

@sullen marlinSorry for tagging but you are probably person to ask
I am kicking my head around this for last 10 days I am trying to load my custom log4j2.xml confguration
but looks like spigot overrides it anyway
Would you be able to tell me is it possible to do it and point me to some info
I would really appreciated it
code:

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class MyPlugin extends JavaPlugin {


    private Logger logger;

    @Override
    public void onEnable() {


        String dataFolder = getDataFolder().getAbsolutePath();

        logger = LogManager.getLogger("com.example.myplugin");
        // Specify the path to your log4j2 configuration file
        String configFilePath = dataFolder + "/log4j2.xml";

        // Initialize log4j2 with the configuration file located in your plugin's directory
        LoggerContext lc = Configurator.initialize(null, configFilePath);



        // Set the logger level to debug
        logger.atLevel(Level.INFO);

        // Use the logger to log a message
        logger.info("Plugin enabled!");
    }```
Xml:
```<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="ConsoleAppender" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="com.example.myplugin" level="info" additivity="false">
            <AppenderRef ref="ConsoleAppender" />
        </Logger>
        <Root level="info">
            <AppenderRef ref="ConsoleAppender" />
        </Root>
    </Loggers>
</Configuration>
weak meteor
#

What could go wrong?

Main:

    public void registerCommand(){
        FGCommand fgCommand = new FGCommand(this.config, this); // Line 57
        getCommand("fg").setExecutor(fgCommand);
    }

FGCommand class:

    public FGCommand(Configuration config, Plugin plugin) { // Line 22
        this.config = config;
        this.plugin = plugin;
    }
sage patio
#

getCommand("fg").setExecutor(new fgCommand());

weak meteor
#

its already defined up there

sage patio
#

also that is not a command class

weak meteor
#

its just the constructor

wary harness
#

FGCommand class line 20 is null

#

debug that

sage patio
weak meteor
#

its just a var: private String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("prefix"));

wary harness
#

6000 is time

sage patio
#

yes

wary harness
#

so what are u trying to do

sage patio
#

when the server starts that timer, it takes 6000 ticks to run the codes right?

wary harness
#

yeah

sage patio
#

i want to run the codes before that 6000 ticks

young knoll
#

Mhm

wary harness
#

well put your code in custom method

sage patio
#

its not possible

wary harness
#

add that method to runnable

#

and before runnable to onEnable

#

and it will run one time instalntly

#

when server start

#

and second time after 6000 ticks

sage patio
#

lemme explain it a little bit

wary harness
#

so you want code to be repetting?

sage patio
#

when player breaks a block, a runnable starts and respawns that block after 6000 tick for example

#

when i turn off the server, there is a lot of not respawned blocks

young knoll
#

Don’t do it like that

sage patio
#

i want to respawn all of them on disable

sage patio
wary harness
#
            @Override
            public void run() {
                
            }
        }.runTaskTimer(this,0,6000);```
#

this will run code on server start and on repeat every 6000 ticks

young knoll
#

You’re just spawning a ton of tasks for no reason

sage patio
#

i know

wary harness
#

store locations

#

to file

#

data base

young knoll
#

Have a single task that respawns blocks, when a block is broken add it to a queue with a timestamp

#

Have the single task check if it’s time to respawn a block, and then process it

sage patio
#

sounds nice but there is a little problem

#

that Time to respawn depends on the player counts

#

its 10 mins by default, and subtracts 15 sec per each online player in server

young knoll
#

So?

weak meteor
#

My plugin isnt being detected (Like 5m it was being detected) whats happening

echo basalt
#

15 seconds is like

sage patio
#

so each time player breaks a block the time is different (maybe)

echo basalt
#

300 ticks

weak meteor
#

i only changed a var to public static bro

young knoll
#

You can calculate that when checking if it’s time to respawn it

echo basalt
#

12000 - onlinePlayers*300

young knoll
#

Or you can calculate that when storing it in the first place

#

Whichever you want

#

If you want the queue to be kept in order you can use a priority queue

sage patio
#

why i can't understand, is it because of this?

wary harness
#

so any of you guys have solutiont to my problem up @young knoll 🤣

echo basalt
sage patio
#

listen, imagine there is a mine with iron ores, player breaks 1 of them while there is 10 players on the server, so the blocks regenrates after 10 min - (15 sec * 10)
when he breaks the next block there is 15 players and its 10 min - (15 sec * 15)
then what? how i can calculate this

#

the runnable is running each 10 mins no matter how many player is there

echo basalt
#

wny

#

just make a runnable to regen it later

sage patio
#

per block?

echo basalt
#

yeah

young knoll
#

No

echo basalt
#

whatever

young knoll
#

One runnable

echo basalt
#

or one runnable

young knoll
#

Keep a list of the blocks and the time they should be regenerated

#

And have the runnable check every second or whatever

echo basalt
#

and a Map<Long, List<WrappedBlockData>> where WrappedBlockData is a class containing location, material type and whatever else

sage patio
# echo basalt yeah

ok thats correct till now
here my problem happens
there is some blocks they are still not regenerated
and i turn off the server

echo basalt
#

onDisable -> regenerateAll

sage patio
#

how?

echo basalt
#

use your 3 braincells to read my message

young knoll
#

Just loop through the map and process everything still in it

sage patio
#

new problem may cause to do not help me more, i'm codding on 1.12.2

echo basalt
#

at this point

#

?learnjava

undone axleBOT
young knoll
#

WrappedBlockData is something you are supposed to make

#

To store data about a block

sage patio
#

hmm

#

thanks, could you gimme a link referred to that tutorial?

echo basalt
#

mans using the romanian vpn

sage patio
#

forgot it, i'll wait untill all the blocks regerates

#

then i turn off the server

#

thanks for help

sage patio
echo basalt
#

I'd write a basic emotional message about how I wasted many years of my life stumbling blindly, being afraid to learn OOP

#

but I've been awake for 36 hours and can't bother thinking atm

weak meteor
#

Line 21: String prefix = config.getString("messagesPrefix");
Line 59: FGCommand fgCommand = new FGCommand(this.config, this);
getCommand("fg").setExecutor(fgCommand);
Line 23: registerCommand(); (the method that i just wrote)
Config.yml:

#

What's happening?

#

i do not understand

young knoll
#

Config is probably null

weak meteor
#

this is from main

#

should i skip the this.config?

#

like, only config

#

Nope

#

same error

regal scaffold
#
            }).consumer(event -> {
                plugin.guiManager.openGUI(new ContactManageMenu(phone, NEWPARAM), player);
            });

If I'm using something like this for my GUI implementation

#

How can I pass a parameter specific to the item where NEWPARAM is

#

Like, I want to pass a UUID

fallow violet
#

How can you set the rotation of an entity with nms without setting the position? (EntityLiving)

torn shuttle
#

if the process to get a repository up somewhere included taking a cyanide pill the process would be made less painful

young knoll
weak meteor
#

or ContantManageMenu?

regal scaffold
#

ConstantManageMenu

weak meteor
#

Okay

#

Show me the class

regal scaffold
#

Like, lets say I make 10 items, each with a unique ID. then I add the consumer method to each one

#
            InventoryButton button = new InventoryButton().creator(player1 -> {
                ItemStack item = new ItemStack(Material.PLAYER_HEAD);
                return item;
            }).consumer(event -> {
                plugin.guiManager.openGUI(new ContactManageMenu(phone,), player);
            });
#
    public ContactManageMenu(APhone phone, UUID contact) {
        super();
        this.phone = phone;
        this.contact = contact;
    }
weak meteor
#

but ur already passing an UUID

regal scaffold
#

It's because the ContactManageMenu is unique for a given UUID, but how can I actually put a UUID in the parameter

#

nono ok hold on

#

Lets say I have 10 items.

Made using

            InventoryButton button = new InventoryButton().creator(player1 -> {
                ItemStack item = new ItemStack(Material.PLAYER_HEAD);
                return item;
            }).consumer(event -> {
                plugin.guiManager.openGUI(new ContactManageMenu(phone,UUID FOR ITEM 1 - 10), player);
            });

#

That's what I'm having issue with, I know the constructor is ready for arguments

weak meteor
#

Ohh

#

Okay

regal scaffold
#

But since it's inside a consumer I'm confused

weak meteor
#

it doesnt matter how many items you have?

regal scaffold
#

They all have unique values

#

I already have that

#

I just need to figure out how to pass it

weak meteor
#

you can pass 10 or 2 if you want

#

or it has to bbe 10

regal scaffold
#

any number

weak meteor
#

Ojay

regal scaffold
weak meteor
#

i think

#

it is

regal scaffold
#

And the value I need to pass is actually in the creator() method

weak meteor
#

UUID contact ...

#

i think

regal scaffold
#
            InventoryButton button = new InventoryButton().creator(player1 -> {
                ItemStack item = new ItemStack(Material.PLAYER_HEAD);
                UUID uuid; <---- This what I want to pass
                return item;
            }).consumer(event -> {
                plugin.guiManager.openGUI(new ContactManageMenu(phone, HERE), player);
            });
#

Wait....

#

I'm an idiot

#

Holy shit

#
            InventoryButton button = new InventoryButton().creator(player1 -> {
                ItemStack item = new ItemStack(Material.PLAYER_HEAD);
                UUID uuid;
                return item;
            }).consumer(event -> {
                plugin.guiManager.openGUI(new ContactManageMenu(phone, uuid), player); <---- Here
            });
#

This literally works

#

I have autism, sry

young knoll
#

Your uuid isn’t set to anything

lost matrix
#

Stop making your fields public...

#

All of them

#

Ability#mayfly for example

#

Mojang does a lot of things

#

Anyways

#

What is keyFly.consumeClick()

#

Wait is this forge fkery?

#

"client sided nms" <- lol

ancient plank
#

that's not--

young knoll
#

Client.minecraft.server

#

Don’t question it

lost matrix
#

Switch the order of the while loop and your fly check

#

The first loop always consumes all key clicks before it reaches the second

#
if(!flying) {
  while(options.keyFly.consumeClick()) {
    ...
#

Same for the second.

#

Or even better: Dont have two while loops

#

Yes

#

But this can be boiled down to half the size

#

Then just make it work for now

#

boolean flying = false; i wonder why