#help-development

1 messages ยท Page 1789 of 1

tender shard
#

?

misty current
#

packets, but there are probably libs online

eternal oxide
#

apache commons is still included as far as I cna see

spare prism
#

I use it and I even downloaded a mod that shows nbt tags for all items

twilit wharf
tender shard
twilit wharf
#

none did anything

spare prism
eternal oxide
tender shard
#

so it basically breaks all plugins that rely on apache commons being located at org.bukkit.craftbukkit...

misty current
twilit wharf
#

yeah, he couldnt help

chrome beacon
tender shard
eternal night
#

I mean, relying on implementation ๐Ÿ™ƒ๐Ÿ™ƒ

eternal oxide
spare prism
eternal night
#

If you depend on the server jar, that jar is now a bootstrap jar

#

Obviously the libs are not going to be plain shaded in

eternal oxide
cedar dawn
#

can you show your full code? like when you're calling the methods

ember estuary
#

when a player dies, does it create a new itemstack for the drops? or does it reuse the itemstack from when they were in the inventory

cedar dawn
#

it creates entities

ember estuary
#

but the itemstacks

#

are they the same

cedar dawn
#

the instance?

ember estuary
#

yeah

spare prism
cedar dawn
#

i have no idea then

ember estuary
#

I do
e.getDrops().remove(itemstackPlayerHadInInventory);
But it doesnt remove it

#

so idk if i do something wrong or if its a new itemstack instance thats just a copy of the old one

spare prism
#

NBT tags doesnt apply (NMS, 1.17.1)

eternal oxide
#

which event?

cedar dawn
#

^

ember estuary
#

PlayerDeathEvent

#

i want a specific itemstack to not be dropped

#

oh wait, maybe it works, might have something else wrong

spare prism
eternal oxide
#

There is no setDrops so it should be a mutable list

ember estuary
#

ok yeah it works, my bad :D

#

Can you change player pitch without teleporting him?

#

as teleporting him causes him to freeze

#

even player.teleport(pos.add(player.getVelocity())); doesnt work

#

oh wait, do i have to re-set the velocity

fast onyx
#

Can someone help me?
I'm very new on plugin development and im getting the following error

#

he error comes from private void commandRegister ig but i dont really know what is happening

summer scroll
#

Are you sure you have added that command in the plugin.yml?

fast onyx
#

yes

summer scroll
#

Show me your plugin.yml

fast onyx
#

lol i put discrod

#

instead of discord

#

:XD:

#

sorry

#

Thanks you

summer scroll
#

oh xd

ember estuary
fast onyx
#

is not making the sound

#

wtf

paper viper
#

what the hell

#

Objects.equals(config.getString(path), true)

#

dafaq

fast onyx
#

getting config string?

#

intellij auto typed that

paper viper
#

config.getString

#

String

#

not boolean

#

and also the Objects.equal is unnecessary

fast onyx
fast onyx
eternal oxide
#

learn java then

fast onyx
#

no

paper viper
#

learn to read method names

#

lol

eternal oxide
#

relying on auto complete with no clue what its giving you is a fools path

fast onyx
misty current
#

i love when people wanna use a java library and refuse to learn java

paper viper
#

you are still

#

comparing a string to a boolean

fast onyx
#

i know lol

paper viper
#

theres even a warning

#

on there

#

??

fast onyx
#

im giving proofs of autocompletion from intellij

#

lol

young knoll
#

Is the config value a Boolean

misty current
#

autocomplete doesn't mean right

paper viper
#

Dude, we dont give a fuck about the auto complete

#

your logic is completely incorrect

#

the auto complete is just going to make it worse

fast onyx
ember estuary
#

That's the problem. the teleporting to change the pit makes the player float. Anyone got an idea how to fix?

young knoll
#

Inb4 == true

#

Tbf I did that at first

eternal oxide
#

or != false

paper viper
#

assert meta != null

#

lol

fast onyx
#
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f);
#

whats wrong?

misty current
#

this.H = new int['่€€']; ayo nms u ok

#

tf is that character

paper viper
#

your're using a different api

#

from the server you're running

misty current
#

you use an api that is not the server

#

oh my english died

fast onyx
#

weird

young knoll
#

Sounds had a breaking change

#

At some point

fast onyx
dire warren
#

how to make a addon for bedwars1058 using the api of thet plugin

wide coyote
#

can i use Location#getBlock async? i wont change the type

eternal oxide
young knoll
#

Yes you can

eternal oxide
#

So long as you don;t trigger any chunk loading

misty current
#

but i doubt it'll happen

#

just make sure to not load any chunk

wide coyote
#

i will use it in a plot so the chunk has to be loaded already

misty current
#

kk

#

are you meant to pass the entity id for a destroy entity packet constructor?

#

that i get with myNmsEntity.getId()

wide coyote
#

wait... does creating a new location instance trigger any chunk load stuff

eternal oxide
#

no

misty current
#

if the chunk is already loaded no

wide coyote
#

aight thanks

eternal oxide
#

makes no difference

misty current
#

oh anyways in case you need to get the state you can't do it async

eternal oxide
#

just creating a Location object will cause not chunk load

#

when you getBlock() it will

misty current
#

oh yea but tryna access stuff from it will

#

my bad

ember estuary
#

is there an api for relative teleporting?

#

or would i have to make the console run the command?

#

because relative teleporting keeps the velocity, and theres no way to do that with spigots normal teleport function

misty current
#

store the velocity of the player before teleporting them

#

and then restore the velocity

ember estuary
#

doesnt work

#

not even when i restore it via scheduler

#
                        if (now.getPitch() < 45f) {
                            now.setPitch(45f);
                            Vector vel = player.getVelocity().clone();
                            player.teleport(now.add(vel));
                            Bukkit.getScheduler().runTaskLater(Main.instance, () -> player.setVelocity(vel), 0);
                        }
ancient plank
#

spacing 100

ember estuary
#

was too busy to remove xD

#
                        if (now.getPitch() < 45f) {
                            now.setPitch(45f);
                            Vector vel = player.getVelocity().clone();
                            player.teleport(now.add(player.getVelocity()));
                            player.setVelocity(vel);
                        }

doesnt work like this either

misty current
#

0 tick scheduler?

ember estuary
#

yea, makes stuff run later

#

fixes some problems

#

but not in this case

#

xD

misty current
#

yeah lol

eternal oxide
#

um, teleporting to a Vector?

ember estuary
#

now = Location

#

where do i teleport to a vector?

misty current
#

maybe nms teleporting?

eternal oxide
#

oh adding the vector

ember estuary
#

yea

misty current
eternal oxide
#

why? you are teleporting the player at the most 1 block

ember estuary
#

so the spigot api cant do relative teleporting

#

?

ember estuary
#

so he doesnt freeze when i reset his pitch

eternal oxide
#

teh Velocity Vector will have a length

ember estuary
#

and

eternal oxide
#

its a unit vector

ember estuary
#

yea

#

thats what its supposed to be

#

my problem is, that player.teleport makes him lose his velocity

eternal oxide
#

why? when all you are trying to do is fix his pitch

ember estuary
#

because to set the pitch you have to teleport the player

#

and doing that removes his velocity

#

allowing him to hover in mid-air if the pitch constantly gets fixed

eternal oxide
#

are you doing this in a move event?

ember estuary
#

nope, in a scheduler running every tick, and then in an if that checks if the player pitch changed

eternal oxide
#

ok

#

if you did it in the move event you could simply adjust the pitch

#

changing teh getTo() location

ember estuary
#

u sure that can be changed?

eternal oxide
#

not sure how reliably the event will trigger though

#

yes

ember estuary
#

but i can try

eternal night
#

That won't work xD

#

internally it just teleports if you change the 'to' location

eternal oxide
#

it should not

ember estuary
#

it deletes the velocity/momentum?

eternal night
ember estuary
#

oh wow, what a shitty implementation

eternal night
#

huh ? how so

#

you have to actively tell the client their pitch changed

#

the protocol does only allow you to do that through a teleport

eternal oxide
#

interesting

ember estuary
#

yea, but using the teleportevent removes any momentum

#

which you dont expect when changing the to location

eternal night
#

again, as already stated to you in paper, you need a relative teleport

ember estuary
#

which is not a thing

eternal night
#

and concerning that there is no API for it either a) use NMS or b) execute the tp command

ember estuary
#

besides using the command

#

is using the tp command every tick for ~10 players a problem?

#

performance-wise

#

cuz it sounds very ineffective

eternal night
#

it obviously has some overhead yes

#

but presumably you don't actually call it every second

#

didn't you have an if check

#

to only teleport if needed ?

ember estuary
#

yeah i do

#

but players may find out it lags the server and abuse it xD

eternal night
#

Well try it

ember estuary
#

alright :D

eternal night
#

if it lags too hard, you'll have to use NMS

ember estuary
#

yea

eternal night
#

just make sure to ensure you call minecrafts tp command

#

(tho directly using NMS is probably be better)

tardy delta
#

if i send the github link of a private repo will people be able to see it?

eternal night
#

no

ember estuary
#

is there any relative-teleport api proposal for spigot?

eternal night
#

github repo links are not a "whoever has that link can see it"

#

not that I know of

ember estuary
#

how can i make one

eternal night
#

?contribute

eternal oxide
#

I've not looked at teh nms code for teleport, but check the code used for nether portals

#

it preserves velocity

ember estuary
#

true

#

but how to see minecrafts vanilla server code xD

eternal oxide
#

its in yoru latest folder in buildtools

quaint mantle
#

Or just use intellij decompiler

misty current
#

EntityPlayer has a teleportTo and enderTeleportTo method

#

maybe one of them preserves momentum?

tardy delta
#

preserves momentum ๐Ÿค“ ?

ember estuary
#

Yeah, normal player.teleport() doesnt preserve momentum. @tardy delta

ember estuary
tardy delta
#

what is momentum?

misty current
#

he was basically saying im big nerd for saying momentum

ember estuary
#

velocity

eternal oxide
#

velocity

ember estuary
#

movement speed

tardy delta
#

ah

#

then say that

ember estuary
#

why not say momentum lol

tardy delta
#

๐Ÿ™„

ember estuary
#

im not even english and i know that word

misty current
#

i've learnt the english word before my main language one

ember estuary
#

xD

misty current
#

which is pretty stupid since it's almost the same

#

momento in italian, momentum in english ;-;

ember estuary
#

xD

misty current
#

btw what's the difference between List.of() and Arrays.asList()

#

else than the first one always being in my autocompletes even if i'm using java 8

ember estuary
#

Arrays.asList returns a mutable list while the list returned by List.of is immutable
Arrays.asList allows null elements while List.of doesn't
contains behaves differently with nulls
Arrays.asList returns a view of the passed array, so the changes to the array will be reflected in the list too. For List.of this is not true

quaint mantle
#

Arrays.asLists creates a wrapper around array
List.of, returns, just immutable list

misty current
#

yea i should've probably googled it :p

ember estuary
#

xD

#

ive googled it myself like 10 days ago

misty current
#

stackoverflow has the answer always for this type of stuff

#

thanks

ember estuary
#

xD

#

yeah

#

np

misty current
#

so if i change a list generated with Arrays.asList it will change the array too

#

interesting

ember estuary
#

only takes a blockposition so no way to change the pitch :/

#

probably gotta use nms then, idk

ivory sleet
tardy delta
#

command classes should be singletons right?

ivory sleet
#

uh who said that lol

fickle helm
#

I just instantiate them and store a ref in my main class

#

even then it's not necessary to store the ref as likely you're not calling any of the command code from your classes

ivory sleet
#

Yeah, its the around the lowest level component in the system, so hopefully nothing depends on it.

neon storm
#

How do you change the direction a powered minecart is going? Like the direction its engine is going

tardy delta
#

a singleton is something where only one instance can be created right?

ivory sleet
#

Yes

#

Singleton pattern:

  • Ensure only one instance can be created at (mostly) compile time.
  • Provide a global access point to the instance (actually not always but 99% this is the case)
tardy delta
#

i've stored an instance somewhere because it has non-static method which should be accessed over time ๐Ÿ˜ณ

ivory sleet
#

Hm

#

Well I have seen non static singletons

misty current
#

i usually use singletons for classes that store data (like player profiles)

eternal night
#

๐Ÿ‘€

ivory sleet
#

I mean I guess singletons are a bit too hated

hybrid spoke
ivory sleet
#

But they do lead to couple code

#

Which can be a problem

misty current
#

i don't really like it as a solution but i'm not aware of a better way

#

sure i can make them classes that are normally constructable but what's the point if instanciating them again is pointless?

ivory sleet
#

Pass your data transfer instance / data access instance through constructors or methods maybe

misty current
quaint mantle
#

classes should as reusable as possible smh

misty current
#

it's a class that holds player data in a player, integer hashmap

#

or something similar

hybrid spoke
#

so a DTO which is easily passable through your constructor, named DI

hybrid spoke
quaint mantle
#

Util classes are fine unless they have mutable state ๐Ÿ™‚

ivory sleet
# misty current yea for a while i did that too

I recall some people used to use static singleton to lazy load stuff, when that stuff was necessarily not going to be needed such as specific storage implementation.

But now when we have Suppliers, and other design patterns which can be written cohesively thereโ€™s less need for static singleton.

misty current
#

something else i do sometimes is make a wrapper class for players that has a private static map with all the instances of the class and a static method that calls a private constructor of the class and adds the constructed object to the arraylist

#

not sure if this is a great approach either tho

karmic grove
#

whats good tuturial series i only see part 1 like 100 times then they all quit after that

ivory sleet
#

Arguably a very fragile design kill05

#

But I mean if its just a plugin shrug

quaint mantle
#

that doesn't really look like a great approach

hybrid spoke
#

so dont say that

quaint mantle
#
  1. Constrcutor should construct object and do nothing else
  2. SRP blablabla
#

class shouldnt hold its instances, thats a task for another entity

misty current
#

point is i don't know how i should do it, i've changed many times how i store player data or data in general in my 3 months of spigot dev, but i've never found a way i like or think is good

ancient plank
#

I wanna do some stuff with json

hybrid spoke
ivory sleet
# hybrid spoke a plugin is also a software optimized for another

Thing is maybe the module is still in its implementation phase in where itโ€™s totally fine to do whatever you want to get it to work.

Itโ€™s mostly impossible to write perfectly clean code from the start, as it will often lead to extreme refactors and major implementation changes which just slows the process down, so usually you get it to work, then clean the code.

hybrid spoke
ivory sleet
misty current
#

i did sometimes something like:

Data.java

public class Data {

  //private Hashmap<Player, PlayerWrapper>

  //Constructor taking plugin instance as parameter for schedulers or whatever

  //Utils methods

  //Nothing static

}

PlayerWrapper.java

public class PlayerWrapper{

  //Variables for data

  //Constructor taking player as parameter

  //Getters and setters

}
hybrid spoke
misty current
ivory sleet
#

Yeah but tdd has some downsides (also)

hybrid spoke
#

and how your tests looks is irrelevant

misty current
#

what's tdd

hybrid spoke
#

test driven design

#

you test your things before implementing them

#

thus you give a certain behavioral pattern

hybrid spoke
ivory sleet
#

If you go all in with tdd it usually results in a lot of tests as you want to make sure you cover all cases. When we write unit tests it usually leads to a lot of mocks since we want to isolate things. Problem is when you want to refactor like extract classes and change implementation details you might end up with a lot of tests broken. So then youโ€™d have to go back and fix them. But yeah as you said it helps with the decoupled design.

misty current
ember estuary
#

How can i run a command in spigot without spamming the console/chat ?

hybrid spoke
misty current
#

i just came up with it, those were not the names i used

hybrid spoke
#

//Utils methods those are not util methods

mortal hare
karmic grove
#

any good tuturials that go past part 1 xd

hybrid spoke
#

?learnjava

undone axleBOT
hybrid spoke
mortal hare
#

why ChatColor.intCode is private

#

now i need to use ordinal and trust bukkit api that it wouldnt change the order

#

because there's no getter for that

ember estuary
#

i think you can trust ordinal, otherwise md_5 wouldnt have made it that way

mortal hare
#

but it makes no sense to use ordinal when there's predefined integer values for each enum

#

in the constructor

ember estuary
#

he also deprecated some other similar functions and you now have to use ordinal instead

#

cant u do valueOf

eternal oxide
#

Dont use magic numbers

mortal hare
#

i can't

#

im working with packet level stuff

ember estuary
eternal oxide
#

use matchMaterial

#

ah

#

not api then

mortal hare
#

i need to convert Bukkit ChatColor value to hex value

#

so i need to get int value of the chatcolor

#

to set it via bitmask for a field

ember estuary
#

ordinal seems like the way to go

mortal hare
#

yea

ember estuary
#

i dont see any better option

#

but maybe im jsut blind

misty current
#

can you get what player loaded what chunk with api or do you need packets

tardy delta
#

is there no getSource or something in the chunkload event?

misty current
#

nope, just getchunk and getworld

#

oh also isnewchunk

patent horizon
#

how would i update my placeholders after registering them?

ember estuary
quaint mantle
rain oxide
#

sorry.

quaint mantle
#

No problem ๐Ÿ‘

vagrant stratus
#
      this.task = new BukkitRunnable() {
        int seconds = 30;

        @Override
        public void run() {
          if ((seconds -= 1) == 0) {
            seconds = maxTime;
            runnable.run();
          } else {
            bossBar.setProgress(seconds / 30D);
          }
        }
      }.runTaskTimer(chaos, 0, 20);

Any way to make this smoother?
I could lower the amount of ticks it takes, but wouldn't that be a bit much or is this light enough to just have run every 10 or less ticks?

quaint mantle
#

You can lower the ticks

#

You should cancel the timer when it hits 0 though

young knoll
#

Look a pretty light to me

vagrant stratus
#

It's a repeating countdown, hence the re-run

young knoll
#

I wonder if you can update boss bars async

vagrant stratus
#

Gonna throw it on 1 tick and see what happens lol

quaint mantle
#

Oh I see now. yeah

vagrant stratus
#

I could have it cancel, but that's pointless for what I'm using it for ๐Ÿ˜‚

quaint mantle
#

Fair enough

#

The smoothness is kind of a trade-off, i'd just do 10 ticks

vagrant stratus
#

Already got a 1 tick build compiled, gonna see what happens lol

misty current
#

can you get the player that loaded a chunk with the events api or do you need packets?

young knoll
#

I mean itโ€™s gonna run fine

quaint mantle
#

๐Ÿ˜›

young knoll
#

The game already does much much more each tick

vagrant stratus
quaint mantle
#

Yeah it won't really have a significant impact anyway, it's not like you're executing a ton of things in that method

vagrant stratus
#

๐Ÿ‘

#

1 tick it is, if anything I'll just throw it to 10 lol

quaint mantle
#

sounds good

vagrant stratus
#

lol didn't even seem to update, weird ๐Ÿค”

quaint mantle
#

Nevermind, simply hiding them and then reshowing them seems to work.

#

that's weird though

ember estuary
#

Can someone tell my why this does not work?

Vector vel = player.getVelocity().clone();
player.teleport(new Location(...));
player.setVelocity(vel);

I really don't get why. It does not set the velocity back.

#

is it a bug?

quaint mantle
#

Maybe wait a tick?

ember estuary
#

nope, doesnt work either

sick portal
#

Hello everyone, can two bungeecord register the same server for bungeecord messaging ?

#

and both receive / send messages to / from it ?

ivory sleet
#

Two bungeecord instances?

#

Are you running a bi-proxy?

sick portal
#

Yes, two separate bungee instances

#

on two separate machines

ivory sleet
#

Unsure probably not

#

You might have to setup a custom server socket system

#

Where one of the two instances runs the server socket

fast onyx
#

can't resolve symbol "config"

#

wut

sick portal
#

but not viceversa

#

thats why i was wondering if by simply adding more bungee the spigot server would just send to multiple bungee

quaint mantle
#

if you have for example

test1
test2

in your arraylist, and use the contains method for test
what will it return ?

ivory sleet
#

afaik bungee doesn't support it natively

#

but it might very much be possible

ivory sleet
#

assert Lists.newArrayList("test1","test2").contains("test") == false

#

:p

brittle loom
#

Hello, does anyone know how I could send a player to a different server in a spigot plugin? I've tried using the dispatchCommand but it wouldn't recognise the /server command because it's a bungeecord command.

vagrant stratus
#

plugin messaging, i think

quaint mantle
#

Shouldn't you use Sound.valueOf(Config.getString("sound"))

brittle loom
quaint mantle
#

Does anyone happen to know how to rotate an NPC? I can rotate the head just fine but I can't figure out how to rotate the body

grim ice
#

doesnt that rotate the body too?

quaint mantle
#

Here

grim ice
#

honestly for npcs I just use libraries

quaint mantle
#

The body does rotate to an extent, but the body rotation compared to the head rotation seems a bit off here

grim ice
#

how are you rotating the head?

#

show code

quaint mantle
#

PacketPlayOutEntityHeadRotation rotate = new PacketPlayOutEntityHeadRotation(entity, (byte) (location.getYaw() * 256.0F / 360.0F));

quaint mantle
tribal gyro
#
       playerHeart.addUnsafeEnchantment(Enchantment.LURE, 1);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);

        playerHeart.setItemMeta(meta);``` anyone know why this isnt making it shiny :/
fast onyx
quaint mantle
#

iirc as long as you don't use nms you can already do that

fast onyx
#

There is a guide or smth?

quaint mantle
quaint mantle
#

Well now you're adding an enchantment and then setting the meta

#

effectively erasing the previous enchant

tribal gyro
#

rlly?

quaint mantle
#

Pretty sure that's how it works

peak granite
#

are setting variables necessary

#

is it good practice

blazing scarab
#

what

young knoll
#

You can add the enchantment via meta or the stack itself

peak granite
#

like

young knoll
#

However if you are already editing the meta, use the meta

tribal gyro
#

ok ill try

peak granite
#

Player player = event.getPlayer();
or
event.getPlayer()

#

is it good practice

#

to set variables

young knoll
#

If you are reusing it several times set a variable

#

Itโ€™s cleaner and easier to read

tribal gyro
#

alr it works

#
    public static void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (!(event.getAction() == Action.RIGHT_CLICK_AIR && event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
            return;
        }
        ItemStack item = player.getInventory().getItemInMainHand();
        if (!item.hasItemMeta()) {
            return;
        }
        ItemMeta meta = item.getItemMeta();
        assert meta != null;
        if (!meta.hasDisplayName()) {
            return;
        }
        if (!meta.getDisplayName().equals(ChatColor.RED+"Extra Heart")) {
            return;
        }
        if (!(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue() < 20.0)) {
            return;
        }
        if (player.getInventory().getItemInMainHand().getAmount() == 1) {
            player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
        } else {
            player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
        }
        player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + 2);
    }``` now im stuck on why this is not working lol
tribal gyro
young knoll
quaint mantle
fast onyx
young knoll
#

command-sound != sound

fast onyx
young knoll
#

You have it called command-sound in the config

#

And sound in the code

fast onyx
#

no

#

"String sound = "config.command-sound";

quaint mantle
#

lol yeah

tribal gyro
young knoll
#

Ah I see

quaint mantle
young knoll
#

Still, Config.command-sound is not the same as command-sound

grim ice
#

I dont know what's wrong, sorry.

peak granite
#

how do i make the plugin wait a tick

#

before doing the rest of the code

young knoll
#

Unless you have that key in a section called Config

young knoll
undone axleBOT
young knoll
#

I see

fast onyx
#

You see

young knoll
#

Having a section named Config is weird, but alright

peak granite
#
            // dd
        }, 1);```
#

does this work

young knoll
#

Is the right file present at runtime

peak granite
#

1L or 1

chrome beacon
peak granite
#

or 1 tick

fast onyx
fast onyx
young knoll
#

Oh wait

#

You have the : on the end

peak granite
young knoll
#

You donโ€™t need that

fast onyx
#

oh lol

#

yes

young knoll
#

In the code I mean

fast onyx
#

XDDD

#

sorry

quaint mantle
#

nothing I just didn't know that was a thing

fast onyx
#

thanks you

young knoll
peak granite
#

what's lambda

quaint mantle
#

() ->

lavish hemlock
#

doubt you don't know what a lambda is

#

considering Coll said lamda but you said lambda when asking about it :p

peak granite
#

๐Ÿ˜ญ

mighty pier
#

how do i set an item's default damage?

peak granite
#

getDefaultDamage()

mighty pier
#

ok ty

#

ant then .set(123)?

#

or something

young knoll
#

Shh I didnโ€™t misspell lambda

#

You have no proof

lavish hemlock
#

hmmmmm

ebon stratus
#

how can i add more attack damage to a sword item without changing its attack speed?

chrome beacon
#

Change the attributes

ebon stratus
#

i tried

young knoll
#

The attack_damage attribute

ebon stratus
#

it makes the sword attack like 1.8

#

maximum attack speed

#

when i only changed the attack damage

young knoll
#

You may have to manually set the attack speed back to default then

#

Which is 1.6

ebon stratus
#

tried that

#

still the same

#

maximum attack speed

peak granite
#

does anyone know how to make a command cooldown

chrome beacon
peak granite
#

does it reset after server stops

chrome beacon
#

Yes

peak granite
#

i want it to save

young knoll
#

Youโ€™ll need to save it to json then

#

Or sql or whatever

peak granite
#

what about yml

chrome beacon
#

That too

young knoll
#

I mean, itโ€™s not really meant for data

peak granite
#

essentials uses yml tho?

chrome beacon
#

It will work though

young knoll
#

But it wonโ€™t kill anyone

#

Probably

peak granite
#

yk how (args.length == 0) checks if they entered /command <argument> how do i check if they didn't enter /command <argument> <second argument> the second argument part

young knoll
#

args.length < 2

peak granite
#

ah

#

thanks

young knoll
#

Setting damage and attack speed should work

#

I can test it I suppose

peak granite
#

nvm

#

i did > instead of <

ebon stratus
ember estuary
#

How can I run Bukkit.dispatchCommand(console, command); without it logging to console and chat?

fast onyx
#

i think i did it good

ember estuary
#

i tried making my own ConsoleCommandSender with empty sendMessage functions

#

but that didnt help

young knoll
#

Unless you mess with one of the gamerules perhaps

ember estuary
#

the thing is

#

if i set them back it gets logged in chat too

#

turning a gamerule back on gets logged

young knoll
#

I mean the proper way to do it would be to not use that method

ember estuary
#

theres alternatives?

#

teach me senpai

onyx shale
quaint mantle
#

centred messages w/ hex.... how?

fast onyx
quaint mantle
#

i have the centred messages method all done and good, but with HEX codes it doesn't add as many spaces, as it sees each HEX value as legit text

ember estuary
#

to run a command

young knoll
#

No

ember estuary
#

:/

young knoll
#

Plugins generally should not be running commands

#

Unless they are something like a crate plugin

ember estuary
#

but its too hard to implement with nms :c

onyx shale
#

..if you register your own logger you can choose to hide certain things..

young knoll
#

What are you trying to implement

ember estuary
#

changing the players pitch while keeping his velocity

#

spigot's teleport() removes any velocity

young knoll
#

Ask on the fourms to see if anyone knows

#

Or open an issue/feature request on the jira

ember estuary
#

alright, will do that

quaint mantle
#

also im still having issues with formatting

ember estuary
#

i think it is one, isnt it

young knoll
#

Not sure if it's intended or not

fast onyx
patent horizon
#
        List<String> members = new ArrayList<>();
        members.add(leader.getUniqueId().toString());``` isnt there a way to create a list with starting values instead of adding them afterwards?
ember estuary
#

@fast onyx what ide you using? if a method doesnt exist it should definetly have warned u

quaint mantle
#

Formatting Issues & HEX in centred messages

ember estuary
#

and that part of the code is not underlined red?

fast onyx
ember estuary
#

oh true it actually isnt

#

hmmm

fast onyx
#

but when is executed yes

#

sad

ember estuary
#

maybe try casting

#

((Player) p).sendTitle

patent horizon
#

it'd just be gray iirc

ember estuary
#

hmmmm

fast onyx
#

exists

#

sendTitle

young knoll
#

You are likely developing against a newer api than your server is using

ember estuary
#

and ur server is on 1.17.1?

fast onyx
#

1.16

#

and 1.13 api

ember estuary
#

hmmm. i know sendTitle wont work on 1.8 servers, but i dont see a problem on a 1.16 server. idk. anyone else?

peak granite
#

making a broadcast command Bukkit.broadcastMessage(Color.translate(args[0])); if i do /broadcast i am cool it doesn't broadcast the whole text

fast onyx
#

sendTitle is only +1.9 true?

ember estuary
#

isnt it 1.11+?

fast onyx
#

๐Ÿค”

ember estuary
#

not sure

young knoll
#

It's certainly in 1.16 is the point

ember estuary
#

yeah

#

and certainly in 1.13

peak granite
#

anyone?

young knoll
#

Hmm?

young knoll
#

args[0] will only be the first argument

fast onyx
#

so, alright, im fixing it

peak granite
#

how do i make it broadcast everything

fast onyx
#

is possible to autochange this string to another sound if the server is +1.13?

young knoll
#

String.join

young knoll
peak granite
#

what about

#

args.toString()

#

is that bad

young knoll
#

That will add [] around them

#

And , between each one

peak granite
#

oh

young knoll
#

Just use String.join(" ", args)

peak granite
#

what's String.join

peak granite
#

is it possible to make console execute a command through the code

quaint mantle
#

can someone look at threads pls

lavish hemlock
#

no :)

peak granite
#

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), String.join(" ", args)); would this work

quaint mantle
lavish hemlock
#

I'm open to your mom ๐Ÿ˜Ž

quaint mantle
#

bruh

peak granite
#

bruh v2

ivory sleet
#

not those silly jokes here

peak granite
#

how do i loop all players

#

then teleport them to a location

young knoll
#

?jd

sterile token
peak granite
#

ty

sterile token
#

Examples:


for (Player p : Bukkit.getServer().getOnlinePlayers()) {
   p.DoSomething();
}
sterile token
shadow night
sterile token
#

You declare an object player then do what ever with that object

shadow night
#

How do you kill a player?

sterile token
#

Let me check

#

No i dont know

#

Do i need to use reflections for example, to check in class what methods it contains and if it contains param?

waxen plinth
waxen plinth
peak granite
#

how do i end a for

#

nvm

#

dumb question

#

sory

#

sorry

sterile token
#

with a return;

#

I think

#

I dont actually remeber

peak granite
#

does this return how many players are online Bukkit.getServer().getOnlinePlayers().size();

sterile token
#

I recommend you learning more about Java for then using the Spigot API

#

If not it will be really difficult for you .

peak granite
#

yes, i'm still learning sorry

calm star
#

Hey guys, ive made this in a event:
if(p.getInventory().getItemInMainHand() == condenseWandCommandClass.condenserWand.getItem())
and the condenserWand is a NBTItem from the NBTapi and it doesnt seem to register

sterile token
eternal night
#

comparing items with == is (as with most objects) pretty useless

#

use ItemStack#equals or ItemStack#isSimilar

calm star
#

still doesnt work

fast onyx
calm star
#

if(p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.condenserWand.getItem())) {}

#

the condenserWand NBTItem is from another class and referenced using CondenseWandCommand condenseWandCommandClass = new CondenseWandCommand();

#

idk if you can check if a NBTItem is in ur hand

#

is there another way to check if an NBTItem is in your hand @eternal night

quaint mantle
#

@eternal night do you have any idea on how i should implement HEX codes to centred messages

eternal night
#

what are centred messages ?

quaint mantle
#

where the lines are centred

#

like so

eternal night
#

do you mean the action bar ?

calm star
#

atm the unique nbt is condenserWand.setString("Condenser Wand", "Condenser Wand");

eternal night
#

Ehhh

#

Well then just check if your item has that key

ember estuary
#

How can i make a bukkitscheduler run at the start of each tick and not at the end?

lean gull
#

can anyone help me with this method? [https://paste.md-5.net/suxenewugo.cs]
basically, i'm making a gamerules gui for easier access for gamerules,
and what i want to do is have like a lot of these methods that will set the items in the gui
and those items could be clicked to turn on and off gamerules (i'll get to the int gamerules later)

peak granite
#

Player target = (Player) args[0]; doesn't work

eternal night
#

one is a string the other a player

lean gull
#

oh and i want help with making it more lag friendly

calm star
peak granite
eternal night
#

to find a player from their name

waxen plinth
#

Sounds like an xy problem though

eternal night
#

and no, why are you serializing the item meta

#

you should have some random trashy nbt methods around already no ?

#

to set and get values

lean gull
#

you talkin to me?

eternal night
#

no

ember estuary
waxen plinth
#

What is your actual goal

ember estuary
#

setting a players pitch without cancelling his velocity

waxen plinth
#

I see

ember estuary
#

My code works when i run it in the PlayerMoveEvent, but it doesnt when i run it in a scheduler

#

Vector vel = player.getVelocity().clone();
now.setPitch(45f);
player.teleport(now);
Bukkit.getScheduler().runTaskLater(Main.instance, () -> player.setVelocity(vel), 0);

waxen plinth
#

You can just set their velocity after calling teleport, no?

ember estuary
#

you cant if you run it in a scheduler

#

cuz that gets run too late

#

player movement calc and stuff is before that i assume

#

but im not entirely sure

#

i need to run it in a scheduler tho, as the playermoveevent doesnt trigger everytime the player moves their head

waxen plinth
#

Might need packets sadly

ember estuary
#

thats not a problem

#

but im failing to do it with packets too

#

trying since 5 hours

waxen plinth
#

You can send a teleport packet that only sets certain things

#

Like pitch

ember estuary
#

i can try that

#

alright

sterile token
misty current
#

what method of the ChannelDuplexHandler should I override to listen for inbound packets(client to server)

calm star
eternal night
#

well you have one to set

calm star
#

ye

eternal night
#

so making one to get the value of an item stack should be easy

calm star
#

just do nbti.getKey();

#

p.getInventory().getItemInMainHand().getItemMeta().getAttributeModifiers().containsKey(condenseWandCommandClass.condenserWand.getKeys())

#

would that work

#

no that dosent

lean gull
calm star
#

nothing i do works

#

p.getInventory().getItemInMainHand().getItemMeta().toString().contains(condenseWandCommandClass.getNBT())

#

idk

#

nothign

eternal night
#

PDC would make this a lot easier

#

or NBT-API

calm star
#

im using NBT-API

eternal night
#

what

misty current
#

nbt api is very gud

calm star
#

IIm using it

misty current
#

wait why r u doing that stuff

eternal night
#

then you have getter methods

misty current
#

what are you tryna do

calm star
#

NBTItem condenserWand = new NBTItem(new ItemStack(Material.STICK));

eternal night
#

then create a new nbt item with the item you wanna check

#

and get the nbt values from that

misty current
#

condenserwand.setString(key, value)

#

or whatever java primitive you need

#

there's also support for some objects

calm star
#

i do that

#

condenserWand.setString("Condenser Wand", "Condenser Wand");

misty current
#

then you need to get the item back

calm star
#

p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.getCondenserWand().getItem())

#

?

misty current
#

condenserWand.getItem()

calm star
#

i do that

misty current
#

or you need to put as the second argument of the NBTItem constructor true

calm star
#
public NBTItem getCondenserWand() {
        return condenserWand;
    }
misty current
#

yea that works fine, but if you want to get the itemstack

misty current
calm star
#

i do that

misty current
#

and what's the issue?

calm star
#

.equals(condenseWandCommandClass.getCondenserWand().getItem())

#

it doesnt register

misty current
#

oh don't compare like that

calm star
#
@EventHandler
    public void onPlayerRightClick(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        Action a = e.getAction();
        if(a == Action.RIGHT_CLICK_AIR){
            if(p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.getCondenserWand().getItem())) {
                System.out.println("Hi");
                }
            }
        }
misty current
#

check for nbt tags

calm star
#

oh

misty current
#

also what version are you on?

eternal night
#

not like I have been saying this

#

for like the last 5 messages ๐Ÿ˜ข

misty current
#

yea lol

#

:p

calm star
#

i saw but idk how to do it

eternal night
#

I would assume new NBTItem(p.getInventory().getItemInMainHand()).getString

#

or smth

#

idk never used nbt api

misty current
#

yea

#

and put in arguments

eternal night
#

yea

sterile token
#

Oh i love java its amazing btw. The connection its being opened but the stream not. Or at least im not receiving anything. :P

hybrid spoke
#

probably not javas fault

#

leave java alone

#

he has kids to feed

fast onyx
#

how ORB_pickup sound is called on +1.13?

sterile token
misty current
#
String key = "mykey";
String value = "myvalue";
String expectedValue = "expectedvalue";

String toolTag = new NBTItem(p.getInventory().getItemInMainHand()).getString(key, value);
if(toolTag.equals(expectedvalue))
calm star
#

if(p.getInventory().getItemInMainHand().equals(new NBTItem(p.getInventory().getItemInMainHand()).getString("Condenser Wand")))

sterile token
#

No

misty current
#

or smthing similar

sterile token
#

Ahh yes

#

Sorry

#

I didnt see the NBTItem btw

patent horizon
#

would anyone know why this case "invites": return String.valueOf(data.getInvites(player).size()); placeholder isn't working in game?

calm star
misty current
#

np

acoustic pendant
misty current
#

do you need to cancel a task?

#

outside of the task?

acoustic pendant
#

yep

ivory sleet
#

Store the BukkitTask object

misty current
#

iirc when you create the task, it returns the int that is the id

#

so just store it when you create it

acoustic pendant
#

hmm

patent horizon
#

this.

misty current
#

yea exactly

ivory sleet
#

?scheduling

undone axleBOT
acoustic pendant
#

oh, ty!

ivory sleet
#

Adri that wiki page I wrote actually goes over cancelling

patent horizon
acoustic pendant
#

it does

#

ty!

ivory sleet
#

๐Ÿ‰

misty current
patent horizon
#

what

misty current
#

never needed them

patent horizon
#

oh

#

welp

ivory sleet
#

Wally

patent horizon
#

yus

ivory sleet
#

Send entire class (:

patent horizon
#

k

ivory sleet
#

That line doesnโ€™t tell us very much

misty current
#

wait are you using PAPI or did you make your own

patent horizon
#
package me.wally.guilds.GUI;

import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;

public class Placeholders extends PlaceholderExpansion {

    Data data = new Data();

    @Override
    public String onRequest(OfflinePlayer player, String params) {
        switch (params) {
            case "guild": return data.getGuild(player);
            case "role": return data.getRole(player);
            case "memberCount": return String.valueOf(data.getMemberCount(player));
            case "memberCountCap": return String.valueOf(data.getMemberCountCap(player));
            case "level": return String.valueOf(data.getLevel(player));
            case "exp": return String.valueOf(data.getEXP(player));
            case "invites": return String.valueOf(data.getInvites(player).size());
        } return null;
    }

    @Override
    public @NotNull String getIdentifier() { return "Guilds"; }
    @Override
    public @NotNull String getAuthor() { return "wally"; }
    @Override
    public @NotNull String getVersion() { return "1.0"; }

}```
#

papi

misty current
#

you wrote guild_invites while ur switch has invites

patent horizon
#

the identifier

#

it's a placeholder prefix

ivory sleet
#

Btw

misty current
#

oh nvm

ivory sleet
#

Is this a separate jar

#

Or is that class embedded/shaded inside your plugin jar?

patent horizon
#

different jar

ivory sleet
#

Ah okay

patent horizon
#

i registered this class in my main

misty current
#

well if the other placeholders work i don't see how would this specific one not work

sterile token
ivory sleet
#

Wait you donโ€™t need to register it in main if its an expansion jar

patent horizon
#

the other placeholders work

patent horizon
#

i just did new Placeholders().register();

ivory sleet
#

Just drop it inside PlaceholderAPI/expansions/

#

iirc

patent horizon
#

in the placeholder's plugin folder?

peak granite
#

is 3 a double

ivory sleet
#

can be

peak granite
#

i mean

patent horizon
#

it could be

misty current
#

3.0 is

peak granite
#

oh

#

oka

misty current
#

depends on where u store it

ivory sleet
#

^

#

3 can be many types (:

sterile token
#

^^^java
A
^^^

#

Amazing

misty current
#

int just rounds it down

#

or any other primitive that holds not decimal numbers

patent horizon
#

so conclure

#

what do i put in the expansions folder

ivory sleet
#

the expansion jar

patent horizon
#

what's the expansion jar

#

just my plugin?

#

or the class

ivory sleet
patent horizon
#

wait what was your question for that

ivory sleet
#

You said you kept the placeholder expansions class in a different jar than your plugin jar

patent horizon
#

oh i thought you mean plugin class

#

it's in the same plugin

ivory sleet
#

Jar != class

#

Jar == java archive file which contains a set of classes

patent horizon
#

i aint good with flashcard vocabulary

#

k anyways

ivory sleet
#

Anyways

#

If itโ€™s in the same jar

#

Override persists method inside the placeholder expansion class

#

and return true

#

Also override canRegister

#

And make it return true

patent horizon
#

i dont have a persists method

ivory sleet
#

its not called persists presumably

#

but smntg like that

patent horizon
#

no i remember it from the api docs

peak granite
#

how do i convert arg1 arg2 arg3 (x y z) to a location

patent horizon
#

just thought i didnt need to add it

ivory sleet
#

you do if its in the same jar

misty current
ivory sleet
#

due to class loading shit and other hackery stuff

patent horizon
misty current
#

pass as world player's world

#

what method of the ChannelDuplexHandler should I override to listen for inbound packets(client to server)

ivory sleet
#

idr but can you send the class

#

?paste

undone axleBOT
misty current
#

yea sure

daring maple
#

Guys how would I best link a placed block with an inventory? (sort of creating a new chest but without a container as the chest item)

misty current
#

what you see in there is what i supposed was correct

patent horizon
#

wait what are you asking

#

to like open the inventory of a chest item in your inventory with nbt?

ivory sleet
misty current
#

yea sec

daring maple
patent horizon
#

is that block always going to be a storage block?

misty current
daring maple
#

Actually never going to be

patent horizon
#

cus if so, you could just clone the inventory into the block's inventory

peak granite
#

(Double) args[0], (Double) args[1], (Double) args[3] doesn't work

patent horizon
#

don't think you can make non-storage blocks have inventories

misty current
daring maple
#

Well I know you technically can I dont know exactly how to execute it tho

#

But I could store metadata from a block and data from the inventory

acoustic pendant
#

@ivory sleetbut i have practically the same as in the guide but getting errors

daring maple
#

And compare those on an onInteract event

ivory sleet
daring maple
#

Just the relationship with the block and inventory I cant really wrap my mind around

patent horizon
acoustic pendant
#

@ivory sleetwell, now it works but can't access from other scope

ivory sleet
#

idr everything but maybe thats true lol

fast onyx
ivory sleet
#

send more code, caye

fast onyx
#

thats all the condition

peak granite
#

Double x = ((Double) args[0]); doesn't work

ivory sleet
#

Double.parseDouble(args[0])

acoustic pendant
#

i can't access from the else if

ivory sleet
# fast onyx

might wanna show me more, I mean like above the branch

patent horizon
misty current
ivory sleet
misty current
#

anyways i guess i'll go trial and error for duplex channel

ivory sleet
peak granite
#
        player.teleport(```
how do i tp them to that location
misty current
young knoll
#

player.teleport(location)

#

?jd

acoustic pendant
#

but, i want to cancel it here:

ivory sleet
#

@misty current

young knoll
#

Also you need to assign that location to a variable

misty current
#

yea?

ivory sleet
#

I think you wanna simply call break;

#

and not return;

young knoll
#

Currently you are creating it and then yeeting it into the void

ember estuary
ivory sleet
#

as it prevents the super.call() if any of the functions fail

#

also

#

use Predicate

#

(which returns a primitive boolean as opposed to the boxed type)

misty current
#

yea i know, if the Function returns true, the packet is blocked

#

o thanks

fast onyx
#

about me?

young knoll
#

You need to learn about variable scope

fast onyx
#

how i can solve this problem?

young knoll
#

Declare reload outside the if

fast onyx
#

i already do that

ember estuary
#

no?