#help-development

1 messages ยท Page 2087 of 1

buoyant viper
#

ohh like wynncraft

#

when ur in a conversation with an npc ur chat is only the dialogue and then it switches back to regular chat when its over

ancient plank
#

mmm

#

I gotta rewrite some code in a plugin which still uses the bukkit conversation api ๐Ÿค”

#

it's been on the server since 2013, and I recently just refactored the code to use the new (by new, I mean it was made in 2017) command framework

summer scroll
#

maybe chat system with channels is good?

ancient plank
#

I made a very very very simple & weh weh version of a chat channel plugin we use on our server, because my friend wanted to test chat ranges in one of his builds on his build server ๐Ÿค”

summer scroll
#

but rip user's chat log

ancient plank
#

can't imagine how that'd look if you played on a smaller chat size

summer scroll
#

true lmao

#

i didn't even think of that

vestal barn
#

can you cancel an event from another function that you pass event into

summer scroll
#

i think you can, yes

vocal cloud
#

As long as it's not async

granite owl
#

then pass the blockplace event to another function

#

and modify it there?

#

do you think its a smart idea to use a plugin from someone else and then attack its data structure?

#

you didnt say that anywhere before

delicate lynx
#

that is what is supposed to happen

#

fork WorldGuard and change it

#

it's always going to do that

coarse finch
#

i have the library installed and it still errors

quaint mantle
#

send pom

coarse finch
coarse finch
arctic moth
quaint mantle
arctic moth
#

?

quaint mantle
#

i had this same issue a couple weeks ago

#

ill try and find how i fixed it

arctic moth
quaint mantle
#

i dont think its that line i think its the plugin, i changed a setting and it worked

arctic moth
#

oh

#

whats the setting

quaint mantle
#

looking for it

#

actually

#

why are you even relocating it

#

shouldnt alex get his credit?

arctic moth
#

idk

quaint mantle
#

seems dicky to include someone elses code and at the least, not even put it in the directory that specifies the author

coarse finch
#

whats a pom

arctic moth
#

it says to relocate it

quaint mantle
#

you dont have to

#

its not ethical to either

coarse finch
#

and how do i send it

arctic moth
#

pom.xml

#

if ur not using maven idk

coarse finch
#

im using gradle

granite owl
granite owl
#

remove the override annotion

quaint mantle
#

no

#

dont

#

wtf

coarse finch
#

ok but how can i fix the import issue

granite owl
#

why its hooked automatically

arctic moth
#

is it tho

quaint mantle
#

its for clarification

#

and in older java versions its required

#

go into any project with abstractation and you will see @Override

arctic moth
#

realizes nitro runs out in 2 days

coarse finch
#

i added it as the thingy

quaint mantle
#

im pretty sure thats only the javadocs

#

๐Ÿ˜‚

coarse finch
#

its in dependancies

arctic moth
#

of what

coarse finch
coarse finch
granite owl
arctic moth
quaint mantle
#

if i really wanted to argue i'd just @ choco cause he can explain everything

arctic moth
#

gradle has build.gradle and stuff

coarse finch
granite owl
coarse finch
quaint mantle
#

its just dependencies

coarse finch
#

oh

quaint mantle
#

im pretty sure its for building spgiot

arctic moth
quaint mantle
#

not actually running it

coarse finch
#

where do i get the spigot jar then

granite owl
#

anyway its weird

arctic moth
#

screenshot

quaint mantle
undone axleBOT
quaint mantle
#

or just add it as a dependency in gradle

granite owl
#

on the one hand it recognizes the JavaPlugin class

quaint mantle
#

which is way easier

coarse finch
#

do i have to build it?

arctic moth
#

no

quaint mantle
#

you dont have to

granite owl
#

on the other hand it doesnt recognize its members?

quaint mantle
#

just add it into your build.gradle

arctic moth
quaint mantle
#

fuck gradle

#

i have no idea how ๐Ÿ™‚

arctic moth
#

lol

coarse finch
arctic moth
#

i hate gradle thats the main reason why im only a spigot dev and not a fabric dev

quaint mantle
quaint mantle
#

it requires you to use gradle

arctic moth
#

same thing

#

fabric is just better

coarse finch
#

i think intellij does it automatically, the thingy i added before is in build.gradle

quaint mantle
#

plugins just need to port to fabruc

arctic moth
#

oh u can?

granite owl
quaint mantle
#

if forge wasnt required on both ends

#
  1. minecraft would be a virus
#
  1. spigot or any server fork wouldnt exist
coarse finch
#

how long does building it take

quaint mantle
#

why not just add it into your gradle

#

@ivory sleet help

#

a gradle user ๐Ÿ˜ฑ

ivory sleet
#

oo

coarse finch
arctic moth
#

lol i was just checking through channels and found a spammer

coarse finch
#

im so confused rn

arctic moth
#

little child

arctic moth
coarse finch
#

i figured lol

arctic moth
#

anyways @quaint mantle ya figure out what u did to fix the maven stuffs

quaint mantle
#

i think

#

<createDependencyReducePom>

arctic moth
#

where

#

settings?

quaint mantle
#

above minimizeJar

#

well

#

in the same section

#

make it false

coarse finch
#

so do i just put the build output as a dependency?

arctic moth
#

might as well just use maven

coarse finch
#

guy on another server said to use gradle its easier

#

ok its done building @quaint mantle

quaint mantle
#

just use gradle..

#

i said you COULD build it yourself

arctic moth
#

how is gradle easier

arctic moth
quaint mantle
coarse finch
#

use gradle to build?

quaint mantle
#

@ivory sleet

quaint mantle
#

are you sure the build command contains package

stuck flax
#

i am creating a plugin with placeholdersapi but it says Cannot resolve symbol 'PlaceholderAPI'

arctic moth
#

where?

arctic moth
arctic moth
#

what am i supposed to do there

stuck flax
quaint mantle
#

then it cant give you that error?

wet breach
#

should learn how to program before trying to do stuff with plugins

buoyant viper
quaint mantle
buoyant viper
#

@lavish hemlock s minimal buildsystem > all

grizzled hazel
#

why is it that you can't directly deserialize any map from a yaml config that doesn't have string keys?

wet breach
#

what other keys would it have?

coarse finch
#

i think i found it

lavish hemlock
#

welllll

#

MMB would be better than every other buildsystem

#

if it existed :p

coarse finch
ivory sleet
arctic moth
arctic moth
#

like for settings and stuff

quaint mantle
#

its just the build command

arctic moth
#

oh

quaint mantle
#
mvn clean package
arctic moth
#

where tho

quaint mantle
arctic moth
#

ok thx

#

what is gigashops btw lol

quaint mantle
#

๐Ÿ˜

grizzled hazel
# wet breach what other keys would it have?

as in the map i serialised had Location keys and the values were a type i made that implemented ConfigurationSerializable
the type i made deserialises just fine on its own but then when it comes to deserialising the entire map i can't do that because getConfigurationSection returns a Map<String, Object> and i have no idea how to convert those string keys back into locations

quaint mantle
#

keys can only be strings

arctic moth
#

still didnt work

quaint mantle
arctic moth
#

was this what i was supposed to do

quaint mantle
grizzled hazel
#

the other annoying thing is it seems to cut half the location off because

    world: world
    x: -96.0
    y: 83.0
    z: -177.0
    pitch: 0.0
    yaw: 0.0```
became

org.bukkit.Location
world: world
x: -96.0```
when i looked at the value of the string key in the deserialised result

arctic moth
#

but does that make a difference

quaint mantle
#

just try it

coarse finch
#

i added it to my build.gradle and the import is erroring heeeeeeeeelp

#

when i run it i get Unexpected input: '{' @ line 8, column 14. repositories { ^

arctic moth
#

nope didnt work

quaint mantle
#

idk

quaint mantle
#

i feel like there should be an easier build system

coarse finch
granite owl
arctic moth
# coarse finch no

just look at the way everything else is , because those brackets arent the right thing

quaint mantle
coarse finch
#

wait i got it

#

i hate these things {}

#

they were messed up

#

still doesnt import though

arctic moth
#

or the other guy

quaint mantle
arctic moth
#

i noticed that build artifacts and the mvn clean package build buttons do separate things in the build log

coarse finch
#

when i run it it just does gradle heeeeeeeeelp

granite owl
arctic moth
#

lol u cant send pictures?

#

i have file perms

#

verified im guessing

coarse finch
#

I GOT ITTTT!!!!!!!!!!

#

i had to reload gradle changes in intellij

arctic moth
#

lol

wet breach
arctic moth
quaint mantle
wet breach
#

its not

quaint mantle
quaint mantle
arctic moth
#

is the clean package exporting to the same place as artifacts?

wet breach
granite owl
quaint mantle
granite owl
#

returns a primitive array from which u can create ur location

arctic moth
#

cuz what is clean package actually doing

wet breach
#

don't have to use the one mavens likes

arctic moth
#

my maven builds are usually pretty quick

wet breach
#

for most people it is

arctic moth
#

just annoying how i feel that even if i copy/paste the same pom in a new plugin it doesnt work half the time

wet breach
#

but most people also don't realize you can configure maven to be more optimal if you have the resources to give it

#

out of the box maven is conservative

buoyant viper
#

those darn liberal build systems

arctic moth
#

gradle takes like 10 mins to build for me

granite owl
buoyant viper
#

gradle takes a while to spool up for me but building its pretty good

wet breach
#

also, most people use clean as part of the default build

#

using clean will remove half the benefits maven has

#

most of the time you don't need to use clean

arctic moth
#

that could be a reason it doesnt work

quaint mantle
#

clean just removes existing build directories

wet breach
#

maven can do incremental building

#

but if you use clean you remove the benefits of incremental building and caching

arctic moth
#

because i have it set in my project settings to build to my plugins folder

#

but idk where the maven builds

buoyant viper
#

target

wet breach
#

clean is a life cycle that removes the entire build directory

arctic moth
buoyant viper
#

probably

granite owl
#

why do i still need to run buildtools to have a local maven repository? like whats the advantage?

buoyant viper
#

id check maven-jar-plugin configuration

wet breach
granite owl
#

but putting the spigot repo as dependencies yada yada throws errors if i didnt run buildtools for that version of the server

arctic moth
#

just the classes

wet breach
#

build tools just conveniently installs the api to your local maven repo because that is one of the few areas when using maven to build your project that maven will look at to see if you have dependencies already there

buoyant viper
#

should be in the top level of target i think

granite owl
#

hm

arctic moth
#

its not

vast apex
#

Hey guys, I have an issue. My plugin for some reason doesn't work on ApexHosting. What can cause this?

arctic moth
arctic moth
#

generated-sources just has an empty annotations folder

wet breach
#

doubt that helps though

buoyant viper
#

yeah no youd see a jar like right in the first level of the folder

vast apex
#

I'm getting this from one of my plugin users

#

(not me cause i dont have an apex server)

buoyant viper
#

ur running mvn package right

vast apex
buoyant viper
#

like to build

vast apex
#

server version is 1.18.2

noble lantern
#

not 1.18.2

vast apex
#

oh

quaint mantle
noble lantern
#

:p

arctic moth
#

lol

buoyant viper
arctic moth
#

wut

noble lantern
#

clean package*

buoyant viper
#

u can just package smh

arctic moth
#

i am

buoyant viper
#

hmm

normal isle
#

Can someone compile a modified plugin for me?

noble lantern
#

package doesnt clean though

quaint mantle
granite owl
buoyant viper
#

u dont need to clean tho

normal isle
#

):

arctic moth
noble lantern
#

always gives errors without cleaning on my end

arctic moth
noble lantern
#

says theres already an existing archive

arctic moth
#

for me thats never happened im just trying to figure out why CustomBlockData doesnt wanna shadow

noble lantern
#

oh hey

#

for custom blocks right

quaint mantle
#

isnt customblockdata just pdc for non-supporting block types

granite owl
#

am i right to asume that pdc just accesses nms methods and namespaces the keys?

arctic moth
#

idk

granite owl
#

i mean basically just namespaces the keys by plugin instance

noble lantern
#

kinda

ivory sleet
#

yes timinator

#

under the tag PublicBukkitValues

buoyant viper
#

why not decompile server and look at source ๐Ÿ˜Ž

granite owl
#

so i could access pdc values with nms methods if ik the namespace ? :P

ivory sleet
#

ye

noble lantern
#

you can access them just by getting the plugins instance you want to use

#

without nms

buoyant viper
#

pdc is just a bukkit front for nbt isnt it

granite owl
#

just trying to understand what pdc actually does

ivory sleet
#

main point of the pdc api is the resistance towards changes, lets say minecraft dont want to use nbt and snbt anymore

#

in that case pdc could stay completely unaffected

buoyant viper
#

snbt?

ivory sleet
#

myes

granite owl
ivory sleet
#

pretty much

#

idk if spigot uses the adapter pattern specifically

#

but sth like that

arctic moth
#

i still have no clue what to do lol

#

ig i could try normal package without clean

ivory sleet
arctic moth
#

but see i dont think this is actually building to anything

#

it takes about a fifth of a second

#

i doubt even saving an empty txt is that fast

granite owl
buoyant viper
#

buildtools does the decompiling for u yes

granite owl
#

i mean it leaves the entire bukkit api

#

as source files

#

so u can look any bukkit class up at any time really

arctic moth
#

where lol

granite owl
#

wherever u ran buildtools

arctic moth
granite owl
#

idk would have to look it up

arctic moth
#

this is my entire target folder

granite owl
#

but ive searched it recently to find out how to tabcomplete commands

#

and figured that JavaPlugin has a member for it

#

xD

ivory sleet
#

ye

granite owl
#

so

ivory sleet
#

basically the fallback cmd executor + tab completer for all commands declared in ur plugin yml iirc

granite owl
#

no

#

onTabComplete()

#

like onCommand()

#

exists

ivory sleet
#

yes

granite owl
#

ah nvm

#

now i get what u mean

#

D

#

xD

ivory sleet
#

x)

granite owl
#

its late

#

:P

ivory sleet
#

ye no worries lol

arctic moth
#

ive noticed that it has the library in external libraries

#

i just dont know why its not in the build

granite owl
#

so where for vanilla commands every command has its own executor

#

every plugin has one for all of its commands

#

so technically

summer scroll
ivory sleet
#

yuh

granite owl
#

every plugin is one command

arctic moth
granite owl
#

has*

arctic moth
#

oh yes

#

NoClassDefFound

ivory sleet
#

didnt imagine already tell u the issue

#

dont include minimize jar

summer scroll
#

gradle or maven?

ivory sleet
#

or whatever the setting is called in maven

quaint mantle
arctic moth
quaint mantle
#

i mean

arctic moth
quaint mantle
#

u can try and remove that

#

and it would probably work

#

but that wasnt the issue for me

coarse finch
#

lets go i made a functional clear command

ivory sleet
#

epic

granite owl
#

@ivory sleet ive recently figured(overridden the vanilla /op command), that a plugins command executor is being handled by bukkit like single vanilla commands xD

arctic moth
#

now it actually has copying resources

#

knew it wasnt building

granite owl
#

and so is the tabcomplete*

arctic moth
#

still didnt work :(

coarse finch
#

whats the right way to send messages when the plugin is starting? should i use the logger or is printing fine

arctic moth
#

logger

coarse finch
#

ok

granite owl
#

to put everything into log files as well

noble lantern
ivory sleet
#

I know there is a lot of hackery

#

especially since the underlying system has heavily incorporated brig

#

whilst bukkit stays away from it

granite owl
#

basically every vanilla command is being registered into the command map by namespaced command and non namespaced command

coarse finch
#

hmmm what to make now

granite owl
#

and every command is a VanillaCommand

ivory sleet
#

yes

granite owl
#

contains its own onCommand implementation

#

so a plugin is just 1 command

ivory sleet
#

but thats just to make the api proper

arctic moth
granite owl
#

and the ignoreequalscase is just the function "internal" splitter

grizzled hazel
granite owl
#

although i cast the cmd to lower case and switch it cause java can cast strings to sha hashes

#

๐Ÿคฃ

coarse finch
#

wait i dont see how this knows what command is being run...

#

its just going straight from on command to ah yes clear command

#

nothing checking it

#

bad tutorial!!

granite owl
coarse finch
#

oh wait nvm he has 1 file per command

#

im stupid

ivory sleet
granite owl
#

am i being stupid for serializing my permission map? xD

arctic moth
#

trying to shadow CustomBlockData, getting the NoClassDefFound error

granite owl
#

dont blocks have metadata?

arctic moth
#

no

ivory sleet
#

tile entities I believe

arctic moth
#

blockdata

#

or that

ivory sleet
arctic moth
#

ig ill run it again but it lags the server cuz its a nested function

ivory sleet
#

sure

granite owl
#
Block.rayTrace(Locationย start,ย Vectorย direction, doubleย maxDistance,ย FluidCollisionModeย fluidCollisionMode)
``` is this new? didnt see it 2 years ago when i needed interpolation
arctic moth
#

@ivory sleet

ivory sleet
#

so do u know that when u use maven you should be getting 2 jars right

#

at least with the shade plugin

granite owl
#

does it interpolate the position of any object in its way?

#

of the vector

ivory sleet
#

no clue honestly, but possibly

granite owl
#

cause like

ivory sleet
#

like in the target directory

quaint mantle
#

original and dependency included

granite owl
#

back then ive written my own very precise but poor performance method for it xD

arctic moth
#

theres nothing in the target directory but a bunch of classes

ivory sleet
#

what maven tasks r u runing

twilit wharf
#

I am creating a custom generation plugin, and I set a chunks biome to DEEP_OCEAN yet there is land there. f3 shows that it is deep ocean to. It is a large landmass even though it is supposedly DEEP_OCEAN. Any ideas? Thanks in advance! ๐Ÿ™‚

arctic moth
arctic moth
#

im just running clean package

quaint mantle
ivory sleet
#

rnt u supposed to run mvn clean install or sth

#

like I never use maven but ye

quaint mantle
arctic moth
twilit wharf
#

and I know it works

quaint mantle
#

so why doesnt it

arctic moth
#

ye still errors

#

ngl i have no clue how to use maven

maiden thicket
#

hey, so i load in a jar from another jar but there's an issue. ( not a plugin, it's a module system im doing kind of? )
jar1 loads jar2
issue is jar2 has a config.yml AND jar1 has a config.yml, and jar2 loads jar1's config.yml
jar2 is loaded on jar1's classpath

#
URLClassLoader loader = new URLClassLoader(
                            new URL[]{file.toURI().toURL()},
                            Plex.class.getClassLoader()
                    );

                    InputStreamReader internalModuleFile = new InputStreamReader(loader.getResourceAsStream("module.yml"), StandardCharsets.UTF_8);
                    YamlConfiguration internalModuleConfig = YamlConfiguration.loadConfiguration(internalModuleFile);

                    String name = internalModuleConfig.getString("name");
                    if (name == null)
                    {
                        throw new ModuleLoadException("Plex module name can't be null!");
                    }

                    String main = internalModuleConfig.getString("main");
                    if (main == null)
                    {
                        throw new ModuleLoadException("Plex module main class can't be null!");
                    }

                    String description = internalModuleConfig.getString("description", "A Plex module");
                    String version = internalModuleConfig.getString("version", "1.0");
                    List<String> libraries = internalModuleConfig.getStringList("libraries");

                    PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
                    plexModuleFile.setLibraries(libraries);
                    Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);```
summer scroll
crisp steeple
#

is there any reason this exception handler doesnt trigger? works in normal java projects but just doesnt work on a server

handler:

    private static final Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
        Bukkit.broadcastMessage("Exception"); // doesnt trigger
        handleException(throwable);
    };

    public static void start(){
        Thread.setDefaultUncaughtExceptionHandler(handler);
        Bukkit.broadcastMessage(Thread.currentThread().getName()); // Server Thread
        Thread.currentThread().setUncaughtExceptionHandler(handler);
    }

exception trigger test:

    @EventHandler
    public void testException(PlayerFishEvent event){
        Bukkit.broadcastMessage(Thread.currentThread().getName()); // Server Thread
        Bukkit.broadcastMessage(Thread.currentThread().getUncaughtExceptionHandler().toString()); // correct instance
        String a = null;
        a.toString();
    }
ivory sleet
#

probably since its overwritten

ivory sleet
#

if u're willing to jump over to gradle

#

I'd be glad to assist you

#

as my field of expertise isnt maven per say

arctic moth
#

gradle is scary

ivory sleet
#

nah

#

people just spread fear, uncertainty and doubt

#

but its really not that bad

#

well

#

they're both not bad

summer scroll
#

and use mvn package to build

arctic moth
#

still not working

odd spear
#

Hey I'm new to plugin dev, so forgive me if this is a stupid question but how do you set a wait command which will pause the execution of code in that class?

crisp steeple
summer scroll
ivory sleet
#

the runnable declared inside the thread could just catch any throwable

crisp steeple
#

yeah thats what i was thinking

noble lantern
#

Is there a way to override a chunk generator without adding it to the bukkit.yml like shown here

arctic moth
crisp steeple
#

which might be annoying

ivory sleet
#

ye

arctic moth
#

just 3.2.4 in the version of maven-shade-plugin

summer scroll
arctic moth
noble lantern
#

tell md_5 to add dark mode

#

no im not using an external plugin

summer scroll
arctic moth
#

people told me not to relocate it

ivory sleet
#

who specifically?

summer scroll
#

might as well try

arctic moth
summer scroll
#

some of libs will conflict if not shaded

ivory sleet
#

I mean its always smart to relocate when you shade libs

#

^

arctic moth
#

welp gtg now

#

ive been on this one problem for almost 4 hours

#

I thought maven was supposed to, like, be easy or smth

#

This exact pom has worked with other plugins, but now its just deciding to not work

arctic moth
ivory sleet
#

noice, well gl

odd spear
# arctic moth welp gtg now

hey thanks a lot for replying! i also have the runnable inside a command executor, how can i pass my arguments into the runnable?

#

waut

#

wait

#

im stupid

summer scroll
coarse finch
#

how do i do newlines in a logger or chat message?

summer scroll
#

Send another message

coarse finch
#

ok

ivory sleet
#

or with \n

coarse finch
#

ok

noble lantern
#

Would ThreadLocalRandom.current() have any performance issues by chance?

Or should i just create a Random instance in my main class and create a getter for it

ivory sleet
#

no not really

#

but it offers no reproducability

#

which kinda sucks

#

so I'd use SplittableRandom

#

also really fast, even in parallel environments

#

in case you wanna use it over threads, could go with ThreadLocal<SplittableRandom>

#

and invoke split on it

noble lantern
#

Nah im not gonna be using it over threads, im just using a random to calculate how many veins of ore should generate in a given chunk so i was wondering what would give the best performance as it would likely get called shittons when players fly through the world like the nether

#

For this i don't really thing reproducability would be an issue as i necessarily wouldn't want to reproduce any values just have random ones like here

odd spear
#

I'm receiving "An internal error occurred while attempting to perform this command" upon running a command. Compiling is fine. How can I diagnose the problem? Is there a way to see what line it is?

past brook
#

how do i add custom structures to my custom generator

noble lantern
#

pasting schems is the best way

past brook
noble lantern
#

good question uhm

#

no idea ngl, i would assume you would have to split the schem into multiple parts

#

and paste accross those chunks

#

would be rather complicated

odd spear
# noble lantern check your console

right, dunno why i didnt do that haha thanks
Im a noob with java so forgive me if this is a stupid question but what does this mean:
java.lang.IllegalArgumentException: Plugin cannot be null

noble lantern
#

Show the command code

#

I also recommend properly learning java before taking a whack at plugins

cold pawn
#

Does anyone know why im getting this error in console. For some context im trying to make a respawn packet using protocol lib, I recently switched to 1.18.2 and reused the respawn packet I had when I was working in 1.16, making some slight updates. So far everything else works except this, any reason why?

past brook
cold pawn
noble lantern
noble lantern
cold pawn
noble lantern
#

Might be worth opening an issue on theyre github asking about it

#

idk if they have a discord

cold pawn
#

Alright.

noble lantern
#

oh holy jesus

#

?paste

undone axleBOT
odd spear
#

mb

noble lantern
#

plus thats the error

odd spear
noble lantern
odd spear
#

this is what was in the console

#

what did you want to see?

#

like the code?

noble lantern
#

your actual command class yes

odd spear
#

oh right haha

delicate lynx
#

Caused by: java.lang.IllegalArgumentException: Plugin cannot be null

odd spear
#

that is the class

delicate lynx
#

you never set Plugin

noble lantern
#

?di

undone axleBOT
noble lantern
#

^

#

you need to pass your plugin through that command class's constructor

delicate lynx
#

pass your plugin instance to the command class, that is that dependency injection is

#

see that link

odd spear
#

yes i do see it

#

currently reading

#

oh i see so i needed to write this.plugin = plugin; in the constructor

golden turret
#

where in the craft bukkit this is called?

#

i really need it

#

or is there a way that i do something like entity.damage(damage, damager) and that event with that constructor is called

noble lantern
#

that's also not a NMS method either (The one i shown)

#

wait hold on my bad

#

thats not a Damageable method

golden turret
#

actually it is

noble lantern
#

okay so how we do it is just getDamager() on EntityDamageByEnetity it procudes a Entity

And using the method you shown damage(damage, damager)

#

No NMS really needed here

Unless you are on a version that doesnt have that event?

odd spear
#

Hey Im really stuck with this code, would someone be down to call and help? I would really appreciate it

ivory sleet
#

uh sure

odd spear
#

sweet

ivory sleet
#

?scheduling

undone axleBOT
stark carbon
#

!verefy

#

?verefy

noble lantern
#

https://paste.md-5.net/qebimovalo.java

So I'm randomly getting a location in the nether dependent upon whether or not my code runs into the ceiling or floor

Pardon my math but I can't seem to get the actual location anywhere other than 0.0 86.0 0.0 (Where y always moves but x and z are always 0)

Is this something in the logic of my code that's not letting the x and z values iterate? Or some type of math I'm doing when converting the block-chunks location to a real-world Location?

noble lantern
ivory sleet
#

?learn-java

#

?learmjava

#

?learnjava

undone axleBOT
noble lantern
buoyant viper
noble lantern
#

i did this instead:

granite burrow
#

Hey what would be the best way to determine if the player has a permission (permission.number.#)
Where # would be any number

I feel like a loop wouldn't be the best way to go about this but thats the only way I can think about getting this info other than using vault

granite burrow
# summer scroll loop is the only way i guess

yeah, I found a nice way to do it with a loop, just finished testing it and it works as well as expected lmao.

public int getNumberedPerm(Player p, String node) {
        // Loop through all players permissions nodes
        for (PermissionAttachmentInfo perm : p.getEffectivePermissions()) {
            // Find the permission node that starts with the desired node
            if (perm.getPermission().startsWith(node)) {
                // Format node to take into account the extra "."
                node = node+".";
                try {
                    // Format the perm to only have the number in it
                    // Convert the string of the number into an integer and return the int
                    return Integer.parseInt(perm.getPermission().replace(node, ""));
                } catch (NumberFormatException numberError) {
                    // Let the server owner know that there is an error with their permission
                    plugin.getLogger().severe("Player ("+p.getName()+") has an invalid permission number, permission name: "+perm.getPermission()+" \nPlayer's UUID: "+p.getUniqueId() + "\nPlease submit the following error to Brand0n_ if you cannot resolve the issue:");
                    // Print the stack trace to make it easier to debug what happened
                    // This should never be useful as no one should be putting in something that isn't a number
                    numberError.printStackTrace();
                }
            }
        }
        return 0;
    }

Made it so that if it can't find the number or if the number is wrong it tells the user in the console and results in a 0 being sent in its place

#

can for sure make it loop prettier tho

summer scroll
granite burrow
#

yeah that would be better

fleet pier
#

what do you think about redis as primary database

wraith delta
#
map.put(player.getUniqueId(), false);
new BukkitRunnable() {
     public void run() {
        if (!map.get(player.getUniqueId())) {
            player.teleport(new Location(player.getWorld(), finalTeleportLocation.getX(),                    finalTeleportLocation.getY() + 1.0, finalTeleportLocation.getZ()));
            map.remove(player.getUniqueId());
        }
 }
@EventHandler
public void onMove(PlayerMoveEvent event) {
        if (map.containsKey(player.getUniqueId())) {
            if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ()) {
                        
            map.put(player.getUniqueId(), true);
            }
          }
    }
```Hello! I am trying to create a cancel teleport on move event using hashmap boolean. Here is a brief piece of the code. See anything out of place? The issue is after moving the TP cancels but you stay in the hashmap.
fleet pier
#

why u doing that in a map

noble lantern
wraith delta
#

Well I also use a cooldown and messages to tell the user whether they cancelled the teleport, or are in cooldown etc. That is just a trimmed code.

noble lantern
fleet pier
#

and redis is faster

#

and i use redis pubsub a lot

noble lantern
#

if you want to store JavaObjects without converting them the MongoDB driver does this

If you use mysql/redis youll likely need to convert

Redis isnt really meant to be used as a persistant database

fleet pier
#

You can change it to be persistent tho

noble lantern
#

I dont reccommend it

summer scroll
#

You can use HashSet maybe instead using Map to store a boolean

wraith delta
#

Darn videos arent allowed here lol.

buoyant viper
#

get verified

wraith delta
wraith delta
buoyant viper
#

if map contains player... insert player? wat

noble lantern
#

im a little confused about that as well lmao

wraith delta
buoyant viper
#

so the map is like a queue of players to be teleported?

#

so do u mean to remove them from it if they move

wraith delta
#

Yes and after the teleport they shall not be in the map

buoyant viper
#

so then remove them on move and on tp id think

wraith delta
#

Hm it seems with Burchards correction you are removed from the map however you can still teleport if you moved during the moment before teleporting

summer scroll
#

Use HashSet please

wraith delta
summer scroll
#

also you want to remove player from the set when they move

wraith delta
#
if (!map.contains(player.getUniqueId())) {
map.remove(player.getUniqueId());
```And on teleport/command
summer scroll
#

that will never happen

severe plume
#

๐Ÿ˜‚

wraith delta
#

Hm, that code doesnt make sense XD

#

I had to reread that

summer scroll
#

if player is in the set, remove from the set

wraith delta
#

Whats strange is it still let me teleport

summer scroll
#

of course

#

you didn't remove the player from the set

#

when they move

summer scroll
wraith delta
#

I may see, so I should add them first thing on command, and continuously remove on move?

summer scroll
#

so when player execute the command, add them onto the set

#

and listen to playermoveevent

#

if they move, remove from the set

wraith delta
#

Great. Ill give it a go

summer scroll
#

and after the cooldown or warm up

#

check if player is still on the set

#

if player is still on the set, teleport them and remove them from the set

wraith delta
#

The reason I had a if statement to check if they are in the set is to make sure they dont run the command a second time to bypass it

summer scroll
#

you can add a check on the command

wraith delta
sleek flume
#

is it possible to give a falling block a potion effect like levitation?

wraith delta
#

Sounds like youve got some crazy antigravity plans. Unlikely you can give a potion, youd have to either cancel the fall event or use armor stand animations

sleek flume
#

oh then i think ill do it with velocity

frigid rock
#

does anyone know why the bot is sending multiple messages instead of one? (i'm using jda) the code: ```java
@EventHandler
public void chatEvent(AsyncPlayerChatEvent e){
String message = e.getMessage();
TextChannel textChannel = jda.getTextChannelById("963443913362927666");
assert textChannel != null;
textChannel.sendMessage("" + e.getPlayer().getDisplayName()+ ": " + message).queue();
}

@Override
public void onMessageReceived(@NotNull MessageReceivedEvent e) {
    super.onMessageReceived(e);
        if(!(e.getAuthor().isBot()) || !(e.getAuthor().isSystem())){
                String message = e.getMessage().getContentRaw();
                User user = e.getAuthor();
    Bukkit.broadcastMessage(user.getName() + "#" + user.getDiscriminator() + ": " + message);
    }
}```
tardy delta
#

How many

buoyant viper
frigid rock
#

hang on lemme try

buoyant viper
#

ur effectively saying

if user is not a Bot(false) OR user is not system(true)

==True

#

instead of

if user is not a Bot(false) AND user is not system(true)

== False

frigid rock
#

still sending like 5 messages

#

instead of one

lavish hemlock
#

Also you uhh

#

Don't need to wrap your booleans in parentheses to negate them

buoyant viper
#

is the listener registered more than once somehow?

lavish hemlock
#

You can simplify !(e.getAuthor().isBot()) to just !e.getAuthor().isBot(). Much more readable.

frigid rock
buoyant viper
#

random nag but i think the super.onMessageReceived isnt needed since that JDA method should be empty

#

nothing else in that code immediately screams duplicate send, idk

frigid rock
#

i think that is a jda problem maybe? idk

buoyant viper
#

maybe

frigid rock
#

thanks anyway for the support ^^

quaint mantle
#

hi
i want help
i put levelledmobs on my server when they kill then show lvl 23 en all i want to do that show zombie lvl when alive how :?

jovial kraken
#

does any1 know how to play the block break anymation and then break the block when the block is placed down? im using spigot 1.8.8

sharp flare
#

is there any way to make particles move slowly or last longer

#

tried the extra parameter and count to 0

jovial kraken
#

yeh but how to like use them ik dis one but i cant import it is it from protocollib ??PacketPlayOutBlockBreakAnimation

sharp flare
#

yeah doing it right now through a runnable

#

gonna do task timer for this

#

how may I find these particle data

#

not that familiar with particle data

#

thanks

#

checked the wiki.vg, no particular data for smoke large unfortunately but the repeating task works fine

raven ravine
#

Hello, I'm trying to code custom enchants in spigot 1.18.2, but this code doesn't seem to work. It throws NoSuchFieldExceptions, but if I look into the class Enchantment.class, there is a field which has this exact name. I checked for typos, but there are none. Please help.

public static void registerEnchantment(Enchantment ench) { boolean registered = true; try { Bukkit.getConsoleSender().sendMessage("accepting " + Enchantment.isAcceptingRegistrations()); Field f = Enchantment.class.getField("acceptingNew"); f.setAccessible(true); f.set(null, true); Enchantment.registerEnchantment(ench); } catch (Exception e) { e.printStackTrace(); registered = false; } if(registered) { Bukkit.getConsoleSender().sendMessage("Enchantment " + ench.getName() + " registered"); } }

noble lantern
#

also

#

use getDeclaredField

#

not getField

thick tundra
#

Hello, im trying to create a custom api for my plugins, but when i try to access the api from a diffrent plugin it gives me a java.lang.ClassCastException

noble lantern
#

how does this API run, is it compiled in or running as a seperate plugin on your server?

thick tundra
#

Its running as a seperate plugin on my serer

noble lantern
#

and your depending on it in plugin.yml correct

thick tundra
#
    private RideManager rideManager;

    @Override
    public void onEnable() {

        rideManager = JavaPlugin.getPlugin(RideManager.class);
    } 
#

this is how i try to get the main class of the other plugin

#

i tried multiple ways, none seemed to work. first i used getServer().getpluginmanager().getplugin

raven ravine
thick tundra
noble lantern
#

if anything

#

just make a static getter for the plugin

#

RideManager.getPlugin()

thick tundra
#

wait i can do that

noble lantern
#

will be loads easier than using the plugin manager

thick tundra
#

xD

noble lantern
#

yes lol

#

as long as your depending on the plugin which you are

thick tundra
#

ohh hwhahah then im going through a lot of trouble for nothing

#

i already have a static instance of the plugin in the main class xD

noble lantern
#

yep your fine getting it this way, its how a lot of other plugin API's do it

thick tundra
#

oh

#

the getInstance() returns null

twilit wharf
#

I set the biome, then Minecraft generates it, and what Minecraft generates is generally correct, except the plain barren land when there should be deep ocean

noble lantern
#

try checking the value of that

thick tundra
#

Yeah im doing that now

#
java.lang.ClassCastException: class eu.ridemanager.base.RideManager cannot be cast to class eu.ridemanager.base.RideManager (eu.ridemanager.base.RideManager is in unnamed module of loader 'base-1.0-SNAPSHOT.jar' @34f798f2; eu.ridemanager.base.RideManager is in unnamed module of loader 'operators-1.0-SNAPSHOT.jar' @6c2f0ff3)```
#

im so confused xD

eternal oxide
#

you included your Ridemanager plugin with your second plugin

thick tundra
#

ohh

noble lantern
#

could definatly be a possibility, what scope for the import are you using miners?

#

should be provided

thick tundra
#

yup

#

forgot that

#

xD

#

<scope>provided</scope> right?

noble lantern
#

Yessir

thick tundra
#

omg it works

#

Thanks so much guys!

noble lantern
#

For a plugin dev what would be a good way to read timings? Is using 1% of a servers load decent without any optimized flags for generating in additional ore veins in new chunks? (in the nether)

This is also while flying around generating new chunks on top of the above ^

echo basalt
#

looking at your code

#

you make a chunksnapshot

#

you can process it async btw

#

also aikar's timings are quite better for debugging

noble lantern
#

one sec

#

?paste

undone axleBOT
noble lantern
echo basalt
#

ChunkSnapshots can be processed async

#

you can make it a CompletableFuture<Block> getRandomNetherBlock

#

and call .whenComplete

noble lantern
#

I see let me give it a whirl

And when I supplyAsync this will make the CompletableFuture run async correct? or should I still wrap this in an async BukkitRunnable?

echo basalt
#

it will run async, yes

#

supplyAsync expects a return value, runAsync does not

noble lantern
#

sounds good thank you! ill come back with my results in a few mins

#

holy shit

#

no way

#

I need to use CompleteableFuture's more often I guess i underestimated how good they were LMFAO

echo basalt
#

you can process blocks async using chunksnapshots

#

that's about it

noble lantern
#

yeah when the completeable future finishes im returning the chunk.getBlock() method

echo basalt
#

ยฏ_(ใƒ„)_/ยฏ

#

you're still processing them async

#

that's the biggest bottleneck

noble lantern
#

weird bukkit isnt throwing me any async errors

#

unless your only talking about the block scanning from ChunkSnapshot

echo basalt
#

yep

#

that's it

noble lantern
#

ahh i see

#

i don't really mind this processing async though, as I'm not doing anything with these blocks once they're generated, i just set theyre BlockDataMeta and the other events handle everything from there

#

but ty for that tip definatly saved a lot on the reports it seemed

#

just seemed odd to me that generating one block randomly in a location used that much power :p

paper lance
#
package me.snazzeh.main;

import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {

    public void onPlayerJoin(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        event.setJoinMessage("Welcome to the server," + p + "!");
        
        
        
    }
    
}
#

anyone know why it doesnt work? Console doesnt throw any errors

eternal oxide
#

needs @eventhandler

paper lance
#

ohh cheers

lavish hemlock
#

oh fun

#

"Yet Another Join Message Plugin"

jagged thicket
#

its a test lmao

river oracle
paper lance
#

plus im not making plugins for other people its for my own server calm down lol

paper lance
lavish hemlock
#

I believe it's uhh

eternal oxide
#

in onEnable

lavish hemlock
#

Bukkit.getPluginManager().registerEvents(this, <listener here>);

#

although I may be wrong

paper lance
#

Bukkit.getPluginManager().registerEvents(this, PlayerJoinEvent); Like this?

summer scroll
#

the other way around

#

listener first and then plugin instance

river oracle
#

implement listener

lavish hemlock
#

ye

paper lance
#

ohh cheers

river oracle
#

and add the annotation

eternal oxide
#

(this, this)

#

as its in your main

paper lance
#
package me.snazzeh.main;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {

    public void OnEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }
    
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        event.setJoinMessage("Welcome to the server," + p + "!");    
    }
}
#

Like this?

river oracle
#

idk probably

paper lance
#

The method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (Main, Main)

#

wait nvm im dumb fixed it

#

cheers for the help

river oracle
paper lance
#

nah im just testing

#

i wanna start learning how to make java plugins but i gotta start somewhere

noble lantern
#

its a good learning project too

paper lance
#

yeah lols

glossy venture
#

your OnEnable should be onEnable

paper lance
#

ive been using skript for about 3 years now ๐Ÿ˜ญ

#

oh okay

glossy venture
#

and might be useful to have @Override before it

paper lance
#

what does @Override do exactly?

eternal oxide
#

ensures you are overriding an actual method defined in the interface/class

paper lance
#

oh okay ty

echo basalt
glossy venture
#

i know

#

but it makes it clear that its overriden

tardy delta
#

not in C#

#

๐Ÿ‘‰๐Ÿ‘ˆ๐Ÿ˜ถ

glossy venture
#

so i usually do it

echo basalt
#

we aren't coding in c#

tardy delta
#

arent we?

echo basalt
#

I also usually do it but no need to point it out if it isn't there

glossy venture
#

makes it more readable tho

eternal oxide
#

reason to point it out is, he's learning

tardy delta
#

teach 'em while they are young

glossy venture
#

also it gives compile time errors when your signature is incorrect

crude loom
#

I want to implement a vanish feature to my plugin
Is there a simpeler way then taking off the players armor and applying an invisibillity effect?

echo basalt
#

player.hidePlayer

crude loom
#

Oh, does that hide the player even if he has armor on?

tardy delta
#

yes

#

wanna take a look at my vanish plugin?

#

yes, smh forgot my github password

#

ah finally

quiet ice
#

@Override is a must as it simplifies updating by a lot

grim ice
#

How to check if a spawner

#

is naturally spawned

tardy delta
#

the hell is wrong with my fonts lol

smoky oak
#

Is it better to pass the same instance of random around, or to generate a new one when it's needed? If the latter, should i manually set a seed or no?

eternal oxide
#

depends on use case

noble lantern
#

?paste

undone axleBOT
tardy delta
#

that font isnt cool lol

echo basalt
noble lantern
#

Hey @echo basalt i used the Completable future system but it seems the server cant really handle calling these in each and every chunk generation? I get a thread dump error like this: https://paste.md-5.net/eyuyamisez.cs

smoky oak
noble lantern
#

sec ill resent the code im using rn

tardy delta
#

unsafe stuff hmm

crude loom
eternal oxide
noble lantern
tardy delta
crude loom
#

Thanks ๐Ÿ˜

grim ice
smoky oak
#

its not like the chunk shit where i had to generate 20000 blocks at once

tardy delta
#

it wont run if the throwable is != null too

noble lantern
#

ill try that, not sure if it would fix the stacktrace im currently getting but ill try it

echo basalt
#

I generally just re-use a util class I made

#

You can take inspiration from here

tardy delta
#

thats alot of loops

smoky oak
#

also

if(block.getType() == from && randomChance())
                            block.setType(to);
//or
if(block.getType() == from){
  if(chance==1.0){
    block.setType(to);
  }
  else if(randomChance()){
    block.setType(to);
  }
}
```?
echo basalt
#

ayo what the fuck

tardy delta
#

some stuff seems to be broken here

noble lantern
#

ah i see theres a max thread pool allowed when using these async

smoky oak
#

what's the sound name for when lava and water collide?

grim ice
#

how to check if a spawner is naturally generated

crude loom
eternal night
#
Player player = ....
player.spigot().getHiddenPlayers()
crude loom
#

Thanks!

eternal night
#

np ๐Ÿ‘

noble lantern
noble lantern
noble lantern
granite owl
#

this always checks wheter or not a player is known to the server right?

#
if (player.isOnline() || player.hasPlayedBefore())
#

because hasPlayedBefore seems to only check if a playerfile exists but idk how exactly it works

#

from which list it retrieves its info

noble lantern
ivory sleet
#

I mean isOnline would always imply that the latter is true

noble lantern
#

^

granite owl
#

yea isonline always returns true ofc if that player is online rn

#

was more about if its still an oversight to check like ths

#

based on hasPlayedBefore

noble lantern
#

hasPlayedBefore() is more or less something you use in PlayerJoinEvent

#

after that fires thats marked as true if it was false before

ivory sleet
#

ye, well Idr exactly the implementation, but it probably just checks the cache or sth

granite owl
#

i use it in my command to modify that player if he is a valid target

noble lantern
#

offline target or online

granite owl
#
UUID uuid = NonReflectables.getPlayerUUID(args[0]);
            
            if (uuid != null)
            {
                OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
                
                if (player != null)
                {
                    if (player.isOnline() || player.hasPlayedBefore())
                    {
noble lantern
#

also

#

if a player is offline

#

player gets nullified

#

so your isOnline() would throw an NPE to my knowledge

ivory sleet
#

yes

grim ice
#

no

#

wait

#

fr

ivory sleet
#

iirc it does

grim ice
#

why does it exist then

#

tf

ivory sleet
#

but implementation might have changed

granite owl
#

huh?

grim ice
#

no that doesnt make sense

granite owl
#

too many opinions rn

#

xD

ivory sleet
#

well

#

idk might be mixing it with Player now

grim ice
#

isOnline wont throw npe

noble lantern
#

didnt know he was using OfflinePlayer tbh

#

thought he was using Player

granite owl
#

Player or OfflinePlayer one of the two inherits the other

ivory sleet
granite owl
#

nono

#

if i explicitly want the online player

#

i just check if hes online by getting him

#

and if its not null

#

its a valid target

#

this is to target offlineplayers

ivory sleet
#

ye

noble lantern
#

so just use hasPlayedBefore()

granite owl
#

for players

grim ice
#

no

granite owl
#

who log in for the first time ever

grim ice
ivory sleet
#

timinator

#

hasPlayedBefore just checks if the .dat file of said player exists

granite owl
#

kk

grim ice
#

cuz if online is true, it definitely hasPlayedBefore(), therefore skipping IO Checks

#

i think hasPlayedBefore uses IO

noble lantern
grim ice
#

not sure tho

granite owl
#

so this if (player.isOnline() || player.hasPlayedBefore()) i suppose is accurate to use?

ivory sleet
#

yes 2hex

granite owl
#

by this isonline should be checked first

grim ice
#

use isOnline first

#

less expensive checks always first

ivory sleet
#

but like File::exists isn't as heavy as writing or reading IO

grim ice
#

but isOnline() will be better

#

to start with

ivory sleet
#

yup

granite owl
#

yea but if java isnt completly janky this should it

#

iterating the conditions left to right

granite owl
#

and executing on the first true return value

grim ice
granite owl
#

on logout

#

it should

#

disconnect of a player

#

when the data is written from memory

#

to his file

undone axleBOT