#help-development

1 messages · Page 1718 of 1

torn shuttle
#

I hope you never have to debug the bs I am debugging right now

crimson terrace
#

I do "Checkpoint 1", "Checkpoint"2", "Checkpoint 3"

shadow gazelle
#

When you forget to build

torn shuttle
#

I do running 1 running 2 running 3

#

and then 3 hours later I do running -1 running -2 running -3

ancient plank
#

I just do
1 2 3 4 "1 in loop" "2 in loop" 5 6 7 8 9 10

shadow gazelle
#

Damnit

torn shuttle
#

1 2 3 is bad because it is annoying to remove

ancient plank
#

or when I get bored of numbers I swap to the alphabet

shadow gazelle
#

It really makes no sense that it only errored the first time when that was the issue

young knoll
#

Imagine not attaching a debugger to debug properly :p

torn shuttle
#

that's most of the reason why I use the class, I just ctrl-click and can instantly see everywhere I have debug messages to remove them

#

attaching debuggers is frequently not an option

ancient plank
#

I can just ctrl+z remove the debug messages when I find the issue

young knoll
#

It's an option with plugins

torn shuttle
#

frequently it isn't

young knoll
#

Explain

torn shuttle
#

bug only happens in x server that isn't yours

#

give em debug messages and let god sort em out

onyx shale
#

me not needing debugging because i write good code that never fails

onyx shale
#

cry normie

quaint mantle
#

me publishing my code immediately after coding it, because my code never fails

onyx shale
#

i agree with you fellow sigma male

quaint mantle
#

sigma programmer

#

💪🏿 😤

torn shuttle
#

me posting the resources without a jar file because my code is so powerful that actually writing it might destroy the planet, and just talking about it is good enough

quaint mantle
#

😟

ancient plank
#

I had a bug that happened only on my server because I accidentally set an essentials permission incorrectly

quaint mantle
#

how long did it take you to figure that out

#

:P

ancient plank
#

uh

ancient plank
#

2 hours and redam helping

torn shuttle
#

I should start a new service

#

not programming as a service

quaint mantle
#

POV: IntelliJ not saving to file after pressing the power off button

torn shuttle
#

I will avoid introducing bugs and performance issues into your server if you pay me to not create code that might lead to doing it

quaint mantle
#

truly an amazing business model

torn shuttle
#

my not programming as a service has a 100% uptime and a whopping 0% impact on server performance

#

and it saves incalculable amounts of potential lag your server might've otherwise had

#

also it is open source and entirely bug free

#

and it will run on any server version right out of the box

woeful crescent
#

Anyone know how I'd simulate player damage with a fake player (entity id only)?

woeful crescent
#

Nah I don't mean that

#

I mean with velo and everything else

mortal hare
#

knockback is calculated by the NMS im pretty sure

#

its serverside

woeful crescent
#

yeah

#

so

mortal hare
#

idk, you'd need to dig into spigot jar

woeful crescent
#

how do i simulate it?

#

alr

mortal hare
#

what i would do is to fool somehow the server that specific player is online, that way the server would treat your fake player as real one and thus it would take damage like a normal player

#

but you would need to dig down how does the player handling works in server

woeful crescent
#

I'm so confused

mortal hare
#

its not an easy task

#

at least for me

woeful crescent
#

I got to the bottom of the .damage() method and this is what I found

protected void ac() {
        this.velocityChanged = true;
}```
mortal hare
#

do you send packets per player?

woeful crescent
#

Not really

mortal hare
#

do you send specific packet to the player to display the human?

woeful crescent
#

I mean I can if I need to

mortal hare
#

or have you fooled the server that player is in the server which is fake via NMS

#

i can't explain it properly sorry

woeful crescent
#

no

#

it's packets

#

NPCLib

#

I can modify it if I need to

mortal hare
#

if you send packets manually, server doesnt know anything about it, thus it doesnt act normally as its desynced with server, and only the clients see it

woeful crescent
#

Yeah

#

I wanna find out exactly what packet the server sends when .damage() gets called

mortal hare
#

it sends animation packet and position packets

#

you can prove that by lagging yourself out and trying to hit player midair

#

it wouldnt fall

#

when you lag

woeful crescent
#

Well I know but like

#

exactly how?

mortal hare
#

that's another topic

#

yeah, that's what you need to really find out

#

by digging down

#

or googling it

#

i've never played around with NPCs much

woeful crescent
#

alright

#

Do you know how to play the hit sound?

#

Like what sound is it?

spare marsh
#

Hi quick question

ivory sleet
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

spare marsh
#

So, I am trying to make this container type of Inventory. I want this inventory to allow a player to only be able to put an item in the slot #4 but the issue is that when on InventoryClickEvent, it also takes my hotbar's slots as the ones I am testing for to cancel the event. For example, slot #5 is just a display pane so it cancels the event but if I grab the item from slot 5 on my hotbar it won't cancel

opal juniper
ivory sleet
#

Yeah but discord on mobile didn’t render

opal juniper
#

🤨

#

lol

ivory sleet
#

Yeah Idk discord mobile just sucks somewhat too bad

spare marsh
#

Lol, yeah I was typing.

ivory sleet
#

Even stuff like this isn’t fixed yet

ivory sleet
#

InventoryClickEvent#getRawSlot and getSlot exist

spare marsh
#

Difference?

somber hull
#

Look it up

eternal oxide
#

?jd-s

undone axleBOT
spare marsh
#

One sec

#

Ah got it

#

Thank you so much

quaint mantle
#

@ivory sleet Smells

ivory sleet
#

Why did you react to your own message?

#

🥴

mortal hare
#

finally i made my trie data structure working

#

but i dont understand how

#

lol

ivory sleet
#

Hehe

#

It works, but why

mortal hare
#

well its kinda hybrid data structure

#

trie is used primarily for strings

#

but i use it for node searching

#

i really need to benchmark this

mortal hare
#

does any of you guys have experience with JMH?

#

(Java microbenchmark harness)

eternal night
#

it really isn't hard to setup

#

afaik their github had a good tutorial

#

there are also a few example projects

#

yea

#

Just make sure to not run anything on your machine or need it for the next few hours if you are testing a few more methods xD

mortal hare
#

i need quick and dirty benchmark

#

to check if my optimization really works

#

it should be noticeable

eternal night
#

well the examples will show you how easy the setup is

#

pretty easy

#

but if you do not care about long warm-ups etc, just write your own benchmarks

#

the tool is designed for proper benchmarks, running multiple benchmarks, doing some cute outlier detection etc

mortal hare
#

i dont really care because the performance difference should be noticeable by a lot not by nanoseconds

eternal night
#

yea then that tool is probably not what you are looking for

#

you might be fine literally just using a stopwatch

#

(not a physical one xD)

#

both googles and apache provide one

young knoll
#

Or just system.nanoTime

quaint mantle
mortal hare
#

well "optimized" one takes 0.004ms to find the argument node

#

lets see about unoptimized one

#

these are rough numbers

#

interesting results! Apparently trie datastructure returns worse results than unoptimized equalsIgnore check with multiple arguments.

young knoll
#

So you wasted time with a micro optimization that didn't even help? :p

mortal hare
#

"Optimized": 0.004 ms,
"Unoptimized": 0.0005 ms

#

no i think i know why

#

equals ignore check is faster because there's not so many commands registered in command dispatcher

#

so its quick to do linear search for it

#

while trie datastructure has constant search time

#

of string length

#

it takes 4000ns to find the argument, but it should be constant time no matter if there's 1 command or 1000 commands registered

#

while equalsIgnore check would struggle to check 1000 command nodes till it found the match

#

Using Trie, search complexities can be brought to optimal limit (key length)

young knoll
#

Why would you have 1000 commands

mortal hare
#

that's a bad example

#

but yeah

#

no one would have that much

young knoll
#

Make a plugin that randomly adds commands

#

That do random things

misty current
#

can you somehow make mongo shut up

#

half of my logs are mongo info

young knoll
#

I had that issue before

#

Fixed it by messing with the version I was using

misty current
#

which one did you use?

#

im on 4.3.2

quaint mantle
#

Logger mongoLogger = Logger.getLogger( "com.mongodb" );
mongoLogger.setLevel(Level.SEVERE); // e.g. or Log.WARNING, etc.

#

Can do something like this

#

In your code

#

Will only show Severe Issues

misty current
#

wish it worked, slapped it at the top of my onEnable

quaint mantle
#

It should work

misty current
#

so rn it's on top of my onEnable method

#

and i connect to the db in another class

#

that is instanciated after

young knoll
#

Yeah that wasn't working for me either

misty current
#

but i still get shit ton of spam

#

then what did you use?

#

to fix it

young knoll
#

player.spigot.sendMessage

misty current
#

kinda sick

#

ive been tryna stop the spam for an hr

paper viper
#

A d v e n t u r e

misty current
#

and for some reason mongo's retarded

paper viper
#

Mongo ain’t retarded, you are just doing something that isn’t really needed

#

Lol

misty current
#

also i don't understand why does my mongo log 10x more compared to other tutorials

young knoll
#

It's two arguments...

paper viper
#

Because it’s Mongo? And it’s big

#

Yes

#

I know

young knoll
#

How what

paper viper
#

I recommend to use Logback then

#

Specify a logback.xml

#

And change where the log output is going

young knoll
#

<groupId>org.mongodb</groupId>

<artifactId>mongo-java-driver</artifactId>

<version>3.12.7</version>

</dependency>```
#

That is the version I switched to to avoid logspam

misty current
#

isnt 3.12 like from years ago

young knoll
#

Probably

paper viper
#

Lol

#

Just use logback

young knoll
#

This project was from a year ago

paper viper
misty current
#

lemme try

#
java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader 'app'; ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @3136318f)
        at me.kill05.**.**.onEnable(**.java:46) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-785]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-785]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-785]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-785]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-785]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:594) ~[patched_1.16.5.jar:git-Paper-785]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-785]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-785]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-785]
        at java.lang.Thread.run(Thread.java:831) [?:?]
#

using the imports the guy said

#

same for the "single liner"

mystic tartan
#

or player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);

young knoll
#

I already said that

#

But they are trying to use 1 argument

mystic tartan
#

ah

toxic lava
#

Hey, does anyone have an idea how to make mobs spawn normally outside of the worldborder?

toxic lava
#

No one? :/

young knoll
#

No idea

#

Why would you want that

timber whale
#

How would i use hex codes instead ChatColor?

quaint mantle
#

?google "spigot hex codes"

undone axleBOT
timber whale
#

LOL

young knoll
#

ChatColor.of

quaint mantle
#

bungee import ^

timber whale
#
      @Override
            public ChatColor getColor() {
                return (ChatColor.YELLOW);
            }```
#

i meann

young knoll
#

What about it

quaint mantle
timber whale
#

ok

#
         @Override
            public ChatColor getColor() {
                return net.md_5.bungee.api.ChatColor.of("#FFFF");
            }    ```
#

could i just

young knoll
#

You are missing two F's

#

But yes

#

Also you should probably use net.md_5.bungee.api.ChatColor anyway

timber whale
#

it needs a maven dependency

quaint mantle
#

does it recognize #\w\w\w

#

or does it not repeat it

timber whale
#

like if i were to do

            @Override
            public ChatColor getColor() {
                return net.md_5.bungee.api.ChatColor.of("#\w\w\w");
            }```
young knoll
#

It's part of spigot

timber whale
#

whats the import for it

young knoll
#

That is the import

timber whale
#

awk wait

#

holy fuvckl i cant put images in here

#

the required type is org.bukkit.ChatColor

#

since i used the ChatColor import

#

from bukkit

#
            @Override
            public ChatColor getColor() {
                return net.md_5.bungee.api.ChatColor.of("ffff00");
            }```
#

so like

#

what would i put instead of ChatColor

young knoll
#

Remove the import then

toxic lava
# young knoll Why would you want that

Wanna do some "XP Level = Border Size"-Stuff, so its important that mobs can spawn outside the border. Got the idea from a Youtuber, and he made it working somehow, sadly he didnt explain it :/

young knoll
#

Set the world border per player

toxic lava
#

Wait, thats a thing? Always thought there was only 1 border

young knoll
#

Packets

golden turret
#

@timber whale ChatColor.of(Color) >>>

toxic lava
sullen dome
#

is it actually possible to make one character a gradient color? guess not?

#

since rgb is a thing since.... about 1.16?

young knoll
#

You want a single character to be more than 1 color?

sullen dome
#

that was basically my question

young knoll
#

No

sullen dome
#

sad

quaint mantle
#

oof

quaint mantle
#

but how can they do it like this?

subtle kite
#

what part

vague oracle
#

Search it on google

#

I’ve seen videos

young knoll
#

None of those characters are more than 1 color

subtle kite
#

what is the question though

#

like the color part

ancient plank
#

unsus

quaint mantle
#

the transition makes it look like its a gradient on 1 character, well made

subtle kite
#

I'm guessing it is something like
&1&9&3&b

and to see it like
111111

&11&91&31&b1

young knoll
#

What

subtle kite
#

&1&9&3&b are color codes

young knoll
#

Correct

#

But those are the legacy codes

subtle kite
#

\u00A711\u00A791\u00A731\u00A7b1

#

is that what you want

#
  • |-
    &11&91&31&b1
#

or you want server list plugin

young knoll
#

RGB codes are &x&r&r&g&g&b&b

#

And yes, it is a bit of an ugly format

quaint mantle
#

runTaskAsynchronously
does every money check (even cached) cause lag?

drowsy helm
#

wdym money check?

quaint mantle
# quaint mantle

If you don't want to use the awful legacy color format, you can use something like MiniMOTD

#

Makes gradients super easy too ^

quaint mantle
#

is there anyway to spawn drops with packets ?

#

i mean the animation of the drop

#

an item

#

it can be floating...

tacit drift
#

Stefatorus did something that was queueing vault changes

#

so plugins that listen for that wouldn't lag that much anymore

eternal oxide
#

Any decent eco will fire events to notify plugins of changes.

misty current
#

can you somehow make mongo shut up, half of my logs are mongo info

drowsy helm
#

are you using a lib for mongo?

misty current
mortal hare
#

have anyone tried this?

#

this seems like perfect platform for minigames

misty current
#

dude this looks insane

#

tho what is it? A server jar?

mortal hare
#

its a blank server, that only communicates with server - client

#

basically you can hardcode your own server software

misty current
#

ohh so you gotta code everything into it

mortal hare
#

on top of this

misty current
#

multithreading also

mortal hare
#

for example you don't need world saving feature, you don't code it

#

perfect for HCF, Skyblock servers

misty current
#

yes

mortal hare
#

i really need to take a look to this later

misty current
#

tho how much do you have to code yourself? what does it provide?

mortal hare
#

it provides only packet level communication

#

you need to code almost everything yourself

misty current
#

So no world generation either?

#

inventories?

#

health/gamemode

mortal hare
#

i think it does have some form of implementation

#

they do have inventory API's

#

and entity API

#

as far i can see

misty current
#

i guess you need to code mob behaviour too

mortal hare
#

it does have api

#

for that

#

it does have API for almost everything

#

but its a modular in a way

#

that you can not include it in the server at all

misty current
#

unless it has nasty or stupid problems this looks the perfect api to use for servers with hundreds of players and with a lot of custom features

mortal hare
#

yea

#

for example hypixel

#

it has little to no vanilla interaction

misty current
#

too bad it's only for 1.17 but still

ivory sleet
#

Only concern is the amount of static they use, I mean it’s a good idea but all the code isn’t quite goodly written imo

misty current
#

well i guess you could code the behaviour of everything?

mortal hare
#

but its a promising software ngl

#

i really want to tinker with this

misty current
#

didnt check code but if it's not good well

mortal hare
#

but i dont have time

tall dragon
#

"goodly" 😆

ivory sleet
#

Idk, I probably wouldn’t do tdd with minestom rn

misty current
#

the multithreading part also looks interesting

ivory sleet
misty current
mortal hare
#

tinker with java's logger class i guess

misty current
#

thats what i did

#

didnt work

mortal hare
#

well logger does the job of outputting to the file so there should be a way to remove mongodb from file buffer stream

misty current
#

I've also tried to use LoggerFactory with some code a guy posted on stackoverflow but that gives me a classcastex

paper viper
#

oh

#

rip that didnt work

misty current
ivory sleet
#

solution, dont use mongo /s

mortal hare
#

maybe mongodb settings have settings to disable logs

paper viper
#

Doubt

mortal hare
#

inside the driver

paper viper
#

they use sl4j or i forgot the logging api

#

usually they dont add ways for users to customise it within the api

#

you'd have to do some logger stuff

eternal oxide
#

You shoudl be able to add a Handler to the Bukkit.getLogger()

quaint mantle
#

is there any way to change the player's skin via spigot

misty current
eternal oxide
#

Bukkit.getLogger().addHandler(new Handler...)

misty current
#

how does handler work

#

never used it

#

like what do i write as constructor param

eternal oxide
#

implement an Anonymous

#

then in check the record.getname() to see which loggers messages come fron

#

once you have teh logger name you can see which one you want to filter

misty current
#

um

eternal oxide
#

type as I did without the three ... then press whatever your IDE has for auto complete

#

CTRL+space for Eclipse

misty current
#

without the three?

ancient plank
#

periods

vivid cave
#

do Set Slot Packets also work for chest inventory/anvil inventory/any inventory or is it reserved for player's inventory?

mortal hare
#

are onLoad, onDisable methods not ran on minecrafts main thread?

eternal oxide
# misty current without the three?
Bukkit.getLogger().addHandler(new ConsoleHandler() {
    
    @Override
    public void publish(LogRecord record) {
        System.out.println("Logger: " + record.getLoggerName() + " : " + record.getMessage());
    }
});```
mortal hare
eternal oxide
#

lets you find the correct logger name

#

then you can ignore any from a specific logger at a specific level

mortal hare
#

you would need to use com.mojang.authlib package to retrieve player's skin data

#

google it @quaint mantle

quaint mantle
#

ok

dreamy mica
misty current
mortal hare
# quaint mantle pls help?

but PaperSpigot afaik has an API for you to change the skin without the hassle of using gameprofiles and packets

misty current
#

^

eternal oxide
#

then mongo is not going through the bukkit log4j

misty current
#

ah

#

do you have any other solutions?

mortal hare
#

also some dude found a way to get 4K quality skins without client modifications

#

via microsoft's education edition skin servers

misty current
#

lmfao

mortal hare
#

also this skin server supports transparency

misty current
#

why tf can't mongo just shu the fuck up

#

why i gotta waste time on this bs

ivory sleet
misty current
#

any other mongo libs i can use

#

i cant have half of my console spammed with useless data

eternal oxide
#

Just create a logback.xml for mongo

#

You can set teh logging level for all elements of it

#

Probably Log4j2 not logback

misty current
#

can I put the .xml under the src package?

eternal oxide
#

no clue

spice hornet
#

Hey there! Is there a list of recommendable utility libraries for Spigot? I have found SpigotUtils but am uncertain whether it is the go-to. I just want some config stuff but honestly you can't have too much utility functions

mortal hare
#

you can try redlib

spice hornet
minor garnet
#

how i could add nms classes using maven

spice hornet
#

Have worked with it, can be quite obscure at times but once set up properly really nice console output

misty current
spice hornet
misty current
# spice hornet You put the logback.xml in your resources folder

kk done, this is what's inside

    <appender name="CONSOLE"
              class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %-4relative [%thread] %-5level %logger{30} - %msg%n
            </pattern>
        </encoder>
    </appender>
    <logger name="org.mongodb.driver.connection" level="INFO" additivity="true"/>
    <root level="OFF">
        <appender-ref ref="CONSOLE" />
    </root>
</configuration>```
acoustic pendant
#

Hello, i need some help,
https://paste.md-5.net/gacuxarara.java
I have this code, all works but when i get to
} else if (e.getView().getTitle().equals(ChatColor.GOLD + "Confirm your creation")){
and after, that code doesn't work

spice hornet
spice hornet
acoustic pendant
#

doesn't send any error

#

just in minecraft

#

i mean

mortal hare
#

so im digging down nms and i found this private synchronized boolean register(@NotNull String label, @NotNull Command command, boolean isAlias, @NotNull String fallbackPrefix) {

#

why is this synchronised

acoustic pendant
spice hornet
#

Check wheter getTitle returns String. If so, leave out the ChatColor part

misty current
#

hold on im getting the dep and i'll try

mortal hare
#

i cant seem to find what causes commands to be registered async

spice hornet
mortal hare
#

yes it does but the question is where does it do asynchronously

spice hornet
#

It is to avoid race conditions. Simply put, mark a method as synchronized and it can only be run by one thread at a time.

mortal hare
#

that's not what im asking

mortal hare
#

im asking where in NMS does it utilize async tasks

#

regarding this synchronization

spice hornet
#

oh zero clue

#

Plugins could utilize asynchronous stuff, even so networking stuff.

#

Otherwise your game would freeze if you request a player list from a server for example (unless solved with a websocket, idk how mc does it)

white thicket
mortal hare
#

i think its security measure, because second overloaded register method that executes provided above register method is not synchronized

misty current
#

ok so my logback is under the resources folder and it contains

    <appender name="CONSOLE"
              class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %-4relative [%thread] %-5level %logger{30} - %msg%n
            </pattern>
        </encoder>
    </appender>
    <root level="INFO">
        <appender-ref ref="CONSOLE" />
    </root>
</configuration>```
#

do i have to do anything else?

#

because it doesnt work

mortal hare
#

no

#

show me your code

misty current
#

dude it cant fucking be that i spend more time tryna disable logs compared to implementing mongo

mortal hare
#

the more i look into NMS, the more disgusted i feel

spice hornet
#

That's what NMS is for basically

white thicket
native lodge
#

I need help with my bungeecord server so everytime i got my servers up one of the server is on and everytime i try to join that i stay there for a second then it sends me back to the lobby saying " The server you were previously on went down, you have been connected to fallback server "

quaint mantle
mortal hare
#

that invokes getConfig() method

quaint mantle
#

?learnjava

undone axleBOT
white thicket
mortal hare
#

this channel is dedicated specifically for programming

mortal hare
quaint mantle
white thicket
#

Oh I found the issue

#

nvm ty

misty current
#

How can I disable mongo console logging

white thicket
gusty bough
#

I don't get the point of Score#isScoreSet(). I tried creating an objective without any score and then doing : Objective#getScore("")#isScoreSet() and it returns true

#

It should return false

mortal hare
#

show me

white thicket
#

dovidas, it is now giving me error for a different line because the line which it was giving error, I fixed that

#

now the line which is giving error is

        if (plugin.getConfig().getBoolean("UseDiscordBot")) {
#

And as it says in error, it is not able to detect plugin.getConfig()

#

But I have set plugin to main class

#

tag me if helping

eternal oxide
#

how did you set plugin to your main class?

#

@white thicket

smoky oak
#

What's the best practice to store/access the main plugin instance?

#

because while this might work i doubt its the intended solution...

public static Echo that = null;
@Override
public void onEnable(){
    this.that = this;} 
ivory sleet
#

Just pass it through the constructor or a method

chrome beacon
#

Doggo is back!

smoky oak
#

well the reason i ask is because i need to access the instance in static methods like the event listeners

ivory sleet
#

Why are the event listeners static in the first place

ivory sleet
high talon
#

I'm currently working on an infinite item plugin. But I can't figure out how to make the item infinite.

smoky oak
#

urgh what i meant is that i need to access the instance in methods that dont have a pointer/variable with that instance like for example onCommand methods and i wanted to know if theres a better solution than what im doing up there

smoky oak
ivory sleet
#

?do I believe this goes over dependency injection which is what you’d normally use

#

?di

undone axleBOT
smoky oak
#

which is basically the same thing with extra steps

ivory sleet
#

It’s not about steps

#

If you care about making your code as small as possible then use static only

#

But you will make your code fragile, rigorous and immobile

smoky oak
#

eh fair enough

burnt current
#

Quick question: What is the best way to query whether a player has walked to a certain coordinate?
In my case, I would like to check whether a player has walked to a certain z coordinate. If this is the case, the player is teleported to another position. I have already tried the following:

@EventHandler
    public void playerMoveListener(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if(player.getLocation().getZ() >= Main.instance.getConfig().getDouble("destination.z")) {
            player.teleport(Main.instance.getConfig().getLocation("start.location"));
        }
    }

destination.z and start.location are values that I have inserted in the config of the plugin as follows:

Main.instance.getConfig().set("start.location", player.getLocation().toString());
Main.instance.getConfig().set("destination.z", player.getLocation().add(0, -1, 24).getBlock().getLocation().getZ());

start.location is the location to which the player should be teleported if he crosses the z coordinate, which is stored in direction.z.
Can anyone help me with this?

smoky oak
#

does the player.teleport function phrase strings back into coordinates?

#

also I'd recommend checking every second or so with a sceduled task instead of checking every tick the player is moving

#

though depending on the situation either could be better

misty current
#

How can I disable mongo console logging

smoky oak
#

dont know if it helps but this only fires once per right click for me IIRR

public static void onInteract(PlayerInteractEvent e){
        if(e.getHand().equals(EquipmentSlot.HAND)
                &&(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))```
haughty plover
#

That is essentially what I am doing already.

smoky oak
#

can we see the entire check?

haughty plover
#

Yes

#

Give me a sec

smoky oak
#

dumb question but dont have those checks to be done with .equals with Enums not being a primitive data type?

haughty plover
ivory sleet
#

a == b is true if and only if a is b

#

And since enum members are global, there’s ever only going to be one existing during runtime we can use the instance equality check or whatever you’d call it

white thicket
lusty cipher
#

how do I set the title of an item to be BaseComponent[]?

eternal oxide
#

what class are you trying to access the config in?

haughty plover
#

I don't believe you

smoky oak
#

someone ban that guy its a phising link

smoky oak
#

nobody told us what else

tardy flame
#

Set main class object as private and create static getter

smoky oak
#

so you got a suggestion i presume?

#

ah fair enough

#

prevents modification you mean?

wispy plume
#

How do I make spigots "talk" with bungee? So that I could invoke commands on bungee and they would execute on specified spigot server and return the response? Without players being needed, so no plugin messaging? I'm open for everything, no matter the difficulty.

native lodge
#

I need help with my bungeecord server so everytime i got my servers up one of the server is on and everytime i try to join that i stay there for a second then it sends me back to the lobby saying " The server you were previously on went down, you have been connected to fallback server "

crimson terrace
#

Im having problems making an editable recipe. its not giving off any errors but when I try making the item is just doesnt work. Ive pasted the relevant code here: https://paste.md-5.net/icunosugul.cs

wispy plume
native lodge
#

Ok

misty current
#

How can I disable mongo console logging

#
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongodb-driver-sync</artifactId>
            <version>4.3.2</version>
        </dependency>
``` my maven import
crimson terrace
native lodge
quaint mantle
#

is there any way to send a player a actionbar message? e.g. p.sendActionbar("somethin")

crimson terrace
#

How do I add things to a config using only code? I want to append my plugins config so that the new things exist and work immediately.

ivory sleet
#

Ideally load the config from the data folder, loop through and check if some of the paths are missing values if so write those values to the memory config and save

crimson terrace
#

do you do that with the config.isConfigurationSection to check wether it has that already?

quaint mantle
#

for example we have a pos1 and pos2
1: x: 10 y: 20 z: 10
2: x: 11 y: 21 z: 11
and we want to check if a location is inside this area

crimson terrace
crimson terrace
quaint mantle
#

🗿🤝 i will read

#

that did not help

#

it is c#

minor garnet
#

can i detect when the server receive a packet without use protocol lib ?

quaint mantle
#

see what protocollib does

#

when packetsendevent gets called

crimson terrace
quaint mantle
smoky oak
#
public static void inventoryClick(InventoryClickEvent event){
  int slot = event.getSlot();
  ItemStack stack = event.getInventory().getItem(slot);}

Why does stack equals null even if there's an item in my cursor and in the clicked slot?

eternal oxide
#

rawSlot

smoky oak
#

wait are they counted differently?

crimson terrace
#

why dont you just do ItemStack stack = event.getCurrentItem()?

smoky oak
#

slot number is important

eternal oxide
#

if getSlot() != getRawSlot() tells you which inventory was clicked.

#

Top or Bottom

smoky oak
#

wait i am in the player inventory i havent opened anything else. Why isnt it working then?

crimson terrace
#

yeah you might wanna use the raw slot

crimson terrace
smoky oak
#

check if the second from the top row is clicked and echo the material of whatever'S there

#

if(17<slot&&slot<27){ works but the item is null

crimson terrace
#

I think i might need more of the code to check for some stuff

smoky oak
#

ok

#
int slot = event.getRawSlot();
if(18<slot&&slot<26){
  Player player = (Player) event.getWhoClicked();
  player.sendMessage("Stack at "+slot+" requested");
  ItemStack stack = event.getInventory().getItem(slot);
  player.sendMessage("Stack equals null result: "+(stack == null));}```
The real joke is that it tells me the id of the slot clicked but still tells me its null even if i am clicking onto an item
#

and the reason why I'm doing it this way is because i dont want to see a stacktrace every time it is null

crimson terrace
#

couldnt you just do the ItemStack stack = event.getCurrentItem() to get the item?

smoky oak
#

as said before I need to get it with stack ids since the location is important. I also need to get the item to the right of that

crimson terrace
#

you still have the id dont you

smoky oak
#

well yes but that still means throwing the slot id +1 into the function is returning null.

#

and i need to get the itemStack of that slot, too

crimson terrace
#

try getClickedInventory()?

smoky oak
#

doing it rn

#

yup that was the issue

crimson terrace
#

ok nice

smoky oak
#

thanks for the help i guess

crimson terrace
#

XD

#

np

smoky oak
#

on another tangent, getSlot and getRawSlot only equal in the player inventory right?

crimson terrace
#

thats the difference

solid cargo
#

why it shows me like this?

smoky oak
#

wdym

crimson terrace
#

the 2016?

solid cargo
#

this is how i defined the vars

solid cargo
#

ohhh

#

wait

crimson terrace
#

what name did you give the Scoreboard?

solid cargo
#

its netherboardAPI

#

and scoreboard

crimson terrace
#

i mean the name of the scoreboard. did you include "2016" in the name?

solid cargo
#

no

crimson terrace
#

oh ok

solid cargo
#

wow i got it working first time

crimson terrace
#

well it seems to be that the health is 20 and the absorption is 16

solid cargo
#

i did this

#

so now it works

crimson terrace
#

yeah thats better. or you could just add them together

white thicket
smoky oak
#
if(event.getInventory().getType() != InventoryType.PLAYER) {return;}```
Why does that code say it's not a player inventory when I am clicking in my inventory
white thicket
#

Are you clicking in your inventory while in creative mode?

smoky oak
#

ah

#

wait

#

same issue in survival

white thicket
#

What are you trying to do?

smoky oak
#

checking if i am clicking in the inventory

#

like i only want to trigger if i havent opened any crafting / storage windows

acoustic pendant
#

could someone let me a guide that explains how to set a command to an entity? pls

smoky oak
#

ah got it. It was getClickedInventory. Why thats different from getInventory in a inventoryClickEven beats me tho

white thicket
#

nvm nice

lost matrix
acoustic pendant
#

i'm creating a pl that creates an armour stand and has different options also i would like to add that the player can set a command when clicking on it

lost matrix
acoustic pendant
#

PDC?

lost matrix
#

PersistentDataContainer

acoustic pendant
#

but the player can set/change a command there?

acoustic pendant
#

do you know any guide?

crimson terrace
acoustic pendant
#

wha

crimson terrace
#

XD

lost matrix
#

?pdc

lost matrix
#

Example:

  private static final NamespacedKey COMMAND_KEY = NamespacedKey.fromString("test:command-key");

  public void setCommand(final ArmorStand armorStand, final String command) {
    final PersistentDataContainer container = armorStand.getPersistentDataContainer();
    container.set(COMMAND_KEY, PersistentDataType.STRING, command);
  }

  public String getCommand(final ArmorStand armorStand) {
    final PersistentDataContainer container = armorStand.getPersistentDataContainer();
    return container.get(COMMAND_KEY, PersistentDataType.STRING);
  }
acoustic pendant
#

i see

#

ty

crimson terrace
#

you could also make the setCommand a boolean and make it return true if it was sucessfully set. (in case it already existed or something)

white thicket
crimson terrace
crimson terrace
#

ive had that a couple times when I set my instance = this in the onEnable at the wrong point

white thicket
crimson terrace
#

?paste the code?

undone axleBOT
white thicket
#
    private static BBCore plugin;
    Discord Discord = new Discord();

    public BBCore() throws LoginException {
    }

    @Override
    public void onEnable() {
        plugin = this;
lost matrix
white thicket
#

yes

lost matrix
#

Then plugin will always be null. onEnable is called much much later.

white thicket
#
    public BBCore plugin = BBCore.getPlugin();
lost matrix
#
    private static BBCore plugin;
    Discord discord;

    @Override
    public void onEnable() {
        plugin = this;
        discord = new Discord();

This should fix it

white thicket
#

hmm let me try

#

It worked

#

tysm

outer steeple
#

Hi! How can i execute this line of code as a player?
Rcd.setScore(1);

opal juniper
#

What is Rcd?

ancient plank
#

descriptive variables 101

opal juniper
outer steeple
#

a score

opal juniper
#

Huh?

#

I need to know what the variable is

#

or is it a class

outer steeple
#

` if (e.getHand().equals(EquipmentSlot.HAND)) {
if (a.equals(Action.RIGHT_CLICK_AIR)) {

        player.sendMessage("rcd set to 1");


        ScoreboardManager m = Bukkit.getScoreboardManager();
        Scoreboard b = m.getNewScoreboard();

        Objective o = b.registerNewObjective("Rcd","Rcd");
        o.setDisplaySlot(DisplaySlot.SIDEBAR);
        o.setDisplayName(ChatColor.DARK_AQUA +"Rcd");

        Score Rcd = o.getScore(player);
        Rcd.setScore(3);
        player.setScoreboard(b);
    }
}

}`

#

this is my code

#

i think i found it

#

Score Rcd = o.getScore(player); here i set the players score to 1 but i cant reset the score with a command for some reason

#

@opal juniper ?

opal juniper
#

let me read this

#

Sorry, i am not familiar with Scoreboards

minor garnet
#

how i could add nms classes using maven?

outer steeple
opal juniper
minor garnet
#

i dont have the nms classes

opal juniper
#

Ah ok

#

you need spigot not spigot-api

undone aspen
#

what would be the best way to store a yml config file or a loot table type thing, then use this config to fill inventories in game with loot? i have been struggling with how i should do this.

minor garnet
#

i already do this but..

opal juniper
#

Show your pom

opal juniper
outer steeple
#

@opal juniper i fixed it. 🙂

minor garnet
#
      <repository>
        <id>spigotmc-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>

      <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot</artifactId>
        <version>1.12.2-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
opal juniper
#

have you run build tools

minor garnet
#

i tried but i get errhor

opal juniper
#

Well you need to install 1.12.2 to your m2

minor garnet
#

send me the run command to build tools

minor garnet
opal juniper
#

Your local repository

minor garnet
#

what

opal juniper
#

java -jar BuildTools.jar --rev 1.12.2

opal juniper
minor garnet
opal juniper
#

how much ram do you have

#

java -Xmx1024M -jar BuildTools.jar --rev 1.12.2

minor garnet
#

i have put the paramenter

#

now i need download git, but i already did this

opal juniper
#

no

minor garnet
opal juniper
#

it downloads

#

git portable

minor garnet
#

automatilly ?

opal juniper
#

automatically

#

so just let it run for a bit

minor garnet
opal juniper
#

yep

#

lgtm

minor garnet
#

aaah i think i need download it manual

#

what is lgtm

opal juniper
#

"looks good to me"

#

no you dont

minor garnet
#

ok

opal juniper
#

let it run

ancient plank
#

downloading git go brrr

golden turret
#

hey mans

#

basically i want to use the registerEvent

#

but im trying to understand

#

what is an EventExecutor

#

i want to make like an event listener builder

#

so you can simply use

#

ListenerBuilder.event(EventClass.class).*other methods*.execution(event -> {});

cold tartan
#

with a player list heart scoreboard, is there a way to hide the empty hearts?

opal juniper
minor garnet
#

and now

hasty jackal
#

it says "please wait" so just wait

woeful crescent
#

Anyone know what the hit sound is?

#

Like which one in the Sound enum

#

I looked through pretty much all of them

cold tartan
#

ty

woeful crescent
fathom idol
#

Hey,
Do anyone know how I can get the ip adress and port of my bungeecord?
I want to get it in my bungeecord plugin.

quaint mantle
#

setMarker method in 1.8.8 for entityarmorstand

#

What is it

#

Other version have it

chrome beacon
#

Pretty sure it doesn't exist

#

Nvm it got added in 1.8.1

#

Anyway NMS might be the only option

quaint mantle
#

Running into the issue where org.bukkit.plugin.Plugin.getDataFolder folder doesn't exist

#

How do I uh make it exist

eternal oxide
#

do you have a config.yml in your jar?

quaint mantle
#

Yes

eternal oxide
#

then call saveDefaultConfig()

quaint mantle
#

Woah it's actually a plugin.yml

#

Is that even a valid naming? Nvm it is for a different more critical purpose

toxic mesa
#

So I made a plugin that just teleport players somewhere on the join event, however when players haven't been in the server yet they don't get teleported. Any clue as to why?

eternal oxide
#

delay your teleport.

winter sand
#

Hi, I'm trying to do a plugin that detects packets that takes a long time to process, how do I capture the time to handle for every packet or every event?

toxic mesa
eternal oxide
#

in the onJoin event the player is not fully logged in yet. If they have not been on the server before extra things have to happen like creating their data

toxic mesa
#

Aaah okay

#

ty

eternal oxide
#

delay teleport a few ticks and it will work fine

#

you should delay it for all players

toxic mesa
#

Yeah I've delayed it with 5 ticks

mortal hare
#

if this is dynamical to scaled player health its possible

opal juniper
#

why doesn't PlayerJoinEvent implement Cancellable :/

chrome beacon
#

You should be using AsyncPlayerPreLoginEvent if you want to cancel

opal juniper
#

thats a point - i always forget about that one

modest garnet
#

CODE https://pastebin.com/jmsvgC5q
ERROR https://pastebin.com/eBRMEbHy

its a custom coded economy any idea how i fix or a alternative storage method?

obsidian bison
#

um use json

modest garnet
modest garnet
chrome beacon
#

So why aren't you using a database like sqlite or JSON

modest garnet
#

im not to sure how thats why

chrome beacon
#

(JSON is not a datsbase)

#

But you get what I mean

obsidian bison
#
JsonObject jsonObject = new jsonObject();
jsonObject.addProperty(UUID.randomUUID(), 1);
try (FileWriter fileWriter = new FileWriter(jsonFile)) {
    new Gson().toJson(jsonObject, fileWriter);
} catch (IOException e) {
    ...
}
modest garnet
#

how do i store and fetch the data?

chrome beacon
modest garnet
obsidian bison
#
File jsonFile = new File("ex.json")
if (jsonFile.exists()) {
    try (FileReader fileReader = new FileReader(jsonFile)) {
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        JsonObject jsonObject = new JsonStreamParser(bufferedReader).next().getAsJsonObject();
        jsonObject.get
        ...
    } catch (IOException e) {
        ...
    }
}
#

Those are 2 methods for saving + loading json

#

just examples

modest garnet
#

what would yall recommend SQL or JSON?

obsidian bison
#

Both have their uses

#

SQL is good for when data is shared between servers/websites.
json is more simple

old cloud
#

Hello, is it somehow possible to convert a WorldEdit-BlockState into a Bukkit-BlockState?

chrome beacon
#

Look at BukkitAdapter

obsidian bison
modest garnet
old cloud
chrome beacon
#

Look at how it converts and reverse engineer it

old cloud
#

bruh

chrome beacon
#

Or ask Engine hub

obsidian bison
quaint mantle
#

Bytebuffers everywhere is my philosophy

obsidian bison
#

lol

quaint mantle
#

Do you need useless String concentration? No. Store the data raw

mortal hare
# old cloud wrong direction

well worldedit is multiplatform plugin, so there should be some kind of wrapper for bukkit blockstates in worldedit source code somewhere

#

if there werent any blockstates for bukkit API there should be at least some kind of wrapper for NMS block data

#

which even that, could be converted to bukkit blockstates easily via craftbukkit ABI

old cloud
#

Thanks 👍

woeful crescent
#

Anyone know why PacketPlayOutEntityTeleport multiplies location values by 32?

echo basalt
arctic moth
#

anyone know how to create maps with gson

#

like

#
{
  "something1": {
    "something2": "something",
    "something3": "something"
  }
}
#

basically im taking two variables and trying to format them like that

#

lol rip dead support

quaint mantle
#

google

#

but that looks proper

paper viper
#

literally first result:

#
Gson gson = new Gson(); 
String json = gson.toJson(myObject); 
#

and it says it works for maps too

quaint mantle
#

Always good to just do what you want in java and convert to json if you're not for sure

arctic moth
#

lol

arctic moth
#

lol nope thats not it

#
"[\n  {\n    \"playeruuid\": \"10c85c47-62d3-404a-83bf-c344014e7e7b\",\n    \"effect\": \"explosion\"\n  }\n]"

this is my output lol

#

why isnt it converting the \n into lines

paper viper
#

like whats the type of the key and value

arctic moth
#

um its a list

#

lol

paper viper
arctic moth
#

when i print it when its through toJson once, it almost does it right

sturdy flower
#

@arctic moth create the Gson using GsonBuilder and disableHtmlEscaping

arctic moth
#

it does

[
  {
    "playeruuid": "10c85c47-62d3-404a-83bf-c344014e7e7b",
    "effect": "random"
  }
]
paper viper
#

thats because you shouldnt covert it into string. if you're gonna write it to a file, only do gson.toJson

#

and also that too

arctic moth
#

lol

paper viper
#

strange enough, i never had encountered this issue before

#

did you enable html escaping or something?

arctic moth
#

no

#

so i just want to do it like that but instead of those brackets i want curly brackets and ofc the map needs a key

#

@paper viper

paper viper
#

can you give me code?

#

idk what you're doing

arctic moth
#
public static void saveNotes() throws IOException {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        File file = new File(plugin.getDataFolder().getAbsolutePath() + "/playereffects.json");
        file.getParentFile().mkdir();
        file.createNewFile();
        Writer writer = new FileWriter(file, false);
        gson.toJson(notes, writer);
        writer.flush();
        writer.close();
    }
#
public class Note {
    private String playeruuid;
    private String effect;

    public String getPlayerUUID() {
        return playeruuid;
    }

    public void setPlayerUUID(String playeruuid) {
        this.playeruuid = playeruuid;
    }

    public String getEffect() {
        return effect;
    }

    public void setEffect(String effect) {
        this.effect = effect;
    }

    public Note(String playeruuid, String effect) {
        this.playeruuid = playeruuid;
        this.effect = effect;
    }
}
paper viper
#

couple things first tho.

  1. don't make your saveNotes() method static. it is not a utility method. Because it's void, it makes the method impure.
  2. use try-with-resources on your Writer.
  3. new File(plugin.getDataFolder().getAbsolutePath(), "playereffects.json") instead of new File(plugin.getDataFolder().getAbsolutePath() + "/playereffects.json")
  4. i have no idea what notes is
#

and also, it seems to be static abuse, because the only way really is if notes is static too

arctic moth
#

lol

paper viper
#

?

arctic moth
#

i just noticed how many statics i used

#

xD

#

literally everything is static

paper viper
#

its gonna take u ages to fix that...

#

thats why you dont use it the first place

#

smh

arctic moth
#

btw notes is an arraylist that has all the notes to be added to the json

#

i did that just while i got the json set up

paper viper
#

Ic

arctic moth
#

ill get from the json once that stuffs working

#

gtg brb

#

ping me with the answer so i can find it

paper viper
#

im just confused on what you are doing...

arctic moth
#

lol

#

basically im trying to use json to store info about players

#

@paper viper

paper viper
#

that literally tells me nothing

#

i dont get what you are talking about and switching between maps, lists

#

idk what you are saying

arctic moth
#

idk

#

lol

paper viper
#

can you give me a step by step thing of what you are doing?

arctic moth
#

srry i suck at java

#

but basically

#

(lol im used to the python json stuff)

quaint mantle
#

you’re tryna save data to JSON?

arctic moth
#

ye

#

where else lol

quaint mantle
#

I saw a good video on this actually

arctic moth
#

lol

quaint mantle
#

Uhh lemme try find

paper viper
#

No hes doing some weird conversion shit

#

between lists and maps

#

and i dont get it

arctic moth
#

tbh i have no idea why i used a list in the first plave

#

its not rlly needed

paper viper
#

what is your goal

#

like

#

your original intention

#

cause this is def an XY problem lmao

quaint mantle
#

Easy fix

arctic moth
#

i just need to store the uuid and effect of each player that joins the server

young knoll
#

So just store a list

paper viper
#

🤦‍♂️

young knoll
#

Gson is great

quaint mantle
native nexus
#

Gson also works well with POJO for mongo

paper viper
#

Yeah

young knoll
#

Mongo can already handle POJO

native nexus
#

I know

quaint mantle
#

Well technically it’s JSON but like

#

Shush

paper viper
#

json and gson are kinda different

#

xD

young knoll
#

Gson is a library for working with JSON

native nexus
#

I just like serialization better for GSON

paper viper
arctic moth
#

baxk

#

what did i miss

#

lo

#

l

arctic moth
young knoll
#

yes

arctic moth
#

like mongodb

#

wait i think ik an ez solution but idk if it works with gson

#

cuz i would rlly only need uuid : effect

#

but the thing is gson uses a variable for the key

#

anyone know a workaround?

#

@paper viper or someone

#

lol srry i keep pinging u

#

but im so impatient

#

ik in python its simple af to do that but idk how to get that to work with gson

paper viper
#

why are you pinging me

arctic moth
#

lol

spare marsh
#

Hello

native nexus
#

It is very simple in java also

spare marsh
#

I want to check if the block a mob moves through or is standing on (A bee) is air. I have done CAVE_AIR, AIR and VOID_AIR but won't work for some reason

native nexus
#

https://www.youtube.com/watch?v=BbI8FdQOKNs This guy is probably the best to know how gson works.

In this video you'll get started with Gson. Gson is a library to (de)serialize JSON from and to Java objects:
►Introduction: [0:07]
►Gson Setup: [1:15]
►JSON Basics: [1:57]
►Serialization (from Java object to JSON): [4:21]
►Deserialization (from JSON to Java object): [6:52]
►Summary: [8:54]

Tip: turn on subtitles to deal with my accent. A short...

▶ Play video
golden turret
#

?xy

undone axleBOT
final fog
#

Is there a way to make an armorstand look like it's moving forward? I currently have it so that it gets teleported forward every tick, is there a better way to do it?

quaint mantle
#

add velocity to it

crisp arch
#

I have a runTaskLater task, which sends a player a message after 60 seconds. If the player goes offline before it sends the message, will it throw an error after the 60 seconds?

Do I have to check if fromPlayer and playerTo are still online?

fromPlayer.sendMessage(colorCode("&cA duel request to &6" + playerTo.getName() + "&c expired."));
final fog
# quaint mantle add velocity to it

When I don't do it, it doesn't move java new BukkitRunnable() { int counter = 0; private Vector vector; @Override public void run() { if (counter == 0) { vector = skull.getLocation().getDirection(); } if (counter == 50) { this.cancel(); } counter++; skull.setRotation(counter * 20, counter * 20); skull.setVelocity(vector);

quaint mantle
#

normalize it

final fog
#

It still won't move if I do that

quaint mantle
#

you're just rotating it

final fog
#

that's a different thing

#

I want it to move while rotating

#

and that part works when I teleport it every tick

quaint mantle
#

is there a decently easy method to switch bungeecord servers without having the dirt background with the "loading world"?

quaint mantle
#

the loading background is for: changing world, server, joining server,... and default in mc. but if a pc is good enough, the time they appear is very, like very little

#

like only 5 to 10 frames

#

thanks but that does not answer my question

young knoll
#

No

#

The client has to load the world

quaint mantle
#

what if i don't tell the client to load the world and instead just replace the blocks in the current world?

#

will it work?

young knoll
#

Maybe

#

Good luck with that

quaint mantle
#

:(

#

that's an idea I've had for years

#

never reconnect someone, just fake all the chunk data around them

#

I'd be very surprised no one has done a proof of concept by now

quaint mantle
sullen marlin
#

The changing screen is so quick it's not worth it

#

You'd just be replacing it with a flash to void

tardy delta
#

?paste

undone axleBOT
tardy delta
sullen marlin
#

Why is blockowner a field

tardy delta
#

Im using it somewhere else

#

I don't have my pc now

carmine pecan
#

Hi! Is there any way to check recently created threads? Like you get from crash reports, but without actually crashing the server? Thanks

ivory sleet
#

Thread.getAllStackTraces().keySet() mb

#

then I guess you could check its state

#

idk if there an actual way to check when they were created

carmine pecan
#

Alright, thanks!

vernal pier
#

How do I check if a value in a int[] array is set

#

if I do (new int[69])[6] it gives 0 even if I don’t set it so how do I check if I actually set it

quaint mantle
#

I don't think i have any errors with this right?

    SpawnRemove spawnRemove;
    SpawnSet spawnSet;

    PlayerDamagePlayer playerDamagePlayer;
    PlayerDeathRespawn playerDeathRespawn;
    PlayerJoinLeave playerJoinLeave;

    Language language;
    LocationsData locationsData;
    PlayerData playerData;

    LangUtil langUtil;
    FantomUtils fantomUtils;
    LocationsUtils locationsUtils;

    @Override
    public void onEnable() {

        spawnRemove = new SpawnRemove(this, locationsData, langUtil, locationsUtils);
        spawnSet = new SpawnSet(this, locationsData, langUtil, locationsUtils);

        playerDamagePlayer = new PlayerDamagePlayer(this, fantomUtils, langUtil);
        playerDeathRespawn = new PlayerDeathRespawn(this, locationsData, fantomUtils, langUtil);
        playerJoinLeave = new PlayerJoinLeave(this, fantomUtils);

        language = new Language(this);
        locationsData = new LocationsData(this);
        playerData = new PlayerData(this);

        langUtil = new LangUtil(this, language);
        locationsUtils = new LocationsUtils(this, locationsData);
        fantomUtils = new FantomUtils(this, playerData);```
in my constructor in other class it still the normal null error...
fading lake
#

wdym null error

quaint mantle
#

but i cant even figure it out 😂

hasty jackal
fading lake
vernal pier
#

thanks

hasty jackal
#

that assumes that -1 would otherwise be an invalid number

quaint mantle
#

my constructor can't do anything 😂

hasty jackal
quaint mantle
#

i thought it was about the order of them

#

yeah im right.

quaint mantle
#

Does anyone have a simple example of dependency injection (dont throw me the spigot wiki)

eternal night
#

using a dependency injection framework ?

#

or just the pure basic concept

quaint mantle
#

The basic concept

mortal hare
# quaint mantle Does anyone have a simple example of dependency injection (dont throw me the spi...

MainClass.java

private ConfigRegistry registry;

public class MainClass extends JavaPlugin {
  @Override
  public void onEnable() {
    this.registry = new ConfigRegistry(this);
    Configuration config = this.registry.load("exampleconfig.yml");
  }

  @Nullable
  public ConfigRegistry getConfigRegistry() {
    return this.registry;
  }

}

ConfigManager.java

public class ConfigRegistry {
  private final JavaPlugin plugin;  

  public ConfigRegistry(JavaPlugin plugin) {
    Objects.requireNonNull(plugin, "Failed to construct configuration registry! JavaPlugin object cannot be null!");
    this.plugin = plugin;
  }

  // String path or URL path, doesnt matter, its an example.
  @Nullable
  public Configuration loadConfig(String path) {
    // Your code for loading config, by getting the main plugin config via. this.plugin.getConfig()
  }
}

Basically dependency injection is the design principle where you pass the required the objects in constructor arguments or set the depedencies of the object via setters, rather than accesing them via static fields or making the object create the object for himself.

quaint mantle
#

Oh ok thank you

mortal hare
#

its used to tighten your code, aka to make it more encapsulated

#

and its easier to read the code, because searching what static method returns is not fun and kinda slower

fading lake
#
  • 90% of the people in this discord will yell at you they see it (sometimes referred to as static abuse depending on the circumstance)
#

although only about 0.5% of that 90% actually have an idea of why its considered bad and what cases its fine

quaint mantle
#

oh ok lol

eternal oxide
#

There are very specific use cases for static

mortal hare
#

utility classes for example

fading lake
#

I only really use them for utilities which is an acceptable use

mortal hare
#

statics are like functions in c

#

they could be accessed almost everywhere

#

if its included as an include inside the file

eternal oxide
#

if you have a class that is instanced in a lot of places but has a field you need to be the same across all, like a Map, then you'd make teh Map private static