#help-development

1 messages · Page 1980 of 1

livid tundra
#

for testing purposes

floral pewter
#

You could probably set player metadata, or use a database

young knoll
#

^

#

Actually I believe you have to delete the player data file

livid tundra
#

ok

floral pewter
#

If it's for testing purposes, you could also just use true in whatever if statement you're using

livid tundra
#

k

floral pewter
#

Do true/false respectively

#

Both are very valid approaches

strong quartz
#

What would be the best way of doing something like this in a config file:

kits:
  - kit1:
      permission: "kits.kit.kit1"
      cooldown: "3d"
#

its fine I parse that a different way

floral pewter
#

This is already in YAML

strong quartz
#

Like how can I make the kits configurable so you can add more

#

but still access permissions and cooldown

floral pewter
#
kits:
  - kit1:
      permission: "kits.kit.kit1"
      cooldown: "3d"
  - kit2:
      permission: "kits.kit.kit2"
      cooldown: "3d"
strong quartz
#

I was looping through the "kits" StringList but it didn't seem to work

#

maybe I was doing it wrong if that looks correct

floral pewter
#

This is a dictionary, not an array

#

You need to loop through the keys, and then recurse into each

strong quartz
#

hm ok

#

I will further look into it

#

yes that's what I had

#

but I can't seem to loop through it like I wanted

quiet ice
#

this works?

#

Hm, let's see

#

?stash

undone axleBOT
strong quartz
#
    private static String getCooldownType(KitsPlugin plugin, Player player) {
        List<String> kits = plugin.config.getStringList("kits");
        for (String kit : kits) {
            String permission = plugin.config.getString("kits." + kit + ".permission");

            if (permission == null) continue;

            if (player.hasPermission(permission)) {
                String duration = plugin.config.getString("ranks." + kit + ".cooldown");

                if (duration.contains("s")) {
                    return "s";
                } else if (duration.contains("m")) {
                    return "m";
                } else if (duration.contains("hr")) {
                    return "hr";
                } else if (duration.contains("d")) {
                    return "d";
                } else {
                    continue;
                }
            }
        }

        return "";
    }
#

that is just getting the cooldown type

#

here is getting the cooldown duration

#
private static int getBanDuration(AppleLifesteal plugin, Player player) {
        List<String> kits = plugin.config.getStringList("kits");
        for (String kit : kits) {
            String permission = plugin.config.getString("kits." + kit+ ".permission");
            String durationType = null;

            if (permission == null) continue;

            if (player.hasPermission(permission)) {
                String duration = plugin.config.getString("kits." + kit+ ".duration");

                if (duration.contains("s")) {
                    durationType = "s";
                } else if (duration.contains("m")) {
                    durationType = "m";
                } else if (duration.contains("hr")) {
                    durationType = "hr";
                } else if (duration.contains("d")) {
                    durationType = "d";
                } else {
                    continue;
                }

                try {
                    return Integer.parseInt("duration".replace(durationType, ""));
                } catch (NumberFormatException exc) {
                    return 0;
                }
            }
        }

        return 0;
    }
#

always returns 0

young knoll
#

There’s also getMapList

misty current
#

can I make the block a player is looking at clickable? (ie makes the client play the hand animation)

quiet ice
#

I mean, you are probably looking for getKeys

misty current
#

like if someone were to try and click on an iron door

young knoll
#

Or swingOffHand

misty current
#

yes but it would play only once

#

wouldn't it

young knoll
#

Yes?

#

You always swing your arm when mining a block

misty current
#

i wanted to keep the animation going as long as the player is right clicking

young knoll
#

Well the event fires every tick if they hold right click

#

So

misty current
#

okay thanks

tall dragon
#

imagine eating

simple anvil
#

i was getting help in a diffrent server
so this is not my clip/video
but is this a bug

young knoll
#

We can’t see your code

quiet ice
young knoll
#

So we have no idea what’s going on

simple anvil
#
@EventHandler
    public void onSneak(PlayerToggleSneakEvent event) {
        Player player = event.getPlayer();
        Bukkit.broadcastMessage("Sneaking: " + player.isSneaking());
    }
simple anvil
#

also if i change the event to PlayerMoveEvent the output will chagne

young knoll
#

The event runs before they actually sneak

quiet ice
#

Given to how most of these mods behave, they should be classified as hacks/cheats

young knoll
#

Lol?

simple anvil
#

t h is is plugin

#

not moid

quiet ice
#

All of them

young knoll
#

I see a clock, a compass, and an arrow counter

quiet ice
#

Yes, that is an unfair advantage and nullifies the reason to have a clock

young knoll
#

Who uses clocks

tall dragon
simple anvil
young knoll
#

What about it

quiet ice
#

You could just flip the boolean to get the state after the sneaking, it's not that hard to do that

young knoll
#

Or use the method I sent

#

That’s part of the event

quiet ice
#

Probably better

simple anvil
young knoll
#

Well yeah

#

If they are sneaking when they move, then they are sneaking

simple anvil
#

what about player sneak

#

yea

simple anvil
#

also how to i use player.getNearByEntitys

dusk flicker
#

check the docs

#

?jd-s

undone axleBOT
simple anvil
#

getNearbyEntities(double x, double y, double z)

#

how would i make it a 30 block radius

dusk flicker
#

read

young knoll
#

15 to each

dusk flicker
simple anvil
#

i did
1/2???

dusk flicker
#

half of whatever the box you want to be

#

so if you want 30, 15; as Coll said

simple anvil
#

so 15, 15, 15

dusk flicker
#

yes, if you want it in every axis

simple anvil
#

and it will output all the entities to the console?

dusk flicker
#

No? It will give you a list of entities, as it says

young knoll
#

No it’ll return them in a list

simple anvil
#

how do i send the list?

young knoll
#

?learnjava

dusk flicker
#

?learnjava

undone axleBOT
dusk flicker
#

LOL, not sure if thats just on my side but both of those bot messages are in one for me

simple anvil
#

yea that one was coming for me

#

thanks

misty current
#

why does intellij warn me about using optionals as a field?

#

is there any reason why i should not?

wary harness
#

any one can explane me how would I get heads with skins for players which never playerd before

#

to generate base64

#

code

#

should I get texture from mojang server

#

some one could point me to some spigot tutorial

#

because I got in problems gui opening to long because heads can't be loaded from mojang data base

patent horizon
#

is it safe to blind cast a HumanEntity to Player?

young knoll
#

Afaik, yes

misty current
#

it should be, but if some plugin implements humanentity for any reason, you might get some troubles

#

i'd suggest putting an instanceof check

patent horizon
#

alr

red sedge
#

is there anyway i can sort the list of configuration values without making the them objects?

#

so like

#

the x value has price in it

#

and i want to sort the values by the price value in the configuration

arctic moth
#

anyone know wtf just happened and why there are a ton of invisible falling blocks

#

btw is there a way to get the blocks in a spherical radius (while im getting help for this lol)

floral pewter
young knoll
#

You can compare the distanceSquard from the block to the center

young knoll
#

Ew .distance

floral pewter
#

Fight me

quiet ice
#

Yeah, use distanceSquared

floral pewter
#

😉

arctic moth
#

this is the error

#

i dont understand why its getting an infinite number

#

and where

young knoll
#

MiscManager line 52

arctic moth
#

its literally count++ lol u sure?

#

its adding 1 to a number

young knoll
#

That’s what the error says

arctic moth
#

huh

chrome beacon
#

Make sure the code you are running is up to date

chrome beacon
#

Then the error wouldn't point to count++

arctic moth
#

or does it

#

reloaded, but im pretty sure its the same

#

btw this is being spammed

young knoll
#

Line 56 now

#

You need to learn to read stack traces

arctic moth
#

ik xD

#

ok its probably my shitty vector code

#

multiplying

#

entity.setVelocity(block.getLocation().toVector().subtract(entity.getLocation().toVector()).multiply(1/(10 - power)).normalize());

eternal night
#

I mean normalizing the vector should prevent this ?

arctic moth
#

ye

eternal night
#

euclidean product goes down to 1 which should be fine

#

but eehh

arctic moth
#

so why this not working lol

#

btw if it helps, the power im using is 5

#

so its multiplied by 0.2

#

so why is it freaking out and making invisible falling blocks

#

and erroring

arctic moth
young knoll
#

I bet it’s multiplying by 0

#

If power is an int

arctic moth
#

lol

cobalt tinsel
#

i need help

young knoll
#

Granted multiplying by 0 still shouldn’t be an issue

cobalt tinsel
#

im making killstreaks and i want to send a chain of messages 1 by 1

#

with 1s of delay between messages

#

cuz

#

if i do

young knoll
#

?scheduling

undone axleBOT
cobalt tinsel
#

thanks

#

k so

#

new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);

#

if i want to send 3 messages

#

i need to put the same code

#

with different text?

arctic moth
#

realizes that im not connected to wifi

#

wait how is discord working then

#

xD

young knoll
#

Make a queue of the messages and then poll from the queue each time

young knoll
#

When the queue is empty, cancel the task

cobalt tinsel
#

new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage("Mooooo!");
Bukkit.broadcastMessage("Mooooo!");

Bukkit.broadcastMessage("Mooooo!");

}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);

cobalt tinsel
#

like that?

cobalt tinsel
#

idk im asking

arctic moth
#

no

#

its not

young knoll
cobalt tinsel
#

how? :c

young knoll
#

Poll is the method to retrieve an element from a queue

arctic moth
#

oh

cobalt tinsel
#

how can I use poll

young knoll
#

?learnjava

undone axleBOT
cobalt tinsel
#

bro I know about java

young knoll
#

Specifically, learn about queues

cobalt tinsel
#

but not, spigot

young knoll
#

Queues are not a spigot concept

cobalt tinsel
#

im alr learning java

#

didn't reached queues

#

im on Arrays

#

lol

young knoll
#

I mean I guess you could use an array too

#

And just increment the index each iteration

arctic moth
#

new BukkitRunnable() {
int count = 0;
@Override
public void run() {
Bukkit.broadcastMessage(listofmsgs.get(count));
count++;
if(count > listofmsgs.size()) {
this.cancel();
}
}
}.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay /, 20L * 5L /<-- the interval */);

#

idk

#

lol

arctic moth
#

@cobalt tinsel

#

that might not work but try it ig

cobalt tinsel
#

no

#

i don't think so

arctic moth
#

lol

cobalt tinsel
#

but

#

the problem is

#

i don't need to cancel

#

cuz my runnable it's inside of a switch

#

so I just need to send the messages with delay

young knoll
#

You still need to cancel it

arctic moth
#

btw listofmsgs is new ArrayList<>() and add stuff

cobalt tinsel
#

1s between message

young knoll
#

Otherwise it’ll go on forever

cobalt tinsel
#

Ikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

#

Im just saying

#

that cancelling it, it's not the problem

cobalt tinsel
arctic moth
#

same thing

cobalt tinsel
#

yeah

#

but it prefer 2nd one

woeful crescent
#

is there any way to call EntityLiving.heal using the API?

cobalt tinsel
#

wdym

#

to check health?

woeful crescent
#

no

#

to heal a player with a cause, event call, etc.

#

as if it actually happened

#

entityliving.heal does that

cobalt tinsel
#

oh, well make an if

woeful crescent
#

no like

#

using a regain reason, everything like that

#

just everything that the server does

cobalt tinsel
#

any example?

woeful crescent
#

public method in EntityLiving

cobalt tinsel
#

oh

woeful crescent
#

i could just copy it..

#

but i dont really want to

arctic moth
woeful crescent
#

intellij idea

cobalt tinsel
woeful crescent
#

with gradianto natural theme

cobalt tinsel
#

you can tell by looking at it

arctic moth
#

lol green theme

sharp mango
#

how do i export my mc plugins from eclipse into minecraft?
i made my own server which is hosted on my wifi network but i dont know how to export plugins into the server

#

can someone help me

arctic moth
arctic moth
sharp mango
#

i tried that

#

and then when i go into server and do /pl to see plugins, i cant see the one i created

#

so...

young knoll
cobalt tinsel
#

new BukkitRunnable() {
@Override
public void run() {
Bukkit.broadcastMessage(CC.translate(Arrays.asList(
"",
ChatColor.YELLOW + "[☢] A Tactical Nuke is coming!"),
ChatColor.YELLOW + "10 seconds until explotion",
ChatColor.YELLOW + "9 seconds until explotion",
ChatColor.YELLOW + "8 seconds until explotion",
ChatColor.YELLOW + "7 seconds until explotion",
ChatColor.YELLOW + "6 seconds until explotion",
ChatColor.YELLOW + "5 seconds until explotion",
ChatColor.YELLOW + "4 seconds until explotion",
ChatColor.YELLOW + "3 seconds until explotion",
ChatColor.YELLOW + "2 seconds until explotion",
ChatColor.YELLOW + "1 seconds until explotion"
));

                        this.cancel();
                }
            }.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
#

all of that messages will

#

be

#

insta sent

arctic moth
#

ahh my eyes i just changed my theme to a different one and now its stuck in light theem

#

lol one dark theme be like

cobalt tinsel
#

how can I add a delay on tht

tall dragon
cobalt tinsel
#

how

arctic moth
cobalt tinsel
#

oh wait

arctic moth
#

nvm

cobalt tinsel
#

i think i can do sth

#

ah no

#

nvm

cobalt tinsel
arctic moth
tall dragon
# cobalt tinsel that's a runnable
Bukkit.broadcastMessage("[☢] A Tactical Nuke is coming!");
        new BukkitRunnable() {
            int count = 10;
            @Override
            public void run() {
                Bukkit.broadcastMessage(count+" seconds until explotion");
                
                if (count <= 1) {
                    this.cancel();
                    return;
                }
                count--;
            }
        }.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
cobalt tinsel
#

oh

#

that will be it?

#

nice!

tall dragon
#

this could be a way to do it yea

cobalt tinsel
#

oh k

#

thanks

young knoll
#

Explotion

cobalt tinsel
#

if i do that

#

isntead of count--

#

it will be better right?

tall dragon
#

that will subtract 10 from count

cobalt tinsel
#

yea

tall dragon
#

idk if you want that

cobalt tinsel
#

yea it's fine

tall dragon
#

well then do that

cobalt tinsel
#

bc

livid tundra
#

how do I use the map from the config maplist

cobalt tinsel
#

adding a chain of messages will be harder

young knoll
#

I believe it’s specifically List<Map<String, Object>>

livid tundra
#

but when I use config.getmaplist, the maps I get in the list are Map<?,?>

young knoll
#

Yes

#

But you can always cast them

livid tundra
#

just to make sure, casting is (object to cast to(value)), right?

young knoll
#

Map<String, Object> newMap = (Map<String, Object>) map

#

Your ide can add the cast for you if you just define the type

livid tundra
#

thanks!

cobalt tinsel
#

last question

sly trout
#

hey guys would Gson be able to save the data object to a file ?

#

this is the class

fierce swan
#

So I'm using Jackson to save data and at any point in time when I try to save data I can but as soon as I go to stop my server it says this. My onDisable function contains the same function call that saves data as the command so it's not that, but I think it's smth to do with how I shaded it?

Here's my pom.xml: https://www.toptal.com/developers/hastebin/runozeteda.xml

fierce swan
#

I've tried so many different solutions and have been trying to fix this for weeks

sly trout
#

Inside of an object

#

Because obj.addproperty only works with string number and boolean

fierce swan
vocal cloud
#

Ran mvn clean as well?

fierce swan
#

Yep

#

I'm trying deleting just jackson-databind from my local repository and ig we'll see if it errors at all again

cobalt tinsel
#

hey

#

how could I remove 5 hearths to nearby players

vocal cloud
#

?jd

vocal cloud
#

Nearby entities is cleaner just use it

cobalt tinsel
#

k

cobalt tinsel
#

for (Player p : Bukkit.getOnlinePlayers()) {
List<Entity> nearbyentities=player.getNearbyEntities(10, 10, 10);
if(nearbyentities instanceof Player) {
double health=((Player) nearbyentities).getHealth();
((Player) nearbyentities).setHealth(health - 10.0);
}

            }
vocal cloud
cobalt tinsel
#

Yes

vocal cloud
young dome
#

What is the cause of this problem? It is quite occasional, does not leave any additional information apart from a NPE in the server console (nothing client log)

#

I did some research but in vain

wet breach
#

as in you quit the game

young dome
# wet breach does it only happen when you disconnect?

It doesn't happen when I log out, I think it's because of my scoreboard packets, however, I'm not sure what I'm saying because there is no problem with the score packets I send when the player logs in for the first time, maybe a packet that the decoder can't decode It doesn't happen when I log out, I think it's because of my scoreboard packets, however, I'm not sure what I'm saying because there is no problem with the score packets I send when the player logs in for the first time, maybe a packet that the decoder can't decode

sullen marlin
#

DO NOT USE PACKETS FOR SCOREBOARDS

frosty geyser
#

lol

young dome
# sullen marlin DO NOT USE PACKETS FOR SCOREBOARDS

it avoids flashing! Bukkit does too many things, it doesn't go straight to the point! And, I don't really think that's the problem, it's more the decoder of the player's channel that does shit in my opinion

young knoll
#

Lol you can avoid flashing with prefixes and suffixes

young dome
#

That's not the problem, the flashing is more due to the fact that by passing through bukkit, there are more things done to the scoreboard, things that are sometimes useless in some cases of use, and this extra processing causes flashing

young knoll
#

That’s

#

Not how things work

#

But yes bukkit does make sure to send all your scoreboard data off to China

young dome
#

Even you admit that xd

#

So, packets are very good in this case to send directly what we want

young knoll
#

You do realize it doesn’t matter how much processing Bukkit does to the scoreboard

vocal cloud
#

If you make a new scoreboard every tick then you'll get flashing.

young knoll
#

In the end it’s still just sending a packet

#

Bukkit could piss around with the scoreboard for a half hour and that still wouldn’t cause flashing

young dome
wet breach
young knoll
#

Just a half hour delay

vocal cloud
young knoll
#

Changing entries can cause it to flash on slower connections

#

Probably because the remove packet for the old entry and the add packet for the new one get split up

young dome
young knoll
#

But you can just use prefix and suffix for that

ancient plank
#

my scoreboard doesn't flash

young knoll
#

Plenty of non flashing scoreboards have been made with the API

wet breach
#

either just accept that packets can get mangled

young knoll
#

But it’s faster!!!1

wet breach
#

or use the api

#

at least with the API if a packet gets mangled it will get resent

young dome
wet breach
#

obviously there is a problem if you are complaining about clients being disconnected and the issue being related to your scoreboard

young dome
#

Yes there is a problem but I doubt it is related to the scoreboard

wet breach
#

Most IO problems occur because of someone messing with packets. Unless you are sending packets directly for everything else as well, the only thing you stated you directly send packets for is the scoreboard

#

You can disagree what everyone else is saying in what the problem is, doesn't mean that isn't the problem. Especially when the owner of Spigot even stated that you shouldn't send scoreboard stuff via packets directly.

young knoll
#

I mean we’ve had an API for many years

wet breach
#

So either you know better then everyone else here, which wouldn't make sense because you came here for help or everyone else here is correct on what the issue is

#

if you don't want to change how you are doing scoreboards that is fine no one is forcing you to do anything, just that you need to accept that clients getting disconnected is just a thing that will happen every now and then

next stratus
#

Is it bad to decompile a premium plugin just so I can work out how to use the api if they don't give documentation? Like I won't share code I just wanna work out what's going on

sullen marlin
#

the API is literally a wrapper around packets

#

do what you do with packets with the api and the result is the same

worldly ingot
next stratus
#

I mean I gotta try and add support for a plugin but the dev won't even give api docs... 😔

#

He even heavily obfuscated the api

young knoll
#

The dev will be informed and you will be collected by the men in black within 13 minutes

#

Who tf obfuscates an API

next stratus
#

$35 my bad

young knoll
#

So it’s from mcm

#

Because that’s above the spigot price cap

next stratus
#

Yeah it is mcm kids are a different breed

young knoll
#

Mcm moment

wet breach
young knoll
#

Thermal expansion?

worldly ingot
#

Something enchants. Can't remember the first part

#

Really, most enchantment plugins are guilty of that practice

#

but that plugin was before our rule change, so ye

wet breach
#

Token Enchant

#

is what I think it refers to

wet breach
worldly ingot
#

That's the one. Token

young knoll
young knoll
wet breach
young knoll
#

Or an execution

young dome
wet breach
#

I am not hurt, just many people come here for help but then refuse that help or instead refuse to accept what everyone is saying as true, which is counter intuitive to the purpose they come here to begin with.

hybrid spoke
#

frostalf is always hurt

young dome
young knoll
#

Did you shade Jackson yourself

#

Did you relocate

#

Changing the package to avoid conflicts

#

Maven or gradle?

#

You should

wet breach
#

relocating is part of shading. It helps to avoid conflicts when there is multiple versions because the package path is the path that gets put on the classpath. If there is multiple versions, the version that gets used is which ever gets loaded/registered first.

#

it should be standard practice when shading that you relocate dependencies you actually need even more so if its version dependent

#

also shows how to exclude transitive dependencies from shading too

#

had a problem at one point with things wanting to get shaded in that I didn't specify so I forced maven to not shade those things in lmao

vocal cloud
#

Holy exclude batman

wet breach
#

I never fixed the duplicate bukkit ones lmao

#

I did that out of frustration if I remember right because bukkit kept getting shaded in XD

#

was really annoying, but all those excludes were the dependencies shaded into bukkit

wet breach
#

that means the dependency was compiled with a higher version of java then what you are compiling with

#

either use a higher java version, or use a dependency that supports the java version you are compiling with

wide coyote
#

hey i am trying to encode a textcomponent with gson but i got this error
java.lang.reflect.InaccessibleObjectException: Unable to make field int java.awt.Color.value accessible: module java.desktop does not "opens java.awt" to unnamed module @3444d69d

#

any idea?

young knoll
#

You’ll need a custom serializer

wide coyote
#
    public byte[] encode(T message) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
            this.gson.toJson(message, this.type.getType(), writer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return out.toByteArray();
    }
wide coyote
#

maven compiler plugin has source and target section you can change it

#

and project structure > project > project sdk if needed

young knoll
#

I have an example for a location serializer

#

They aren’t too complicated

wide coyote
#

everything works now but color

#

how can i fix it

young knoll
#

?paste

undone axleBOT
young knoll
#

That’s an example adapter for Location

#

Color should be much simpler

#

Huh, I have a typo in that :p

wide coyote
#

yes but im not just trying to encode a color

#

i am trying to encode a textcomponent

#

which has color in itself

#

i mean ChatColor has Color*

young knoll
#

Yes, making an encoder for that should work

#

Otherwise you need to make one for ChatColor

#

Or possibly one for component

wide coyote
young knoll
#

You can’t use gson.toJson in your encoder

#

That’s kind of the point of the encoder, to tell that method how to store something

vestal moat
#

Is there any reason bukkit doesnt send plugin message to client

#

My client isnt receiving it

worldly ingot
#

Did you register the outgoing channel?

vestal moat
#

Yes

#
   public void onEnable() {
        this.getServer().getMessenger().registerOutgoingPluginChannel(this, "testclient:main");
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        getServer().getScheduler().runTaskLater(this, () -> {
            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF("moduledisable");
            out.writeUTF("{\"modules\":[\"packet-canceller\"]}");
            e.getPlayer().sendPluginMessage(this, "testclient:main", out.toByteArray());
        }, 5);
    }
#

(i register the event listener i just removed the line)

tranquil viper
#

what's the best way of storing something like a hashmap in a .yml with the ability to freely add and remove from it

eternal oxide
#

getConfig().put("path.to.map", Map)

#

may be set not put. I can't remember

young knoll
#

It’s set

tranquil viper
#

wait

#

you can actually put maps

#

in config files?

young knoll
#

As long as the keys and values are configuration serializable

tranquil viper
young knoll
#

It’s an interface

#

ConfigurationSerializable

stark silo
#

@ancient planki've never done anything, i've been downloading the sace plugin from spigotmc, but i'm banned i can't get into the ip ban for no reason why i'm banned

#

pls help

#

@tender forge

young knoll
#

Are you using a vpn

#

Is there a ban reason

stark silo
#

off

stark silo
stark silo
wide coyote
#

bungeecord has a method for that but i dont think spigot has one

#

the method you currently use is for plugin messaging

west bone
#

a

sharp saffron
#

idk how related this is to development but i feel this chat is the best place to put it. So im using a windows PC with intelij to code spigot plugins when I try to compile the plugin my anti virus (mcafee which came pre-installed) says "we have stopped something malicious" i cant exactly remember the message but it was saying something about "fileless threats" does anyone know why this is happening?

#

FYI its not too big of a problem as the file does compile into a .jar but i just want to know why its happening and should i be concerned

sullen mica
sharp saffron
#

so you think its just a false alarm basically?

sullen mica
sharp saffron
#

ok ty!

sharp flare
#

does this look bad when run in a live server? its a runnable that run every 3 ticks

#

executed spark for 5 minutes for that profile

drowsy helm
#

what exactly does the runnable do

sharp flare
#

Its like a guardian mob beside you, literally floating the right side

#

It will target any entities that damaged the player

#

I'm not using nms for that

drowsy helm
#

so is the runnable just a teleport?

#

or what

sharp flare
#

Pretty much yes

#

The one that will bork the timings

#

Unless teleportation can be done in another thread which is not possible ig

red sedge
#
  1. What is the fastest way to clone an array?
  2. How can I reverse an array, fast
midnight shore
#

how can i save a yaml configuration?

#

is it save(file); method?

red sedge
midnight shore
#

you could make something like this

blazing scarab
midnight shore
#

i think it will work

midnight shore
#

Cannot invoke "net.minecraft.nbt.NBTBase.getTypeId()" because "var1" is null
what does this mean

blazing scarab
#

Var1 is null

midnight shore
#

but i don't have any var1 in my code

wide coyote
#

send code please

midnight shore
#

i'm saving a PlayerHead itemStack to a file

#

this builds the item

#

and this is an example of an item

#

please help

sharp flare
#

are u able to retrieve your itemstack from the file properly

midnight shore
#

i can't even save it, i didn't made the retrieve part yet

sharp flare
#

u using yml for it?

midnight shore
sharp flare
#

the first one should do it ig, as long as the file is being written properly and aint blank after executing the save method

midnight shore
#

i don't have any file because whenever it tries to save the item it throws an error

#

and it doesn't save anything

#

also i think its a problem with player head data because as you can see in the error it says something about SkullMeta

midnight shore
sharp flare
#

have you made a method where it makes the yml and loads/save it #onEnable()

midnight shore
sharp flare
#

thats from the spigot guide and I used it for my backpacks that saves the contents

midnight shore
#

so basicallly there is a problem creating the file?

sharp flare
#

if it doesn't exist in the first place and you're trying to save to it then might be it

midnight shore
sharp flare
sharp flare
midnight shore
#

oh it is in the main file ok

sharp flare
#

gets the embedded yml file and saves it in the plugin's parent folder along with its contents if it has

sharp flare
midnight shore
#

i can't. The whole point of this is that it does everything automatically, saving every CustomItems enum value (builded with the ItemBuilder) into a yml file in the plugin folder

#

i have like 100 custom items values

#

i can't make 100 files in the package folder

sharp flare
#

so you can't save those in a single yml file in its contents?

midnight shore
#

i'd prefer having multiple files but i can try thart

sharp flare
#

you can retrieve those as list then to itemstack array

midnight shore
#

like this?

sharp flare
#

maybe you can get an idea from this, I'm about to go out

midnight shore
#

ty bye

#

btw my problem is that i can't save a PlayerHead SkullMeta

#

the creation part now is working fine

sharp flare
#

var1 is null, that explains it already

#

you gotta focus on that var1

midnight shore
#

but thats not a thing i made, thats a NBTBase class var

sharp flare
#

I'm not familiar with nbt's unfortunately, hopefully others can help you with that

midnight shore
#

ty

misty ingot
#
    private void registerFile() {
        file = new File(getDataFolder(), "messages.yml");
        fileConfig = YamlConfiguration.loadConfiguration(file);
        saveFile();
    }

    public void saveFile() {
        try {
            fileConfig.save(file);
        } catch (IOException e) {

        }
    }
#
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;```
#

I am very new to plugin development so please forgive me if the error is very simple or solve and I just look very dumb here

#

All I want to do is create a messages.yml file alongside the normal config.yml file so I can store the messages stuff there and let the user edit all sorts of messages in the plugin

wary harness
#

What would be the bast way to save player skins data to file

#

and when I should update it

#

should I go with yml file

#

or json

#

and put all data to one file

misty ingot
#

works every time

floral pewter
wary harness
misty ingot
wary harness
floral pewter
#

Sounds good

#

But why would you want to save skin data?

wary harness
#

but no sure when should I update it

#

in case skin changes

#

you are limited on 600 request per 10 min

misty ingot
#

you want players to not be able to change their skins?

wary harness
#

to mojange servers

wary harness
#

I got gui which laggs

rotund pond
floral pewter
#

Are you making a custom plugin?

#

Or are you trying to work with an existing one?

floral pewter
rotund pond
#

Right, maybe you could just cache skin data instead of storing it in a db

dull whale
#

is there a function for 1.7, 1.1, 1 -> 2

zealous osprey
#

Is there an alternative to the PlayerChatTabCompleteEvent, since it is deprecated ?

#

Might just need to use TabCompleteEvent and check manually

#

Oh that works perfectly for my needs, neat

lost matrix
red sedge
#

if i want to replicate a entitydamage event

#

without calling it

wet stream
#

When I'm running my command from file CreateCompany.java code: package `com.biolegs.company;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class CreateCompany implements CommandExecutor {

private Company plugin;

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = (Player) sender;
    plugin.eco.depositPlayer(player, 10);
    return false;
}

} it shows to me this error in the console: Caused by:java.lang.NullPointerException: Cannot read field "eco" because "this.plugin" is null ` I can't show full message because its too long how can I fix it?

lost matrix
wet stream
#

but how

#

I mean on the top I'm writing to create a private variable called plugin oh and this
"Company" its the name of main class

lost matrix
#

By using very very basic java...

#

?di

undone axleBOT
sharp flare
#

backread what I sent

#

its a picture

sharp flare
lost matrix
#

?learnjava

undone axleBOT
misty ingot
smoky oak
#

removing a value from a persistent data container - that change is effectively saved, right?

brittle loom
#

Hello, does anyone know how to get the hand item location of a small armour stand? If you could help it would be much appreciated.

lost matrix
opal juniper
#

oh wait

#

lol

#

misread

lost matrix
brittle loom
#

Thanks I'll have a look at this

cobalt tinsel
#

hello

#

got a question

#

is any way to cancel pvp near some coordinates, like i get spawn coordinates and near it, nobody can fight

dapper ether
#
    @EventHandler
    public void onChestExit(InventoryCloseEvent e) {
        if (e.getView().getTitle().contains("LOOTCHEST")) {
            e.getInventory().getLocation().getBlock().setType(Material.AIR);
        }
    }

The chest doesnt deletes, why?

lost matrix
cobalt tinsel
#

radial

#

cuz cancelling entitydamagebyentity wouldn't be that professional hahaha (with an equals on locations)

lost matrix
#

And cancel the EntityDamageByEntityEvent if the radiusSqared is smaller than N * N

cobalt tinsel
#

kk

misty ingot
lost matrix
dapper ether
#

bruh

#

im so dumb

#

sorry

misty ingot
#

lol

lost matrix
#

Happens to everyone

sharp flare
misty ingot
#

what is a config manager

dapper ether
lost matrix
cobalt tinsel
#

ih

#

oh

cobalt tinsel
#

i need to put an uuid value on there

#

or an String

#

should i put "World"?

lost matrix
cobalt tinsel
#

k

smoky oak
#

if i set a permission to 'default: false' does someone with '*' still have it?

cobalt tinsel
#

thx

eternal oxide
#

depends

#

if your perms plugin understands *, and the perm is registered in your plugin.yml

smoky oak
#

craftbukkit apparantly understands '*' as 'everything'

#

on a different note, player.setMaxHealth(double) is deprecated, would player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(double); work the same?

smoky oak
#

k

misty ingot
#

hey so I have a file which is config.yml and I have a file which is messages.yml
How do i specify in the code when I want to take data from which file

wary harness
#

hey after appalyign new metadata to item stack which is in player inventory do I need to set new itemstack or current one will be changed ?

sharp flare
lost matrix
wary harness
#

I am settign skin on head

#

async

#

and it is not taking effect

#

and now I am thinking

#

do I need to set dam stack again

lost matrix
#

You cant interact with any spigot api from another thread. Even if it sometimes looks like it.

wary harness
#

brain freez

wary harness
midnight shore
#

what dependency should i add in order to have access to this class?

wary harness
#

something like this

wary harness
#

insted of spigot-api

#

you add dependancy of spigot

midnight shore
wary harness
midnight shore
wary harness
#

for example

wary harness
# midnight shore

I think minecraft-server will return mojang mappings(Classes are named with original names of majang )

midnight shore
#

I also have spigot

wary harness
cobalt tinsel
#

which event is the one that lets you throw things

wary harness
#

that can access only spigot api

midnight shore
#

So i also need to have spigot?

cobalt tinsel
#

playerinteractevent?

wary harness
#

like on my screen shoot up

#

but you will need to build it with BuildTools

midnight shore
#

Okay

wary harness
#

to your maven repository

cobalt tinsel
#

which event is the one that lets you throw things

wary harness
cobalt tinsel
#

k

#

thanks

wary harness
#

something like that

#

or PlayerItemDropEvent

cobalt tinsel
#

PlayerDropItemEvent

wary harness
cobalt tinsel
#

yep

smoky oak
#

I'm opening a custom inventory, how can I check if a closed inventory is the corresponding inventory? InventoryView is an interface, and the title can be changed by players afaik

young knoll
#

Save the view to a set

smoky oak
#

thanks
also i found this

tardy delta
#

i see people using a list in places where they could use a set

smoky oak
#

I'm trying to mimimize my code so that image is pretty useful for me

misty ingot
#

is there a way so that when my plugin generates its config.yml in the folder, it keeps the comments
Like this -

##### GENERAL CONFIG #####
spawnonjoin: false
spawnondeath: false

##### MESSAGES CONFIG #####
prefix: "&7[&cPlugin&7]&r "

But when the file generates, it removes the comments, I dont want that

tardy delta
#

thats a snakeyaml issue

#

or how it is called

cobalt tinsel
#

hey

tardy delta
#

it's fixed in newer versions iirc

cobalt tinsel
#

how much staruation should i put if i want to fill their steaks

young knoll
#

Modern versions of 1.18.1 preserve comments

cobalt tinsel
tardy delta
#

1.17 is also doing it afaik

cobalt tinsel
#

player.setSaturation(20.0F);

young knoll
#

Saturation is not hunger

cobalt tinsel
#

oh

#

good point

young knoll
#

It’s the hidden value behind hunger

smoky oak
#

its 20 points, half a bar each. Saturation is a 'second' hunger bar that drains first

cobalt tinsel
smoky oak
#

the reason golden food is so good is because it's saturation is higher than it's hunger

young knoll
#

setFoodLevel iirc

smoky oak
#

it can fill up both bars

cobalt tinsel
#

oh

misty ingot
tardy delta
#

or how is it called

misty ingot
#

I use this

young knoll
#

That’s SnakeYaml

misty ingot
#

oh

#

well

cobalt tinsel
#

who's on mc rn that can help me testing

tardy delta
#

snek

#

not me

misty ingot
cobalt tinsel
#

1.8

tardy delta
#

but i can start my launcher

cobalt tinsel
#

or 1.7

tardy delta
#

oh god 1.8

misty ingot
#

ye ol 1.8

cobalt tinsel
#

og minecrafter

quaint mantle
#

1.2.5 is OG minecraft without singleplayer chat

misty ingot
#

you misspelled old

misty ingot
#

alright

#

tell me the ip

#

@cobalt tinsel

cobalt tinsel
#

wait

tardy delta
#

tell me too

cobalt tinsel
misty ingot
#

sussy

tardy delta
cobalt tinsel
misty ingot
#

I dont

cobalt tinsel
#

it's a thing that u use to "open" your port

#

so people can join your localhost

tardy delta
#

where is the ok button lol

misty current
#

does isBlockPowered() work on non redstone blocks? (stone, grass blocks...)

tardy delta
#

oh lol its not visible on my screen

tardy delta
#

stupid 2nd screen

misty current
#

does it also work on translucent blocks?

young knoll
#

Maybe

#

It works on blocks that can be powered

misty current
#

so on blocks like glass it would not work

smoky oak
#

wouldnt it throw back false then

young knoll
#

Probably

misty current
#

aight i'll test, thank you

cobalt tinsel
#

you can join back

#

@misty ingot

misty ingot
#

k

#

joining

errant narwhal
#
    private Plugin plugin = Main.getPlugin(Main.class);
    public void customRecipe() {
        ItemStack item1 = new ItemStack(Material.WOOD_PICKAXE, 1);
        ItemMeta meta = item1.getItemMeta();
        meta.setDisplayName(ChatColor.GRAY + "Wooden Hammer");
        ArrayList<String> lore = new ArrayList<>();
        lore.add("hammer!");
        meta.setLore(lore);
        item1.setItemMeta(meta);
        @SuppressWarnings("deprecation")
        ShapedRecipe f = new ShapedRecipe(item1);
        f.shape(" # "," $#","$  ");
        f.setIngredient('#', Material.WOOD);
        f.setIngredient('$', Material.STICK);
        plugin.getServer().addRecipe(f);
    }

someone help please idk what i wrong but i can't craft my hammer

tardy delta
#

1.8 pvp

smoky oak
#

try using a non-deprecated method

#

they're flagged like that for a reason

young knoll
#

(You need a namespaced key)

errant narwhal
young knoll
#

?jd-s

undone axleBOT
errant narwhal
quiet ice
#

we have an even shorter command for the spigot javadocs now?

gleaming zenith
#

Is there a for(ItemStack i: p.getInventory().getAllItems()){}?

#

or something like that

young knoll
#

.getContents

gleaming zenith
#

thx

quiet ice
#

or just for (ItemStack i : p.getInventory())

young knoll
#

Oh yeah inventory is iteratable

wary harness
#

Can you set itemmeta to final ItemStack ?

young knoll
#

Yes

wary harness
main dew
#

How check if Player on ground in PlayerMoveEvent?

smoky oak
#

if the vertical speed is 0 that's a pretty good bet but i think there's a method for that

#

you can use player.isOnBlock, but that can be changed by the client and is therefore deprecated

young knoll
#

Yes but it’s deprecated

#

Because it can be spoofed

long fog
#

how do i get the paper api from buildtools

young knoll
#

You don’t

tardy delta
#

can a record have an abstract method?

long fog
#

what

young knoll
#

Paper doesn’t use buildtools

tardy delta
#

it says not allowed

young knoll
#

Go talk to paper

smoky oak
smoky oak
#

one morme thing

young knoll
#

I believe y velocity is constantly negative

#

Because “gravity”

smoky oak
#

you need to check if the player's actual y component ends on .000, or they could be swimming up into a block

#

also getVelocity() returns the vector the player is moving in

#

if they're on the ground they're not moving

#

on a completely different topic, can i somehow serialize ItemStack[] into a string instead of a map?

tardy delta
#

what do yall think about this idea to handle subcommands?

#

its a little small lemme paste it too

young knoll
#

Why a set

tardy delta
#

then i just extend that class to make a command and have methods with the signature CommandResult doSomething() which i add as subcommands

young knoll
#

And not a map so you don’t have to stream and check name

tardy delta
#

mye i was thinking about that too

main dew
#

How I can check if Player inGround in PlayerMoveEvent?

tardy delta
#

if the player is in a block?

young knoll
#

The deprecated onGround method still works

#

As long as you are aware it can be spoofed

main dew
tardy delta
#

ah because you said "in ground"

main dew
narrow stag
#

Hi i have one question.
If there are tutorial on OpendJDK 16.0.2 and i have OpenJDK 17. is it a huge different in coding ?

main dew
#

java JDK 17 have more functions

narrow stag
#

What about minecraft versions ?

#

its not a problem

#

so 1.16.5

narrow stag
#

for example

quiet ice
#

Not if you are using maven though

narrow stag
quiet ice
#

But gradle and spigot do get a heart attack if you use future java versions

main dew
#

you must check it 😅

narrow stag
#

ok thx

quiet ice
#

1.16 only supports J16 at most

tardy delta
#

1.17.x works with jdk16 too

main dew
narrow stag
#

Im trying to download OpenJDK 16 but it does not work

#

on IDEA

tardy delta
#

what does not work

main dew
tardy delta
#

check the block below his feet?

#

if its something else than air

main dew
tardy delta
#

oh that still exists too

#

but if you just check if the type != Material.AIR it would work i guess

main dew
tardy delta
#

why?

misty ingot
#

dude github copilot is just so op

ivory sleet
#

!Material.isAir() uwu

tardy delta
#

owo

smoky oak
#

is the code for how the ender chest saves stuff avaliable somewhere?

stuck flax
#

When using the .dropItem method the item flops around, is there a way to make it just appear/drop without flopping around?

lost matrix
tardy delta
#

World#dropItem instead of World#dropItemNaturally?

#

i've heard that there isnt really a big difference

stuck flax
stuck flax
tardy delta
#

which one are you using now?

stuck flax
#

world#dropItem

tardy delta
#

well then it wont help

#

smh then and than lol

lost matrix
lost matrix
#

show a gif or video pls

tardy delta
#

could be a resourcepack too

stuck flax
stuck flax
chrome beacon
#

Clientside mod

tardy delta
#

plugin than

#

or that

chrome beacon
#

Or just a client

stuck flax
#

wait I think I know whats wrong

honest sentinel
#

What event do I need to use to not make tnt ignite other tnts? And what even to prevent the exploded blocks from dropping items?

tardy delta
#

please does anyone has a boolean simplifying cheatsheet?

stuck flax
#

Yeah, Item Physics was doing that

lost matrix
tardy delta
#

not sure if !a && !b is the same as !(a || b)

lost matrix
tardy delta
#

dunno what that means lol

#

anyways got a cheatsheet

lost matrix
worldly ingot
#

boolean = true or false

tardy delta
vague swallow
#

Hey uhm, I wanted to ask how the effect is called that grants knockback resistance

smoky oak
#

turtle master does but thats not the only thing it does

#

if you just want knockback resistance i think you have to manipulate attributes

lost matrix
vague swallow
#

ah ty

vague swallow
lost matrix
#

0

vague swallow
vague swallow
smoky oak
#

mm

#

btw 7smile?

lost matrix
#

Hm?

smoky oak
#

do you know if its possible to (easy-ish) serialize a itemStack into a string?

#

I've been ripping out my hair trying to save a item to a player's PDC for a while now

#

or more specific a itemStack[] array with length 9

wet breach
vague swallow
#

or @smoky oak maybe you know

smoky oak
#

its something along the lines of 'Player.getAttribute(Attribute.KNOCKBAKC_RESISTANCE).set(double)'

lost matrix
#

There are several ways of (de)serializing an ItemStack to/from a String.
What method you use depends on what dependencies you want to have
on your classpath.

I like the one that uses version agnostic bukkit methods.

smoky oak
#

?

#

do you mean to json?

lost matrix
# smoky oak do you know if its possible to (easy-ish) serialize a itemStack into a string?

This is for just one ItemStack:

  public static String itemStackToBase64(final ItemStack item) {
    try {
      @Cleanup final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      @Cleanup final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
      dataOutput.writeObject(item);
      return Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }

  public static ItemStack itemStackFromBase64(String base64) {
    try {
      @Cleanup final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
      @Cleanup final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
      return (ItemStack) dataInput.readObject();
    } catch (IOException | ClassNotFoundException e) {
      e.printStackTrace();
      return null;
    }
  }
wet breach
#

ah 7smile7 with an example for base64 way

smoky oak
#

i mean if it works

wet breach
#

it does work 🙂

#

7smile7 wouldn't lead you astray 😉

smoky oak
#

the annoying part is that i know there's a internal method that does almost exactly what i want

#

but i cant find it

tardy delta
#

@Cleanup kekw

wet breach
#

yes MC/bukkit has an internal method that utilizes base64 serializing, however why depend on the server jar, when 7smile7 gave you perfectly working code

lost matrix
tardy delta
#

does the compiler changes it to a try with resources or what?

lost matrix
#

I think it compiles to a try catch finally block

#

Wait... i think it does a bit more even

smoky oak
#

7smile?
that second code block is dependent on another class

lost matrix
#

It analyses the code flow and closes the resources on the right position

tardy delta
#

oeh sick

smoky oak
#

and i dont know enough about serialization to reverse engineer that one

lost matrix
#

Its from snakeyaml. Should be on the craftbukkit classpath i believe

#

If not then use some other encoder

#

But im away for now. Gonna get some water supplies because russia just put their nuclear deterrent force at high alert -.-

tardy delta
#

lol

smoky oak
#

dumb question probalby not belonging here, but this
https://www.source-code.biz/base64coder/java/Base64Coder.java.txt
which the class is 7smiler's methods use, specifies that it 'may be used under the terms of the following license', does that mean that part of the code (the class) or the entire software has to fall under that license?

#

ah wait

#

copyright already ran out

#

nevermind

misty ingot
#

hey so I have this array
private ArrayList<String> IsMuted = new ArrayList<>();
then in a different file, I try to access that array
else if (IsMuted.contains(player.getName())) {}
but it says Cannot resolve symbol 'IsMuted'

am I doing something wrong?

tardy delta
#

its private in that class so ye obviously you cant access it in another class

smoky oak
#

either set it as public or write a setter/getter method for the array

lost matrix
#

Super important to strongly encapsulate collections. So dont make it public pls.

tardy delta
#

^^

misty ingot
#

so what da HECC do i do

lost matrix
#

So:
Not public
No setter
No getter

misty ingot
#

;-;

lost matrix
#

mutator

misty ingot
#

wut do me do den

tardy delta
#

make some method isMuted(UUID) or something

#

dunno why you're using player names instead of uuid

lost matrix
#
  private final Set<UUID> mutedPlayers = new HashSet<>();

  public boolean isMuted(UUID playerID) {
    return this.mutedPlayers.contains(playerID);
  }

  public void setAsMuted(UUID playerID) {
    this.mutedPlayers.add(playerID);
  }

  public void unsetAsMuted(UUID playerID) {
    this.mutedPlayers.remove(playerID);
  }
#

Example

full pilot
#

can someone tell me a good plugin for login 1.8

tardy delta
#

hehe you changed it to set

#

was going to say it xd

delicate lynx
lost matrix
misty ingot
dusk flicker
#

unsetAsMuted

#

yikes

lost matrix
#

yeah
mute and unmute would be better names

misty ingot
#

its still the same issue but now with Cannot resolve method IsPlayerMuted

dusk flicker
#

well is that the method?

lost matrix
#

?learnjava

undone axleBOT
misty ingot
dusk flicker
#

obviously not

lost matrix
#

No offense. Actual advise.

misty ingot
#

I actually did learn the basics, I just have very very really very bad memory

quaint mantle
lost matrix
#

We also need ?npe tho