#development

1 messages · Page 49 of 1

shell moon
#

¯_(ツ)_/¯

hazy nimbus
#

I'm not sure whether you can bypass this limit in the tablist

#

I'm afraid you'll have to update the position manually

wind tapir
hazy nimbus
#

Then apparently it is possible

#

check TAB's source

wind tapir
#

but if the as is passenger

hazy nimbus
wind tapir
#

I can't modify the position

hazy nimbus
wind tapir
hazy nimbus
wind tapir
# hazy nimbus wdym by this?

if I set the armorstand passenger, then tp it lower, it wont work ( no error ofc )
and if I tp first the as then set the as passenger, it will be too high

hazy nimbus
#

I'm afraid you can't do it simply by setting it as a passenger

#

iirc most servers just sent the packets manually instead of spawning a real entity to avoid lag

#

So you will have to send a packet to spawn an armor stand and then update it's position each tick (ideally async)

wind tapir
#

by updating the position, you mean tp it ?

hazy nimbus
#

Honestly, if I were you, I would really reconsider whether it is worth doing this.

wind tapir
#

well

hazy nimbus
#

This sometimes bugs out and leaves "ghost" names in the air

wind tapir
#

the problem is that for custom ranks, a player who wants to make a lot of colors, they can't

#

because there will be an error showing that the prefix is too long

wind tapir
hazy nimbus
#

What don't you understand?

wind tapir
#

how to use what they written

hazy nimbus
#

You will have to use NMS

#

Or ProtocolLib (I'm not sure whether it still supports 1.8)

wind tapir
#

By doing packetplayout ?

hazy nimbus
#

yes

wind tapir
#

okay thanks

#

uh

#

as is entity living or entity please ?

hazy nimbus
#

I don't know

#

Try it and see

wind tapir
#

okay

#

ok uh

#

I'm really not good with nms

#

I have to initialize the entityliving before the packet ?

hazy nimbus
#

I don't know

wind tapir
#

oh

hazy nimbus
#

I've used 1.8NMS several years ago

fading stag
#

I'm doing a RTP plugin and I don't want players to teleport to lava / water:

    fun getRandomLocation(world: World) : Location {
        val x = (minX..maxX).random()
        val z = (minZ..maxZ).random()
        val y = world.getHighestBlockYAt(x, z)
        val selectedBlock = world.getBlockAt(x, y, z)
        if(selectedBlock.type.isSolid) {
            return Location(world, x.toDouble(), y.toDouble(), z.toDouble())
        }
        return getRandomLocation(world)
    }

I'm doing a recursive call but I wonder is it dangerous? Or is there any better way than that?

wind tapir
#

im not sure sorry

fading stag
wind tapir
#

oh ok

hazy nimbus
#

Before you would reach stack overflow, you would most likely crash the server by loading the chunks

shell moon
#

If I get an image from an endpoint X and process it for example to modify colors, extract sections, or whatever, would it be a good idea to use something like this so it's removed after some time of not being used? The question is what happen if the image "linked" to the key is updated, i'd would take 5 minutes after write to be deleted so it can be cached again?

public Cache<String,MyClass> avatarCache = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(5, TimeUnit.MINUTES).build();

Question is actually what would be the best way?

minor summit
#

unless you manually invalidate and refresh it, yes that's what will happen

#

"best way" depends on your design goals and constraints

shell moon
#

In few words the scenario is this:
Player joins > checks if current name or texture (string) is in cache > uses the data and creates something with it > if not in cache, requests the image skin and process it and add it to cache and create something with it

minor summit
#

should prolly use a loading cache instead of doing the checking yourself

#

idk about guava, but with caffeine there's a build method that takes an asynccacheloader or whatever, guava is like old caffeine so it should have something similar

shell moon
#
LoadingCache<String,List<String>> cache = CacheBuilder.newBuilder().maximumSize(100).build(new CacheLoader<String, List<String>>() {
        @Override
        public List<String> load(String key) {
            return getListFromEndPointAndProcess(key);
        }
    });```
#

something like that?

minor summit
#

sure

#

then when you request a value from the cache, it will use the loader if there's nothing for the key

shell moon
#

just wondering, thats async? eyes_shake

minor summit
#

idk how guava works but if the whole loading thing is similar to that of caffeine, no

shell moon
shell moon
#

api-version: 1.20?

trail burrow
#

yes

#

minecraft

#

I don't think it was coded to detect version of Minecraft

proud pebble
#

minecraft version in this case wouldnt matter afaik

#

it should just pick them up

#

1.20 blocks/items do show up in Material

trail burrow
#

thats what I thought I must be missing something

dense star
#
    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent event){
        Player player = event.getPlayer();
        String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%player_name%%luckperms_meta_chatcolor%: ");
        event.setFormat(format + ChatColor.stripColor(event.getMessage()));
    }
#

somehow when ever player chat %

#

it throws an error

#

or anything related to %

bright pier
#

You need to use %1&s for player name and %2&s for the actual message.

dense star
bright pier
#

If you are changing the format, you need to use those two placeholders. You'll also need to use %% instead of a single one otherwise it complains.

dense star
#

while still be able to send % related

dusky harness
#

and event.setFormat(format + "%2&s")? (I think that's what @bright pier meant?)

dense star
#

hmm

#

let me try

dusky harness
#

idk what the &s is tho

dense star
#

now it just thows full error

dusky harness
#

can u show code and error?

dense star
#
        Player player = event.getPlayer();
        event.setMessage(ChatColor.stripColor(event.getMessage()));
        String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%player_name%%luckperms_meta_chatcolor%: ");
        event.setFormat(format + "%2&s");
#

it now show Conversion = '2' error

dusky harness
#

what if you do System.out.println(event.getFormat()) at the top

#

to see the default

dense star
#

<%1$s> %2$s

#

here is what i get at the top

dusky harness
#

ohh its $ not &

#

try ```java
Player player = event.getPlayer();
event.setMessage(ChatColor.stripColor(event.getMessage()));
String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%1$s%luckperms_meta_chatcolor%: ");
event.setFormat(format + "%2$s");

dense star
#

now it came to Conversaion = 'l'

#

[OWNER] porudev: Hello!

#

is what i expected

#

or [OWNER] porudev: 50%

#

[OWNER] porudev: %luckperms_prefix%

dusky harness
#

can u show the full error?

neat pierBOT
dusky harness
#

lol

dense star
#

here @dusky harness

#

sorry for pinging!

dusky harness
#

im not sure

#

wait

#

try using ChatColor.translateblahblah on the format

dense star
#
        Player player = event.getPlayer();
        String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%player_name%%luckperms_meta_chatcolor%: ");
        event.setFormat(format + ChatColor.stripColor(event.getMessage()));
#

doing this seems perfectly fine

dusky harness
#

oh

dense star
#

until i chat % or anything has % in it

#

either % or %something%

#

or %%

dusky harness
#
        Player player = event.getPlayer();
        event.setMessage(ChatColor.stripColor(event.getMessage()));
        String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%1$s%luckperms_meta_chatcolor%: %2$s");
        event.setFormat(ChatColor.translateAlternateColorCodes('&', format));
#

try this

dense star
#

i don't think translating & is necessary

#

since

dusky harness
#

yeah ig

#

¯_(ツ)_/¯

dense star
#

all my placeholders use the minecraft colorcode it self

#

§

#

this

dusky harness
#

try ```java
Player player = event.getPlayer();
event.setMessage(ChatColor.stripColor(event.getMessage()));
String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%1$s%luckperms_meta_chatcolor%: %2$s");
System.out.println("Format: " + format);
event.setFormat(format);

dense star
#

let me try

dense star
dusky harness
dense star
#

Format: §c[OWNER] %1$s%luckperms_meta_chatcolor%: %2$s

dusky harness
#

oh

#

so thats not being converted

#

wait

#

nvm

#

wait

#

why don't you just leave format blank

dense star
#

idk how does AdvancedChatTorch manage to do it

dusky harness
#

and put everything in message

dense star
#

uh

#

DiscordSRV

dusky harness
#

oh

dense star
#

read getMessage

#

so if i modify getMessage

#

the message in DiscordSRV will be weird

dusky harness
#

what if you do /papi parse me %luckperms_meta_chatcolor%

dense star
#

because %1$s%

dusky harness
#

oh

#

papi boooooooooooo

dense star
#

is overriding it

dusky harness
#

ok i have an idea lol

dense star
#

how do these guy even do it

#

in the first place

#

oh hey

dense star
#

and now it give me just [OWNER[

dusky harness
#

what symbol-

dense star
#

[OWNER] : %

#

with no error

#

String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%%luckperms_meta_chatcolor%: %2$s");

#

change it to this

dusky harness
#

try ```java
Player player = event.getPlayer();
event.setMessage(ChatColor.stripColor(event.getMessage()));
String format = PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%supercoolplayerwoooooooo%luckperms_meta_chatcolor%: %2$s");
event.setFormat(format.replace("supercoolplayerwoooooooo", "%1$s"));

#

🥴

#

trust

dense star
#

done fixed it

#

tysm

dense star
dusky harness
#

oh

dense star
#

the problem is %2$s

#

it solved the problem

worn jasper
#

What could be going wrong with this code? It's not spawning the armorstand...

return loc.getWorld().spawn(loc, ArmorStand.class, armorStand -> {
  armorStand.setGravity(false);
  armorStand.setCanPickupItems(false);
  armorStand.setArms(true);
  armorStand.setBasePlate(false);
  armorStand.setCanMove(false);
  armorStand.setVisible(true);

  armorStand.setItem(EquipmentSlot.HEAD,     ItemBuilder.skull().owner(player).build());
  armorStand.setItem(EquipmentSlot.CHEST, ItemBuilder.from(Material.LEATHER_CHESTPLATE).color(Color.RED).build());
  armorStand.setItem(EquipmentSlot.LEGS, ItemBuilder.from(Material.LEATHER_LEGGINGS).color(Color.RED).build());
  armorStand.setItem(EquipmentSlot.FEET, ItemBuilder.from(Material.LEATHER_BOOTS).color(Color.RED).build());
});
wind tapir
#

armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
        armorStand.setSmall(true);
        armorStand.setCustomName(player.getName() + "§5test");
        armorStand.setCustomNameVisible(true);
        armorStand.setPosition(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
        PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armorStand);
        PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
        connection.sendPacket(packet);

        main.getServer().getScheduler().runTaskTimerAsynchronously(main, () ->{
            Double X1 = player.getLocation().getX();
            Double Y1 = player.getLocation().getY();
            Double Z1 = player.getLocation().getZ();
            armorStand.setPosition(X1, Y1, Z1);
            PacketPlayOutEntityTeleport teleport = new PacketPlayOutEntityTeleport(armorStand);
            connection.sendPacket(teleport);
        }, 0, 0);

#

the video is with 0 ticks

hazy nimbus
#

Perhaps you should set a vector instead of tping it?

#

I honestly don't know

#

Or you should do it in the player move event? Idk

wind tapir
#

armorStand = (ArmorStand) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
        armorStand.setSmall(true);
        armorStand.setCustomName(player.getName() + "§5test");
        armorStand.setCustomNameVisible(true);
        armorStand.teleport(player.getLocation());
        main.getServer().getScheduler().runTaskTimerAsynchronously(main, () ->{
            armorStand.setVelocity(new Vector(player.getVelocity().getX(), player.getVelocity().getY(), player.getVelocity().getZ()));
        }, 0, 0);

``` please help the armorstand wont even spawn
#

no error

hazy nimbus
#

As I've said, I don't know

river solstice
#

wild thought

#

but

#

on move event

#

get the armor stand

#

and set armor stand velocity the same as player velocity

#

🦧

wind tapir
river solstice
#

hence why it lags back behind

hazy nimbus
#

Yeah, you should only send packets async

#

Not do server stuff

river solstice
#

yeah don't send packets

#

and just use player move event

#

lol

hazy nimbus
river solstice
#

what are you doing

#

plugin manager has no such methods

#

hence the error

#

tf

wind tapir
#

what is the best please ?

#

bruh

#

AsyncPlayerChatEvent or PlayerChatEvent ?

#

the playerchatevent is deprecated

dense drift
#

I guess you answered yourself

#

in paper there's AsyncChatEvent iirc

#

you are most likely confusing PermissionManager or whatever with PluginManager

wind tapir
#

armorStand = (ArmorStand) e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.ARMOR_STAND);
            armorStand.setCustomName("§6test " + e.getPlayer().getName());
            armorStand.setCustomNameVisible(true);
            armorStand.teleport(e.getPlayer());

#

@EventHandler
    public void onMove(PlayerMoveEvent e){
        Player player = e.getPlayer();
        armorStand.setVelocity(new Vector(player.getVelocity().getX(), player.getVelocity().getY(), player.getVelocity().getZ()));
    }

hazy nimbus
#

I mean, you will also have to teleport it ig

#

Maybe teleport and then set vector?

dense drift
#

what do you want to do?

hazy nimbus
#

Have longer names above the player than what's allowed

dense drift
#

ok, then attach the armor stand as passenger to the player?

hazy nimbus
#

They said it was too high

river solstice
#

why are you creating new vector

#

just do armorStand.setVelocity(player.getVelocity());

river solstice
#

what problem

proud pebble
#

armorstand.setGravity(false)

and then just teleport it to the player's location every time it moves

#

or a bukkit task that constantly teleports itself every tick

proud pebble
wind tapir
#

            armorStand = (ArmorStand) e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.ARMOR_STAND);
            armorStand.setCustomName("§6test " + e.getPlayer().getName());
            armorStand.setCustomNameVisible(true);
            armorStand.setSmall(true);
            armorStand.setBasePlate(false);
            armorStand.setVisible(false);
            armorStand.setGravity(false);

proud pebble
#

you should also set it as marker

wind tapir
#

@EventHandler
public void onMove(PlayerMoveEvent e){
    armorStand.teleport(e.getPlayer());
}
wind tapir
proud pebble
wind tapir
#

what does it do ?

proud pebble
#

it gets rid of the armorstands hitbox

#

which would causes issues

proud pebble
#

yeah it does that

#

you will have to offset it more

wind tapir
#

please

proud pebble
#

you teleport it higher

#

you modify the location that your teleporting it to and add to the Y coodinate

wind tapir
#

but the thing is that the as is too slow

proud pebble
#

tbh i have no idea why its not instantly teleporting to you

wind tapir
#

oh

proud pebble
#

ig you could try changing the teleport cause, it might make a difference

wind tapir
#

it doesn't change :/

#

are the positions of the as change anything on the position when it's passenger ?

surreal laurel
#

[11:55:43 WARN]: [TestPlugin] Plugin TestPlugin v0.0.1 generated an exception whilst handling plugin message
java.lang.NullPointerException: Cannot invoke "me.clip.placeholderapi.PlaceholderAPIPlugin.getLocalExpansionManager()" because the return value of "me.clip.placeholderapi.PlaceholderAPIPlugin.getInstance()" is null

What is the problem? I have added the PlaceholderAPI in dependencies and 'plugins' folders.

dense drift
#

you shade papi

surreal laurel
#

?

proud pebble
shell moon
#

Make sure its not like "compile", but "provided"

wind tapir
proud pebble
#

you might be better off using packets to create the armorstand

#

cus it sounds like the teleport method at some point sends the move to packet instead of the teleport packet which is annoying

hoary scarab
#

If an entity is teleported within 8 blocks of its previous position the move packet is sent instead of teleport.

proud pebble
#

which is what its doing

hoary scarab
#

Yeah just providing context

proud pebble
#

id assume if you always sent the teleport packet instead of the move packet it would just teleport the armorstand instead of doing the moving thing

surreal laurel
shell moon
#

Refresh maven

hoary scarab
surreal laurel
proud pebble
#

actually if tab already does this might be better to just go look at the source

#

fucking old versions

hoary scarab
proud pebble
#

i didnt know you could update packets that are already created

#

since as far as i could tell there wasnt any setters in them

shell moon
#

Recreate artifacts maybe, it prob stuck as compiled in it

hoary scarab
surreal laurel
shell moon
#

Decompile your output .jar, it contains papi?

proud pebble
hoary scarab
proud pebble
#

i did consider that but wasnt sure if that was actually an option

#

doing 2 teleports on the same tick wasnt sure if that actually was possible

#

like if only one of the teleports would actually occur

surreal laurel
shell moon
wind tapir
#

can anyone tell me why this method doesn't work ? ( no error ofc )

#
e.getPlayer().setPassenger(armorStand.getBukkitEntity());
dense drift
#

I believe it is the other way around

#

d;Player#setPassenger

#

ah nvm

wind tapir
#

im on 1.8.8

#

the add passenger doesn't exist

worn jasper
surreal laurel
wind tapir
# worn jasper Also, why.

it doesn't take much ram, and for now it's the best version i've tried bc on paper, I have a lot of problems, and in spigot it takes a lot of ram

dense drift
#

lol

worn jasper
#

💀

#

I won't even reply to that message

wind tapir
worn jasper
#

just to prevent being muted

wind tapir
#

no answer

#

tell me why

#

please

worn jasper
#

because your logic is not logic

#

You deprive yourself from several features, security patches and more just to save up some tiny amount of ram??

worn jasper
#

that version is almost 10 years old.

wind tapir
#

it struggle at the starting with 4gb ram*

#

or 3

worn jasper
#

Would you use a 10 year old pc?

#

guess not

wind tapir
worn jasper
#

your mistake in using spigot

wind tapir
worn jasper
#

yes, you a lot of problems cause you are on an almost 10 year old version of minecraft

#

what do you expect

#

candies?

worn jasper
wind tapir
#

this

worn jasper
#

never had those issues

#

like ever

wind tapir
#

but I had

worn jasper
#

only versions I have seen ghost blocks are 1.8

#

and its a client issue

wind tapir
#

in another pc

#

on another connection

#

and it's on 1.19.4

river solstice
#

paper >>> bad

#

change my mind

wind tapir
#

ig the answer is good

#

i'm gonna try paper for the idk time

#

1.15

#

bruh

worn jasper
#

paper and its forks are the best option in the market

hazy nimbus
#

Imagine using spigot in 2023

wind tapir
#

for maven what dependency should I use please ?

#

I have this:

rose depot
#

Hello, I reached out to you as someone who could help me solve an error in my code. Since the error occurs every time in the same situation, we know roughly what it is. But everything seems flawless. Who would be willing and good at programming java plugins for version 1.8.8 please? Debug show us that it occurred, but no other info except when. We have a minigame that has an arena. After restarting, when I join the arena, everything works correctly. You play, you die, the game ends, it teleports you to the location it's supposed to. The second game without restarting, after connecting, you will classically join the waiting spawn, and after the countdown, it will not connect you to the arena, but to a completely different world. So the first time it teleports me correctly after restarting and the second time it doesn't. I have no idea what it could be.

worn jasper
rose depot
#

it is pvp minigame based, it needs 1.8.8

#

Alright give me some minutes.

rose depot
# worn jasper 1. don't use 1.8.8 2. We need code, we are not akinator
                    int num = Utils.getRandomNumber(1, arena.getSpawns().size() - 1);
                    Location loc = arena.getSpawns().get(num);
                    Location telLoc = loc;
                    System.out.println(loc.getWorld());
                    System.out.println(loc.getY());
                    System.out.println(loc.getZ());
                    System.out.println(loc.getX());
                    System.out.println(telLoc.getWorld());
                    System.out.println(telLoc.getY());
                    System.out.println(telLoc.getZ());
                    System.out.println(telLoc.getX());

                    loc.subtract(0, -1, 0);
                    Block block = loc.getBlock();

                    loc = telLoc;
                    block = loc.getBlock();
                    block.setType(Material.AIR);
                    loc = telLoc.subtract(0, 1, 0);
                    block = loc.getBlock();
                    block.setType(Material.AIR);

                    Location save = telLoc;
                    save.setY(save.getY() - 1);
                    System.out.println("SAVE POZICE - " + save.getY());
                    save.getBlock().setType(Material.WOOL);

                    player.teleport(telLoc);
                    System.out.println(telLoc.getWorld());
                    System.out.println(telLoc.getY());
                    System.out.println(telLoc.getZ());
                    System.out.println(telLoc.getX());
                    player.getInventory().clear();
                    Utils.giveArenaItems(player, member.getColor());
                    player.setGameMode(GameMode.SURVIVAL);
                    cancel();
                    return;
              }```
#
        World world = worlds.get(arena.getName());
        if (world == null) {
            System.out.println("WORLD JE NULL!");
            return;
        }

        Bukkit.unloadWorld(worldName, false);
        world = Bukkit.createWorld(new WorldCreator(worldName));
fading stag
#

Is creating an ItemStack in another thread (async runnable) a problem?

dense drift
#

a simple new ItemStack() is not going to blow up your server, ig it depends what you want to do with that item shrug

hazy nimbus
fading stag
worn jasper
#

people understand 1.8.8 is outdated

hoary scarab
fading stag
hoary scarab
#

👍

proud pebble
wind tapir
# proud pebble that looks like you created an armorstand with nms, did you make sure to actuall...

yes, now I have another problem, the as is not spawning:


armorStand = new EntityArmorStand(((CraftWorld)p.getWorld()).getHandle());
        armorStand.setCustomName(rmain.getPrefix(p.getUniqueId()));
        armorStand.setInvisible(true);
        armorStand.setPosition(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());

        PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armorStand);
        for(Player pl : Bukkit.getOnlinePlayers()){
            PlayerConnection connection = ((CraftPlayer)pl).getHandle().playerConnection;
            connection.sendPacket(packet);
        }
        PlayerConnection connection = ((CraftPlayer)p).getHandle().playerConnection;
        connection.sendPacket(packet);

proud pebble
#

that will spawn the armorstand

#

actually, you could be trying to spawn it packet only, lemme see

wind tapir
#

 armorStand = new EntityArmorStand(((CraftWorld)p.getWorld()).getHandle().addEntity(EntityArmorStand));

#

between the ()

#

it has an error

#

Expression expected

#

I have to do new EntityArmorStand ?

dense drift
#

I guess you need to run that after you set all the properties to the armorStand

proud pebble
#

yes

dense drift
#

But not the way you typed it

wind tapir
#

no error

#

World world = ((CraftWorld)p.getWorld()).getHandle();
        armorStand = new EntityArmorStand(world);
        armorStand.setCustomName(rmain.getPrefix(p.getUniqueId()));
        armorStand.setInvisible(true);
        armorStand.setPosition(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());

        PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armorStand);
        for(Player pl : Bukkit.getOnlinePlayers()){
            PlayerConnection connection = ((CraftPlayer)pl).getHandle().playerConnection;
            connection.sendPacket(packet);
        }
        PlayerConnection connection = ((CraftPlayer)p).getHandle().playerConnection;
        connection.sendPacket(packet);

proud pebble
#

addfreshentity might not exist for 1.8.8

wind tapir
#

i used addentity

proud pebble
wind tapir
#

ye

proud pebble
#

just so you can check to see if its actually there or if the custom name failed and it just doesnt show it for whatever reason

proud pebble
wind tapir
#

nothing

wind tapir
#

so everyone can see the packets

#

but if i do a for

#

all players can see

#

i'll remove ti

proud pebble
#

im just saying your sending the packet to the original player twice

wind tapir
#

yes

proud pebble
#

since they are included in the getonlineplayers

wind tapir
#

it's spawning

#

it was just bc I sent the packet twice

proud pebble
#

makes sense

wind tapir
#

thanks

proud pebble
#

just remember because your spawning the entity with packets only, you will have to manually keep track of it

wind tapir
#

task = Bukkit.getScheduler().runTaskTimerAsynchronously(main, () -> {
            armorStand.setPosition(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());

            PacketPlayOutEntityTeleport teleport = new PacketPlayOutEntityTeleport(armorStand);
            for(Player pl : Bukkit.getOnlinePlayers()){
                PlayerConnection connection = ((CraftPlayer)pl).getHandle().playerConnection;
                connection.sendPacket(teleport);
            }
        }, 0, 0);

proud pebble
wind tapir
hoary scarab
proud pebble
#

yeah you need to create one armorstand per player

wind tapir
#

I did this

#

 private void setNametag(Player p) {

        scoreboard = p.getScoreboard();
        team = scoreboard.getTeam("-" + p.getName());

        if (team == null) {
            team = scoreboard.registerNewTeam("-" + p.getName());
        }

        team.setPrefix(rmain.getColor(p.getUniqueId()));

        team.addEntry(p.getName());

        armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
        armorStand.setCustomName(rmain.getPrefix(p.getUniqueId()));
        armorStand.setCustomNameVisible(true);
        armorStand.setVisible(false);
        armorStand.teleport(p.getLocation());

        task = Bukkit.getScheduler().runTaskTimerAsynchronously(Bukkit.getPluginManager().getPlugin("Nametags"), () -> {
            armorStand.teleport(p.getLocation());
        }, 0, 0);
    }

dense drift
#

well since they use the armorstand for player's name, they need to send it to all players though (without the player for whom you display the name though)

hoary scarab
#

I just read what luna said and added to it xD

proud pebble
#

that doesnt look like they are saving the armorstand's entity id or uuid anywhere to keep track of which armorstand to send to which player

broken elbow
#

Well they don't need to because they run a task for each player

proud pebble
#

ohh i see

broken elbow
#

which contains each armor stand

wind tapir
#

do I need to create a hashmap?

dense drift
#

I wonder why when you add the armorstand as passenger, the name is so high

wind tapir
#

i already tested it before, it wasn't that high

proud pebble
#

i didnt think they were adding it as a passenger anymore?

wind tapir
#

yes

hoary scarab
proud pebble
#

so i or others can understand exactly whats occuring

dense drift
proud pebble
#

i think they want to replace the player's nametag with it

wind tapir
dense drift
#

have you set invincible = true?

wind tapir
#

and isn't the slime blocking while attacking ?

dense drift
#

if it is invisible, no, it won't

proud pebble
#

can entity names be bigger then 48 character or is it only players that are limited to that?

dense drift
wind tapir
#

only invisible exists

#

in the version i use

dense drift
#

ahh it is invurnerable, not invincible

wind tapir
dense drift
#

nvm 1.8 doesn't have that either lol

wind tapir
#

I could simply do that, right ?

#

@EventHandler
    public void onDamage(EntityDamageEvent e){
        if(e.getEntity() instanceof EntitySlime){
            e.setCancelled(true);
        }
    }

mortal scaffold
#

how i can get list of server players on fabric/forge?

dense drift
wind tapir
warm steppe
#

Did you try?

wind tapir
versed carbon
#
    public void onClickEvent(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
            player.sendMessage(ChatColor.GRAY + "10 Seconds on the delay.");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            player.sendMessage(ChatColor.GRAY + "5 Seconds on the delay");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            player.sendMessage(ChatColor.GRAY + "Event Happens!");
            //Ta Da!
        }
    }```
Hey all, what could I replace this with?
```Thread.sleep();```
I have no experience with making multiple threads so I'm looking to avoid that for now.
wind tapir
versed carbon
dense drift
#

no it won't

wind tapir
#

someone told me that it pause the entire server, I stopped using it

#

GabyTM

#

it's hiding my nametag

#

do you have an idea why please

#

?

#

        Slime slime = (Slime) p.getWorld().spawnEntity(p.getLocation(), EntityType.SLIME);
        slime.setSize(-1);
        slime.setCustomName("test ");
        slime.setCustomNameVisible(true);
        slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999, 2, false, false));
        slime.teleport(p);
        p.setPassenger(slime);
dense drift
#

perhaps because of the invisibility?

wind tapir
#

I know how to do it wait

dense drift
#

try setInvisible(true)

wind tapir
#

EntitySlime slime1 = ((CraftSlime)slime).getHandle();
        slime1.setInvisible(true);

#

negative size doesn't work...

#

wait

#

and invisibility too wtf ,

#

?

dense drift
#

yeah the person said to use a slime and then add a small armor stand as passenger to the slime

#

I don't know much about NMS, so Idk why it doesn't work

wind tapir
#

like this ?


Slime slime = (Slime) p.getWorld().spawnEntity(p.getLocation(), EntityType.SLIME);
        slime.setSize(-1);
        slime.setCustomName("test ");
        slime.setCustomNameVisible(true);
        slime.teleport(p);

        p.setPassenger(slime);

        slime.setPassenger(armorStand);
        EntitySlime slime1 = ((CraftSlime)slime).getHandle();
        slime1.setInvisible(true);

dense drift
#

yeah

#

also, why do you combine nms and spigot api like that? Just use NMS directly if you go on that direction

wind tapir
wind tapir
dense drift
#

the curse of using 1.8 kek

worn jasper
#

any ideas why loc.getWorld().spawn(loc, ArmorStand.class); doesn't spawn the armorstand?

wind tapir
dense drift
wind tapir
#

if so, then the method I gave is right

#

normally

worn jasper
#

confusion

wind tapir
worn jasper
#

apparently it's multiversecore?

#

but I didn't disable anything though

#

is the there a propriety for this?

dense drift
#

I wonder what is the difference between spawn and create

#

@pulsar ferry any idea?

#

also, with the new name I can finally not mention someone else by accident kek

pulsar ferry
#

One returns T other returns Entity, type safety is the difference

dense drift
#

oh but the behaviour is the same?

pulsar ferry
#

Yeah

dense drift
#

good to know, thanks bb

dense drift
#

Does anyone know if Bukkit#performCommand triggers any event?

dire flint
#

i want to show action bar every 3 second with different text (list<string>) and use placeholderapi in it how to do it

dense drift
#

Send an action bar every 3 seconds?

versed carbon
#

Anyone able to tell me why it's doing this? It's driving me nuts and I've re wrote it twice now and I can't see what the issue is at all.
https://imgur.com/a/JdWOaxl

    @EventHandler
    public void onEntityDeath(EntityDeathEvent event) {
        Player player = event.getEntity().getKiller();
        if (!(event.getEntity() instanceof Vindicator))
            return;
        if (event.getEntity().getCustomName() == null)
            return;
        if (!event.getEntity().getCustomName().contains("Ivan The Immovable"))
            return;
        for (Entity entity : event.getEntity().getNearbyEntities(10, 10, 10)) {
            player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 2));
            player.sendMessage(ChatColor.GRAY + "Using his last ounce of strength Ivan hit the ground with as much strength as he could muster,");
            new DelayedTask(() -> {
                player.sendMessage(ChatColor.GRAY + "hitting you hard enough to leave a slight concussion.");
                new DelayedTask(() -> {
                    event.getDrops().clear();
                    Random random = new Random();
                    int number = random.nextInt(1000) + 1;
                    Random randomEmerald = new Random();
                    int numberEmerald = random.nextInt(15) + 1;
                    Random randomEmeraldBlock = new Random();
                    int numberEmeraldBlock = randomEmeraldBlock.nextInt(7) + 1;
                    if (number < 600) {
                        for (int i = 0; i < numberEmerald; i++) {
                            event.getDrops().add(new ItemStack(Material.EMERALD));
                        }
                        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&7Congratulations " + event.getEntity().getKiller().getName() + " for slaying [&cIvan The Immovable&7] and getting the drop [&c" + numberEmerald + "&7] Emerald(s)"));
                    } else
                        for (int i = 0; i < numberEmeraldBlock; i++) {
                            event.getDrops().add(new ItemStack(Material.EMERALD_BLOCK, 1));
                        }
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&7Congratulations " + event.getEntity().getKiller().getName() + " for slaying [&cIvan The Immovable&7] and getting the drop [&c" + numberEmeraldBlock + "&7] Emerald block(s)"));

                    ItemStack ivansShield = new ItemStack(Material.SHIELD, 1);
                    ItemMeta ivansShieldMeta = ivansShield.getItemMeta();
                    ivansShield.setItemMeta(ivansShieldMeta);

                    Random randomShield = new Random();
                    int numberShield = randomShield.nextInt(100) + 1;
                    if (numberShield < 25) {
                        event.getDrops().add(ivansShield);
                        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&7Congratulations " + event.getEntity().getKiller().getName() + " You obtained the [&cIvan The Immovable's Shield&7]!"));
                    } else
                        return;
                }, 20 * 3);
            }, 20 * 4);
        }
    }
dire flint
#

again(show action bar => 3 seconds => show action bar with different text )

#

?paste

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

versed carbon
worn jasper
#

How would you make it impossible to get the armor of armor stands?

spiral prairie
#

cancel interact event

worn jasper
#

PlayerInteractEntityEvent?

#

or just PlayerInteractEvent?

#

cause it's not working lol

spiral prairie
#

which one?

pulsar ferry
#

PlayerArmorStandManipulateEvent

worn jasper
#

eyo that exists?!

#

ty

dark garnet
#

hey guys anyone know how to import another gradle plugin into ur own?

#

trying to use some features from the java plugin

signal grove
worn jasper
#

uhm what's the alternative to setCustomName in newer versions since that's depricated

#

ignore, it's customName()

river solstice
#

Yes

#

I was always interested behind the reasoning of paper not using the getX setX convention and instead 0 overloads = get, else set

dusky harness
#

and i think the adventure devs in general tend to use that naming convention

worn jasper
#

I actually prefer this conventation tbh

#

looks cleaner

river solstice
#

Oh nvm

#

I was thinking about the setter, that it wouldnt matter since it's a different param

#

But getter wouldnt work

dusky harness
#

How do I teleport a fishing hook? ex this doesn't do anything: ```kt
@EventHandler
private fun ProjectileHitEvent.onHit() {
if (entity is FishHook) {
Bukkit.broadcast(text("Teleporting up")) // prints
entity.teleport(entity.location.clone().add(0.0, 5.0, 0.0))
return
}
}

#

🤔

worn jasper
#

uhm any ideas why #remove() doesn't remove an armorstand? (also, not idea about the above)

dense drift
#

Ah nvm, I just saw the comment

tawny tree
#

How do i revoke a players advancement? for some reason i can't find a single thread that helps

dire flint
#

i want to send actionbar to players and use placeholder to format text and i want to show their own output from placeholder how to do it?

dense drift
#

As in to expose it to projects that use your plugin? Otherwise I guess you simply import it as usualy, in the plugins {} block

dark garnet
dire flint
#

how to make own library to my plugins (i change library plugin it will apply to all plugins)

dense drift
river solstice
#

no that's Player class

#

🧌

river solstice
#

yes

dark garnet
dense drift
#

was adventure updated to 1.20 / works in 1.20?

dusky harness
#

since paper is out as well

#

i think fabric adventure 1.20 isn't ready yet though

#

but besides that the others should

dense drift
#

yeah i need only the bukkit platform

shell moon
#

I guess latest version does work in 1.20

dusky harness
#

so

shell moon
#

as there are people using my library (yes, adventure bukkit shaded in it)

dusky harness
#

¯_(ツ)_/¯

shell moon
candid arch
#

Hey there, question.
Some uses of my plugin wants that I add a leaderboard of the most gentle and the most evil players (let's call it a Score).

When disconnected players data are stored into database, it is simple to do so: get Scores from database (ignore online players), then compare.

But for servers that stores datas into .yml files (with 1 file per player instead of one big file for all), is it gonna be problematic for perfs ? (I have an idea of just storing the most extreme Scores updated amounts into a separated file but. What do you think of it ?)

lyric gyro
#

Can anyone help me so I setup guylab with a. Runner when I commit it start to build it build successfully but won’t artefact it

dense drift
candid arch
#

I'll check sqlite then !

icy shadow
#

Normal files are also fine in a lot of situations

#

You don’t always need a database

dense drift
#

yeah that's true, but this might not be one of those situations

fading stag
versed carbon
#

I think I'm losing the plot ;-; it's one issue after the other with this entity.

int number = random.nextInt(100) + 1;
Random randomEmerald = new Random();
int numberEmerald = randomEmerald.nextInt(16) + 1;
Random randomEmeraldBlock = new Random();
int numberEmeraldBlock = randomEmeraldBlock.nextInt(8) + 1;

                    if (number < 60) {
                        event.getDrops().add(new ItemStack(Material.EMERALD, numberEmerald));
                        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&7Congratulations " + event.getEntity().getKiller().getName() + " for slaying [&cEntity&7] and getting the drop [&cEmerald x" + numberEmerald + "&7]"));
                    } else {
                        event.getDrops().add(new ItemStack(Material.EMERALD_BLOCK, numberEmeraldBlock));
                        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&7Congratulations " + event.getEntity().getKiller().getName() + " for slaying [&cEntity&7] and getting the drop [&cEmerald Block x" + numberEmeraldBlock + "&7]"));
                    }```
I'm trying to simply set the drops of an entity on it's death to either emeralds or emerald blocks.
It's saying the message so I know the if parts are working, I also know I'm changing the entities drops because 'event.getDrops().clear();' works but adding items just isn't working.
river solstice
#

and don't re-create the random class for each roll 💀

versed carbon
#

so it doesn't save the random number? it re rolls per part?

river solstice
#

everytime you call .nextInt or .nextWhatever, it spits out a pseudo-random number

dense drift
#

yeah it generates a new number every time

river solstice
#

so you don't need to create a new instance of it everytime, just do smt like
private static final Random rnd = new Random();

dense drift
#

you probably need to drop the items manually with World#dropItem

versed carbon
river solstice
#

what

#

I'm talking about the random class, not the event handler

#
private static final Random rnd = new Random();

@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
  rnd.nextInt();
}
dense drift
#

or ThreadLocalRandom.current()
edit: or not

river solstice
#

lets keep it shrimple

versed carbon
river solstice
#

yeah well I'd suggest some learning OOP fundamentals first

versed carbon
#

I'll look into one 🙂 (might be a bit off topic) do you know where I could take one online?

river solstice
#

googol => OOP fundamentals java

versed carbon
#

thanks 🙂

versed carbon
river solstice
#

well if you'd know the basics of what I'm saying, then no, it won't
it's just a performance save

#

tldr

  • cancel the event
  • get the death location
  • drop items manually
versed carbon
#

that worked thanks 🙂

river solstice
#

ah maybe not cancel the event but nvm

dark garnet
#

even just helping me google how, cause ive tried so many different searches

minor summit
#

add the plugin in the dependencies block of the plugin's build script

#

or if it's a convention plugin you can also add it to the plugins block

dark garnet
#
/**
 * Sets the Java (and possibly Kotlin in the future) version for the project
 *
 * @param javaVersion The java version to set (example: `1.8`)
 */
fun Project.setJavaVersion(javaVersion: JavaVersion = JavaVersion.VERSION_1_8) {
    require(hasJavaPlugin()) { "Java plugin is not applied!" }
    java {
        sourceCompatibility = javaVersion
        targetCompatibility = javaVersion
    }
}
minor summit
dark garnet
# minor summit you need to get the extension directly

ahhhh so like this right?

fun Project.setJavaVersion(javaVersion: JavaVersion = JavaVersion.VERSION_1_8) {
    require(hasJavaPlugin()) { "Java plugin is not applied!" }
    val java: JavaPluginExtension = extensions["java"] as JavaPluginExtension
    java.sourceCompatibility = javaVersion
    java.targetCompatibility = javaVersion
}
minor summit
#

yea

dark garnet
#

thank u that makes much sense @dusky harness

dusky harness
#

oh interesting

#

wait howd u import it

#

whats in ur build.gradle.kts?

dark garnet
#

since java is a built-in pugin the classes (JavaPluginExtension) were already accessible

#

it was just a matter of how to get an instance of it

#

also dkim, does kotlin require/use the java plugin?

dusky harness
#

it automatically imports it

dark garnet
#

does kotlin use compileOnly and stuff

dusky harness
#

wdym

#

yeah

dark garnet
#

ok then yea kotlin does import java cause i think its what adds those

dusky harness
dark garnet
#

ah ok yeye

green latch
#

Hey I am trying to create a link detector but it doesn't really detect the link if it's combined with words:

public class ClickableLinks {

    private static final String LINK_REGEX = "^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$";
    private static final Pattern pattern = Pattern.compile(LINK_REGEX);

    public static BaseComponent[] convertLinksToClickable(String message) {
        ComponentBuilder builder = new ComponentBuilder("");
        Matcher matcher = pattern.matcher(message);

        int lastEnd = 0;

        while (matcher.find()) {
            String textBeforeLink = message.substring(lastEnd, matcher.start());
            String link = matcher.group();

            builder.append(textBeforeLink);

            BaseComponent[] linkComponent = new ComponentBuilder(link)
                    .color(ChatColor.AQUA)
                    .underlined(true)
                    .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link))
                    .create();

            builder.append(linkComponent);

            lastEnd = matcher.end();
        }

        if (lastEnd < message.length()) {
            String textAfterLink = message.substring(lastEnd);
            builder.append(textAfterLink);
        }

        return builder.create();
    }
}```
I've got no idea why
dense drift
#

remove the ^ and $

green latch
#

with: "https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)";

hazy nimbus
#

I honestly don't know regex, but here's the regex I'm using for this same purpose.

Pattern.compile(
            "(?:^|[\\W])((ht|f)tp(s?)://|www\\.)(([\\w\\-]+\\.)+?([\\w\\-.~]+/?)*[\\p{Alnum}.,%_=?&#\\-+()\\[\\]*$~@!:/{};']*)",
            Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL
    );
lyric gyro
#

it doesnt do anything

dawn viper
#

send the updated code

lyric gyro
#

oh

#

sorry i was just in need of help and i didnt know what category to go to

dawn viper
#

add debug messages before and after each if statement to see where it stops working

lyric gyro
#

ok

green latch
hazy nimbus
#

it does

#

Send your code

lyric gyro
dawn viper
#

here

#

?paste

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

green latch
# hazy nimbus Send your code
private static final String LINK_REGEX = "(?:^|[\\W])((ht|f)tp(s?)://|www\\.)(([\\w\\-]+\\.)+?([\\w\\-.~]+/?)*[\\p{Alnum}.,%_=?&#\\-+()\\[\\]*$~@!:/{};']*)";
    private static final Pattern pattern = Pattern.compile(LINK_REGEX, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);

    public static BaseComponent[] convertLinksToClickable(String message) {
        ComponentBuilder builder = new ComponentBuilder("");
        Matcher matcher = pattern.matcher(message);

        int lastEnd = 0;

        while (matcher.find()) {
            String textBeforeLink = message.substring(lastEnd, matcher.start());
            String link = matcher.group();

            builder.append(textBeforeLink);

            BaseComponent[] linkComponent = new ComponentBuilder(link)
                    .color(ChatColor.AQUA)
                    .underlined(true)
                    .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link))
                    .create();

            builder.append(linkComponent);

            lastEnd = matcher.end();
        }

        if (lastEnd < message.length()) {
            String textAfterLink = message.substring(lastEnd);
            builder.append(textAfterLink);
        }

        return builder.create();
    }```
dawn viper
#

you're casting the item instead of the meta

green latch
#

Maybe it's not the regex then but the actual code that contains an error... maybe

lyric gyro
green latch
hazy nimbus
#

no idea

green latch
#

Ah okay, just thought you modified it

granite narwhal
#

How can I make the deluxe menu open by clicking on an item (for example, the hell star)
I tried to use this code:

@EventHandler
    public void onPlayerInteract(PlayerInteractEvent event){
        try{
            ItemStack clickItem = event.getItem();
            Action playerAction = event.getAction();
            Player player = event.getPlayer();
            if(clickItem.getType() == Material.NETHER_STAR && playerAction.toString().contains("RIGHT") && clickItem.getItemMeta().getCustomModelData() == 25){
                Bukkit.dispatchCommand(player, "menu");
            }
        }catch (Exception e){
            System.out.println("click with nothing item");
        }
    }
#

we are fix

@EventHandler
    public void onPlayerInteract(PlayerInteractEvent event){
        try{
            ItemStack clickItem = event.getItem();
            Action playerAction = event.getAction();
            Player player = event.getPlayer();
            if(clickItem.getType() == Material.NETHER_STAR && playerAction.toString().contains("RIGHT") && clickItem.getItemMeta().getCustomModelData() == 25){
                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dm open main_menu " + player.getDisplayName());
            }
        }catch (Exception e){
            System.out.println("click with nothing item");
        }
    }
proud pebble
dark garnet
#

anyone know if i need to use com.github.srnyx in my jitpack publishing configuration in my build file if i have a custom domain (xyz.srnyx) set-up instead? or can i just use xyz.srnyx as the groupId in the configuration?

// Maven publishing for Jitpack
configure<PublishingExtension> {
    publications {
        create<MavenPublication>("maven") {
            groupId = "com.github.srnyx" // instead, could it be "xyz.srnyx"?
            from(components["java"])
        }
    }
}
dusky harness
#

When importing the dependency

dusky harness
#

Like in another project when you add the dependency

river solstice
dark garnet
#

so idk if i need to keep com.github.srnyx as the groupId in the api's build file (for jitpack) or if it just doesnt matter

dusky harness
#

Prob should be xyz then

wind tapir
#

Hello, can anyone give me the dependence ( maven ) for paper 1.8.8 ? Thanks

#

because:

#

com.destroystokyo.paper:paper-api🫙1.8.8-R0.1-SNAPSHOT was not found in https://papermc.io/repo/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of papermc has elapsed or updates are forced

proud pebble
hazy nimbus
#

Isn't using paper 1.8 a security risk due to log4j?

proud pebble
hazy nimbus
#

Well then

wind tapir
#

I'll just take the 1.19.4 version for the event

dusky harness
wind tapir
dire flint
#

does anyone know i deploy compiled jar file to sFTP server (maven)

signal grove
#

anyone know off top if i can call config.getDouble() on an int? or if its gonna throw an exception

#
x: 0

config.getDouble("x")

#

im just gonna assume it works and find out later

tired olive
#

it does

rancid bronze
#

JavaPlugin#getConfig() is in memory right?

#

like the config file is only read on startup

dusky harness
#

unless you do saveDefaultConfig or reloadConfig i think?

fading stag
river solstice
#

would be dumb not to

nova minnow
#

Hey,
I've got a ptoblem: I am trying to loop a SignChangeEvent so it updates the lines automatically. I am creating a minigame and as soon as the Staus of the Lobby changes, it should automatically be changed on the sign too. However, as soon as the sign is updated, it becomes blank :/

#

For reference: The loop is probably the main cause of the issue

                        @Override
                        public void run() {
                            e.setLine(0, "§8[§3Hide§fand§bSeek§8]");
                            e.setLine(1, "§7" + e.getLine(1));
                            e.setLine(2, "§b" + cfg.getInt("HAS.Maps." + ChatColor.stripColor(e.getLine(1)) + ".PlayerAmount") + " §8/ §b10");
                            switch(status) {
                                case "OPEN":
                                    e.setLine(3, "§a" + status);
                                    break;
                                case "RUNNING":
                                    e.setLine(3, "§6" + status);
                                    break;
                                case "CLOSED":
                                    this.cancel();
                                    break;
                            }
                            s.update(true);
                        }
                    }.runTaskTimer(pl, 0, 20L); ```
hoary scarab
nova minnow
#

Ahh okay, thank you 🙂 So in that case I can use the "s" variable, right? The s Variable is just the BlockState of the Sign

nova minnow
#

Yeah exactly

#

Thank you 😄

hoary scarab
#

Ah yeah didn't see the s.update()

nova minnow
#

Don't worry. Thank you for your help

hoary scarab
#

Np

#

Also I would keep track of that task incase you need to forcefully cancel it later.

nova minnow
#

By which means?

#

The runnable gets cancelled, as soon as the sign is broken or the game has ended

hoary scarab
hoary scarab
nova minnow
#

Yeah, sry. I added it afterwards

broken elbow
#

If anyone already knows this or has the time to test this, can you have a list of objects that have different types with spigot's snakeyaml? I don't minding it just giving me a List<Object> and letting me handle the type check and casting.

worn jasper
#

Uhm how would I get the player that killed another player with a respawn anchor or minecart?

#

any ideas?

worn jasper
#

you can kill players with respawn anchors and tnt minecarts

#

question is how I would get the killer, aka who ignited/explodes the respawn anchor or tnt minecart

dense drift
#

Get the last damage cause? It might be EXPLOSION or smth

hoary scarab
worn jasper
dusty frost
#

LivingEntity#getKiller() might work

worn jasper
#

but how would you get the person who ignited the minecart though?

dense drift
dusty frost
#

cause the death messages know who killed them right

worn jasper
#

yes

dusty frost
#

so surely that's tracked somewhere

worn jasper
#

I mean yesno

dusty frost
#

probably in Player#getKiller()

broken elbow
hoary scarab
worn jasper
#

anchors for example:

dusty frost
#

yeah but doesn't the death message know who ignited the TNT

worn jasper
#

crystals just say I blew up

#

same for minecarts

hoary scarab
worn jasper
#

they don't store who ignited them

dusty frost
#

oh that's annoying

worn jasper
#

yeah...

dusty frost
#

whelp yeah i guess we'll never know

#

and/or it's time to fork Paper and add your own patch >:)

dense drift
#

TNTPrime has getSource which returns Entity, can you get TNTPrime from the damage event?

worn jasper
#

I could check for EntityExplodeEvent but that doesn't get me who ignited it

#

aaaaaaaaaa

#

but a minecart tnt isn't tnt prime or is it?

dense drift
#

Ah I thought you want normal tnt as well

worn jasper
#

nha

dense drift
#

I think the cart explodes on impact or whatever, it doesnt behave like normal tnt

broken elbow
#

you can also ignite it

#

with some rails

dense drift
#

See what the damage event returns for tnt minecart ig

#

Yeah but doesnt it explode instantly?

broken elbow
#

no

#

at least that's how I remember it

dense drift
#

Yeah idk either exactly, some debug on the death event should help

dusty frost
#

apparently there's BlockIgniteEvent, but I'm guessing that doesn't count for respawn anchors and tnt minecarts that blow up instantly

dense drift
#

I think anchors and end crystals trigger entity explode, or at least that is the only event that makes sense to me

dusty frost
#

would be nice if they ignited 😔

worn jasper
worn jasper
#

I already added crystals

dense drift
#

No it is a block

leaden sinew
dusty frost
#

have you tried BlockIgniteEvent

worn jasper
#

for crystals I listened to EntityDamageByEntityEvent and stored the crystal UUID and player in a map, then when the player died, got the id of the killer entity and voila

dense drift
worn jasper
worn jasper
#

only the cause

dense drift
#

You can 100% because it returns entity damage event

#

You might need to cast it to EntityDamageByEntityEvent

worn jasper
#

let me see

#

restarting the server

#

getKiller is null and damager is MINECART_TNT

dense drift
#

Amazing

worn jasper
#

yes but that doesn't solve the issue

#

I still don't know who ignited that minecart

#

I need to detect when someone shoots a minecart tnt with a bow with flaming

#

and store that info

dense drift
#

Entity damage by entity probably

fading stag
dense drift
#

I saw a post on bukkit and they suggested to set a meta key to all players in the radius of the explosion and then check for that meta on the death event

dusky harness
#

You can use PDC for minecarts

#

And respawn anchor

dense drift
#

Yeah, or PDC, the post was old and back then only metadata existed xD

arctic flint
#

im developing a client, and i need help with a crash, that idk how to fix

#

nvm i fixed it lol

worn jasper
dusky harness
#

Yea

worn jasper
#

uh... #getDamager() in EntityDamageByBlockEvent is returning null when a respawn anchor explodes lol

#

shouldn't it return the anchor block object?!

dense drift
#

😩

worn jasper
#

yes.

signal grove
#

i'd just define a few special cases like if the player directly set off the explosive or if they directly shoot it, theyre the killer. if not, idk.. either assign nobody the killer or whoever placed the explosive

signal grove
#

yeah thats good enough

worn jasper
#

here's the thing

#

same thing seems to be happening like respawn anchors

#

or wait...

#

yeah no

#

but yeah respawn anchors are an issue

#

apparently paper issue

worn jasper
#

yeah no idea

dense drift
#

Dead end

worn jasper
#
    private void removeAmount(Player p, ItemStack item, int amount) {
        PlayerInventory inventory = p.getInventory();
        for (ItemStack inventoryItem : inventory.getContents()){
            if (inventoryItem == null || inventoryItem.getType() == Material.AIR){
                continue;
            }
            if (inventoryItem.isSimilar(item)) {
                if (inventoryItem.getAmount() > amount){
                    inventoryItem.setAmount(inventoryItem.getAmount() - amount);
                    return;
                } else {
                    amount -= inventoryItem.getAmount();
                    inventory.remove(inventoryItem);
                    if (amount <= 0) return;
                }
            }
        }
    }

any ideas what's wrong with this? Cause right now, if amount is 200 for example, and I have 4x64 of that item, instead of removing 200 it will remove all the stacks

#

I am a bit lost on what's causing it

#

probably just missing smt lol

dusky harness
worn jasper
#

it's removing the items, the issue is that it's removing too many

worn jasper
dense drift
#

nice

worn jasper
#

Simply, on the PlayerInteractEvent listener, when the player exploded the anchor, it would get all players in a 12 block radius (from what I tested, you get dmg till 12 blocks) and then stored in a hashmap, the damaged player and the player that caused it. It gets wiped 5 ticks after, but that's enough for the PlayerDeathEvent to check if the player is in that list.

#

Quite a workaround but welp

#

Still opened the paper issue though

rigid mountain
#

Working on some enchants, and i just had a thought would it be easier/more efficient to store the enchants in a PDC and then refrence that or register them and add them normally?

void orchid
worn jasper
dusky harness
#

bc ur not removing the specific slot

#

you're removing the ItemStack instance

#

which I assume uses #equals instead of ==

#

¯_(ツ)_/¯

worn jasper
#

confusion

void orchid
worn jasper
#

debugged, only called once

void orchid
#

Very well! I just checked the #remove (https://helpch.at/docs/1.16.5/org/bukkit/inventory/Inventory.html#remove(org.bukkit.inventory.ItemStack)) method for you, and it states this on 1.16.5 version of Spigot:

Removes all stacks in the inventory matching the given stack.
If you are using a different version, or on Paper, and it still states the same thing, then Dkim was perhaps right afterall

#

Try using the #clear(slot) method instead maybe? That could ought to do it

worn jasper
#

yeah that works, thanks a lot.

void orchid
#

Anytime! :)

dusky harness
#

🥲

#

i just explained very poorly lol

void orchid
#

Yeah haha, I (rightfully) credited that to ya

worn jasper
#

yeah.. didn't understand at first

dark garnet
#

hi i need to apply a gradle plugin (non-built-in) with a specific version using apply(...), cant use plugins { } dsl unfortunately as this is in my own plugin FLOOSH
here's what happens when i try using plugins { }:

Using 'plugins(PluginDependenciesSpec.() -> Unit): Nothing' is an error. The plugins {} block must not be used here. If you need to apply a plugin imperatively, please use apply<PluginType>() or apply(plugin = "id") instead.
icy shadow
#

I mean

#

It tells you the issue lol

dark garnet
icy shadow
#

It also tells you what to do lol

dark garnet
river solstice
sonic nebula
#

[16:45:32 INFO]: [ZXRust][Debug]1 Ammo: 20
[16:45:32 INFO]: [ZXRust][Debug]2 Ammo: 19
[16:45:32 INFO]: [ZXRust][Debug]3 Ammo: 19
[16:45:32 INFO]: [ZXRust][Debug]Shoot was called by player
[16:45:33 INFO]: [ZXRust][Debug]1 Ammo: 19
[16:45:33 INFO]: [ZXRust][Debug]2 Ammo: 18
[16:45:33 INFO]: [ZXRust][Debug]3 Ammo: 18
[16:45:33 INFO]: [ZXRust][Debug]Shoot was called by player
[16:45:46 INFO]: [ZXRust][Debug]1 Ammo: 19
[16:45:46 INFO]: [ZXRust][Debug]2 Ammo: 18
[16:45:46 INFO]: [ZXRust][Debug]3 Ammo: 18
[16:45:46 INFO]: [ZXRust][Debug]Shoot was called by player
[16:45:54 INFO]: [ZXRust][Debug]1 Ammo: 18
[16:45:54 INFO]: [ZXRust][Debug]2 Ammo: 17
[16:45:54 INFO]: [ZXRust][Debug]3 Ammo: 17

#

what causes the event be fired but the itemstack not to update?

spiral prairie
#

Have you sent any code?

sonic nebula
#

yeah sec i remove all not nessecery thngs from iit (things that are doing other things and work well.)

#
        Player player = event.getPlayer();
        CLog.ConsoleDebugMessage("1 Ammo: " + WeaponsUtils.getGunAmmo(player.getInventory().getItemInHand()));
        String itemID = compound.getString("ID");
        int itemSID = compound.getInt("SID");
        if (WeaponsUtils.getGunAmmo(player.getInventory().getItemInHand()) > 0) {
            ItemMeta meta  = item.getItemMeta();
            List<String> lore = meta.getLore();
            lore.set(lore.size() - 1,"Ammo: " +  (WeaponsUtils.getGunAmmo(player.getInventory().getItemInHand()) - 1));
            meta.setLore(lore);
            item.setItemMeta(meta);
            CLog.ConsoleDebugMessage("2 Ammo: " + WeaponsUtils.getGunAmmo(player.getInventory().getItemInHand()));
#

the getGunAmmo is basically int dont tmind the caps i know its java and not C#

#

it just returns the amount of ammo from lore

#

dont suggest to use PDC. player meant to see the ammo viia lore

#

else i would use map to control it

spiral prairie
#

Use PDC

sonic nebula
#

no no dont suggest PDC please player cant see PDC

dense drift
#

PDC is just bukkit's api for nbt, but you can not edit any tags with it

spiral prairie
#

They can see lore though

sonic nebula
#

i do use nbt for something else.

#

a compounds

#

to store item Serial ID

dense drift
#

Dont strip lore for data

sonic nebula
#

no no GabyTM lett me explain i do have other way to ttrack ammo

#

i use map with weapon Serial ID (every weapon has unique Serial ID) and int ammo

#

now problem is lets say player wants to see amount of ammo

#

because the server is survival server and ammo is sometthing exclusive

#

i dont update item constatly if lore wont work i guess ill just use handler that loads weapon ammo from database each time if its not in the server cache already

#

so basically lore wont work? thats why its so broken?

dusky harness
#

I would just use PDC and lore, and no database stuff

sonic nebula
#

how nbt compound can be displayed on itemlore?

#

just wondering

dusky harness
#

And no other nbt stuff
Just PDC and lore
Whenever you modify ammo, modify both PDC and lore

#

No compound stuff

#

No weapon serial

sonic nebula
#

compound is basically pdc

dusky harness
#

Ik but I mean use PDC not the other nbt

#

No need for database and serial Id and stuff

#

When PDC exists

sonic nebula
#

PDC is basically API that allows you to use nbt compunds

#

i use compunds directtly no need shit api

#

nms ftw

dusky harness
#

. Ok
I'm on phone anyways so that's my input but I can't give any code or anything rn

sonic nebula
#

i dont need any code

#

bruh

dusky harness
#

Ok

sonic nebula
#

i dont ask for spoon feed so you guys saying lore is broken af? and its a game limit?

#

i prefer to just update it in the memory

#

then actually updating the item tags

#

too much to update

spiral prairie
#

Shits gonna get crazy with unmarked weapons

sonic nebula
#

wdym unmarked

#

nah user will complain but ill make it if you right click (hit) it says ammo amount

#

i think its fine

spiral prairie
#

I was joking about the irl fact that there are weapons with untraceable serial ids

sonic nebula
#

haha xD

#

americans joke

#

the jokes syrian guys wont get since all of the weapons are untracable

#

haha

#

ill return here with new code so you can rate it guys and tell me if its better 😄

#
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInHand();
        net.minecraft.server.v1_6_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
        NBTTagCompound compound = nmsItem.getTag();
        if (compound == null) {
            return;
        }
        String itemID = compound.getString("ID");
        int itemSID = compound.getInt("SID");
        if (!WeaponAmmo.containsKey(itemSID)) {
            WeaponAmmo.put(itemSID,WeaponsUtils.getGunAmmo(item)); //todo later to change it to load from database if database returns none get gun ammo.
        }
        if (WeaponAmmo.get(itemSID) > 0) {
            CLog.ConsoleDebugMessage("2 Ammo: " + WeaponAmmo.get(itemSID));
            WeaponAmmo.put(itemSID,WeaponAmmo.get(itemSID) - 1);
            CLog.ConsoleDebugMessage("3 Ammo: " + WeaponAmmo.get(itemSID));
            PacketUtils.sendActionBar(player,"&4&lAMMO: &6" + WeaponAmmo.get(itemSID));
            //rest of code works fine.
#

whatt do you think about hat

#

ofc i will ; the int so i wont ask request db

#

so often its just for debugging

edgy lintel
#

v1_6_R3😯
you must be doing mod+plugin servers

#

since mods are abundant on 1.6-1.7

sonic nebula
#

yeah so it looks fine i think i hope it will work

edgy lintel
#

lmao

spiral prairie
#

Imagine being on a version that's so ancient the greek gods have played it

sonic nebula
#

u know whats awesome about that version

#

that in the server we never get to encounter any cheaters

#

my anti cheat is way more advanced that cheats that were created at that ancient ver

#

[17:20:35 INFO]: [ZXRust][Debug]2 Ammo: 23
[17:20:35 INFO]: [ZXRust][Debug]3 Ammo: 22
[17:20:35 INFO]: [ZXRust][Debug]Shoot was called by player
[17:20:36 INFO]: [ZXRust][Debug]2 Ammo: 22
[17:20:36 INFO]: [ZXRust][Debug]3 Ammo: 21
[17:20:36 INFO]: [ZXRust][Debug]Shoot was called by player
[17:20:36 INFO]: [ZXRust][Debug]2 Ammo: 21
[17:20:36 INFO]: [ZXRust][Debug]3 Ammo: 20
[17:20:36 INFO]: [ZXRust][Debug]Shoot was called by player
[17:20:36 INFO]: [ZXRust][Debug]2 Ammo: 20
[17:20:36 INFO]: [ZXRust][Debug]3 Ammo: 19
[17:20:36 INFO]: [ZXRust][Debug]Shoot was called by player

#

issue was fixed thanks for the suggestion~ now using a map instead of item data to store ammo.

worn jasper
#

uhm how can I get the content of a component without the tags? aka just the message, with the colors, etc

sterile hinge
#

what

dense drift
#

LegacyComponentSerializer ?

#

Idk what you mean by "without the tags", MM tags?

worn jasper
#

yes

#

isn't that with legacyAmpersand?

#

or wait no

sterile hinge
#

Components don't contain MM tags anymore

worn jasper
#

confusion be like

dense drift
#

If you serialize them with MM, the string will contain tags obv

worn jasper
#

serialize*

dense drift
#

Yeah, serialize

worn jasper
#

legacyApersand returns the legacy color code though

dense drift
#

And?

sterile hinge
#

you probably want the PlainTextSerializer?

#

not sure what you actually want to achieve here

worn jasper
#

YES

#

I just want the text

#

like no color codes

#

or whatever

worn jasper
#

fk

#

meant without the colors

#

sorry guys

#

lol

dark garnet
# dark garnet anyone know how?

i think i have to use the legacy plugin applying method, right?

//TODO Apply the shadow plugin
buildscript {
    repositories { gradlePluginPortal() }
    dependencies { add("classpath", "${ShadowVersion.parse(shadowVersion).groupId}:shadow:$shadowVersion") }
}
apply(plugin = "com.github.johnrengelman.shadow")
pulsar ferry
#

What are you trying to do?

minor summit
#

summon satan

wind tapir
#

Hello, I have a problem, when I want to setSpectatorTarget to a player on join, the player isn't the first time on the spectatortarget, but when I open my hotbar to tp to the player, I am on the spectator target... Idk if y'all understood me but here's my code

#

            p.setPlayerListName("");
            p.setGameMode(GameMode.SPECTATOR);
            List<Player> playerList = new ArrayList<>();
            for(Player pl : Bukkit.getOnlinePlayers()){
                playerList.add(pl);
            }
            playerList.remove(p);
            Random r = new Random();
            int ri = r.nextInt(playerList.size());
            Bukkit.broadcastMessage(ri + "");
            SpectatorTarget.put(p, playerList.get(ri));
            isSpectating.put(playerList.get(ri), true);

            p.teleport(playerList.get(ri));

            main.getServer().getScheduler().runTaskLater(main, () -> p.setSpectatorTarget(playerList.get(ri)),45);


#

I tried everything

#

that's why there's the nms player

#

wait

sonic nebula
wind tapir
#

me

sonic nebula
#

why you got this ( main.getServer().getScheduler().runTaskLater(main, () -> p.setSpectatorTarget(playerList.get(ri)),45);) can you explain?

#

just curious

wind tapir
sonic nebula
#

u never do a wait you debug instead

#

to see what executes and what values your code outputs

#

also , for(Player pl : Bukkit.getOnlinePlayers()){
playerList.add(pl);
}
playerList.remove(p); wtf is this

#

u already have a list

#

by bukkit

#

why do you re create another list

#

isee you remove the player so it wont tp to him self

wind tapir
#

yes

sonic nebula
#

but why you use a new list instead of bukkit one?

wind tapir
#

I removed the player

#

i can't remove the player from the bukkit list

#

right ?

sonic nebula
#

"tp to the player, I am on the spectator target" from your words

#

it should not be random

#

what r u even coding

wind tapir
sonic nebula
#

so he spectate spectetor?

#

instead just get a random player and check if he survival else use while()

#

so it will try few times

#

since no sense in your code

#

it will just tp to other spectetor also

#

or if he is in playersmap for example

wind tapir
#

what,
?

sonic nebula
#

use uuid instead of players too

#

i just told u what to do

#

will work like charm

#

and simple

#

because what you wrote there lets say if it will work it will be broken af

#

and why teleport

#

why you want to teleportt him

#

use o#setSpectatorTarget(ob2) instead

#

that it so simple

#

also cancel then PlayerSpectateEntityEvent if u want to force players to watch someone

#

do you understand?

dark garnet
dark garnet
#

and u might also need to add a delay when setting the spectator target after teleporting, as sometimes it still wont work cause the player is still being teleported or something. ive had the issue before, so did someone else

sonic nebula
dark garnet
#

but thats like the only correct thing there 💀

sonic nebula
#

idk thats a weird code also pretty sure u dont need to tp the player to targe

#

t

#

i dont think spigot devs are that dumb

#

there no reason to delay it specially not 45 ticks

#

also something i would like to mention about java things happen only when task before was done