#help-development

1 messages · Page 1346 of 1

harsh kayak
#
        if (e.getEntity() instanceof Arrow) {
            Arrow arrow = (Arrow) e.getEntity();
            Entity shooter = (Entity) arrow.getShooter();
            Location loc = getLocation(e);

            if (arrow.hasCustomEffect(PotionEffectType.CONDUIT_POWER)) {
                int size = 10;
                loc.getWorld().createExplosion(loc, size, setFire, destroysBlocks, shooter);
            } else {
                if (arrow.hasCustomEffect(PotionEffectType.DOLPHINS_GRACE)) {
                    ((Entity) arrow.getShooter()).teleport(loc);
                }else{
                    if(arrow.hasCustomEffect(PotionEffectType.WATER_BREATHING)){
                        loc.getWorld().strikeLightning(loc);
                    }else{
                        if(arrow.hasCustomEffect(PotionEffectType.FAST_DIGGING)){

                            loc.setPitch((float) 0.0);
                            loc.setYaw(90 - loc.getYaw());
                            Vector dir = loc.getDirection();
                            Location wallLoc;



                            for (int height = 0; height < 2; height++) {
                                for (int width = -1; width <= 1; width++) {
                                    wallLoc = loc.clone();
                                    wallLoc.add(0, height, 0);
                                    wallLoc.add(dir.clone().multiply(width));
                                    wallLoc.getBlock().setType(Material.STONE, false);
                                }
                            }



                        }
                    }
                }
            }

            return true;
        }
        return false;
    }```
daring sierra
#

?paste

queen dragonBOT
harsh kayak
#

i just tested it it allways faces north

eternal oxide
#

get the entities location. The code I gave you definitely works

harsh kayak
#

so ive tried that and it sort of works

#

it doesnt do exactly what you said it would

#

but now i dont have to modify it to do a 221

#

and the wall is diagonal

eternal oxide
#

it does exactly what I said it does. The wall will be 90 degrees to the player and 2x3

harsh kayak
#

oh for me it ends up at 135

eternal oxide
#

it all depends on which way you are facing. it will always be 90 degrees to the player

lost matrix
#

Take it slow. Create methods that run the operations line by line. You would need a stream for doing it like this

quiet ice
#

Are you sure that the API exists at runtime and that the method exists there at runtime?

quaint mantle
#

When do you use return true or return false when it comes to commands?

eternal oxide
#

If you return false, spigot will display the command syntax

quaint mantle
#

Oooooooh

#

Thanks

quiet ice
#

Maybe update the API ¯_(ツ)_/¯

#

You might have an outdated API jar

#

But you are still linking to the newest version

steep nova
#

How do I run a command every minute? Should I use a Bukkit runnable or is there a better way

proper notch
#

What's the command every minute to do?

#

Is it vital that it's exactly 60 seconds and is representative of real world time? If so use a scheduled service executor, otherwise use the bukkit scheduler.

steep nova
#

Thank you

ivory sleet
#

It’s not an api but it’s weird still

#

Do you build it right?

quiet ice
#

maybe check whether the method really exist with a bytecode editor or something similar

#

Although, it is basically a given that the method does not exist

#

If Java tells that it didn't find a method, that's because it wasn't there in the first place

ivory sleet
#

My guess he might be using plugman or just build it wrongly

eternal oxide
#

accessing another plugins API before the server is fully started is not a good idea.

unreal quartz
#

did you depends it?

eternal oxide
#

run yoru setWelcome 1 tick after your onEnable has finished

oak mica
#

Hi,
I was wondering if someone could help me figure out how to save my hashmap in onDisable and read it in onEnable. My hashmaps are:

    public static HashMap<Player, BossBar> bossbar = new HashMap<Player, BossBar>();

Until now, I have found ```
for (Entry<String, String> set : money.entrySet()) {
getConfig().set("money." + set.getKey(), set.getValue());
}
saveConfig();

for (String users : getConfig().getConfigurationSection("money").getKeys(false)) {
money.put(users, getConfig().getString("money." + users));
}

eternal oxide
#

You can;t read/create player objects in onEnable, unless its a reload

eternal oxide
#

when the server is starting there are no player objects at all

oak mica
#

I want to like save it in config file

#

Or something like that

#

But I have no idea how to

eternal oxide
#

save the players UUID not the player object

oak mica
#

ok

paper viper
#

you shouldn't even be saving Player either cause if the player disconnects the instance becomes invalid

ivory sleet
#

^

oak mica
young knoll
#

UUID

ivory sleet
#

Well WeakHashMap can solve it otherwise

oak mica
ivory sleet
#

new WeakHashMap

#

Instead of a regular HashMap

quiet ice
#

Don't use WeakHashMaps if you do not know what they do

ivory sleet
#

But it’s not liable really

quiet ice
#

Or better said, if you don't know how java's GC works

paper viper
#

Conclure does

#

lmfao

eternal oxide
#

just don't store player objects at all. reference UUID and whatever data you need

oak mica
ivory sleet
#

I mean if another plugin holds a player object then it won’t be cleared in that weakhashmap subsequently

paper viper
#

Bukkit.getPlayer(uuid)

eternal oxide
#

or getOfflinePlayer as that is persistant

quiet ice
#

UUID.fromString(string)

oak mica
#

so something like ```
List<String> hashmapData = new ArrayList<String>();
for(UUID uuid: kills.getKeys()) {

String data = uuid.toString() + ":" + kills.get(uuid);
hashmapData.add(data);

}

getConfig().set("your.path.here", hashmapData");
saveConfig();
#

    String[] raw = rawData.split(":");
    kills.put(UUID.fromString(raw[0]), Integer.valueOf(raw[1]));

}
young knoll
#

Are you sure you set up the loadbefore properly

paper viper
#

what is SMPAdmin's plugin.yml?

eternal oxide
#

then your test API is failing to load

paper viper
#

is TestAPI a plugin?

#

or an api

eternal oxide
#

also, don;t use softdepend if you need it. only depend will control load order

paper viper
#

thats not really an api then tho

#

oof

ivory sleet
#

.

eternal oxide
#

depend does control load order

ivory sleet
#

Oh it doesn’t?

quiet ice
#

Though it is encouraged to use softdepend instead of depend when it is not a hard depend, even if it does not control load order

#

Or better said, mandatory

eternal oxide
#

I went through all the CB loading code a while back to resolve a load order issue. depend does control load order. soft doesn't

ivory sleet
#

Hmm interesting

quiet ice
#

depend makes it a harddepend = plugin won't load if the dependency is not found

ivory sleet
#

That’s good though

quiet ice
#

Unless that has been changed (or I am misremembering things)

eternal oxide
#

you are correct

#

loadbefore is not depend

unreal quartz
#

if you're making an API, you shouldn't be explicitly defining any loadbefores as you can't possibly predict what will depend on it

eternal oxide
#

?paste your full plugin.yml

queen dragonBOT
strong kestrel
#

Hello, I can not send packets from spigot, after looking at the forums :

((CraftPlayer) player).getHandle().playerConnection.sendPacket(Packet<?> packet);

I found this trick but it does not work, it tells me that the class is not found, I am in 1.16

eternal oxide
#

and depend goes in your test plugin not yoru API

#

main plugin

unreal quartz
eternal oxide
#

ok remove the softdepend

#

now show your test plugin yml

strong kestrel
unreal quartz
eternal oxide
#

remove the loadbefore

strong kestrel
#

gradle

unreal quartz
#

nms isn't hosted online anywhere, so you will have to run buildtools at least once to add it to your local repo

eternal oxide
#

and test

unreal quartz
#

the dependency itself will be the same as spigot-api, except remove -api

#

and of course make sure to include mavenLocal()

eternal oxide
#

CB loading is weird, softdepend and one other messes up load orders. I only ever found depend to actually control the load order.

strong kestrel
young knoll
#

The what

unreal quartz
#

assuming you meant library, it's not hosted online as it means hosting mojangs code, which is illegal

young knoll
#

I like bookstore better honestly

unreal quartz
#

?bt

queen dragonBOT
unreal quartz
#

run that for your minecraft version

#

it'll be installed to your local repo

strong kestrel
#

but that is not for spigot plugin ?

young knoll
#

It's for the spigot jar

#

Running it will install NMS in your local maven repo

quiet ice
#

Also known at the .m2 folder

young knoll
#

You can return consumers

cloud berry
#

im also interested bout this in java lol in c++ u just use function pointer

quaint mantle
#

Is a there a playername parameter in Material.HEAD itemstack or something?

young knoll
#

SkullMeta

quaint mantle
#

ty

young knoll
#

You can just return the result of getConfig?

oak mica
#

How is this for saving my hashmap?

eternal oxide
#

always check teh javadocs

young knoll
#

Depends how your API is set up

#

Could be static or not

strong kestrel
young knoll
#

Change the dependency to spigot instead of spigot-api

#

And make sure you have mavenLocal as a repo

quiet ice
sour jasper
#

(i.e. there are sections of void which get progressively larger the farther you get)

quiet ice
#

I've seen this one once

#

I think I messed something up with X and Y or something like that, cannot really recall what I did then

silent vigil
#

how do i add potion effects to players?

silent vigil
young knoll
#

That will work

#

But it will only last 1/2 a second

silent vigil
#

why would it only last 1/2 a secccond?

sour jasper
silent vigil
#

ohhhhhhhhhhh cus of ticks tright?

young knoll
#

10 ticks is 1/2 a second

silent vigil
#

tysm

quiet ice
oak mica
#

cool thing

sour jasper
#

well I'm currently afk so I'll do it later

#

I think it being relative would make a lot of sense

#

for how it generated

young knoll
#

The plugin is null

cloud berry
#

explain ur situation more .-.

young knoll
#

I assume this refers to the main class

#

And it extends JavaPlugin

#

Show code

gritty urchin
#

how do I check the display name of a clicked item in a gui?

young knoll
#

event.getCurrentItem.getItemMeta.getDisplayName

gritty urchin
#

thanks

young knoll
#

Be aware a lot of that is nullable

#

Are you calling the static methods before you call the constructor

quaint mantle
#

How do i remove a block

#

without it dropping it

eternal oxide
#

location.getBlock().setType(Material.AIR)

strong kestrel
oak mica
#

Hi, I am trying to disable renaming of 2 items. The code is:

@EventHandler
    public void inventoryClickEvent(InventoryClickEvent event) {
        if (!(event.getInventory() instanceof AnvilInventory)) {
            return;
        }
        if (event.getSlotType() != InventoryType.SlotType.RESULT) {
            return;
        }
        if (event.getCurrentItem().getItemMeta().equals(ItemManager.sword.getItemMeta()) || event.getCurrentItem().getItemMeta().equals(ItemManager.wand.getItemMeta()) ) {
            event.setCancelled(true);
        }
    }
#

It doesn't work though

eternal oxide
#

debug

#

sysout and see where its failing

oak mica
#

Ok changed code

#
    public void inventoryClickEvent(InventoryClickEvent event) {
        if (event.getInventory().getType() == InventoryType.ANVIL) {
            if(event.getSlotType() == InventoryType.SlotType.RESULT) {
                event.setCancelled(true);
            }
        }
    }
#

this is code

#

but this disables anvils completely

#

which i dont want

#

how do i fix that?

eternal oxide
#

sysout the event.getSlotType().name()

quaint mantle
#

How can I set the position of itemstack inside the inventory?

young knoll
#

In an inventory? setItem(slot, stack)

oak mica
#

How should I make my item rightclickevent work even when the item is renamed?

quaint mantle
#

thx ive been using it differently

quaint mantle
young knoll
#

Depends what you want to detect

#

A specific material, a specific item?

oak mica
outer crane
#

dont do that!

oak mica
#

Like i have a custom item

#

with a ability

quaint mantle
#

NBT tags

dusky lynx
#

Persistentdatacontainer

young knoll
#

Use PDC

oak mica
outer crane
#

PDC

oak mica
quiet ice
#

NBT is 2000% more complicated than PDC

oak mica
#

but i dont understance concept of that

quaint mantle
quiet ice
#

NBT is a wrapper around PDC as far as I know thanks to bukkit patches

young knoll
#

Other way

quaint mantle
young knoll
#

PDC wraps NBT

quiet ice
#

No, the other way around

young knoll
#

And you can do almost everything you can with NBT using PDC

eternal oxide
#

NBT is the root, PDC is the wrapper API

quaint mantle
#

Just use one of them, the one u like the most

quiet ice
#

okay, then I am wrong

#

NBT requires NMS, would not recommend it though

young knoll
#

Well one is an API that won't need changing for each version

#

The other is NMS

oak mica
#

I don't understand either

young knoll
#

You have Javadocs and a tutorial

quiet ice
#

I am a bit new to the convo, so what exactly do you want to store?

oak mica
#

Does comparing item metas compare itom names?

quiet ice
oak mica
#

and i want ability to work even when item renamed

young knoll
quiet ice
#

Ah, so first get the PDC which is the itemMeta

eternal oxide
#

Yep, Store a type flag in the PDC.

oak mica
#

ok

quiet ice
#

Then store a Byte in the PDC, which will act as a flag, you can then remove it if you want to remove the action

oak mica
#

so itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI); line basically ?

quiet ice
#

Yes, somewhat like that

oak mica
#
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();

if(container.has(key , PersistentDataType.DOUBLE)) {
    double foundValue = container.get(key, PersistentDataType.DOUBLE);
}
#

this is code to access

#

right?

quiet ice
#

This should work

#

Altough you can also use getOrDefault if you wish

oak mica
#

ok

eternal oxide
#

not a good idea if you want to do somethign only if the flag exists

quiet ice
#

Always depends on the usecase I would say

eternal oxide
#

yep

young knoll
#

PDC is great for APIs

#

My plugin supports adding a thirst replenishment value to any item with PDC

oak mica
#

Ok doesn't matter

#

I am just disabling anvils

lyric grove
#

when i run this, it sends nothing in chat

worldly ice
#

Is there a way to add custom nbt data to an armor stand? I've already tried NMS, but couldn't get it working for entities. Is this possible without the use of external API's?

eternal oxide
#

PDC

worldly ice
#

so, would it be something like armorStand.getPersistentDataContainer().set(...)?

eternal oxide
#

yes

worldly ice
#

thanks!

rapid vigil
#

I'm basically trying to make a /heal and /heal <player> command..
When I have perms for heal.heal I can heal myself and heal other players
and When I have perms for heal.heal.others I can't heal myself or other players.. I want to do it so If I do /heal it heals the one who did it, and If I do /heal <player> It heals arg1

#
        Player player = (Player) sender;
        if (cmd.getName().equalsIgnoreCase("heal")) {
            if (player.hasPermission("heal.heal")) {

            } else {
                player.sendMessage(ChatColor.RED + "Sorry, you do not have permission to use that command.");
                return false;
            }
            if (args.length == 0) {
                player.setHealth(20);
                player.sendMessage(ChatColor.YELLOW + "You've just healed yourself.");
                return false;

            } else if (player.hasPermission("heal.heal.others")) {

                    } else {
                        player.sendMessage("You don't have permission");

                    }

            if (args.length == 1) {
                if (player.getServer().getPlayer(args[0]) != null) {
                    Player targetPlayer = player.getServer().getPlayer(args[0]);
                    targetPlayer.setHealth(20);
                    player.sendMessage(ChatColor.YELLOW + "You've just healed a player.");
                    targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed.");
                } else {
                    player.sendMessage("This player is not actually online.");
                }
            }

        }
    return false;}
}
humble stirrup
#

?paste

queen dragonBOT
dusty herald
#

bruh put the codeblock back pls

#

this is

#

why

rapid vigil
#

What

dusty herald
#

you have no return statement for the second permission check btw

rapid vigil
#

You mean for if (args.length == 1) { if (player.getServer().getPlayer(args[0]) != null) { Player targetPlayer = player.getServer().getPlayer(args[0]); targetPlayer.setHealth(20); player.sendMessage(ChatColor.YELLOW + "You've just healed a player."); targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed."); } else { player.sendMessage("This player is not actually online."); ?

dusty herald
rapid vigil
#

oh

#

Where should I put the return statement?

#

under "player.sendMessage("You don't have permission"); ?

dusty herald
#

yes

#

DogKek you should learn java tbf

rapid vigil
humble stirrup
#

you need a good working knowledge of java to effectively write plugins

ivory sleet
#

Then Jochyuas statement makes sense

dusty herald
#

my statements never make sense

ivory sleet
#

🎈

dusty herald
rapid vigil
#

Yeah but

#

It doesn't work really well

#

If I had no "heal.heal" permission

ivory sleet
#

LucyCommonLib

#

Lmao

rapid vigil
#

and I had "heal.heal.others"

#

I can't heal other players

humble stirrup
#

dont worry its not one of those

dusty herald
#

does your textformatter take basecomponent

humble stirrup
#

nope :D

#

i need to redo it

dusty herald
#

rats

rapid vigil
#
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
        Player player = (Player) sender;
        if (cmd.getName().equalsIgnoreCase("heal")) {
            if (player.hasPermission("heal.heal")) {

            } else {
                player.sendMessage(ChatColor.RED + "Sorry, you do not have permission to use that command.");
                return false;
            }
            if (args.length == 0) {
                player.setHealth(20);
                player.sendMessage(ChatColor.YELLOW + "You've just healed yourself.");
                return false;

            } else if (player.hasPermission("heal.heal.others")) {

                    } else {
                        player.sendMessage("You don't have permission");
                        return false;

                    }

            if (args.length == 1) {
                if (player.getServer().getPlayer(args[0]) != null) {
                    Player targetPlayer = player.getServer().getPlayer(args[0]);
                    targetPlayer.setHealth(20);
                    player.sendMessage(ChatColor.YELLOW + "You've just healed a player.");
                    targetPlayer.sendMessage(ChatColor.YELLOW + "You've been healed.");
                } else {
                    player.sendMessage("This player is not actually online.");
                }
            }

        }
    return false;}
}
#

This is the code

dusty herald
#

so if you don't have the heal.heal permission, you get returned

#

you need heal.heal and heal.heal.others

young knoll
#

@SuppressWarnings("deprecation")

rapid vigil
#

Is it possible to do If I had no heal.heal but only heal.heal.others so I can heal only other players?

dusty herald
#

it's the healing portion

#

uhh

#

yes but my brain just woke up

rapid vigil
#

so how?

dusty herald
#

have you used switch statements before?

rapid vigil
dusty herald
#

can you stop ping me please

heavy mason
#

Im not trying to

#

Sorry

dusty herald
#

its ok

rapid vigil
#

I'm not pinging

dusty herald
#

i dont mind

#

not you c:

rapid vigil
#

It's someone

#

that is pinging then removing the message

dusty herald
#

yes, I know

heavy mason
#

Its autoremoving it

dusty herald
#

it is pesto

heavy mason
#

Yes apologies

ivory sleet
#

@dusty herald 💩

dusty herald
heavy mason
#

???

rapid vigil
#

so how do I do it tho

dusty herald
#

Conclure bully

heavy mason
#

What black magic is this

heavy mason
rapid vigil
#

ohh

#

I didn't see it

#

I can't understand anything xd...

dusty herald
#

so if I were to do something like that with permissions, I'd probably do this

switch(player.getPermission()){
    case "heal.heal":
    
    break;
    case "heal.heal.others":
    
    break;
    default:
       player.sendMessage("You don't have permission");
    break;
}```
#

not because I love switch statements tho

deft sedge
#

So I'm trying to make a custom book and i've been looking around at some code for a while trying to figure out how to do it. The code gives me this error that I haven't seen happen to anyone here is my code.

dusty herald
#

so what're you trying to do exactly

rapid vigil
dusty herald
#

open a book server side?

rapid vigil
#

or should I add the code you sent?

deft sedge
#

I can't paste an image

humble stirrup
#

verify

deft sedge
#

ok

vestal dome
#

Does someone know how minecraft generates BIOMES?

humble stirrup
#

that's very vague

vestal dome
#

agreed.

humble stirrup
#

procgen is an artform in itself

vestal dome
#

what

humble stirrup
#

procedural generation

vestal dome
#

huh

sleek pond
#

especially in opengl

dusty herald
rapid vigil
vestal dome
#

hm

sleek pond
#

also why did you capitalize that

vestal dome
#

I know that it uses a seed...

humble stirrup
#

doesnt it just use the seed for an rng

dusty herald
#

replace all of your permission checks with it, but only put it once

sleek pond
#

it uses the seed to generate noise

#

idk how that happens

humble stirrup
#

ah ok

rapid vigil
#

Bruh..

sleek pond
#

bruh what

rapid vigil
#

I'm not lazy but

humble stirrup
#

noise is random but ok

rapid vigil
#

I don't understand where should I put it

vestal dome
#

well biomes also use the seed... a lil bit

sleek pond
vestal dome
#

it is?

sleek pond
#

you always get the same noise from a seed

vestal dome
#

PerlinNoiseGenerator uses a random..

#

exactly

sleek pond
#

if you use the same method to generate that noise

#

so it's not random

vestal dome
#

alright.. going back to the question...

humble stirrup
#

whatever it is, it's bloody complicated

sleek pond
#

that is tru

deft sedge
#

I am trying to make a written book but i get an error that says "enum types may not be instantiated" Here is my code

vestal dome
#

does anyone know the equation? to generate a biome?

#

that minecraft uses..

deft sedge
#

Any ideas?

vestal dome
#

exception?

outer crane
humble stirrup
#

Material.WRITTEN_BOOK

#

no new Material()

sleek pond
#

it's not an equation

humble stirrup
#

it's an enum, it's already instantiated

sleek pond
#

or it is

#

but very loosely

outer crane
sleek pond
#

or looking through obfuscated source

humble stirrup
#

or deobfuscating that source

vestal dome
#

best bet is decompiling NMS

oak mica
#

Hi, I was wondering if someone could help me stop renaming items in an anvil but keeping the ability to apply enchantment books. I have some code right now:
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent e){
if(!e.isCancelled()){
HumanEntity ent = e.getWhoClicked();
if(ent instanceof Player){
Player player = (Player)ent;
Inventory inv = e.getInventory();
if(inv instanceof AnvilInventory){
InventoryView view = e.getView();
int rawSlot = e.getRawSlot();
if(rawSlot == view.convertSlot(rawSlot)){
if(rawSlot == 2){
ItemStack item = e.getCurrentItem();
if(item != null){
ItemMeta meta = item.getItemMeta();
if(meta != null){
if(meta.hasDisplayName()){
String displayName = meta.getDisplayName();
e.setCancelled(true);
}
}
}
}
}
}
}
}
}
which I got from: https://bukkit.org/threads/inventory-anvil-events.142990/
However, this stops using anvils altogether, not just renaming. I was wondering if someone could help me solve this problem.

vestal dome
#

and killing myself for 10 minutes to figure it out

humble stirrup
#

code blocks reeeeeeeeeeee

outer crane
#

why stop renaming?

sleek pond
vestal dome
#

it is obfuscated..

#

so it is 10 times more fun

deft sedge
vestal dome
#

am I right?

humble stirrup
outer crane
#

got this feeling you should be using PDC's instead of stopping renaming

deft sedge
#

sure

oak mica
sleek pond
humble stirrup
#

how?

sleek pond
#

also iirc, spigot deobfuscates class names

humble stirrup
#

the maps are public

outer crane
sleek pond
humble stirrup
#

it's much easier than doing it obfuscated

sleek pond
#

what maps?

#

world maps?

humble stirrup
#

deobf maps

oak mica
#

but i couldnt figure it out

sleek pond
oak mica
#

so here i am

vestal dome
#

how

outer crane
#

well you should definitely try pdc's, its better in the long term

humble stirrup
#

mcf has deobfuscation maps for every release since 1.14 ish

vestal dome
#

mcf?

humble stirrup
#

minecraftforum

outer crane
#

try again

oak mica
#

but could not figure it out

oak mica
humble stirrup
#

then you need to spend more time learning

vestal dome
#

Life's hard.

ivory sleet
humble stirrup
#

what

sleek pond
#

hmm?

ivory sleet
#

?mmh

sleek pond
#

kik

humble stirrup
#

you know that feeling when you start looking through your code and realising its shite and then begin having a breakdown

#

:)

dusty herald
#

every day

ivory sleet
#

relatable

dusty herald
#

know what I do?

#

ignore it and patch it instead of replacing it

ivory sleet
#

cute

dusty herald
#

sleek pond
#

imagine spelling it centre instead of center

dusty herald
#

a

sleek pond
#

and colour insteaed of color

ivory sleet
#

just starred it lucy :]

humble stirrup
#

it's literally a load of shit

ivory sleet
#

why not lmao

humble stirrup
#

it's a danger to your wellbeing having that thing starred

#

i mean it looks pretty

ivory sleet
#

lmfao

humble stirrup
#

i need to redo it with components at some point

sleek pond
#

why did you set a commit messaeg to be oops

#

xD

humble stirrup
#

i forgot to commit a file

dusty herald
#

any idea how to edit just the text of a component DogKek

sleek pond
dusty herald
#

rn I'm editing just the json and it's being a bitch to me

humble stirrup
#

yeah im not exactly smart

sleek pond
#

ja son

dusty herald
#

ja son

humble stirrup
#

ja son derulo~~~~

dusty herald
humble stirrup
#

just shoot me

oak mica
#

@lost matrix

quaint mantle
#

I have getCommand("ag").setExecutor(new Commands()); in my onenable, but how do i add a permission to this

rotund ravine
oak mica
rotund ravine
#

Yep

oak mica
#

found that is an issue

hallow latch
#

hey is there any way for me to make it so a player can use riptide during non-rainy weather? Spigot api doesn't seem to offer this

oak mica
#

and fixing it

rotund ravine
#

Yeah, also you're using the ManaSystem as an object, but only accessing static methods?

#

Why

#

Why bother with anything static then?

oak mica
#

welp

#

Player player = .... // your player
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.inWater = true;

#

online

#

search

oak mica
#

or ```
Map<UUID, World> fakeRainWorld = new HashMap<>();

@EventHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) return; //prevent double firing
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
if (event.getItem() == null) return;
ItemStack item = event.getItem();
if (item.getType() != Material.TRIDENT) return;
if (item.getEnchantmentLevel(Enchantment.RIPTIDE) <= 0) return;

Player p = event.getPlayer();
World world = event.getPlayer().getWorld();
if (world.hasStorm()) return;

world.setStorm(true);
fakeRainWorld.put(p.getUniqueId(), world);

for (Player player : world.getPlayers()) {
    player.setPlayerWeather(WeatherType.CLEAR);
}

}

// reset real weather again if player riptided
@EventHandler
public void onTrident(PlayerRiptideEvent event){
fakeRainWorld.remove(event.getPlayer().getUniqueId());
World world = event.getPlayer().getWorld();

// no reason to keep fake rain if no-one is trying to riptide anymore
if (!fakeRainWorld.containsValue(world)){
    world.setStorm(false);
    for (Player player : world.getPlayers()) {
        player.resetPlayerWeather();
    }
}
oak mica
#

if rightclick

#

and player is holding trident

#

player.getInventory().getItemInMainHand().getEnchantments()

#

check if riptide

lost matrix
# oak mica <@!220605553368498176>

Im probably too biased regarding code structure and design patterns so i would probably just scrap and re-write it. But ill give you the low hanging fruits.
For one: Single character variable names are pretty much a no-go unless they are used int 2 or 3 consecutive lines.
Next: max mana is a hard coded constant
Then: Hard referencing a Player object is a bad idea in most cases. Use the UUID instead.
Finally (and most important):
Your code doesnt work.

Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
            public void run() {
                for (Player p : Bukkit.getOnlinePlayers()) {
                    if (!(hasMaxMana(p))) {
                        continue;
                    }
                    if (getPlayerMana(p) < MAX_ArcanePower){
                        addMana(p, 1);
                    }
                    bossbar.get(p).setTitle("Arcane Power: " + getPlayerMana(p));
                    bossbar.get(p).setProgress(getPlayerMana(p)/ MAX_ArcanePower);
                    bossbar.get(p).setVisible(true);
                    bossbar.get(p).addPlayer(p);
                }
            }
        }, 0L, 20L);

This will just skip every player unless he has max mana. And in that case no mana is added.

oak mica
#

oh right yh

#

forgot to remove exclamation mark

#

wait it does work

#

im dumb

#

that why work when not supposed to

#

public static boolean hasMaxMana(Player p){
if (getPlayerMana(p) < (MAX_ArcanePower +1)){
return true;
}
return true;
}

#

this tells if player not got maxmana

#

not if got maxmana

#

im dumb

#

gonna update it

faint snow
hallow latch
#

by doing player.setPlayerWeather(WeatherType.DOWNFALL), i'm able to make the player riptide in place

#

does Minecraft require water particles in the air for the Riptiding trident to actually go forward?

humble stirrup
# faint snow I need help, My tablist header and footer do not want to go, there is no error i...
    
        System.out.println("§8§m--------------------------------------------------------");
    
        System.out.println("§7§m");
    
        System.out.println("§8§l                >> §d§lWurmiTabList v1.0 §8§l<<");
    
        System.out.println("§7§m");
    
        System.out.println("§d                WurmiSystem was successful activated!");
    
        System.out.println("§d                         Created by CUTE CAT");
    
        System.out.println("§7§m");
    
        System.out.println("§8§m-------------------------------------------------------");
    
        
    
    }```
#

please dont do this

lost matrix
humble stirrup
#

and if you're going to do it, please at least use the right method

oak mica
lost matrix
oak mica
#

if standing in water then again works

worldly ice
#

is there a way to stop a spawned item from being pushed out of a block

quaint mantle
#

SO I am trying to get the normal overworld world to be passed in as a World object becuase my code doesn't use a player but does require a world for a Location object any easy way to do this?

eternal oxide
#

Bukkit#getWorld(String)

#

or getWorlds()

#

the latter will have the first entry being your overworld.

faint snow
chrome beacon
#

You need packets in 1.8 iirc

quaint mantle
chrome beacon
#

Not going to bothered looking that up for an ancient version

humble stirrup
#

especially with colours

humble stirrup
#

not being mean

#

just blunt

dusty herald
#

all you really need is the default enable message imo

humble stirrup
#

^

#

only write in console if its relevant

faint snow
#

but i want to see that the plugin is activated 🙂

faint snow
humble stirrup
#

theres a message built in for that

dusty herald
#

literally says in console any plugins that are enabled or disabled

#

without custom messages

opal sluice
#

Hi, I was wondering if it was possible to add armor/toughtness to a skull or an other item ?

sullen marlin
#

yes, see itemmeta and attribute modifiers

opal sluice
#

Ok, thanks ^^

candid galleon
#

I love 5+ lines in console for every plugin ever

#

really brings out the artistic side of console

dusk flicker
#

yes

#

i hate it

vocal cloud
#

Yeah who would do that

eternal oxide
#

Handles too short.

#

Not sure that is a sword though 🙂

vocal cloud
#

I'll add some extra girth

dusky lynx
#

Looks nice lmao

deft geode
#

is this not the right way to spawn a custom colored redstone dust particle?
It says it Needs data, but null was provided

toSpawnOn.spawnParticle(Particle.REDSTONE, toSpawnOn.getLocation(), 1, colorArray[0], colorArray[1], colorArray[2], 1);
faint snow
wary harness
#

is it bad idea to extand Player interface to my BTPlayer inerface ?

#

should i just make Player fieald in my class and assignee player to it ?

young knoll
#

The later

deft geode
#

Now I used this and its the same error:

toSpawnOn.spawnParticle(Particle.REDSTONE, pLoc.getX(), pLoc.getY(), pLoc.getZ(), 0, colorArray[0], colorArray[1], colorArray[2], 1);
Caused by: java.lang.IllegalArgumentException: Particle REDSTONE requires data, null provided
young knoll
deft geode
young knoll
#

Sigh

#

I meant to print the return from that

#

It will tell you what data it wants

deft geode
#

ah

quaint mantle
#

How can I store the information about a banner in a config file? This code doesn't seem to work for me:

    public BannerMeta getBanner(String clan) {
        ConfigurationSection cs = clanData.getConfigurationSection("clan." + clan + ".banner");
        return (BannerMeta) ConfigurationSerialization.deserializeObject(cs.getValues(false));
    }
    
    public void setBanner(String clan, BannerMeta meta) {
        clanData.set("clan." + clan + ".banner", meta.serialize());
        saveClanData();
    }

It gives me:

[16:36:46 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'setbanner' in plugin
...
Caused by: java.lang.IllegalArgumentException: Args doesn't contain type key ('==')
        at org.bukkit.configuration.serialization.ConfigurationSerialization.deserializeObject(ConfigurationSerialization.java:204)
#

This is what gets stored in the config:

    banner:
      meta-type: BANNER
      patterns:
      - ==: Pattern
        color: BLACK
        pattern: cs
      - ==: Pattern
        color: WHITE
        pattern: cs
      - ==: Pattern
        color: BLACK
        pattern: sc
      - ==: Pattern
        color: WHITE
        pattern: mc
      - ==: Pattern
        color: WHITE
        pattern: mc
      - ==: Pattern
        color: WHITE
        pattern: mc
young knoll
#

Pretty sure you should just be passing the section

#

Not the values

quaint mantle
#

The method deserializeObject(Map<String,?>) in the type ConfigurationSerialization is not applicable for the arguments (ConfigurationSection)

#

Should I just do a typecast?

#

Caused by: java.lang.ClassCastException: class org.bukkit.configuration.MemorySection cannot be cast to class java.util.Map (org.bukkit.configuration.MemorySection is in unnamed module of loader 'app'; java.util.Map is in module java.base of loader 'bootstrap')

return (BannerMeta) ConfigurationSerialization.deserializeObject((Map<String, Object>) cs);
young knoll
#

Huh

#

I normally just work with item stacks, so it handles that itself

quaint mantle
#

My plugin has clans, and each clan can set their flag. If the clan is the top clan then their flag replaces all banners at spawn

#

To do that it looked to me like the best way is just save the banner meta

#

Doesn't seem to want to load properly though, and the only method of a ConfigurationSection that returns a Map<String, Object> is getValues()

young knoll
#

hmm

sinful tundra
#

hello, how can I get InputStreamer and get it as a FileConfiguration?

quaint mantle
young knoll
#

It implements ConfigurationSerializable

#

So it should be

quaint mantle
#

Can't find them, when I try to use them eclipse says they don't exist

rapid vigil
#
    public void onHunger(FoodLevelChangeEvent e) {
        e.getEntity().getWorld().getName().equalsIgnoreCase("ffa");
        e.setCancelled(true);
    }
}```

The world I'm in is not "ffa" and it still cancels the event of foodlevelchange... Anyone help me please
rapid vigil
#

statement?

#

Should I put "return false;" ?

#

under "e.setCancelled(true);" ?

#

ohhh

young knoll
rapid vigil
#

Wait

#

if (e.getEntity().getLocation().getWorld().toString().equalsIgnoreCase("ffa")) { This one?

#

do you mean this?

young knoll
#

yes

drowsy helm
#

not toString

rapid vigil
#
    public void onHunger(FoodLevelChangeEvent e) {
        if(e.getEntity().getWorld().getName().equalsIgnoreCase("ffa"))
        e.setCancelled(true);
    }
}```
#

This works?

drowsy helm
#

try it out

rapid vigil
#

Yes I know, but I didn't put ";"

#

but it says no errors no warnings

drowsy helm
#

where would you need ;

rapid vigil
#

I won't need it I guess

#

I meant in ``` if(e.getEntity().getWorld().getName().equalsIgnoreCase("ffa"))

young knoll
#

If statements use { } instead

#

Unless it's 1 line, then you can use nothing

drowsy helm
#

you dont need semicolons for if statements

#

^

rapid vigil
#

ah

#

I'm new to java lmao

#

Thanks for help guys!

drowsy helm
#

if you do

if(my stuff);
#

thats the same as doing nothing

rapid vigil
#

ah

drowsy helm
#

the semicolon is just saying stop here, go to the next line

rapid vigil
#

Thanks for telling me that too

drowsy helm
#

no worries

rapid vigil
#

I will try to put my world name now

#

I hope it works

#

and no hunger

#

It works!!

#

Thanks a lot. I appreciate that.

drowsy helm
#

😄

quaint mantle
drowsy helm
#

when in doubt, base64 it lel

young knoll
#

You can, I was just showing you it exists

quaint mantle
#

I don't have anything under org.bukkit.craftbukkit

#

spigot-api-1.16.5-R0.1-SNAPSHOT.jar

drowsy helm
#

arent you using maven

quaint mantle
#
    <dependency>
      <groupId>org.spigotmc</groupId>
      <artifactId>spigot-api</artifactId>
      <version>1.16.5-R0.1-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
young knoll
#

That won't include NMS

#

But you shouldn't need it for this

drowsy helm
#

you need to depend on craftbukkit for nms

young knoll
#

More specifically you need to depend on spigot

#

Which requires you to build the source locally with buildtools

quaint mantle
#

So if I wanted to put this into maven I'd use my local repo/cache thing?

young knoll
#

mavenLocal()

quaint mantle
#

Yeah

#

/home/<user>/.m2/repository

#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
#

mvn install:install-file -DgroupId=com.stackoverflow... -DartifactId=yourartifactid... -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/jarfile

#

you can use NMS with these dependencys.

young knoll
#

You only need the 1

raven shadow
#

guys is there a way to fix this error in buildtools?

#

org.eclipse.jgit.api.errors.JGitInternalException: Could not rename file CraftBukkit._LGPL.txt2874828113175665030.tmp to CraftBukkit\LGPL.txt

quaint mantle
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

you need this one for NMS so idk what you mean?

#

Changing everything to CraftMetaBanner didn't fix anything

#

Even BannerMeta had serialize, what I was looking for was deserialize, valueOf or a constructor accepting Map<String, Object>

#

I found the constructor in CraftMetaBanner but it's not public (I can't access it)

sullen marlin
#

wtf are you doing

wet breach
#

lol

sullen marlin
#

just call .set / get and cast appropriately

#

dont touch deserialize / serialize manually

#

Literally config.set("foo", banner); BannerMeta banner = (BannerMeta) config.get("foo")

quaint mantle
#

lol

#

Works...

#

tyvm

south onyx
young knoll
#

@EventhHandler?

#

Registered?

south onyx
#

yessir

young knoll
#

Add some debug prints to figure out where it stops

latent talon
#

is it possible to use a placeholderapi placeholder without a player?

#

PaceholderAPI#setPlaceholders(Player, String);
I want to get rid of the Player, since there's no Player field in my method

wet breach
#

@south onyx obviously the problem is going to be line 22

#

is the condition returning what you expect it to?

#

have no idea what your main looks like, and also recommend changing the name of your main class from main to something else

#

not required, but its good etiquette

limber dust
#

looking into the methods, you require either player or offlineplayer

latent talon
#

i see

#

i'll have to have a player then

#

kinda weird that it doesnt exist tho

limber dust
latent talon
#

oh

#

Well I want to use bungee placeholders inside a runnable which is inside a void thats being called from onEnable

#

I guess I'll have to make a separate method just to get the placeholder

sage swift
#

Player extends OfflinePlayer...

#

you can pass in a player to something that requires an OfflinePlayer

latent talon
#

not what i was saying but ok

sage swift
#

pass in a random offline player and just return the same thing no matter the player

languid rune
#

Ok so I am trying to code a plugin but I don't want to use / as the command prefix I want to use @ but whenever I type a command from my plugin into chat It prints out what command I ran into global chat, how can I make it so it doesn't output any message

quaint mantle
#

event.setCancelled(true);

#

if you dont mind im gonna spoonfeed a class since i feel like it

#

might add it to galaxylib

#

nvm ill just code it later

languid rune
#

like /help

#

but @help

young knoll
#

use the AsyncPlayerChatEvent

quaint mantle
#

event.setCancelled(true);

languid rune
#

Ok 👍

quaint mantle
#

also thats a horrible idea

languid rune
#

Oh

quaint mantle
#

no tab complete

#

i wouldnt play your server if the commands didnt have tab complete

languid rune
#

It's complicated

quaint mantle
#

k no worries

deft sedge
#

Does anyone know what code i would need to find a book in a players inventory and then take the page data out of said book?

#

all documentation i can find is old

worldly ice
#

Maybe set the health of it to half of max health

compact haven
#

I ahve question

#

if you're making a plugin in kotlin, can't you just make the main class an object

quaint mantle
#

How do I set the base colour of an already-placed banner? Here's what I have so far:

Block bannBlock = ((Player) sender).getWorld().getBlockAt(-88, 72, -194);
CraftBanner banner = new CraftBanner(bannBlock);
BannerMeta meta = getBanner("clan2");
banner.setBaseColor(DyeColor.RED);
banner.setPatterns(meta.getPatterns());
banner.update(true);

The patterns are applied to the banner but the base colour of the banner is not changed from its original.

deft geode
#

What is the best pratices for creating and accessing mysql databases on servers?

young knoll
quaint mantle
deft geode
young knoll
#

Depends on what type of DB

#

HikariCP is a good connect pooling library

young knoll
quaint mantle
#

The problem now is if I use Banner.setType() the rest of the metadata (or whatever it is in 1.16) is removed

#

So the rotation of the banner is broken

young knoll
#

You can probably copy the rest of the data from the blockstate

#

Or blockdata, forget which it is

quaint mantle
#
boolean isAttached = ((Attachable)bd).isAttached();
BlockFace facing = ((Directional)bd).getFacing();
                    
banner.setType(clans.getBannerType(clan));
                    
((Attachable)bd).setAttached(isAttached);
((Directional)bd).setFacing(facing);

I guess this is OK

queen dragonBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.

limber dust
#

?ask

drowsy helm
#

ask then we may be able to help

open vapor
#

packet listeners aren't working for me

drowsy helm
#

show some code

open vapor
opal sluice
#

Hi, how could I get the base attributes from a vanilla item ? (So the basic generic.attack attribute from a sword for example)

drowsy helm
tepid estuary
open vapor
#

laziness

quaint mantle
open vapor
#

that is the wiki example thing

quaint mantle
open vapor
#

inside my onenable

drowsy helm
#

have you debugged whether it is even firing

opal sluice
open vapor
tepid estuary
#

oh, i see, yeah that would makes sense if it has no modifiers

drowsy helm
#

so it fires, it just doesn't cancel?

opal sluice
tepid estuary
#

for a modified item or?

open vapor
opal sluice
#

A non modified one

young knoll
#

I would think the default getValue would be the vanilla attributes

#

But it could be some weird hard coding

drowsy helm
#

no error msg?

open vapor
#

no

drowsy helm
#

also

#

why two managers

#
 manager = this.getServer().getPluginManager();
        manager.registerEvents(this, (Plugin)this);
  
        
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
open vapor
#

idk the first is for events, the second is copied from the tutorial

#

ohh

drowsy helm
#

should definitely change the name on one of them

opal sluice
#

The thing I would achieve is to get the property of an armor for example and transfer them to a non armor item like a feather

young knoll
#

I meant item.getAttribute(x).getValue

#

Or getBaseValue

open vapor
young knoll
#

However if it returns null for getAttribute that’s an issue

opal sluice
#

yeah it does returns null :/

tepid estuary
#

ItemStack#getDurability will get nms #getDamage if that's what you're looking for (i think) .. i also think that other stuff might be in nbt so you might be able to get it through that? not 100% sure though it's been a sec

opal sluice
#

I'm not looking for the durability

#

But for the Armor and thougness for example

#

or event the damage of a sword

young knoll
#

Yeah it’s probably accessible in NBT, but that would be NMS

opal sluice
#

thoses kind of things

tepid estuary
#

yeah that would be #getDurabiltiy() to get the sword damage

young knoll
#

No

#

Attack damage

tepid estuary
#

no?

young knoll
#

Not durability

opal sluice
#

Yeah attack damage ^^

drowsy helm
young knoll
#

You could make a lookup table to avoid NMS I suppose

drowsy helm
#

make sure you're running the correct version

tepid estuary
#

nbtapi for nbt is helpful

#

CraftItemStack#getDurability()

young knoll
#

Yes

#

Damage is not attack damage

opal sluice
#

Mmmh maybe with an nms copy of the item I can get all the actual attributes

tepid estuary
#

terminology is dead

opal sluice
#

Yeah, over there the damage are the damage the item got from it's usage

#

Not the damages it deals

tepid estuary
#

hmm

young knoll
#

Yeah it appears those values aren’t accessibly with the attribute API

#

So lookup table or NMS

opal sluice
#

ok ok thanks for the help

quaint mantle
#
BannerMeta meta = clans.getBanner(clan);                    
BlockData bd = Main.plugin.getServer().createBlockData(banner.getBlockData().getAsString().replaceAll(":[a-z]*_", ":red_"));
banner.setBlockData(bd);
banner.setPatterns(meta.getPatterns());
banner.update(true);

Is there any better way to set the base colour of a banner than this abomination? I tried using Banner.setBaseColor() and it didn't work because it's in BlockData now, and I tried using Banner.setType() to set it to another banner material but that destroyed all the other block data like rotation and whether it's attached.

I tried this but it didn't work (the type casts were invalid):

boolean isAttached = ((Attachable)bd).isAttached();
BlockFace facing = ((Directional)bd).getFacing();
                    
banner.setType(clans.getBannerType(clan));
                    
((Attachable)bd).setAttached(isAttached);
((Directional)bd).setFacing(facing);
open vapor
#

ohhhhh, the plugin didn't even enable

#

i forgot to check /plugins

quaint mantle
#

With shitty regex?

#
String colour = clans.getBannerType(clan).toString().replaceFirst("_.*$", "").toLowerCase();                    
BlockData bd = plugin.getServer().createBlockData(banner.getBlockData().getAsString().replaceAll(":[a-z]*_", ":" + colour + "_"));

:(

deft geode
#

I'm trying to usePlayer.launchProjectile() and the docs say I should use something which extends projectile. I'm trying to get it to have the player launch an arrow, so what's the best way to do that? I can't create an instance of Arrow (duh) so what should I do?

wet breach
#

you can definitely spawn arrow's

deft geode
#

an implementation of arrow?

wet breach
#

Arrow is a projectile last I recalled

deft geode
#

hold on one sec

open vapor
#

how do I get the data out of a packet from a packet listener

deft geode
wet breach
#

Sure, and you can cast it to Projectile as well

deft geode
#

how am I supposed to create an instance of arrow

#

It's abstract

young knoll
#

Pretty sure it just takes the class

#

Yes, it does

wet breach
#

There is AbstractArrow and there is Arrow

deft geode
#

so literally Player.launchProjectile(Arrow.class);

young knoll
#

Mhm

wet breach
#

Yep

#

That easy 🙂

#

the method should take care of the spawning for you

deft geode
#

Phew

#

I thought I had to extend it whatever

#

*implement

wet breach
#

you can if you really wanted to. IE want custom projectile objects etc

deft geode
#

no thanks

opal sluice
# young knoll So lookup table or NMS

Got it 😄

    public static ItemMeta computePreexistingAttributes(ItemStack item)
    {
        ItemMeta meta = item.getItemMeta();
        if(meta == null) return null;
        
        for(EquipmentSlot slot:EquipmentSlot.values()){
            Multimap<AttributeBase, net.minecraft.server.v1_16_R3.AttributeModifier> multimap = CraftItemStack.asNMSCopy(item).a(CraftEquipmentSlot.getNMS(slot));
            for(Entry<AttributeBase, Collection<net.minecraft.server.v1_16_R3.AttributeModifier>> entry : multimap.asMap().entrySet())
            {
                Attribute attr = Attribute.valueOf(entry.getKey().getName().replace("attribute.name.generic.", "GENERIC_").toUpperCase());
                for(net.minecraft.server.v1_16_R3.AttributeModifier nmsMod : entry.getValue())
                {
                    AttributeModifier mod = CraftAttributeInstance.convert(nmsMod);
                    meta.removeAttributeModifier(attr);
                    AttributeModifier clone = new AttributeModifier(UUID.randomUUID(),
                                                                    mod.getName(),
                                                                    mod.getAmount(),
                                                                    mod.getOperation(),
                                                                    slot);
                    meta.addAttributeModifier(attr, clone);
                }
            }
        }
        return meta;
    }
young knoll
#

Use PDC instead

wet breach
#

Depends on the purpose

#

PDC doesn't create custom entities but rather stores custom information

young knoll
#

Correct

#

Which is basically all you can do without a client mod

wet breach
#

You don't need a client mod for custom entities

#

you do if you want to change the look of said entity

#

or should say, the look of said entity with custom graphics XD

open vapor
#

how do I get the raw data from a packetlistener or know what data to read from

wet breach
#

Depends how you are doing it

young knoll
#

If you aren’t changing the look you generally just need to store extra information, unless you are doing custom mob AI

limber dust
wet breach
#

If you are using ProtocolLib it has methods for getting the raw packet data

open vapor
#

what is the method

wet breach
#

if you are using NMS you would need to cast to get it

open vapor
#

i am using protocollib

wet breach
#

well they have documentation for their plugin

#

@limber dust no they are not, was just making a point there is times where it is valid to extend or implement bukkit classes/interfaces

limber dust
#

ye

wet breach
#

I do it all the time for custom player objects 🙂

limber dust
#

makes sense

#

i tend to just have a getPlayer() method (mainly cause i use uuids, not actual players)

graceful oak
#

Hey guys im using the BlockPistonExtendEvent and BlockPistonRetractEvent to try and cancel the event if they move a specific block but when I am checking the event block I get the piston as the location instead of the block it is moving any ideas?

open vapor
young knoll
#

Choco is very adamant about not extending bukkit

#

With some exceptions

wet breach
#

Well as I said it just depends what you are doing. For most things it isn't necessary

sullen marlin
#

The docs say the same

#

You don't extend bukkit classes unless they're obviously meant to be

young knoll
#

I believe the only classes I’ve ever extended are JavaPlugin and BukkitRunnable

sullen marlin
#

Yup, that's basically the extent of what it's meant to be

open vapor
#

how do I get out of the asynchronous scope? I need to call a synchronous function from an anysychronous one

drowsy helm
#

whats the context of this

#

usually theres a better way than calling from async

young knoll
#

Use a scheduler

#

With just a runTask

#

I am assuming it’s the async packet listener

deft geode
#

Is there a way to make an arrow (from Player.launchProjectile()) fly faster using a vector?

drowsy helm
#

setVelocity

hybrid spoke
#

armorstand#setMarker(true) shrinks the armorstands hitbox to a minimum and also lowers the armorstand. Is there a way to prevent the "armorstand-lowering"?

candid galleon
#

@deft geode the length of the vector should determine its speed

candid galleon
#

or the magnitude I think if you wanna get techincal

wet breach
#

you are correct on magnitude @candid galleon

candid galleon
#

@hybrid spoke could you send an example?

deft geode
#

high school geometry coming in clutch rn

candid galleon
#

trig is surprisingly useful

#

I think my teacher was just shit at teaching ngl

#

took me like 3 more classes to finally understand it

deft geode
#

I'm more asking how to combine the vector with the way the player is facing

candid galleon
#

well you have the way that the player is facing with Player#getLocation.getDirection

deft geode
#

I cant just use new Vector(3.0, 3.0, 3.0) because that's 1) not where the player is facing 2) i have no idea if they're near there

deft sedge
#

I am trying to get the contents of a Written book anyone know how I would do that I know it's a vauge question but ill give any details that anyone needs

candid galleon
#

that's already normalized, so you just have to multiply it by the power you want

#

@deft sedge assuming you have the ItemStack, you'd get its ItemMeta and cast it to Book

young knoll
#

Use player.getEyeLocation.getDirection

#

And then .multiply

candid galleon
deft sedge
#

I do that but I need to get the data from the pages

candid galleon
#

right, so you have the BookMeta ?

deft sedge
#

yes

hybrid spoke
deft sedge
#

ill show what UI hae so far

candid galleon
#

BookMeta#getPages

deft sedge
#

basically just gets the meta if the item player is holding

candid galleon
#

quick tip, you don't need the else {

deft sedge
#

yea i know

candid galleon
#

aight

deft sedge
#

Just wanted to be shure lol

candid galleon
#

well can you try meta.getPages()?

deft sedge
#

yea

#

and then do I just do an if statement to check if the stuff is equal to this

#

i basically need to get the words form the pages

#

into a variable

#

sorry if it's obvious to you i'm kinda new 😅

candid galleon
#

right, so something like
List<String> text = meta.getPages();

would put the text contents of the pages into the variable text

#

no worries, it's always fun seeing new people learn

#

@sick ravine >:(

deft sedge
#

ok thanks

#

when I do that list is bolded in red

candid galleon
#

try highlighting hovering over it

#

what does it say?

deft sedge
#

nvm

#

just had to import it

candid galleon
#

there ya go

deft sedge
#

and then I can do the same thing for specific pages right

sick ravine
#

hmm
List<String> pages = meta.getPages();

deft sedge
#

like get page and then a number

candid galleon
#

you know what Lists and Arrays are right?

deft sedge
#

yea sort of

#

a list is just a list of things

#

right

candid galleon
#

yeah basically

deft sedge
#

not so sure on arrays

wet breach
deft sedge
#

trying to learn coding while doing something I enjoy

candid galleon
#

a list is basically an implementation of an array

deft sedge
#

I am kinda picking it up

#

ok

candid galleon
#

for beginner purposes you can consider them similar

#

tldr the first page would be pages.get(0), second would be pages.get(1), etc.

#

if it was an array (it isn't), you'd do pages[0] for the first page

deft sedge
#

yea

#

i understand that

candid galleon
#

@sick ravine 🥜 gallery emojis imagine 😄

deft sedge
#

I think i can figure it out on the website you gave me

#

i can just grab the contents of specific pages and store them to variables

candid galleon
#

you could, depends on how you're using it 😛

deft sedge
#

List<String> text = meta.getPage(1);

#

would that get data of first page

#

or second if it starts with 0

candid galleon
#

it would get the second page

deft sedge
#

yea

candid galleon
#

generally indexes start at 0

deft sedge
#

bc it sarts with 0

#

i don't know if I formatted it right tho

#

it is red underlined

#

Oh i think i figured it out

#

it's this

#

List<String> text = meta.getPageCount(0);

#

and that would give the first page

#

to the variable text

candid galleon
#

getPageCount returns the number of pages

deft sedge
#

yea

candid galleon
#

so what's the 0 for?

deft sedge
#

first

candid galleon
#

but you're getting the number of pages

deft sedge
#

I thougt it was the index

#

like i just want the stuff on page 0

candid galleon
#

what is the difference between getPage and getPageCount?

deft sedge
#

idk

sick ravine
#

em

deft sedge
#

ill test

young knoll
#

The first returns a list of pages

deft sedge
#

it

young knoll
#

The second returns a number

deft sedge
#

o ur right

sick ravine
deft sedge
#

?

candid galleon
#

🔫

#

get em bois

deft sedge
#

I jsut want to be able to get the words from a specific page and put them in a variable

#

which one is that

candid galleon
#

well which do you think?

#

what do you think getPageCount returns?

deft sedge
#

the page number

#

ohh

#

no

sick ravine
#

😳

deft sedge
#

the number of all the pages

candid galleon
#

I KnoW WhAT It Is RoLL Im TeAchInG

deft sedge
#

it confused me because it was under gtet page

candid galleon
#

it doesnt hurt to read methods lol

deft sedge
#

yea

#

so to get the contents of page 1 I would do String text = meta.getPage(1);

#

wich would return page 2 bc of how ther're numbered i know

sick ravine
#

in IntelliJ IDEA, if you hover over a method, its description will be highlighted

deft sedge
#

ok

#

thanks for the help everybody

#

and the lesson lol

#

have a good night!

candid galleon
#

👍

deft sedge
#

Oh no

#

i got an error

#

BookMeta meta = (BookMeta) item.getItemMeta();
String testPage = meta.getPage(0);
player.sendMessage(testPage);

#

that is the code

#

is there anything wrong that is obvious?

sick ravine
#

error?

deft sedge
#

yep

#

ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
else {
BookMeta meta = (BookMeta) item.getItemMeta();
String testPage = meta.getPage(0);
player.sendMessage(testPage);

#

here is the whole thing

#

i noticed that intelij put a cross through get Item in hand

quaint mantle
#

would be useful if we knew what the error was

#

yeah because the player has 2 hands now

#

OffHand and MainHand

deft sedge
#

could that be the error

quaint mantle
#

depends

deft sedge
#

ill show u what the console told me

quaint mantle
#

invalid page number

deft sedge
#

should it be 1

#

i put 0 thinking it would be 1