#help-development

1 messages · Page 2133 of 1

tardy delta
#

anyways is List the same as List<?>?

supple elk
#

How can I easily turn a list of these:

#

into a list of Location?

#

I could iterate over each element of the list and convert then add

#

but I'm guessing there's quicker syntax

tardy delta
#

stream them

#

list.stream().map(c - > new Location(someWorld, x, y, z, yaw, pitch)).collect(tolist)

#

im waiting for the time two varargs parameters are possible

#

this is stupid lol

opal herald
#

im still not sure what to do for this ```package com.tuwtle.TorchHandler;

import com.tuwtle.testplugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;

public class TorchHandler implements Listener {
public TorchHandler (testplugin plugin){
Bukkit.getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void TorchBomb (PlayerInteractEvent e){
    Player p = e.getPlayer();
    Action action = e.getAction();
    ItemStack item = e.getItem();

    if (!item.getType().equals(Material.TORCH))
        return;

    if (action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) {
        World w = p.getWorld();
        w.createExplosion(e.getClickedBlock().getLocation(),100,false);
        Location explosionLoc = p.getLocation().clone().add(p.getLocation().getDirection().multiply(1));
    }
}

}```

#

nothing happends when i try this

tardy delta
#

why returning after you made local variables?

opal herald
#

idk

#

what did return do agan

#

that works

#

the issue i have rn is that im trying to make my have "reach" with the torch

#

so pretty much i want to get an explosion whereever the player left cliks

#

but to do that you need reach

#

so im trying to make the torch cause an explosion wherever i left click

sacred prairie
#

how do i get the name of an enchantment?

echo basalt
#

probably the second part of the key

sacred prairie
#

Works, thank you

pastel juniper
#

I want to add and remove minecraft recipes from recipe book, is there a way to do it???

#

Also I want to add custom textures to custom items, but not checking the name, checking the Persistent Data Container

trail oriole
#

How can I send actionbar messages without legacy Texts in 1.8

opal juniper
#

read legacy docs idk

#

we dont support here

trail oriole
#

I said without :(

opal juniper
#

1.8

trail oriole
#

?

tardy delta
#

legacy does that mean old?

opal juniper
#

yes

opal juniper
trail oriole
#

Yes

opal juniper
#

if so its Player#spigot(TextComponent)

#

mb

tardy delta
#

player.spigot().sendMessage(MessageType.ACTION_BAR, new TextComponent(text)) and use a runnable to keep sending it

#

or it will be gone after a few ticks

mortal hare
#

man I've never thought having two classes shown at the same time on a 2K screen was so useful

tardy delta
#

lol never thought about that either

#

im not even using he whole size of my screen

mortal hare
#

also im a weirdo who uses light mode

#

on an ide

#

I feel like dark mode makes me sleepy

#

af

tardy delta
#

oh god my eyes will burn at night

#

just put on the good music

mortal hare
#

and in daytime my eyes have a hard time focusing on dark elements

mighty pier
#

how do i use p.performCommand?

#

i tried p.performCommand("kits"); and it doesnt work

sterile token
sterile token
mighty pier
#

thankyoiu

sterile token
#

One of them should work

tardy delta
#

isnt it on my profile?

#

there isnt much on it

cold field
sterile token
#

Because i want to take ideas to design some things

tardy delta
#

there isnt a lot of good stuff in it

dense geyser
#

can someone explain in simple terms what a daemon is in terms of threads? ex Thread#setDaemon(boolean), I thought daemons were to do with docker exclusively 😅

ivory sleet
#

basically means background process

#

in Java, setting a thread daemon will make sure that the java program can terminate w/o having to await termination of the thread

#

(ofc the thread will terminate afterwards)

#

but well, in the background

opal juniper
#

(daemon isnt java specific though)

dense geyser
#

so its the equivalent of calling cancel on a bukkitscheduler task?

ivory sleet
#

not really

dense geyser
#

oh

opal juniper
#

Threads run seperately to the main thread of execution but all fall under one java process, so when the main thread terminates these other threads will prevent the actual ending of the java process.

Setting the daemon to true tells the jvm that it is safe to just end that thread once the main is done so that the java process can finish

#

@dense geyser

tardy delta
#

so those other threads will finish their job in the background?

opal juniper
#

not in the background, they will just be terminated

dense geyser
#

alright, so say if daemon = true and I were using Thread alongside redis pub/sub, if the thread managing redis closed, would that also close any lingering pub/sub threads?

tardy delta
#

ah like that

opal juniper
#

Yep

dense geyser
#

interesting, thank you ❤️

steady rapids
#

noob question: how do I get the nametag of a mob (not the default name)?

ivory sleet
#

tho idk if its smart to use pub sub w/a daemon thread

#

since thats basically io

tardy delta
#

so in a normal situation those threads will prevent the process from stopping but if they are daemon threads the jvm knows that it just can kill those in order to terminate the process?

ivory sleet
#

myes jvm can pretty much end them whenever its plausible

dense geyser
#

alright, so I should just not worry about daemons rn then lol

ivory sleet
#

it doesnt care about code statements such as finally

#

so lets say you do have a connection, then you might risk to leave it open

#

mye

#

well I use daemon threads for my pubsub implementation, but thats mainly for event processing and not the pub sub itself

dense geyser
#

wdym

#

oh connecting it to bukkit events etc?

ivory sleet
#

mye a similar event bus to the bukkit one

#

since thats basically getting some data, process it, and invoking relevant observers

#

and can be completely isolated from any redis stuff

dense geyser
#

i see

#

so daemonising something like this would be a bad idea, since its just a publish?

public void publish(String channel, String message) {
    Thread thread = new Thread(() -> {
        try (Jedis jedis = getResource()) {
            jedis.publish("channel", "msg");
        }
    });
    thread.setDaemon(true);
    thread.start();
}
ivory sleet
#

thats probably a less good idea

dense geyser
#

alright

ivory sleet
#

since it may not complete that try block fully (aka calling close() on the getResource()) to lend back the connection to the pool

#

if we're post finish state

dense geyser
#

thats a good point actually, thank you

ivory sleet
#

tho I'd assume that you close the pool during termination in which it might be fine shrug

dense geyser
#

yes, but better safe than sorry ¯_(ツ)_/¯

ivory sleet
#

yeah

#

idk much about jedis, but I do know its blocking when invoking subscribe, so using subscribe might be worse of an idea than simply publishing, and you're only publishing

dense geyser
#

so daemonising subscribe is a defo no no?

vestal dome
#

guys why is managing block states in Spigot 1.8.8 so difficult.

dense geyser
#

because its 1.8.8

#

welcome to my life lol

ivory sleet
#

probably, unless it uses some internal thread that isnt daemon

#

but its nothing Id rely on honestly

dense geyser
#

interesting, alright, thank you

brittle lily
#
 public int setCoin(FileConfiguration config, Player player, int number) {
        config.set(player.getDisplayName() + ".money", config.getInt(player.getDisplayName() + ".money") == number);
        coin = config.getInt(player.getDisplayName() + ".money");


        return coin;
    }

number is my args[1] and its doesnt setting money to my arg. Its setting to 0 Why?

ivory sleet
#

cheers

vestal dome
#

because I map NMS, and I can confirm bukkit over complicated the states systems in 1.8.8 or legacy versions 😂

#

(I map NMS for compatibility purposes, never for the purpose of replacing bukkit)

dense geyser
#

I mean I can do it now, its just there are a lot of things in 1.8.8 which don't have the honour of being made easier in 1.12+

#

also

#

the lack of pdc in 1.8 x-x

vestal dome
#

it's called NBT.

dense geyser
#

if only I knew how to implement it myself

vestal dome
#

you don't need to

dense geyser
#

yeah but NBT clears itself on entities

vestal dome
#

NBTAPI already does it for you.

#

does it?

dense geyser
#

yeah

#

1.12+ implemented a thing for it to stop it doing it

vestal dome
#

unlucky.

dense geyser
#

so far the only thing that doesnt clear afaik is itemstacks

#

ikr

vestal dome
#

oh well..

tardy delta
#

save it

vestal dome
#

I would actually suggest you store the data in memory,

#

and when the server is shutting down save it to the file..

#

I had this experience where it was super slow to set values in-real-time to files in bukkit

#

idk why

tardy delta
#

a fileconfiguration is basically in memory

vestal dome
#

yeah but would you really like to specify every string?

tardy delta
#

#save is saving it to the file

vestal dome
#

like "player." + uuid + ".money"

#

everywhere?

#

instead you could have an Object like

#

"PlayerData"

#

that stores the money, status, rank (for example)

brittle lily
brittle lily
tardy delta
#

why setting it to a bool too

ivory sleet
#

oof

tardy delta
#

better than writing plugin: this

vestal dome
#

that's not java tho?

tardy delta
#

i know

#

it was just their ide telling the name of the parameter

manic delta
#

Is there a way to enable/disable pvp for a certain player?

tardy delta
#

block the damage event for that player

manic delta
#

O

#

I see

#

There are no other ways?

#

I want to see the one that best suits what I want

tardy delta
#

what would you do otherwise

manic delta
#

Idk lol

wind tulip
#

Hey. Does anyone know why I can't access my library's methods even though they seem to be loaded in properly?

I'm using Maven for both projects and I exported the library using maven & added it as a dependency. I've reloaded both projects, clean installed the library, and even restarted IntelliJ. What's wrong?

#

First image (top) is of the library when you ctrl+click on the import, and second is of the plugin itself

kindred valley
#

why this happening

wind tulip
#

is that the issue or is that just a practice

manic delta
vestal dome
fossil lintel
vestal dome
#

it says that because you might of not registered the commands in plugin.yml

kindred valley
#

but after this shit commands are not working

manic delta
kind hatch
#

???

manic delta
vestal dome
#

since?

wind tulip
fossil lintel
#

Yes, the library is okay

wind tulip
#

but after I import it it looks like this

#

wait wrong image

manic delta
wind tulip
#

like this

#

oh

#

you mean

#

okay

fossil lintel
vestal dome
fossil lintel
#

But the place where you try to use it is the issue

vestal dome
#

if static methods lagged, they wouldn't be used.

#

simple.

manic delta
tardy delta
#

class names starts with an uppercase character, the compiler thinks youre referring to a variable called main i guess

vestal dome
#

NO?

manic delta
#

excessively

kind hatch
manic delta
#

Not always

vestal dome
wind tulip
manic delta
#

Yes, a lot

vestal dome
#

even excessively it won't cause lag.

manic delta
#

it does

vestal dome
#

did you do the test?

fossil lintel
#

static methods don't lag the server, they're just usually not really good for writing reusable code modules

vestal dome
#

exactly.

manic delta
#

The server does not, but your plugin is less optimized

vestal dome
#

who said?

#

you need a singleton for example for instance

kind hatch
#

You clearly don't know what static is used for then. :/

tardy delta
#

@wind tulip you saw what i wrote?

vestal dome
#

statics are utilities for example.

kindred valley
vestal dome
#

or singletons

manic delta
wind tulip
#

but

vestal dome
#

well I feel bad for you.

wind tulip
#

the import statement itself is also giving me an error

kind hatch
#

What about oracle themselves?

tardy delta
#

also method names starts with a lowercase character

wind tulip
fossil lintel
wind tulip
#

oh

vestal dome
#

or just use <class of the static method>.<static method>(<parameters>)

#

always works

#

not that import static won't work ofc

#

I just think it's more organized, since it actually says the class before the method.

wind tulip
manic delta
#

I looked for information too lol

wind tulip
fossil lintel
vestal dome
#

yeah...

fossil lintel
#

It gives the other valid reasons for not using static, but it does not explain why it would lag a server

crisp steeple
#

using static doesnt cause lag

#

its just not good practice

tardy delta
#

static methods are actually faster to invoke

kind hatch
vestal dome
#

I would add

crisp steeple
#

yea

fossil lintel
#

You're right that overusing static is not a smart idea, it just doesn't have the performance impact that you claim

manic delta
#

Not the total server

fossil lintel
#

What kind of optimization are you talking about?

manic delta
#

response times

vestal dome
#

wait what?

fossil lintel
#

I don't think that is related to static

tardy delta
#

indeed

manic delta
#

I will search more then

vestal dome
#

If I am not mistaken

#

correct me if I'm wrong

crisp steeple
#

provided the class is referenced somewhere

tardy delta
#

iirc

fossil lintel
vestal dome
#

well there's gotta be a point to using static.

#

if there's no point in using static, it wouldn't of been created.

crisp steeple
#

utility

vestal dome
#

or it would of been long removed..

crisp steeple
#

initializers

kind hatch
#

Utility is one. Another is to have something that needs to be shared between instances of the same class.

fossil lintel
#

Statics have their uses

manic delta
tardy delta
#

the point of static is for stuff that doesnt belong to a class

manic delta
#

Not just a single variable

vestal dome
#

I guess you got a point

quaint mantle
#

i like to think as static as a floating variable

#

it doesnt have a base, it just exists

#

you could explain static by saying its global

#

exists once

manic delta
#

I understand that the static things are loaded into memory at compile time and not as the lines of code in the program are executed.

#

||Correct me if I'm wrong||

vestal dome
#

are loaded into memory when the class in specific is loaded*

tardy delta
#

loaded into memory at compile time that doesnt make sense

manic delta
#

That's why I was told that its excessive use can lead to less response time or poor optimization.

crisp steeple
#

its not loaded into memory at compile time

#

how would that even work

vestal dome
#

eh, might be beginner..

#

unlucky.

manic delta
#

Im not, but I understand that it works like that (That's what someone taught me lol)

vestal dome
#

||hope it wasn't a school|| it definitely wasn't.

manic delta
#

Nope

ivory sleet
#

static bad

#

🙂

opal juniper
ivory sleet
#

shush

opal juniper
#

but yes,

ivory sleet
#

you weren't supposed to mention that

#

but I mean

ivory sleet
#

tbf kotlinify it and use extension functions or sth Ig :3

opal juniper
#

just don’t use python for oop

#

you will have a bad time

#

#whats a singleton

ivory sleet
#

oh lol, right does py still not have static when it comes to class declaration?

#

or global thing within a type

opal juniper
#

i’m basically certain you can’t

crisp steeple
opal juniper
#

@quaint mantle am i right

crisp steeple
#

and inefficient

fossil lintel
#

Doesn't Lombok just generate the code?

quaint mantle
#

like static variables in python?

ivory sleet
#

yes

opal juniper
#

ye

ivory sleet
#

like contained within a class

#

similar to Java Ig

ivory sleet
quaint mantle
#
class A:
    static_variable = 5
#

lol

fossil lintel
#

Why would it be inefficient then?

ivory sleet
#

hence its evilness tho Sansko

opal juniper
#

lol

crisp steeple
#

not inefficient at runtime

#

just actually writing the code is inefficient

opal juniper
#

didn’t realise

fossil lintel
#

Yeah, I don't like it either, don't get me wrong 😂

ivory sleet
opal juniper
fossil lintel
#

I rather use records nowadays

quaint mantle
crisp steeple
#

intellisense is broken + its not really executed great with having to do @extensionmethod(class1, class2) for every extension method you want to use

ivory sleet
#

so a singleton would just be

class Config:
  __instance = Config()

  @staticmethod
  def get_instance() -> Config:
    return instance
#

?

quaint mantle
#

well __instance for private

#

not actually private but naming convention

opal juniper
#

@staticmethod as well

quaint mantle
#

^

ivory sleet
#

does the annotation even do something?

opal juniper
#

yeah

quaint mantle
#

yeah

ivory sleet
#

oh

#

unlike Java then

opal juniper
#

cause if not it will try and pass the instance as a param

quaint mantle
#

stop typing so fast

#

stealing the words from my fingers

ivory sleet
#

wait will it?

quaint mantle
#

probably used to

ivory sleet
#

ah

#

fair

opal juniper
#

so predictive swipe typing goes brrrrr

quaint mantle
#

you have that ttoo?

#

its great

ivory sleet
#

I remember googling on stack overflow how to declare a singleton and I literally got 0 answers... and it was this simple all along

quaint mantle
#

i can type with one hand efficiently

opal juniper
#

exactly

opal juniper
ivory sleet
#

lol fr

#

guess thats a good thing tho

opal juniper
#

i’m yet to find a use for @classmethod

quaint mantle
crisp steeple
#

just gotta use kotlin where objects are technically singletons

#

even though they act like static in kotlin

quaint mantle
#
@classmethod
def a(cls) -> None:
    cls.__iter__ = lambda: SomeIter()
#

@opal juniper theres like no use for it

#

idek if that runs

ivory sleet
#

@JvmStatic deotime :3

crisp steeple
#

yea

ivory sleet
#

or if it was StaticJvm

#

idr

crisp steeple
#

its jvm

quaint mantle
crisp steeple
#

its a crab

quaint mantle
#

boring

ivory sleet
#

I mean companions are great apart from the fact that you cant write them inlined

#

companion object const X = 5 would be so nice

crisp steeple
#

true

#

the amount of times i strugged writing a main function when i started kotlin was unreal

ivory sleet
#

lmao

#

:c

#

phj

#

wait wrong one

#

ah I cant find it

#

frick

ivory sleet
#

but yeah there was a proposal for that deotime

#

altho got denied

crisp steeple
#

rip

opal juniper
#

ah so you can use class method for a factory function - but i see no difference between that and init

quaint mantle
#

yeah its dum

ivory sleet
#

isnt there getHook?

quaint mantle
#

because it doesnt always have one

#

i literally just showed you how

#

🥲

#

i fully understood you

crisp steeple
#

you could just do event.getPlayer().getItemInHand()

#

why not

ivory sleet
#

yeah I believe there might be missing api for this

crisp steeple
#

md_5 hates fishing rods confirmed

ivory sleet
#

lol ye

tardy delta
#

i have three hands

ivory sleet
#

sounds a bit Illuminati

quaint mantle
#

yeah ik

ivory sleet
#

yes I just concluded it

#

zacken, you have your golden ticket to become a primary spigot contributor here :3

quaint mantle
#

i mean theres like no way to do it

#

theres no point

#

because it would have to store the item and the player in a map

patent horizon
#

whats the best way to check if a player has a list of permissions?

quaint mantle
patent horizon
#

sorry i meant if they dont have any of the permissions in the list

quaint mantle
#

check if they dont have them

#

bruh

#

no i mean the code would be shit for it

#

and dirty

patent horizon
#

no yes i know the hasPermission

#

but if there's 10 permissions im testing for, using if perm1||perm2||perm3||perm4||perm5 wouldnt be the best yes?

quaint mantle
#

!?!

#
for (String permission : permissions) {
    if (player.hasPermission(permission)) {
        return;
    }
}
#

this is just java dude

#

thats horrible dude

#

:*

ivory sleet
#

player::hasPermission :3

quaint mantle
#

no watch

#

BITCH

ivory sleet
#

;*

quaint mantle
#

dude why can i never type things why do yall take my words

ivory sleet
#

whats ur wpm btw

quaint mantle
#

140

#

when im trying

ivory sleet
#

else if you're not trying?

quaint mantle
#

like 110

ivory sleet
#

hmm thats still better than me

#

significantly

quaint mantle
#

in conclusion: i mess up alot

ivory sleet
tardy delta
#

i dont try that kind of tests cuz im soo bad at it

quaint mantle
dense geyser
#

stupid question, but if I return something from inside an autocloseable try/catch, does it still close

ivory sleet
ivory sleet
#

thats the point of it being extremely safe

quaint mantle
#

shit i forgor

#

i see it

ivory sleet
#

does it?

#

:c

dense geyser
#

a little bit yeah

supple elk
#

I don't see it tbh

ivory sleet
#

might be last time you see me with this pfp then shrug

supple elk
#

It's hard to decipher

quaint mantle
#

i mean i kinda see a dogs arse

supple elk
#

I see an upside down dog

ivory sleet
#

woaw

#

back

#

:3

supple elk
#

the banner??

#

ik

#

how

#

tho

quaint mantle
#

not that

#

his pfp

supple elk
#

^?

#

You said the banner

#

pfp not the banner 🤔

#

right right

#

I thought you were saying the banner looked like a dog dick

#

possibly

quaint mantle
#

iykyk

supple elk
#

What's the best way for me to trigger code for when a player walks into a specific area?

#

I'm making a boat racing game with checkpoints

#

easy enough to find whether the person is in the area or not

#

but the question is when to perform the check

#

every tick?

#

seems intensive

#

but I don't see an alternative

ivory sleet
#

PlayerMoveEvent?

supple elk
#

Ig that's probably less intensive

#

I dunno actually

crisp steeple
#

it can only be called once a tick though (per player)

#

so pretty much the same if not less intensive as a repeating runnable

upper crater
#

a friend told me to do it lioke this but this keeps erroring this... what do i do?

undone axleBOT
river oracle
#

bruhs need to atleast know contructors come on

upper crater
#

i do

#

but when I make a constructor

river oracle
#

clearly not

#

Bro legit eclipse is telling you don't have one

upper crater
#

it says

river oracle
#

so don't say you do

upper crater
#

i have

#

already

#

for over a year

river oracle
#

clearly not

#

how do you have a year of experience yet have no clue why tf the super keyword is throwing you an error

upper crater
#

look

river oracle
#

I highly doubt you have more than a month of java experience constructors and inheritence takes a bit to get the handle on but don't say you know something you don't

upper crater
#

i was told to put this into the constructor, what am I supposed to do with Main then?
I know how it works, but I don't know how the command system works here

#

i do know

river oracle
#

so you have a year of java experience and still don't know that an interface can't have a constructor

upper crater
#

bruh, can you just tell me why my friend told me to implement .setExecutor like that and what the correct way is

#

or just tell me the correct way

river oracle
#

your using the setexecutor fine this issue is your arguments and your lack of ability to figure out basic constructor mechanics

#

super keywords calls the super constructor which can't exist for an interface because interfaces can't have constructors

#

your friend is showing you basic dependency injection since you have a grasp on java given 1 year of experience you should beable to properly use dependency injection to pass important objects at this point

river oracle
#

?main

river oracle
#

I reccomend learning more java clearly your a bit slow to learn given you've already been learning Java for a year Spend some time working with inheritance and don't think any JS experience translates java and JS are very different

upper crater
#

i know

#

i just never had to use interfaces to that level

river oracle
#

wdym to that level

#

its basic knowledge

upper crater
#

so i didn't understand that immediately

final star
#

guys, how can I access player data using NBT, at the moment I'm doing it like this, but it doesn't go beyond 0 (XP is just an example, I'll get another data later)

upper crater
#

apparently not 🤷‍♂️

river oracle
final star
#

I'll try

river oracle
#

its super easy

final star
#

thanks

fleet pier
#

how to set a players prefix via bungeecord?

wicked totem
#

is there a better way to add potion effects than addPotionEffect? it works initially but then stops when someone dies (even when i try to reapply it).

quaint mantle
#

is it possible to make items like armor go over the 20 cap for generic.armor?
i want netherite armor to have double diamond and have 40 in total when all pieces are on, but i cant because of minecraft's cap.

again, is there a way to bypass this?

#

(i'm not in a position to code this myself tho :(. )

quaint mantle
#

would making a run task later for 15 minutes to forcefully end a duel in my duels plugin affect performance hugely

sharp flare
#

no

maiden acorn
#

anyone have any ideas on the best way to force a player's client to re-request a chunk?

#

or, alternatively force the server to send an entire updated chunk (rather than individual blockChanges) so the client reloads the entire chunk?

wet breach
#

there are methods to send chunk updates in the api

maiden acorn
#

ah, perfect... that solves one of my problems!

#

the other is that I'm sending a decent number of block change packets to players... I notice some of the world methods allow you to request changes and have them queued (like unloadChunkRequest(...) instead of unloadChunk(...)... does anything like this exist for block change events? I'm trying to spoof a pretty large structure and would prefer to queue these events instead of sending them all at once

ebon coral
#

When did they add the ability to send plugin messages just through Bukkit.getServer()? Literal blessing lol

wet breach
maiden acorn
#

gotcha, that makes sense

upper crater
#

what's the easiest way to make a config folder like the one viaversion has?

kind hatch
#

By using #saveDefaultConfig()

upper crater
kind hatch
#

#reloadConfig() updates the cached version of the config by reading what is on the disk.
Yes, #saveDefaultConfig() will create the file if it doesn't exist.

upper crater
#

how often should I do reload config

#

and does savedefaultconfig have a different file than saveconfig?

kind hatch
#

Depends on your usecase. Normally, you would only need to call it if you are making changes to the config file manually. Usually implemented with a reload subcommand.

#

#saveDefaultConfig() will look for a file called config.yml in your plugin jar and then write it to disk if it doesn't already exist. That's all it does. It's the same exact config that's returned with #getConfig().

upper crater
#

Ok

#

Got it

ivory flume
#

What are bungeecord plugins?

upper crater
#

Thanks

ivory flume
#

is there a github repo or guide anywhere on how to get started with bungeecord plugins

brave sparrow
ivory flume
#

how do you make them

brave sparrow
#

very similarly to how you make a spigot plugin

#

and all the documentation is in the same place as it is for spigot

upper crater
#

What is bungeecord and why bungeecord over spigot

brave sparrow
#

it's not an either-or

#

bungeecord is a proxy that can be used to link together multiple spigot servers

#

you can't just have a bungee

ivory flume
#

the guide is in maven

#

is there any gradle guides

#

or at least any tips on what to watch out for

brave sparrow
#

it's just a dependency

#

you add it the same way you'd add any other dependency

ivory flume
#

all right thank you

ebon coral
#

Can you send a plugin message async?

upper crater
kind hatch
#

The contents in the config.yml that is part of your plugin.

upper crater
kind hatch
#

If you're using maven yes.

#

Well

#

actually

upper crater
kind hatch
#

The path #saveDefaultConfig() uses is the parent directory of the compiled jar. So maven will take all of the resources from /src/main/resources and put them in the parent dir of the jar. (This can be changed of course, but it's default behavior)

upper crater
#

ohk

manic delta
#

Is there an event that is executed when the player puts on an armor piece?( I just searched the javadocs and didn't find one, does anyone have an idea how to do something like this?)

kind hatch
# manic delta Is there an event that is executed when the player puts on an armor piece?( I ju...

There's not. You'll have to check for a few events in order to cover the full functionality.
InventoryClickEvent - Check to see if the player shift clicks armor in their inventory.
InventoryDragEvent - Check to see if the player manually moves the armor to the armor slots.
PlayerInteractEvent - Check to see if the player equips the armor piece from the hotbar.

Alternatively, you could use this resource: https://github.com/Arnuh/ArmorEquipEvent

sharp flare
#

weird

#

i right clicked an entity and it triggers the left one

#

how come it would trigger the one :/

crisp steeple
#

all the others use some weird methods as well

#

i would honestly just think someone would have made something with nms

kind hatch
sharp flare
#

Player interact event and Player interact at entity event

#

picture above is PlayerInteractEvent

kind hatch
crisp steeple
#

yea

kind hatch
sharp flare
#

I'm not damaging it

#

i left click the staff after right clicking an entity

#

but then it triggers both at the same time when i right click an entity

#

so entity damage event is not applicable here

crisp steeple
#

theres a lot of them as well

#

honestly would probably be better off just using that resource

#

as theres also a ton of blocks that dont equip the armor when you right click

kind hatch
sharp flare
#

have u checked the 2 pictures above?

#

I'm explicitly checking the action and hand there

#

player interact at entity event only has hand checks unlike the player interact event

kind hatch
#

Sorry, I thought the names were MAIN_HAND and OFF_HAND, not just HAND.

#

Maybe that's for inventories.

sharp flare
#

isRightHand for player interact event, the second picture is not reference inside a variable

crisp steeple
#

entityinteractevent gets fired twice for some reason

#

a lot of servers have that bug

sharp flare
#

based from the checks it shouldnt be even triggering left click when I right click an entity

crisp steeple
#

or maybe its intentional with how clicking it works

sharp flare
#

so it might be the case with player interact at entity event not having appropriate #getAction checks

crisp steeple
#

i dont think thats the case

sharp flare
#

would gladly accept a reason why if its not

sharp flare
crisp steeple
#

no

kind hatch
#

Doubt it.

crisp steeple
#

dont think we're talking about the same thign

kind hatch
#

Also, for clarification., Are you using the PlayerInteractEntityEvent or the PlayerInteractAtEntityEvent?

sharp flare
#

I'm using the first, to be honest I didn't event know the latter exist

hard lake
#

HELP ME

#

PLS

#

"Cannot send chat messages" in multiplayer (chat settings are already on SHOWN AND CONSOLE NO ERROR)

#

pls

sharp flare
#

im using the parent class then

kind hatch
sharp flare
#

correct

kind hatch
#

Ok, so then it comes down to how you check for things.

sharp flare
#

when right clicking the entity it then triggers the left action in the player interact event

#

these doesn't happen on some servers but on my local one it does

kind hatch
#

Then you probably need more checks in your PlayerInteractEvent.

#

Like, staff state and whatnot.

#

It may also help to break up your if statements.

#
if (!(stick instanceof AbstractStaff)) {
  return;
}

if (!(event.getRightClicked() instanceof Player)) {
  return;
}
// etc
sharp flare
#

can shorten it out

#

might do same thing with hand check

crisp steeple
#

ok so

#

you are never left clicking

#

and somehow it ends up firing a left click action playerinteractevent?

sharp flare
#

yeah

#

exactly

#

its damn weird

#

but since they are both interact events idk why though

kind hatch
#

It's likely an issue with just one of them.

#

Something unaccounted for.

#

Can you share the code for both events?

#

?paste

undone axleBOT
sharp flare
kind hatch
#

Oh, it's slimefun related. pain

#

I've had so much trouble with it.

crisp steeple
#

seems redundant to have both of them

kind hatch
#

That's true.

sharp flare
#

wdym

kind hatch
#

He only needs left click for the player interact event.

crisp steeple
sharp flare
#

fair

crisp steeple
#

might fix the issue somehow

#

idk

kind hatch
#

That, but also he stated that players will left click with the staffs.

crisp steeple
#

yea

sharp flare
#

I'm just making it more readable though but ill take that

kind hatch
#

There is no need for a right click check.

#

If that is the only functionality*

sharp flare
#

not all staffs can be left clicked though

#

most of them are just right clicks

kind hatch
#

Well, are there different types of staff implementations? Because you could make another event and just check if it's a different staff. A little redundant, but guaranteed to work.

sharp flare
#

only have entity staff implementations

kind hatch
#

Well you may want to split your logic up like this then.

if (!(stick instanceof AbstractStaff)) return;
if (!(stick instanceof EntityStaffImpl)) return;
if (!isRightHand) return;

if (isRightClick) {
  // do right click things
} else {
  // do left click things
}
sharp flare
#

then any staff that doesn't implement entitystaff aint gonna work

kind hatch
#

But you said that's all you have to work with. :3

sharp flare
#

but thats good for a seperate listener

#

Not sure if u mean staff implementations but entity staff is just an interface

kind hatch
#

Yea, I was asking if you had other ones that you were going to check for.

#

Cause if that's the case, you could just copy the listener and change the one check.

sharp flare
#

no actually, thats why I have instance of check in the if conditions

kind hatch
#

So what's the issue with just checking if all staffs are not an instance of EntityStaffImpl?

#

It would still meet the criteria would it not?

sharp flare
#

I would have to move the #onClick method above for abstractstaff only

#

if im using ur code above

#

cuz I dont have in mind of making seperate listeners for this

#

when the checks are on time and should not be even triggered when i right click

#

Appreciate your time though ill be heading out for now

kind hatch
#

Oh, you have both checks there.

#

Didn't notice that till now.

copper dove
#

so i am working on a plugin for a sub server that i host and im trying to make it so u can walk up to any living entity shift right click then pick them up into ur inventory but when it comes to villagers how would i say collect the data needed so if they have a job when they get spawned back into the world that they still have that job

ancient plank
#

store it as pdc in whatever item you're using to identify

#

then read the pdc and do w/e when they place it back down

copper dove
#

well i have looked through things but i cant seem to figure out how i get the profession they have as im using the PlayerInteractEntityEvent

sharp flare
drowsy helm
#

its not just right and left theres also offhand

sharp flare
#

already made a check for that

#

you can backread the code above

ancient plank
drowsy helm
#

how peculiar

sharp flare
#

very peculiar, but I'll adjust add a workaround for that

copper dove
#

okay i will look into thanks for the help @ancient plank

warm light
#

I am still getting error

ebon coral
#

Is there a way to send a player to another server while the server is shutting down?

#

Like a pre-disable event or someethhinggg because plugin messages don't work when the server is shutting down :(

glossy venture
#

use catch (Error e) or catch (Throwable t)

dark arrow
#

if i increase the atribute of strength by one will it double the damage?

opal juniper
grim ice
#

how is public static Object obj; static abuse

hybrid spoke
lost matrix
grim ice
#

class X {
public static Object obj = new Object();
}

class Y {
void x() {
X.obj.toString();
}
}

lost matrix
grim ice
#

Some person I know

hybrid spoke
grim ice
#

is really experienced however he still static abuses

quaint mantle
#

anyone here good with python xd got an assignment due in a bit 😂

lost matrix
grim ice
#

Lmao

golden kelp
#

xdd

lost matrix
#

Or this:

        try {
            SSLContext sc = SSLContext.getInstance("SSL");
            sc.init(null, trustAllCerts, new java.security.SecureRandom());
            return sc.getSocketFactory();
        } catch (Exception ignored) {
        }

Do you want to get bugs that need to be tracked down over a week? Because thats how you get them.

chrome beacon
lost matrix
#

Anyways thats static abuse what hes doing

grim ice
#

he kept saying

#

that its a singleton

#

and that nothing that makes it static abuse actually applies to his case

hybrid spoke
#
        api = new Hypixel();
        auctions = new AuctionHouse();

why don't he just declare them right away and make them final

lost matrix
hybrid spoke
#

and whats the purpose of all those new threads

lost matrix
wet breach
#

always a good to ignore the security of https with MITM 🙂

hybrid spoke
noble forge
#

has anyone found a solution to this?

#

I am currently moving around an armor stand using that packet but it seems like I am getting the same desync issues

noble forge
#

o

#

embeds dont work?

#

the positions of certain bones start clipping in-game but in blockbench they arent

ebon coral
#

How do I shut down ma server without flagging Pterodactyl as crashed?

lost matrix
noble forge
#

o

#

the protocol specified that I should use move relative packets for movements < 8 blocks

#

should I just be using teleport packets then?

ebon coral
#

Actually na I figured it out

lost matrix
noble forge
noble forge
#

will there be any downsides to me using this packet? since in the past I was told to not use it when movements are < 8 blocks

lost matrix
noble forge
#

I see

#

thank you for your advice

#

I've looked across the internet and couldnt find anything, but youve helped me :)

ebon coral
#

Is there any useful tools for creating a regex? I keep struggling with it.

sharp flare
#

your possibly hindering your plugin of handling other unchecked exceptions

lost matrix
lost matrix
faint harbor
#

I cannot seem to figure out how to set the result of a grindstone when a certain item is used, does anyone know a way to achieve this?

granite owl
#

braindead question but the docs aint that well in that category

#

how to get the kind of player respawn?

#

worldspawn, bed, anchor causes?

#

or does the anchor also use the bed spawn loc?

lost matrix
#

I think the docs are pretty clear on that...

golden turret
crude loom
#

How can I disable an item drop? (not done by the player I mean when the block breaks)

lost matrix
crude loom
#

I will try the BlockDropItemEvent, thanks !

#

How can I check what version was something added in? because I don't see this event and I think it was added after 1.8?

lost matrix
crude loom
#

Yeah but I have to use it for this plugin because of the PVP

#

I agree that it's harder coding in this version but I dont have much choice

supple elk
#

why can a switch statement not be used with a double 🤔

lost matrix
lost matrix
supple elk
#

🤷

supple elk
#

I'm guessing it's needed cause of rounding errors

#

but how does the epsilon help?

wet breach
#

it dictates how many places from the decimal is acceptable

#

the ambiguity comes in when you have CPU's that support varying levels of floating point values

supple elk
#

I see

#

I guess I could store an int and just the number of ticks instead

#

I'm working with time

wet breach
#

just depends how much precision you need

#

nanoseconds are supported in Java

supple elk
#

I only need it as a number of ticks

#

Making a racing game

#

Using a runnable for number of ticks is probably more accurate for timing anyway

#

cause server lag won't be counted then

wet breach
#

probably a separate thread would be better but again depends how accurate you need it to be

#

runnable won't guarantee accuracy. Runnables are affected by lag

supple elk
#

ik, the point is they are affected by lag

wet breach
#

if there is lag, the longer it takes to get to the task for the runnable. Unless the runnable is running in a separate thread

supple elk
#

say the server is lagging and a player goes around the track

#

it will take longer for them to get around than if the server wasn't lagging

#

so if the rate at which the runnable counts is also effected by the lag, and is just counts the number of ticks, it takes the lag into consideration so is more accurate

#

effectively the time isn't affected by the lag as the player also lags

#

at least that's my theory

faint harbor
#

How can I remove lore using a grindstone

#

because there doesnt seem to be a PrepareGrindstone event like there is for anvils

rough drift
#

When creating a potion effect, amplifier level 0 is effect level 1 right?

earnest forum
#

there isnt

#

i checkerd

#

u could try inventory click

rough drift
#

^

earnest forum
#

check if the inventory is grindstone

granite owl
#

what if my client sends 2 block breaking event requests within 1ms, will those 2 requests be reckognized with 1ms or 20ms

#

with the next gametick

earnest forum
#

events are queued

#

since theres 20 ticks in a second

faint harbor
granite owl
#

so if someones cheating by breaking 9 blocks at once, theres no way to determine it by delta timing

#

?

rough drift
#

there is

granite owl
#

how

rough drift
#

check the time difference

#

between breaks

granite owl
#

yea thats what i do

#

but if the requests being queued with 50ms

#

how can i determine <1ms

rough drift
#

good point

earnest forum
#

cant really

#

thats why all anticheats arent perfect

granite owl
#

hm

granite owl
#

how to practically determine a cheater then

#

whos breaking blocks spherical around him

#

automatically without actually mining them

#

just sending requests to the server

earnest forum
#

or just look at docs

rough drift
#

the docs 90% of the time is what I see in my ide

earnest forum
#

try it and see

#

lol

dark arrow
#

how to remove ai form mob

golden turret
#

i think there is a method inside LivingEntity

#

?jd-s

undone axleBOT
earnest forum
#

thats complicated tho

golden turret
#

1.9 be like

echo basalt
fossil lintel
faint harbor
#

This may not be possible, but is there a way to get the InventoryType of the Inventory that an item is shift clicked into?

golden turret
#

yes

#

insjde the InventoryClickEvent

faint harbor
#

getClickedInventory() returns the inv that it was clicked from, not the one that it went into

#

and I cant see and other method that would find it

golden turret
#

exactly

#

the event will be called when you click the inventory

#

and you have both top and bottom inventories

#

so you can check if the below inventory have enough space to store that item

faint harbor
#

It seems that I have misdiagnosed my error, thanks for the help

earnest forum
#

you can check the current item

#

its the item thats inside the player's hand

#

if there is one inside the hand, that means it was taken

#

if there's not, it was placed

#

@faint harbor

granite owl
#

i suspect thats a noob question but anyway ```java
public static HashMap<String, String[]> anticheatParams = new HashMap<String, String[]>();

ArrayList<String> list = new ArrayList<String>();

list.add("test")

main.anticheatParams.put("", (String[])list.toArray());

#

getting a typecast error

fossil lintel
#

You'd need to use List<String> instead of String[] in your HashMap declaration

#

An Object[] is a primitive Array in Java. List<Object> is a data structure that internally probably uses []

granite owl
#

yea ofc its just a wrapper that re-declares its primitive array internally

#

with the new size

#

but the return type of .toArray() is Object[]

#

so i thought i could upcast the object array to a string array

#

sec lemme check

#

ill prob just declare my own array with the size of the arraylist then if thats not working

tender shard
fossil lintel
#

Oh ofcourse, I missed that part. Yes, the toArray() returns an Object array because Java removes the generic (<String>) information while compiling. This makes it impossible for the JRE to know the actual type of the Array it should build during runtime

#

as @tender shard said, toArray(new String[0]); will probably give you the right primitive array type

#

You can just create an array with an empty size in this case. It will only use it for the type lookup

granite owl
#

kk ty

#

if those aint working ive written a simple alternative

#
if (parser.jumpToHeader("Config"))
                {
                    parser.setSeperatorValue(',');
                    
                    while (parser.getNextLine())
                    {
                        ArrayList<String> list = new ArrayList<String>();
                        
                        int i = 0;
                        while (!parser.getValueString(i).equals(""))
                        {
                            list.add(parser.getValueString(i));
                            i++;
                        }
                        
                        String[] arr = new String[list.size()];
                        for (int ii = 0; ii < list.size(); ii++) arr[ii] = list.get(ii);
                        main.anticheatParams.put(parser.getKeyValue(), arr);
                    }
                }
#

like that

#

but prob wont say much to u since the parser is my own custom ini parser

#

so theres no documentation xD

fossil lintel
#

Haha fair nuff

#

Why don't you use the build-in yaml functions?

granite owl
#

while (!parser.getValueString(i).equals("")) and this works because ive written the parser that incase the value is null to return ""

granite owl
#

to be fair, i serialize most of my stuff anyway, i only write those files for config files that are supposed to be edited later on as plain text

#

anything backend only is stored as serialized objects anyway

harsh totem
#

I don't know why but my command doesn't show up ingame

fossil lintel
#

Did you register it in your plugin.yml?

harsh totem
#

my command is registered in plugin.yml and in the main

version: '${project.version}'
main: com.ytg667.economy.Economy
api-version: 1.18
prefix: Economy
permissions:
  economy.*:
    default: op
    description: Allows you to use all of the economy commands!
permission-message: You not have have permission to use this command.
commands:
  getCoins:
    description: Lets you collect any coin
    usage: /<command>```
#

getCommand("getCoins").setExecutor(new getCoins());

fossil lintel
#

Where are you executing that line?

harsh totem
#

in the main

fossil lintel
#

Where in the main?

harsh totem
#

onEnable

fossil lintel
#

That should be fine. Does the server show any exceptions?

harsh totem
#

it doesn't show up

hybrid spoke
#

so you mean autocompletion

#

and not the execution

harsh totem
#

no

fossil lintel
harsh totem
#

the command is also not executed

#

let me check

#

there is nothing in console

#

it only says unknown command ingame

#

@fossil lintel

hybrid spoke
#

is the plugin loaded?

harsh totem
#

yes

#

i just checked

fossil lintel
#

Could you share more of the server log?

harsh totem
#

it says the i issued the command but ingame is says Unknown command

fossil lintel
#

Like, the whole log since startup?

harsh totem
#

i got it

#

i have & in the name

hybrid spoke
#

try to execute the exact command /getCoins

harsh totem
#

the problem is that i have & in the name

granite owl
#

@fossil lintel @tender shard works now with declaring the null sized primitive as param like this

#

list.toArray(new String[0])

#

teye

tender shard
#

np

eternal night
#

isn't there just .toArray(String[]::new)

tender shard
#

no, that's for Stream.toArray

eternal night
#

oh rip

tender shard
#

Collection uses toArray(T[])

eternal night
#

did they never port that qol to collections

#

I mean, streams have that method too

tender shard
#

probably not 😄

granite owl
#

im using an arraylists method to typecast itself to a primitive array

golden turret
#

List<int>?

#

nvm

tender shard
fossil lintel
tender shard
#

btw since Spigot includes Apache commons, you can also just use ArrayUtils.toPrimitive

blissful pumice
golden turret
#

ik

eternal night
#

alex you lied to me

tender shard
fossil lintel
#

Ooooh it works

eternal night
#

💔

fossil lintel
#

new ArrayList<String>().toArray(String[]::new); is possible 😄

eternal night
#

bruh

#

who is not on java 17 in plugin development 😂

tender shard
#

I always answer questions for java 8 because that's the most common one

eternal night
#

it is ? 👀

tender shard
eternal night
#

1.17 was java 16 wasn't it

fossil lintel
tender shard
fossil lintel
#

Yes, but everyone should be using Java 17 anyway since it is the LTS release

eternal night
#

lol

tender shard
# eternal night

yeah maybe for MC. If you install any linux distro, they either have java 8 or java 11 included by default (well, at least 90% of them)

fossil lintel
#

That's changing rapidly though

#

Java is just very slow with their LTS releases

tender shard
#

yeah which is good, but unless java 8 has disappeared, I won't use java 17 since tbh it doesn't really add anything you can't do with java 8

fossil lintel
#

They're going to speed it up to every 2 years instead of every 3 years

tender shard
#

sure, it has some nice convenient features, but nothing that one would really need

eternal night
#

I would die without records

tender shard
#

I just use @Data

eternal night
#

lombok kekBan

crude loom
#

I'm working on a bedwars plugin and I want to make it so players won't be able to break blocks of the map but will be able to break player-placed blocks
I thought about saving the player-placed blocks in a config file and then in the blockBreakEvent check if the block is in the config
Is there a better way to do this?

blissful pumice
#

i odnt think so

eternal night
#

I mean, you don't want to do IO

tender shard
eternal night
#

a config seems useless

#

ye

#

PDC is probably better here, maybe there is a cool lib for that

#

🤔

tender shard
#

alternatively, which is probably the easiest way: hook into coreprotect or similar

fossil lintel
#

Yeah or just allow players to only place a specific kind of block and allow destroying of those

tender shard
#

i'd probably create a custom data class that implements configurationserializable that represents chunk coordinates (three shorts/ints) and save those as Set<ChunkLocation> inside every chunk's PDC

crude loom
#

Thinking about it, maybe I can just color the name of the blocks and check if the block placed has this name

blissful pumice
fossil lintel
tender shard
blissful pumice
#

and beds

#

right??

crude loom
#

Yeah

tender shard
#

so just store a List or Set with the chunk coordinates of player placed blocks in the chunk