#help-development

1 messages · Page 1994 of 1

lost matrix
#

No. You can also use ProtocolLib. But in many cases you would want to use nms.

dusk flicker
#

gnoogle it

red sedge
#

yes

#

to the pdc

hexed hatch
#

Very insightful

#

Which one

red sedge
hexed hatch
#

The new type?

wanton atlas
red sedge
#

use the existing ones

tender shard
wanton atlas
#

okay

#

ty

hexed hatch
#

Is it a particularly bad idea to make a new type?

tender shard
#

no

#

it's perfectly fine

#

depending on what information you wanna store, you can use my lib (MorePersistentDataTypes) or Redempt's lib

#

e.g. my lib allows you to store FileConfiguration/YAML stuff inside a PDC

hexed hatch
#

For context, I'm currently in the process of writing a plugin that overhauls difficulty in Minecraft without making mobs damage sponges. I'm trying to assign mobs that spawn some behaviors from a pool, as well as some stats that do not exist for entities. So I guess a couple integers, doubles, and some enums

red sedge
#

yeah use the existing ones

hexed hatch
#

So just throw it in a string and parse it out?

red sedge
#

yeah sure

hexed hatch
#

but that seems filthy

red sedge
#

or just store it as a int id

narrow berry
#

this option is not available. I have thrown out all plugins now, the error still persists

tender shard
#

just create a new PDC type

red sedge
hexed hatch
#

Sorry lol. I appreciate your advice but I will ignore it

red sedge
#

oki

tender shard
hexed hatch
#

sorry alex there is nothing you can do or say to make me use your library

tender shard
#

I dont care whether or not you use it lol

hexed hatch
#

but I will steal from it without hesitation as I see fit

tender shard
#

in fact it's better for me if you not use it

#

because it might save me a bug report / github issue

hexed hatch
#

Okay now I'm going to use it

#

just to make your life more difficult

brave goblet
#

how can i get what plugin it is?

 public void timer(Player player){
        Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
            @Override
            public void run() {
                player.sendMessage("Exploding");
            }
        }, 0L, 20L);
    }```
brave goblet
#

well how can i get the plugin?

#

i mean

hexed hatch
#

you need the plugin instance?

#

dependency injection or static instance getter

delicate lynx
#

do you need your own or another one

brave goblet
tender shard
tender shard
brave goblet
#

mhm ty

#

reading through it now

tender shard
#

I recommend method 1 because it's easier

#

some people say it's bad practice and to use number 2 instead. I totally disagree with that though

#

but just choose whatever you like more

wanton atlas
#

alex, can u help me with nms

tender shard
#

no

wanton atlas
#

I mean

tender shard
#

I gotta go now

wanton atlas
#

with installing

brave goblet
#

for dinner

tender shard
#

if not, I can't help, I have a three course meal booked in 8 minutes

naive bolt
#

how do i fix it

quiet ice
#

Did you run git pull or similar?

#

or better said, which repo did you clone?

smoky oak
#

how do i use [] in a string without it throwing me some error

quiet ice
#

hm, what exactly do you want to achieve?

#

Convert an Object[] to a String or what?

smoky oak
#

no actually

#

it gets yellow and talks about a string literal

naive bolt
smoky oak
#

i just want to split a string at '[]'

naive bolt
quiet ice
#

Then you are unlikely to have accidentally started a merge. You can try to re-clone (not pull, CLONE) the repository which may solve it (make sure to fully delete the old folder beforehand to prevent any chance of accidentally pulling) but the bigger chance is that the author forgot to reconcile a merge conflict.

quiet ice
naive bolt
#

yea i deleted dir and re cloned and still same

quiet ice
#

Something like [StringA, StringB]?

smoky oak
quiet ice
smoky oak
#

see issue is

#

its nbt

quiet ice
naive bolt
#

how do i manualy reconcile

quiet ice
#

Uh, explaining the basics of merge conflicts will be a bit complicated to explain

smoky oak
#

would this work?

quiet ice
#

Regexes do not work

smoky oak
#

'work' as in be treated as a [

quiet ice
#

Then just #substring?

naive bolt
#

it isnt giving a very useful error

quiet ice
#

That is because the IDE does not know that it is a merge conflict

smoky oak
naive bolt
#

idk what i did but i fixed it

quiet ice
#

You probably just removed the line, but that MAY not solve it

naive bolt
#

it built fine

quiet ice
#

You may have dependencies declared multiple times or what, send me the pom

dire salmon
#

is it possible to make particles move?

quiet ice
#

Basically if you have a file X with the contents Hello and you change it to Hello World and commit it with the commit Id of let's say 48574646.
Now, if someone else modifies the contents of X to Hello Everyone! and commits it it will get a commit Id of let's say 457433.
If you then pull 457433 onto your main branch (which will be tracked at 48574646) you get a conflict.
Upon trying to merge it, git will say "whoa hold on" and will modify the file to something like

<<<< HEAD
Hello World
======
Hello Everyone
>>>> OtherBranch

You have to choose between one of the two variants, or just change one of them to fit the current state of the repository

dire salmon
nova fossil
#

Is log4j safe to use now?

main dew
narrow berry
#

how can i fix this error: ** Inner Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Bad package ID 83 **. the bug according to various forums is caused by forge, I personally only use bungeecord / servers and paper servers. the second error is a cracked launcher. Personally, I use a premium launcher and the nickname does not exceed 11 letters error: **Internal Exception: io.netty.hadler.codec.DecoderException: java.lang.IndexOutOfBoundsException: Index 83 out of bounds for length 5 **. I am asking for a hint where the error may be. the servers are on my home server they are not a lease.

misty current
#

hey, i am trying to disable mongo logging by using
((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.WARN);

But i'm getting a classcastexception:

Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader java.net.URLClassLoader @504bae78; ch.qos.logback.classic.LoggerContext is in unnamed module of loader 'cosmicsky-1.0-SNAPSHOT.jar' @3ae0ea7b)
    at me.kill05.cosmicsky.mongo.MongoManager.<clinit>(MongoManager.java:40) ~[cosmicsky-1.0-SNAPSHOT.jar:?]
    ... 12 more
narrow berry
misty current
#

i have also tried to put it in a clean project and it worked just fine, the only difference with maven imports is the spigot one

#

do i need to put some exclusions in the spigot dependency or something? im very confused

main dew
smoky oak
#

i hate regex and intelliJ string highlighting

#

but i will admit it's useful

#

on a different topic

#

when i open a nbt file in intelliJ it gets parsed into something closely resembling json

#
    size: [
        5,
        1,
        7,
    ]
    entities: []
    blocks: [...```
#

does anyone know if i can automatically parse that? Or do i need to open the file and do strg+a, strg+c, strg+v

dire salmon
#

what is v v1 v2 v3?

smoky oak
#

doesnt the javadoc say?

kind hatch
dire salmon
#

oh so its the amount of particles?

kind hatch
#

If you need more than that, there is a method that has particle offsets.

misty current
#

x y and z should be the particle spread compared to the location

dire salmon
#

ok

#

im trying to make moving particles, is it possible?

kind hatch
#

Moving as in using the same particle instead of spawning new ones?

misty current
#

depends on how you want the particle to move

paper gazelle
#

hi,
Is the mcmmo plugin still supported for Minecraft Server 1.12.2?

dire salmon
kind hatch
#

IIRC, there is only one particle that has the ability to move from one location to another. It being the Vibration particle.

#

Otherwise you would have to spawn each particle individually.

naive bolt
#

what do i use to build the plugin to a jar

hexed hatch
#

you can also direct certain particles in a particular direction but you can only do that for one particle at a time

dire salmon
#

ill have to know the maths tho

delicate lynx
kind hatch
naive bolt
#

i just get Fatal error compiling when compiling parent

kind hatch
delicate lynx
#

well what is the error?

naive bolt
#

when i compile just the plugin name one i get [ERROR] Failed to execute goal on project ServerNPC: Could not resolve dependencies for project com.isnakebuzz:ServerNPC:pom:1.14.0-DEV: The following artifacts could not be resolved: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_8:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_16:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_17:jar:1.14.0-DEV: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

narrow berry
west forge
#

Hello, i am trying to make a gun system in Minecraft and at the moment i iterate throught all the online players to check for the hit player.
This is kinda heavy and i was wondering if there is a better way to do it, here's the code:

Location playerLocation = player.getLocation();
Vector direction = player.getEyeLocation().getDirection();

for (int i = 0; i < range; ++i) {
    // Display particles

    for (Player p : Bukkit.getOnlinePlayer()) {
        double d = playerLocation.distanceSquared(p.getLocation().add(0, p.getEyeHeight() / 2.0d, 0));
        if (d <= 0.85d) {
            // Damage player
        }
    }
}```
kind hatch
#

There should be a button for it in IntelliJ

naive bolt
#

yea in file menu

smoky oak
#

maybe there's a method doing what you need

misty current
#

i know what a class cast exception is

#

but thats the way you are supposed to do it

kind hatch
smoky oak
#

where'd you get that info?

misty current
#

if you read what i wrote, trying it in a plain java project works fine

west forge
#

Vector collision detection question

misty current
paper gazelle
#

i have problem with plugin mcmmo who can help?
i use MC Server v1.12.2 Magma with plugin mcmmo v1.5.10
have log ERROR Spam. if i use Extra Utilities 2 Quantum Quarry
u can error reproduce

misty current
naive bolt
#

i do get this tho

misty current
kind hatch
# naive bolt still happens

Oh, I didn’t realize you have a multi module setup. There should be a button for turning on offline mode for maven. Toggle that and then try clean package

paper gazelle
#

can who help, pls?

misty current
#

i'm pretty sure you are not running a spigot server if you have extra utilities 2

smoky oak
#

i have no clue why it wouldnt work

#

also

#

anyone a better idea on how to do this?

String[] split1 = structString.split("size:|entities:\\[\\]blocks:|palette:|Data");
String[] dimensions = split1[0].split("\\[|,|\\]");
String[] position_objects = split1[1].split("\\[\\{|\\},\\{|\\},\\]");
String[] palette = split1[2].split("\\[\\{Name:\"minecraft:|\"\\},\\{|\"\\},\\]");```
waxen plinth
#

Dear god

#

What are you trying to do

smoky oak
#

you see

#

there's no usable nbt parser

#

for structure nbt

kind hatch
paper gazelle
#

@misty current
The mod, however, supports via Magma Server.

waxen plinth
#

Don't use fucking regex as a parser lol

#

Regex is not capable of parsing recursive data

naive bolt
#

[ERROR] Failed to execute goal on project ServerNPC: Could not resolve dependencies for project com.isnakebuzz:ServerNPC:pom:1.14.0-DEV: The following artifacts could not be resolved: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_8:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_16:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_17:jar:1.14.0-DEV: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV has not been downloaded from it before. -> [Help 1]

waxen plinth
#

Do you want an nbt parser

#

I will literally make you an nbt parser if it means you don't use regex

#

It'll be easy too

smoky oak
#

i need a structure.nbt -> Material[][][]

waxen plinth
#

Easier than regex

smoky oak
#

essentially

waxen plinth
#

I have a library for something very similar to this

#

Why don't you just use my MultiBlockStructure library

smoky oak
#

can i find it online?

waxen plinth
#

One sec

#

Firefox mobile is so fucking slow wtf

smoky oak
#

imma take a look at that thanks

paper gazelle
#

hmm

kind hatch
#

I gotta get back to work, but it looks like your modules aren’t being found in your local repo. I’d look into that.

smoky oak
#

@waxen plinth assuming im reading this right, I can scan in a structure, and scan for that structure at a location. How does your library handle Air, VoidAir, deepAir and StructureVoid ?

waxen plinth
#

You can have it ignore air

#

And you can have it ignore specific materials as well

#

So you could have it ignore structure void

#

You can easily change how it builds anyways

waxen plinth
#

You can call forEachBlock on it and just skip building blocks of certain types

#

It's super easy

#
mbs.forEachBlock(location, b -> {
    if (b.getType() == Material.STRUCTURE_VOID) return;
    b.update(false);
});```
#

ez

smoky oak
#

I'm going to assume you have javadoc in the code, then?

waxen plinth
#

Yes it's all documented

#

One moment

smoky oak
#

I think I'll just throw it into my project. Strg+Q is a thing in intelliJ, luckily...
To credit that library, how exactly would i go about it?

waxen plinth
#

It's under MIT so technically no credit is required but putting "thanks/credit to redempt" anywhere is always appreciated

smoky oak
#

ah well i was planning on doing that anyways

#

last question

#

how can i compile my plugin so that the library does not get baked into it, and makes so that it still works when your library is also loaded as a plugin on the server?

#

I'd like to keep unnecessary inflatation out of my projects

waxen plinth
#

You just add it as a dependency in your plugin.yml

#

Are you using maven or gradle

smoky oak
#

maven

waxen plinth
#

Set scope to provided

#

And you're good

smoky oak
#

ah thanks

#

well im off

waxen plinth
#

Feel free to DM me if you have more questions on how to use it

smoky oak
#

sure thanks

hardy swan
#

what's the craftbukkit version for 1.18.2

#

1_18_R2?

quiet ice
#

1.18.2-R0.1 or something like that

hardy swan
#

not that one

quiet ice
#

it's just changing the 1.18.1 (or 1.18, idk) part to 1.18.2, anything else can be kept as-is and without warranty, whether express or implied

hardy swan
#

server version string

#

the one where the version for 1.16.5 is 1_16_R3

#

you may know it as nms version

quiet ice
#

(MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 1d7a6a0) this thing?

#

or do you mean the craftbukkit package ver? But in this case your IDE auto-completes it

#

Really, it's just 1.18/1.18.1->1.18.2, there is no second revision or anything like that for the imminent future

hardy swan
#

Refer to "NMS version"

quaint mantle
#

Hey, guys! Got a question, sorry if it's stupid.
I'm developing a library I'll use later in a plugin and need to log, to the plugin's logger. I wan't to avoid adding the Spigot API as a dependency of this library, as I want it to be "General purpose", so passing the plugin or it's logger is out of the table.
You know how could I have logs from a external library logged into my plugins Logger? I'm trying with slf4j, but I can't wrap my head around it.

quiet ice
#

What the fuck is nms version

#

[mcMMO] Platform String: 1.18.2-R0.1-SNAPSHOT this thing?

hardy swan
#

Click into the link I sent

#

and search in page "NMS version"

#

you probably won't know what it is

quiet ice
#

It is the package prefix for cb classes, but that one should be auto-completed by any IDE

#

so you are not searching for that one

#

So I am a bit confussled

hardy swan
#

there must be a reason why I am asking here, I am building 1.18.2 jar as we speak

tulip owl
#

How do I make an alias in my plugin (I use ACF) that runs another plugin's command, including arguments.

hardy swan
#

but its ok, I got this

quiet ice
#

org/bukkit/craftbukkit/v1_18_R2/

smoky oak
tulip owl
#

But how do i get subcommands to work?

smoky oak
#

🤷‍♂️

tulip owl
#

as passing in too many arguments would give an error wouldn't it

#

(context, i gave up with MyCommand so i'm just doing it custom)

smoky oak
#

well depends on the plugin

#

& command

#

some commands just ignore args[]

#

others discard any extra args if there's too many

minor garnet
#

it is possible through spigot when a player has the inventory open to see which slot the mouse cursor is in or if it is over a certain item

smoky oak
#

no

#

that's not sent to the server

#

what you can get is the slot it is over on Inventoryclickevent

tulip owl
smoky oak
#

i haven't really worked with subcommands yet

#

chat never was of great interest to me in the first place

echo granite
#

Hello, where should I put my program(not a plugin)'s configuration file?

minor garnet
smoky oak
#

i actually dont know that one

#

it might be worth looking into the spigot docs on the inventory

dire salmon
#

is it possible to make a runnable run for x ticks, then a 2 seconds delay?
run for 20*5 ticks, have a 2 second delay, repeat

smoky oak
#

include a counter

#

reset after 20*5 ticks + 2 secs, only run when equal or less to twenty

dire salmon
#

ok

dire salmon
smoky oak
#

make a runnable class with a int counter = 0 variable

#

then have it count up every time run() is called

#

only execute if less or equal twenty

#

and if it goes over twenty plus i believe four

#

reset

#

(to 0)

dire salmon
smoky oak
#

kinda

young knoll
#

No for loop

smoky oak
#

the thing you have to keep in mind here is

#

well yes that too

#

but the counter needs to be declared outside the run() function

#

hence you need to make a class extending BukkitRunnable

#
class Example extends BukkitRunnable{
  int counter = 0;
  @Override
  public void run(){
    if(counter<21){
      doSomething();
    }
    counter ++;
    if(counter>24){
      counter = 0;
    }
  }
}
dire salmon
smoky oak
#

why dont you adjust particle lifetime then

#

so that once the first particle despawns a new one is spawned there

dire salmon
#

oh.

#

how i do that

#

first time using particles and runnable things

smoky oak
#

how do you spawn them exactly?

dire salmon
#

spawnParticle

#
for (int degree = 0; degree < 360; degree=+10){
                    double radians = Math.toRadians(degree);
                    double x = Math.cos(radians);
                    double z = Math.sin(radians);
                    location.add(x, 0, z);
                    location.getWorld().spawnParticle(
                    Particle.END_ROD, 
                    location, 1, 0, 0, 0);
                    location.subtract(x, 0, z);
                }
#

Location location = p.getPlayer().getLocation();

misty current
#

hey, i am trying to disable mongo logging by using
((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.WARN);

But i'm getting a classcastexception:

Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader java.net.URLClassLoader @504bae78; ch.qos.logback.classic.LoggerContext is in unnamed module of loader 'cosmicsky-1.0-SNAPSHOT.jar' @3ae0ea7b)
    at me.kill05.cosmicsky.mongo.MongoManager.<clinit>(MongoManager.java:40) ~[cosmicsky-1.0-SNAPSHOT.jar:?]
    ... 12 more
#

executing the exact same code in a normal java project works fine

smoky oak
#

it's annoying that the javadoc does not specify what the other numbers are used for

dire salmon
#

yea

misty current
#

i have put a main method inside a class and ran that code with all the same imports in the same projects and no errors

dire salmon
#

it just says v 1,2,3,4,5,6 t etc

#

java.lang.OutOfMemoryError: Java heap space
i did something wrong lol

smoky oak
#

also nevermind, particle lifetime is handled client side

dire salmon
#

sad

smoky oak
#

just use my method, it'll probably work

quiet ice
dire salmon
misty current
#

oh

#

can i work around it?

#

iirc it worked fine in legacy versions of spigot/paper

smoky oak
misty current
#

probably the code was different

smoky oak
#

i dont even know if runnable would work

quiet ice
#

Try not to use logger-specific code

misty current
#

what do you mean?

quiet ice
#

Well, if the implementation changes the used logger your code will break if you specifically cast it to log4j's logger factory or logback's logger factory. The best would be to only use slf4j especially because mojang appears to be paving the road to employ their own logger framework

misty current
#

i haven't found a way of disabling mongo logging in any other way

#

which is kinda sad

#

i guess i could use nms code to get the logger factory somehow unless spigot already has the option to

dire salmon
smoky oak
#

as far as i understood you it is supposed once every five ticks for twenty times then pause for two seconds

#

also oops

#

it should be 28

smoky oak
#

once per second you mean then

#

the numbers change then

dire salmon
smoky oak
#

once per tick for five seconds?

dire salmon
#

runs for 5 seconds

#

yea

smoky oak
#

k then the numbers are

#

less than 101 (For five seconds)

#

and above 140 (for seven seconds)

#

at which point it resets

misty current
dire salmon
#

?

smoky oak
#

yea looks right

#

that 140 might have to be a 139 but im not too sure

misty current
quiet ice
#

No

smoky oak
#

it doesnt matter too much if you have a single duplicate imo

quiet ice
#

That resolves the java.util.logging logger

#

I mean LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver").setLevel(Level.WARN);

misty current
quiet ice
#

Then how the hell does your code compile in the first place ...

misty current
#

it was compiling with the cast

#

it was able to find the method

#

i guess LoggerContext provides an implementation of the Logger class when you call getLogger instead of a Logger

#

i could try casting the Logger that getLogger returns but not sure what to cast to

grim ice
#

i want the chunk first position and second position

tardy delta
#

lmao logger stupid, it uses the color codes of the end of the previous message

misty current
#

there's a bunch of them

grim ice
#

is

        final int minX = chunk.getX() << 4;
        final int minZ = chunk.getZ() << 4;
        final int minY = world.getMaxHeight() - world.getMinHeight();
        final int maxX = minX | 15;
        final int maxY = world.getMaxHeight();
        final int maxZ = minZ | 15;

fine for getting the first, second positions of the chunk

dire salmon
# smoky oak yea looks right
int counter = 0;
  @Override
  public void run(){
    if(counter<101){
  for (int degree = 0; degree < 360; degree++ ) {
                        double radians = Math.toRadians(degree);
                        double x = Math.cos(radians);
                        double z = Math.sin(radians);
                        location.add(x, 0, z);
                        location.getWorld().spawnParticle(Particle.END_ROD, location, 1);
                        location.subtract(x, 0, z);
                    } 
    }
    counter ++;
    if(counter>140){
      counter = 0;
    }
  }
smoky oak
#

um

#

that spawns three thousand six hundred particles every tick

#

is that supposed to happen?

quiet ice
smoky oak
#

*360

dire salmon
#

no, i put the wrong numbers

misty current
#

yeah thats what i expect

dusk flicker
#

yikes

smoky oak
#

still

tardy delta
quiet ice
#

I'm trying to find some native SLF4J way of setting the log level, but apparently we live in a world where everything is dictated by config files

dire salmon
smoky oak
#

you spawn three hundred sixty particles every tick, for five seconds

misty current
tardy delta
#

oh

smoky oak
#

what is the two second delay for then?

mortal hare
#

is there any way to convert container slot to raw view slot back

mortal hare
#

ik you can convert it to inventory slot

#

but can i do the opposite via api

smoky oak
#

well that code would run but im not too sure what you need the delay for

grim ice
dire salmon
#

for case server owners see people dont like particles spawning everytime

quiet ice
#
Logger logger = LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver");
if (logger instanceof org.apache.log4j.Category cat) {
    cat.setLevel(org.apache.log4j.Level.OFF);
}

something like that I guess, and then continue with every other logger framework

smoky oak
#

wouldn't you need to make the delay configurable too, then?

dire salmon
#

yes

#

it will be

#

im just testing it without config

smoky oak
#

i see

#

then the reason you spawn three hundred sixty particles per second is...?

dawn hazel
#
if(args[0].length() > 0) {
    Player p = Bukkit.getPlayer(args[0]);
    assert p != null;
    if (p.hasPlayedBefore()) {

    } else {
        sender.sendMessage("This player has never played before.");
    }
}```
its telling me that its null (yes ive tried without the assert too)
misty current
#

can you get with reflections all implementing classes of an interface somehow

#

i could brute force it

dawn hazel
quiet ice
#

Nyes, just a chain of if-else should suffice

smoky oak
quiet ice
#

Brute-forcing doesn't help either given that every logger framework is going to implement it different

smoky oak
#

are you doing that?

misty current
#

so what do i put? all the implementations of ILoggerFactory in instanceof checks?

quiet ice
#

I'd do the instanceofs at the Logger layer

misty current
#

aight i'll try

#

brb

tardy delta
dawn hazel
#

the args length isnt 0 tho

tardy delta
#

also dont assert

grim ice
#

it will throw an arrayoutofbounds

#

:)

dawn hazel
#

im defining a player in the command

tardy delta
quiet ice
#

You may need to try-catch all the if statements in case some class is missing at runtime (some hosts are known to cut down on available classes at runtime), but ¯_(ツ)_/¯

tardy delta
#

i found someone catching npe and index out of bounds on his commands

#

dont think you can get worser than that

dire salmon
manic delta
#

not working 😔

dusk flicker
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

grim ice
tardy delta
#

what are that

misty current
quiet ice
#

Which in turn is an child class of Category

misty current
#

whats the import for it? i doubt any of these are the right one

cobalt tinsel
#

hi

#

i want to get global server count

quiet ice
#

oh probably not

cobalt tinsel
#

how can i do it

#

ik it's with bungee messaging

misty current
#

Bukkit#getOnlinePlayers()

cobalt tinsel
#

but idk how to do that

misty current
#

then get the zize

#

oh you have a bungee

cobalt tinsel
quiet ice
#

(why are there so many slf4j<->log4j bridges?)

misty current
#

i have no idea, i barely know what log4j is

quiet ice
cobalt tinsel
#

yep, how can I do that

grim ice
#

literally just

quaint mantle
#

do any one know how to remove npc from tablist using packet?

grim ice
#

but made it for chunks

#

LOL

quiet ice
#

Apparently log4j 2 API has no way of disabling a logger outside config files

#

Which honestly is just stupid AF but what can you do I guess

quaint mantle
#

I stuck at this step for 2 days

misty current
#

hold on Log4jLogger has a field which has some implementation to set the logging level

#

imma try to get it with reflection

#

that's sketch af but what u gonna do about it

quiet ice
#

Hm, that may be actually better. It is hacky but far better than what I would otherwise propose (Invoking LogManager.getLogger("logger name") and casting that to SimpleLogger to have .setLevel available)

misty current
#

it didn't throw any exception but it didn't do anything either

glossy venture
#

doesnt log4j depend on config files for some reason

misty current
#
        try {
            Log4jLogger jLogger = (Log4jLogger) LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver");
            Logger logger = (Logger) FieldUtils.readDeclaredField(jLogger, "logger", true);
            logger.setLevel(Level.WARN);
            Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Done.");
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
#

Logger is org.apache.logging.log4j.core.Logger;

quiet ice
#
setLevel(Level) - Method in class org.apache.logging.log4j.simple.SimpleLogger
setLevel(Level) - Method in class org.apache.logging.log4j.status.StatusConsoleListener
setLevel(Level) - Method in class org.apache.logging.log4j.status.StatusLogger

You could try either of these three methods

#

Actually you need to try all three

misty current
#

this is the field i am trying to get

misty current
#

unless im missing something

manic delta
#

guys can someone help me? I have a plugin but to upload it to spigot I need it to weigh 4mb, I already managed to compress it to compile it but the problem is that I use an external jar (and when compressing it only compresses the pom stuff and not external) that is not in maven-central a guy was helping me to be able to put that external-jar in the pom.yml but it is not possible, I have used mvn commands with that and still nothing.😢

quiet ice
#

You can obtain that instance via LogManager.getLogger("org.mongodb.driver") already

misty current
#

ah

quiet ice
#

where as logmanager is org/apache/logging/log4j/LogManager

quiet ice
glossy venture
misty current
#

this is getting stupidly complicated just to disable mongo from flooding my console

quiet ice
#

Just fork mongo at that point

misty current
#

lol

#

it completely makes no sense that mongo devs have not added a way to set the logging level in all the years it has been out

#

since its one of the most annoying things of it

quiet ice
#

Also, if you want to change the mongo log level for only your own server, you can already do that via the log4j2.xml or something like that

#

Never tried it, but I know that setting your own logger settings is certainly possible

misty current
#

if i wanted to go the reflection way i was trying before what am I supposed to get

#

im a bit lost

quiet ice
#

no idea either

dawn hazel
#

anyone know why when i do this i can give the other player hearts when i dont have enough hearts for the inputted integer

grim ice
#

whats the point of send

dawn hazel
#

it gets the bukkit name of sender

#

aka im lazy and dont feel like putting in a long method

grim ice
#

u made it longer tbh

#

and ur not following java conventions

#

and ur static abusing as well

dawn hazel
#

one i know

#

two i know

#

and three i know

#

none of this code is permanent

misty current
#

i'll try a bit myself i guess

grim ice
#

when to use static thenÉ

dawn hazel
#

im just trying to figure out how to do all of this

quiet ice
grim ice
quiet ice
#

oh

#

could've been an inner class

dawn hazel
#

this code is never going to meet public eye once im done

manic delta
dawn hazel
#

its being thrown out and replaced with better code

quiet ice
#

Also, your first Integer.parseInteger is pointless

grim ice
midnight shore
#

How can i get a vector for moving an entity towards another entity?

grim ice
#

maybe

quiet ice
#

Doesn't need to be a map

brave goblet
#
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);

final Runnable runnable = new Runnable() {
        int countdownStarter = 10;

        public void run() {

            System.out.println(countdownStarter);
            countdownStarter--;

            if (countdownStarter < 0) {
                System.out.println("Kaboom");
                scheduler.shutdown();
            }
        }
    };```
how can I make it so when i do 
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);
I can parse a player so in the void run i can do sum like player.sendMessage?
quiet ice
#

Could just be a map-like singleton with static mutators

dire salmon
dawn hazel
grim ice
#

e.g when i see my code

#

i know its bad

quiet ice
#

I do stuff like that quite often

grim ice
#

Lol

grim ice
#

Good thing hes storing uuids though lol

dawn hazel
#

now i just need an answer to my question not to have every single thing but what im looking for nitpicked

lost matrix
dawn hazel
quiet ice
#

Makes incrementing/decrementing much easier

lost matrix
dawn hazel
lost matrix
midnight shore
#

so i should have target.getLocation().getDirection().subtract(base.getLocation().getDirection());?

undone axleBOT
dawn hazel
#

which means id have to refactor all these classes by a lot

ivory sleet
quiet ice
#

atomic integer does not lock... that is the whole point of the atomic series of objects

ivory sleet
#

To be able to control the dependencies of yours

#

Which singletons aren’t very great at

chrome beacon
undone axleBOT
grim ice
quiet ice
#

Not that you should not loop over Bukkit#getOnlinePlayers outside the main thread

brave goblet
#

like player hurt event

grim ice
#

there isnt a static getter

dire salmon
#

i cant find it in org.bukkit

smoky oak
#

?scheduling

undone axleBOT
grim ice
#

only a public static field

dawn hazel
grim ice
#

No

ivory sleet
quiet ice
chrome beacon
quiet ice
#

Right now you have only * 1

#

But you are decrementing with * 2

ivory sleet
dawn hazel
#

oh yeah

#

right

quiet ice
#

However at this point you could simply just leave it at a multiplier of 1

ivory sleet
#

But just to make stuff a bit simpler

dawn hazel
#

forgot the math

grim ice
#

I would call it static abuse, not a singleton

ivory sleet
#

Idk

grim ice
#

calling it a singleton makes singletons look bad

quiet ice
#

That is a singleton if you pull it off right

ivory sleet
#

Having a static map isn’t probably the greatest idea

lost matrix
grim ice
ivory sleet
#

But well, if you’re aren’t doing something scalable, then it probably doesn’t matter

grim ice
#

so it isnt a singleton

quiet ice
#

We do not know the impl

quiet ice
grim ice
#

Oh btw conclure

young knoll
#

What about a public static final volatile transient native map?

brave goblet
ivory sleet
#

Anyways, iirc smile, atomic framework classes allow you to with VarHandle read variables as normal non volatile ones if needed

brave goblet
#

scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS, player?);

lost matrix
#

Also maps have a bunch of methods like compute and computeIfPresent that are a good alternative to mutables

ivory sleet
#

Which eliminates most of overhead you might encounter

dawn hazel
#

oh my java complicated brainspaghetti of methods

dire salmon
grim ice
#

checking my github:
https://github.com/2Hex/ (i privated a lot of shitty repos btw)
do u think my code would be accepted as a premium plugin?
Im not making one, just had a thought

dire salmon
#

oops ping

grim ice
#

having 4 repos shows how dry my brain is

#

i cant get any idea

chrome beacon
undone axleBOT
ivory sleet
#

2Hex send me the repo you’re most proud of

grim ice
#

the 4 repos prob include my profile config

grim ice
#

Im not proud of any since i know my place but okay a second

#

Im open for criticism btw

#

even the smallest mistakes, I want to learn

ivory sleet
#

No, be open for feedback, not criticism

grim ice
#

same thing kekw

quiet ice
#

This will only work for 1.17.1+
1.12 compat please

grim ice
#

lol

quiet ice
#

This library sux

grim ice
#

1.17.1- would require nms kek

quiet ice
#

Idiot

ivory sleet
#

Criticism can be anything, whilst feedback usually is more constructive and criticism in a kind way 2Hex afaik but yeah let me check now

grim ice
#

this is the only way that wouldnt require nms, and its required to use 1.17.1+ for it

quiet ice
#

You can use my lib and you do not have to use nms

grim ice
#

lemme see

#

can u link it

ivory sleet
#

So what’s the point of the first class

quiet ice
#

It's called imagination

grim ice
ivory sleet
#

Why do you have the plugin variable mutable

#

I’m just curious

grim ice
#

hmm

#

maybe the plugin changes

#

nah im jk

#

i should prob fix that

ivory sleet
#

Yeah

#

Have a constructor taking a plugin instance

grim ice
#

would be better

ivory sleet
#

Where the initialization logic also takes place

#

This would allow you to completely refactor away your private init method you for some reason have

grim ice
#

yep

#

shit i didnt realize that

ivory sleet
#

Then again, the api package doesn’t really contain an api

quiet ice
ivory sleet
#

Or well, not an api which is particularly abstracted

grim ice
#

how would i achieve better abstraction?

ivory sleet
quiet ice
#

I don't use them for some reason

ivory sleet
#

Let the consumer only talk to interfaces and enum state representations

#

Hide actual implementation

#

Easiest example I can find as of now is probably vault api, or just spigot api itself lol

brave goblet
#

if i get any spam in console

#

ill just add some try catches

ivory sleet
#

For impls like the skip list map and concurrent hm iirc

grim ice
#

but

#

what if multiple people use it at the same time

ivory sleet
#

I’d argue for that keeping it non static is more scalable, but really depends on how you’re gonna scope the library

quiet ice
#

just have it be locked behind an AtomicObject

grim ice
#

shouldnt i just move it

quiet ice
#

Oh actually

grim ice
#

to some other place

quiet ice
#

Yeah I see what you mean

brave goblet
quiet ice
#

Then you should employ a factory pattern

#

Especially given that #setPlugin is mandatory

grim ice
quiet ice
#

And if you make use of sealed classes you will still avoid the risk of internal API exposure

grim ice
#

o

ivory sleet
#

Hmm, 2Hex, hide concrete classes behind interfaces

#

And let consumers only ever be disclosed to the interfaces of yours

ivory sleet
fossil lily
#

Is it possible to find the amount of damage just done by a player?

ivory sleet
#

And also

#

Don’t shutdown the executor like that

#

instead if you wanna cancel the task, use ScheduledFuture::cancel or sth

misty current
sacred mountain
#

anyone know why this error occurs?

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.clonkc.vlands.kitpvp.vlandsinterfaces.CustomItems

grim ice
brave goblet
sacred mountain
#

thats the class

#

and in my command class i imported

import com.clonkc.vlands.kitpvp.testinterfaces.CustomItems;

brave goblet
#

and you do have the library/dependency?

sacred mountain
#

wdym

#

what dependency

#

@brave goblet

brave goblet
#

like how did u import the class?

brave goblet
#

and that isn't highlighted?

#

in red or

#

an error

sacred mountain
#

no...

quiet ice
# grim ice wdym?

Something like

public abstract class BuilderFactory {
    private static BuilderFactory field;
    public static BuilderFactory get() {return field;}
    public static void set(BuilderFactory factory) {
        if (field != null) throw new InternalError();
        field = factory;
    }
    public abstract Builder getBuilder(JavaPlugin plugin);
}
public abstract class Builder {
    public abstract EntitySerializer build();
}

Where as you set the instance of the builder factory somewhere in your API implementation

brave goblet
#

idk then

#

what ur problem is

#

does it say which line the error occurrs?

grim ice
sacred mountain
quiet ice
#

NoClassDefFoundError is ALWAYS caused by another error

sacred mountain
#

it was caused BY the noclassfound

quiet ice
#

wha

sacred mountain
#

yed

quiet ice
#

And no stackraces before this one?

sacred mountain
#

so my interface isnt initializing

brave sparrow
#

@sacred mountain let’s see the code for the command

quiet ice
#

Then you have something that is sponging up a CNFE

#

Or have a class init error

sacred mountain
brave sparrow
#

Nah

quiet ice
#

(also, the stacktrace will be at startup)

brave sparrow
#

Unless there’s something horrifically wrong with the command

#

Lol

quiet ice
#

I'd rather like to see the code for CustomItems

brave sparrow
#

They sent that before

sacred mountain
#

idk why its an interface

brave sparrow
quiet ice
#

the error is in that class

brave sparrow
#

Yes

#

Lol

sacred mountain
#

well

#

its like 6 lines

#

you could look at it

brave sparrow
#

I want to see the command anyway

quiet ice
#

Either
A) The class is not compiled
B) You are unable to find the stackraces
C) Java classloading moment

sacred mountain
brave sparrow
#

Yes

quiet ice
#

Since I am very sure that it is B, send me the whole log

quiet ice
sacred mountain
#

eh

#

its worked before

#

hm

quiet ice
#

You are loading the class before your plugin loaded

brave sparrow
#

@quiet ice take a look at the command classes in the thread and you’ll see why I wanted to see them

quiet ice
#

sneakythrows?

brave sparrow
#

A reflection snake

sacred mountain
quiet ice
#

I know all too well what it does

sacred mountain
#

ok

quiet ice
#

It could be that sneakythrows it supressing the NPE

#

but eh, I always avoided any form of sneaky throws so I do not know for sure if that is the culprit

brave sparrow
#

There’s so much reflection everywhere it’s hard to see what’s going on

quiet ice
#

What is the reflection even used for?

brave sparrow
#

A lot

#

@sacred mountain do me a favor, make CustomItems a class and make each of those variables public static

#

Just for now

#

And see what happens

quiet ice
#

The issue that they encounter is caused by an NPE in the CustomItems interface

brave sparrow
#

Then my request won’t fix it

#

Which is good

#

More information is always better than less

quiet ice
#

Or a deadlock

#

actually, it might be a deadlock now that I think about it

brave sparrow
#

There’s no multithreading

quiet ice
#

The clinit of two classes could be referring to each other

sacred mountain
#

nvm

brave sparrow
#

That seems unlikely

quiet ice
#

It would throw a gigantic stack overflow exception, but given that we do not have the exception at hand it is the most probably for me

#

And all it requires is either the clinit of Main, Main#getConfigUtils, Main#getTfbConfig, Main#getTtntConfig or Main#getGhConfig requiring CustomItems

#

Actually, wouldn't that result in a null value?

dire salmon
#

where can i find runScheduledTask()?

quiet ice
#

Yeah, probably does now that I think of it.

#

?jd-s

undone axleBOT
brave sparrow
dire salmon
dire salmon
olive lance
#

is it acceptable to have 2 listeners for the same event in a plugin?

olive lance
#

ok

#

ty

brave sparrow
#

Lol

quiet ice
#

probably what you are searching for

brave sparrow
#

^

dire salmon
#

@Moterius#2597 troll me 😠

minor garnet
#
        ItemStack item = new ItemStack(this.type);
        final ItemMeta meta = item.getItemMeta();
        
        meta.setDisplayName(this.name);
        meta.setLore(this.lore);
        meta.setUnbreakable(true);
        item.setItemMeta(meta);
        item = Nbt.setNBT(item, "gun", parent());
        
        if (!Nbt.hasNBT(item, "gun")) {
            plugin.sendMessage("tem");
        }
        
        item = Nbt.setNBT(item, "ammo", "8");
        
        if (!Nbt.hasNBT(item, "gun")) {
            plugin.sendMessage("tem");
        }
        return new GunItem(item);```

why when i add a new nbt to an item the nbt i had put removes ? 

https://paste.md-5.net/ukozupebak.cs Nbt class
wary harness
#

how would I disable chat for specific person so they don't receive messages

reef acorn
#

Hello, how can I make it so that when a player has 10 stones, for example, they are deleted?

wary harness
#

I mean I can cancle event

brave sparrow
#

getRecipients()

wary harness
#

oh

#

ok thanks all clear

dire salmon
#

something like this

if(p.getInventory().contains(new ItemStack(Material.Stone), 10)){
code to remove
}
olive lance
#
    public void addArcherTagAndRemoveLater(Player p){
        if(archerTagged.put(p, new BukkitRunnable() {@Override public void run() {archerTagged.remove(p);}}.runTaskLater(plugin,ConfigManager.ARCHER_TAG_LENGTH).getTaskId()) != null) {
            Bukkit.getScheduler().cancelTask(archerTagged.get(p));
        }
    }``` any better ideas for this
dire salmon
#

formatting

olive lance
#

shit

brave sparrow
olive lance
#

thanks

#

i wanna do computeifAbsent but dont know how it works. Would it even be useful there?

quiet ice
# olive lance ```HashMap<Player, Integer> archerTagged = new HashMap<>(); public void addA...
Map<UUID, BukkitTask> archerTagged = new HashMap<>();

public void addArchertagAndRemoveLater(Player p) {
   BukkitTask newTask = Bukkit.getScheduler().runTaskLater(plugin, () -> {
          archerTagged.remove(p.getUniqueId());
      }, ConfigManager.ARCHER_TAG_LENGTH);
   BukkitTask old = archerTagged.put(p.getUniqueId(), newTask);
   if (old != null) {
       old.cancel();
   }
}

I'd use something like this

olive lance
#

if i run the function twice on the same player before the tag_length will it ensure its not deleted until after the new cooldown?

quiet ice
#

Oh no

#

Lemme change that

olive lance
#

ight. also if im checking to see if a player is in the set is it cheaper to get the uuid and then check that or is it not really getting much more because the uuid is in the player alr

smoky oak
#

well the runScheduledTask takes the delay and the period of a task

#

as such doing (0,1) at the end means

dire salmon
#

this method doesnt exist

smoky oak
#

must be a similar one then

#

?scheduling

undone axleBOT
dire salmon
#

runTaskLater?

quiet ice
#

ight, changed it

smoky oak
#

runTaskLater does it once only iirc

#

its runTaskTimer(plugin, delay, period)

quiet ice
#

Run task timer?

dire salmon
#

ok

quiet ice
#

But in this case I do not think that you need a repeating task

#

actually, you'd need to null check it

dire salmon
#

the armor is not doing what it should and the plugin didnt load the things

quiet ice
#

now it should work

olive lance
#

ah i see

#

you edited it

#

was confused

rough drift
#

I'm sending a title where the title is "" and the subtitle is the text i wanna show, however it aint showing up

#

why's that

olive lance
#

thanks @quiet ice

rough drift
#

using

Player#sendTitle(String, String, int, int, int);
elfin atlas
#

Does someone know if there is packet for LeashHolder?

dire salmon
#

but ```java
runTaskTimer(this, 20L2, 20L5);

did 5 seconds delay
rough drift
#

yes ofc

#

20 * 5 = 100 = 5 seconds

dire salmon
#

yes

#

runTaskTimer(plugin, delay, period)

#

shouldnt it run for 5 seconds?

olive lance
#

delay is run after 5 seconds

dire salmon
#

oh, nvm, it makes sense

olive lance
#

every period

dire salmon
#

yea

#

it does nothing for a while

rough drift
#

yes

#

because you added 20*2

dire salmon
#

yes

rough drift
#

that adds a 2 second delay on first startup

olive lance
#

ye u can just do 0

dire salmon
#

now i need to know how to make it show 1 particle every 2 tick

#

making a "spinning" animation around the player

olive lance
#

EntityDamageByEntityEvent.getDamager returns what if its an arrow?

#

or is it another event

#

or will it be both

dire salmon
#

i think it returns Entity.ARROW

#
@NotNull
public Entity getDamager()
/*Returns the entity that damaged the defender.
*Returns:
Entity that damaged the defender.*/
olive lance
#

Ah ok ty

sharp flare
dire salmon
rough drift
#

and cancel it when its done

sharp flare
#

?scheduler

dire salmon
#

?scheduling

undone axleBOT
sharp flare
#

Read that also, there are self cancelling examples there ig, if u pass an parameter to ur consumer, use it to cancel the task by condition

dire salmon
#

i tried looking finnbon's math tutorial but its too confusing

#

cant i do

for (int degree = 0; degree < 360; degree++) {
                        double radians = Math.toRadians(degree);
                        double x = Math.cos(radians);
                        double z = Math.sin(radians);
                        location.add(x, 0, z);
                        Bukkit.getScheduler().runTaskLater(ObsidianExpansion.i(), ()->{
        //particle
      Bukkit.getScheduler().runTaskLater(AlchimiaVitae.i(), () -> {
           //more particle
          }long
}long
                    }
```?
manic delta
#

guys can someone help me? I have a plugin but to upload it to spigot I need it to weigh 4mb, I already managed to compress it to compile it but the problem is that I use an external jar (and when compressing it only compresses the pom stuff and not external) that is not in maven-central a guy was helping me to be able to put that external-jar in the pom.yml but it is not possible, I have used mvn commands with that and still nothing.😢

#

I already published it to local maven and it still doesn't work

dire salmon
#

then i keep stacking Bukkit.getScheduler().runTaskLater() and spawning particles

sharp flare
#

run task later only runs once

#

If you want repeating one, should be runtasktimer

dire salmon
#

so same thing but replace runTaskLater with runTaskTimer?

#

and change parameters

#

it worked but big circle

#

gtg

#

tomorrow i continue it

sacred mountain
#

hey im still having a problem with my configs

#

Main plugin = Main.getPlugin(Main.class);

#

TFBConfig tfbConfig = plugin.getConfigUtils().getTfbConfig();

waxen plinth
#

?paste please

undone axleBOT
sacred mountain
waxen plinth
#

💀

sacred mountain
#

sry

misty current
#

does anyone have a clue about how can I disable mongo logging? I have tried getting the Logger with the getLogger method, using the IloggerFactory but nothing worked since minecraft does something weird with the default logger

vocal cloud
#
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger rootLogger = loggerContext.getLogger("org.mongodb.driver");
rootLogger.setLevel(Level.INFO);

Works for me though you need ch.qos.logback

main dew
#

How I can get client source? to see how the player e.g. processes and sends packets

vocal cloud
#

You build it via buildtools and import it into maven with spigot instead of spigot-api

main dew
#

no server side

vocal cloud
#

Um for that you'll need to find someone who's decompiled the client source

mortal hare
#

?paste

undone axleBOT
main dew
vocal cloud
mortal hare
#

So i haven't found a way to convert inventory's slot index to raw slot one, so i've made one myself and i decided to share it if you guys need it

#

it converts your container slot to raw slot, that way you can convert slots back and fourth

#

not particularly useful, but in rare cases it is

#

green is inventory slot

#

yellow is raw slot

#

and orange is raw slot converted from inventory slot (green)

misty current
#

1.18 spigot

#

Iirc it worked for me on a 1.8 server

#

No idea why it wouldnt now

shadow bluff
#

I need a dev that can do work tonight dm me if you can

vocal cloud
dire salmon
sharp flare
#

You're high af if its free

shadow bluff
#

Nope

tall dragon
#

i don't think this channel is meant for that kind of stuff.

shadow bluff
#

Oh

sharp flare
#

Spigot site has a subforum for this

elfin steppe
#

I've been looking for ages how to get my armorstand from another method into my new method. I am making an FFA plugin and i'm working on a /kit remove beast command, which will remove the armor stand containing the custom name (ChatColor.RED + "Beast"). I've been looking for hours but I just can't find a way to get the armorStand of the spawnBeast method into my removeBeast method. Can someone help me out?

tall dragon
elfin steppe
#
public void spawnBeast(Player p) {
        ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
        armorStand.setArms(true);
        armorStand.setBasePlate(false);
        armorStand.setCustomName(ChatColor.RED + "Beast");
        armorStand.setCustomNameVisible(true);

        ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
        helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
        chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
        leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
        boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        armorStand.getEquipment().setHelmet(helmet);
        armorStand.getEquipment().setChestplate(chestplate);
        armorStand.getEquipment().setLeggings(leggings);
        armorStand.getEquipment().setBoots(boots);

        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        armorStand.getEquipment().setItemInMainHand(sword);

        p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccessfully spawned Beast armor stand!"));

    }

 public void removeBeast(Player p) {
}
#

this is the code i got

#

I have been trying to work with so much things, i think ive been looking for a solution for 4+ hours now, but i just can't find anything.

#

I feel like it's not even hard to do it

#

But i just can't manage to get it

tall dragon
#

all you need to do is keep a reference when you created it

elfin steppe
#

I'm sorry, but can u maybe tell me how to do that?

#

I'm not a beginner in Java, i've followed multiple courses but there are just a few things that are still hard for me to understand

#

I've done a lot in this plugin already that works exactly as how i expected it to be, it's just this that i can't achieve.

tall dragon
#

well first off. tell me what exactly are you attempting to achieve

elfin steppe
#

Okay so

tall dragon
#

when a player runs a command it should spawn a armorstand with some armor im guessing

elfin steppe
#

I'm currently working on an FFA plugin, the spawning will be supported by armorstands. If i do /kit (kitname) it will spawn an armorstand with some armor and a custom name (in this case ChatColor.RED + "Beast"). Now I want a command to be able to remove these armorstands, f. ex. /kit remove beast. I am using the spawnBeast method to spawn the Beast armor stand but I just don't know how i'm supposed to get the Beast armorstand in my removeBeast method so I can get the armorstand removed (despawn it).

tall dragon
#

so in theory every player could have their own beast armorstand correct?

elfin steppe
#

Yes

tall dragon
#

okay

elfin steppe
#

It will just look like this: https://imgur.com/7VXqFLo . An ffa spawn where you will be able to select the kit that u want to spawn in with.

#

But if i misplace an armorstand or i want to move it to somewhere else i need a command to remove that armorstand

#

So i did /kit remove (kitname)

tall dragon
#

huh. but this looks like there will be one armor stand

#

not one per player

elfin steppe
#

Oh oops i'm sorry yeah

#

U can spawn as many as u want tho

#

But i'll prob only need one

tall dragon
#

okay one second

elfin steppe
#

alright

tall dragon
# elfin steppe alright

this is one way you could do it

public class ExampleClass {

    private final List<ArmorStand> beastStands = new ArrayList<>();

    public void spawnBeast(Player p) {
        ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
        armorStand.setArms(true);
        armorStand.setBasePlate(false);
        armorStand.setCustomName(ChatColor.RED + "Beast");
        armorStand.setCustomNameVisible(true);

        ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
        helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
        chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
        leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
        boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
        armorStand.getEquipment().setHelmet(helmet);
        armorStand.getEquipment().setChestplate(chestplate);
        armorStand.getEquipment().setLeggings(leggings);
        armorStand.getEquipment().setBoots(boots);

        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        armorStand.getEquipment().setItemInMainHand(sword);

        p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccessfully spawned Beast armor stand!"));

        beastStands.add(armorStand);
    }

    public void removeBeast(Player p) {
        List<Entity> nearby = p.getNearbyEntities(2, 2, 2);
        beastStands.removeIf((stand) ->
        {
            if (nearby.contains(stand))
            {
                stand.remove();
                return true;
            }
            return false;
        });
    }

}

bassically removeBeast() will look in a radius around the player for any beast armorstands and remove them

ebon coral
elfin steppe
#

Hmm, it looks like a good solution indeed.
Only thing is when i execute it it's not doing anything, but i'm not catching an error in the console either.

ebon coral
#

How do I fix this issue?

tall dragon
elfin steppe
#

Yeah

#

I'm just trying to figure out where you got 'stand' from

#

Shouldnt it be 'armorStand' ?

tall dragon
#

its just a variable name

elfin steppe
#

Oh okay

#
if (args.length > 0) {
            if (args[0].equalsIgnoreCase("remove")) {
                if (args.length < 2) {
                    sender.sendMessage(ChatColor.RED + "Please specify which kit armor stand you want to remove.");
                    return true;
                }
                if (args[1].equalsIgnoreCase("beast")) {
                    Player p = (Player) sender;
                    new Beast().removeBeast(p);
                    return true;
                }
#

Maybe i did do something wrong in here

#

But i don't think so

#

It runs the removebeast method

tall dragon
#

yea i think you did

#

show me the create

elfin steppe
#

i can send you the entire /kit command if u want

#

It contains /kit name and /kit remove name

tall dragon
#

if you want

#

put it in

#

?paste

undone axleBOT
elfin steppe
#

Okay

tall dragon
#

yea so i know whats going wrong

#

you are creating a new Beast class and calling remove from there

#

what you need to do is keep a reference to your beast class

#

one second

ebon coral
elfin steppe
#

tyt

tall dragon
elfin steppe
#

Ohhh, okay I understand my mistake now. I haven't really worked with references before tbf so I didn't really know that I had to use that.

#

Thanks a lot for your time, appreciate it

tall dragon
#

yea bassically you were creating a new reference every time. meaning the arraylist in there would be empty

#

while now. it will hold the same one. so you can access it

elfin steppe
#

I see. Again, thanks a lot for your help!

tall dragon
#

no problem.

elfin steppe
#

If I would reload my server the ArrayList would be empty again and I won't be able to remove it anymore right?

tall dragon
#

correct

#

so you will need to store the locations to the armorstands & remove them when the server stops then respawn them later

brave sparrow
#

If you reload everything is basically like the server just turned on

elfin steppe
#

Alright, will do that, thanks guys :)

quaint mantle
#

why isnt my plugin enabling? i have the enable thing
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("loging on to servr");
}

tall dragon
#

do you have an error?

quaint mantle
#

yes

tall dragon
#

show me

quaint mantle
#

it says that string a null so cannot work

tall dragon
#

ye, show me the stracktrace

quaint mantle
#

no thx

tall dragon
#

really

#

then i cant help

quaint mantle
#

im worried you could hack my computer with it

tall dragon
#

do you know what a tracktrace is?

quaint mantle
#

no

tall dragon
#

its bassically information so you can track in which line of your code went wrong