#help-development

1 messages · Page 567 of 1

ocean hollow
#

help please

shy rock
#

Wanted to do a lvl 40 to test the diference fast

ocean hollow
smoky anchor
shy rock
#

lmao

smoky anchor
# ocean hollow

do your Boards have a reference to File object ?
Is is possibly private ?

ocean hollow
smoky anchor
#

"Failed making field 'java.io.File#path' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type."

#

Probably does not like the JavaPlugin then

drowsy helm
#

make plugin transient

smoky anchor
#

Oh right, that keyword exists
Have not used it in years

ocean hollow
smoky anchor
ocean hollow
#

how to make that?)

drowsy helm
#

transient JavaPlugin plugin

#

just like any other variable keyword

smoky anchor
#
transient JavaPlugin plugin;
ocean hollow
#

oh, thanks

drowsy helm
#

transient just indicates that the serializer will ignore the variable

ocean hollow
#

I have that problem again

drowsy helm
#

whats List<Task>?

ocean hollow
drowsy helm
#

you should probably isolate the data you want to be serialized into a separate class

#

what even is java.lang.ref.Reference

#

sounds like some post compile shit

shy rock
#

@smoky anchor Thanks for helping me, all works now!

ocean hollow
#

problem in List<Tasks>?

drowsy helm
#

make that transient

#

and see if it still errors

ocean hollow
#

i made that

smoky anchor
#

Do you have any other parameters in there ?

drowsy helm
#

would be nice if gson gave the tree

ocean hollow
#

no

drowsy helm
#

oh

#

you might have to make a TypeAdapter for Location

smoky anchor
#

I'd assume that has to be somewhere somehow registrated, no ?

drowsy helm
#

yeah in the gson lib

smoky anchor
#

or is the instance enough

drowsy helm
#

nvm ignore that gist, they did it wrong

#

you have to extend TypeAdapter

#

similar tho

ocean hollow
#

so I need to use "extends TypeAdapter'? ChatGPT gave me that

drowsy helm
#

have a look at that tutorialspoint link

north hornet
#

does anyone know how i can stop this error from coming up in the console? The plugin doesn't break or anything everything works but it's annoying and some people may think the plugin is broken because of it

[12:45:57] [Server thread/ERROR]: Error occurred while enabling EliteSpawn v1.4.1 (Is it up to date?)
java.lang.IllegalArgumentException: The permission elitespawn.set is already defined!
chrome beacon
#

Only register the permission once?

ocean hollow
drowsy helm
#

lets see the TypeAdapter

ocean hollow
#

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import org.bukkit.Bukkit;
import org.bukkit.Location;

import java.io.IOException;

public class LocationAdapter extends TypeAdapter<Location> {
    @Override
    public void write(JsonWriter out, Location location) throws IOException {
        out.beginObject();
        out.name("world").value(location.getWorld().getName());
        out.name("x").value(location.getX());
        out.name("y").value(location.getY());
        out.name("z").value(location.getZ());
        out.name("yaw").value(location.getYaw());
        out.name("pitch").value(location.getPitch());
        out.endObject();
    }

    @Override
    public Location read(JsonReader in) throws IOException {
        String worldName = null;
        double x = 0, y = 0, z = 0;
        float yaw = 0, pitch = 0;

        in.beginObject();
        while (in.hasNext()) {
            String name = in.nextName();
            switch (name) {
                case "world":
                    worldName = in.nextString();
                    break;
                case "x":
                    x = in.nextDouble();
                    break;
                case "y":
                    y = in.nextDouble();
                    break;
                case "z":
                    z = in.nextDouble();
                    break;
                case "yaw":
                    yaw = (float) in.nextDouble();
                    break;
                case "pitch":
                    pitch = (float) in.nextDouble();
                    break;
                default:
                    in.skipValue();
                    break;
            }
        }
        in.endObject();

        return new Location(Bukkit.getWorld(worldName), x, y, z, yaw, pitch);
    }
}






smoky anchor
#

try to delete the json you're reading and have it generate again

drowsy helm
#

damn gson really hates you hey

north hornet
chrome beacon
#

💀

#

Only create the permission once

north hornet
#

that's what im asking how tf do i do that

smoky anchor
#

then what are you reading

chrome beacon
#

or if you want you can register the permission in your plugin.yml and get the permission object from the plugin manager

north hornet
#

sorry im quite new to this what does static final variable mean?

chrome beacon
#

um you might want to learn basic Java before making plugins

ocean hollow
# smoky anchor then what are you reading

I have nothing to read, I need to first create a file and then upload it. But when the server is turned on, my information is loaded, and when it is turned off, it is saved

drowsy helm
#

that error just means whatever gson is reading isinvalid

#

it got a [ instead of {

#

which can't happen if theres no intervention

#

or it's reading the wrong thing

smoky anchor
ocean hollow
#

So how can I save/create the file then?

smoky anchor
#

the saving seems alright, but you have to make sure you don't load a file that does not exist

ocean hollow
#

I ran the code with only save after shutdown and nothing was created. However, there were no errors.

smoky anchor
#

First create the file then ?
var f = new File(path);
f.createNewFile();
and maybe pass the file to filewriter

ocean hollow
#

so I made that method

#

remade loading

#

but file still be empty

smoky anchor
#

Why is filewriter crying in orange?

ocean hollow
tawdry echo
#

Do try with resource

tardy delta
#

Probably want a buffered one too

#

And please don't create that gson instan every invocation

green prism
#

How can I apply a cached PNG file as a player's skin using Spigot API?

karmic mural
#

ok guys so when a player places an itemstack in an inventory... WHAT EVENT IS THAT. I swear to god man I can't figure it out. It's not in this list, so what is it?

#

It's an inventoryinteractevent but like, what is the action, how do I capture it, what is it called

smoky anchor
#

PLACE_ALL

karmic mural
smoky anchor
#

but you can just print all the actions to see what is doing what

#

just print it

karmic mural
#

💀


        InventoryAction action = e.getAction();
        p.sendMessage(String.valueOf(action));

#

There's nothing when I place the stack in an empty slot

#

But say I have 32 grass blocks in a slot, and 32 on my cursor, when I then place all of those on the grass block slot, it says place_all

#

Which is why I am losing my mind at this, I can't figure out how to capture the specific action of a player placing an itemstack into an empty slot

#

Does anyone know if there's a different event or something I can do to detect this?

tall dragon
#

cant u just check for place_all and an empty slot?

#

like u have the slot clicked dont u ? or am i misunderstanding

karmic mural
#

I know what slot is clicked, since it's always the same. But when there's nothing in the slot already, and the player places any itemstack in that slot, there's no action printed from my code above

tall dragon
#

none?

#

can i see the entire event?

karmic mural
#

It's basically just this:

public void onMenuClick(InventoryClickEvent e) {
  Player p = e.getPlayer();
  InventoryAction action = e.getAction();
  p.sendMessage(String.valueOf(action));
}

tall dragon
#

let me just test that real quick

smoky anchor
#

random q but: what version are you using ?

tall dragon
#

for me it prints place_all fine

smoky anchor
#

may have broken in latest ?

tall dragon
#

i am on latest

smoky anchor
#

may have broken in older version, but is fixed on latest ?

karmic mural
#

I am on latest as well

tall dragon
#

well then it should work for you too

karmic mural
#

well, I might be one API version behind? But I am on 1.20

#

I'll update just in case

subtle folio
#

for 1.20

karmic mural
#

bruh 💀

#

Thank you guys, I will make sure everything is up to date next time

smoky anchor
#

wait it was actually broken in some version ?

karmic mural
#

Yes it seems so

smoky anchor
#

ok lol
Glad that helped :D

karmic mural
#

Frustrating lol

mild violet
#

hey @smoky anchor (hope the ping is ok)
so I am running the plugin on a spigot server now, however, it does not seem to find a net.kyori dependency...
so not sure, if I can test that on a spigot server

young knoll
#

You’ll need to shade adventure

smoky anchor
#

ping is not ok unless we had a convo before

#

just ask, ppl who know/can will answer you

mild violet
smoky anchor
#

well yes, but this is a separate issue that I would not have been able to answer

mild violet
#

fair

karmic mural
mild violet
#

no?

young knoll
#

Adventure is a library

#

It’s native on paper, not on spigot

karmic mural
#

Oh, so it's a paper problem then? 💀

mild violet
#

oke this explains it :)

eternal night
#

you don't

#

they have to be signed by mojang

smoky anchor
#

you can change the skin of a player

#

but the png has to be uploaded to mojang servers first iirc

young knoll
#

Theres a resource for this

#

Trying to remember the name

hard socket
ocean hollow
#

it is saving, but not loading

copper scaffold
#

I have a problem with my PrepareGrindstoneEvent
i want to remove my custom Enchantment i set the name of the enchantment with a lore.
but the problem is that i want to see if one of the two enchantments are applyed or if both are applyed. and want to remove them the problem now is that i have som infos in the lore as attackdamage. and the enchants are applied at the top. Here is my code pls help me...
https://mclo.gs/xzsramb

shadow night
#

In 1.8 there is no Custom Model Data for items, what could I use to identify Items from my plugin instead?

kind hatch
#

NBT

hard socket
shy rock
#

anyone can help me out? why my plugin doesn't load?
" 16.06 15:33:20 [Server] [ERROR] [DirectoryProviderSource] Error loading plugin: Directory 'plugins/SimpleLevels-1.0-SNAP.jar' failed to load!
16.06 15:33:20 [Server] [INFO] java.lang.RuntimeException: Directory 'plugins/SimpleLevels-1.0-SNAP.jar' failed to load! "

smoky anchor
shy rock
#

bro tagged the admin for assistance

hard socket
#

I've been trying to fix this for almost 2 weeks no one helped me I have no choice

smoky anchor
#

I just wish md comes here and says "And I have no choice but to ban you"
This is not how you ask for help here..

hard socket
#

anyways I am not here to argue

livid dove
#
                return;
            }```

Anyone think of a way to do this check without the inventory holder?
eternal oxide
smoky anchor
smoky anchor
tardy delta
#

thats literally what its made for

livid dove
#

It may very well be what its "designed for" but its also snapshotting the entirety of a player's inventory every time they click...

livid dove
# smoky anchor What are you trying to check

In this case I believe it is a check to see if the inventory is of a type that is applicable to logging (this is an event in core protect).

For the sake of clarity, yes... this is something worth changing as, utilising the paper boolean they added to onHolder, it (i shit you not) took the the thread utilization down from 12% to 0.5% under heavy loads involving custom items

#

But I want something that would be spigot compatible too before I make a pr

ocean hollow
#

please guys, who can help with GSON?

tardy delta
#

?ask

undone axleBOT
#

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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

ocean hollow
#

I saved data to json, when I loading it - it doesn't work

#

this is my load method

tardy delta
#

dont create a new one on every invocation too, i already told you

livid dove
tardy delta
#

yes

#

and what dym with 'doesnt work'

white root
#

How do I have a permission node that is only given when a player explicitly has that permission node, and not when they are just OP?

chrome beacon
#

Tested on 1.12.1 and I replaced SmithingRecipie with SmithingTransformRecipe

ocean hollow
white root
# subtle folio OP has all permissions

Ive seen plugins be able to have a permission node that isnt given when a player is OP
i.e. they have to actually have that specific node, and not just OP

#

I just don't know how to do that.
I suspect itll be something in the plugin.yml, but maybe not

chrome beacon
#

Yeah you can set the permission default in each permission in the plugin.yml

subtle folio
#

Do you mean PermissionAttachment?

chrome beacon
#

Try default: false

#

on the permission

white root
# subtle folio Do you mean PermissionAttachment?

I'm not sure.
I use Vault for permissions, via this extension function: ```kt
fun OfflinePlayer.hasPermission(permission: String): Boolean {
val permissionManager = Bukkit.getServer().servicesManager.getRegistration(Permission::class.java)?.provider
?: throw IllegalStateException("Could not find valid permissions plugin to use!")

return permissionManager.playerHas(null, this, permission)

}

And if I have a permission that, for instance, exempt's the player from some sort of logging that my plugin does, I don't want OPs to be exempt, only players who explicitly have that permission.
white root
tardy delta
#

Bukkit.getServer()

#

bukkit delegates all server methods to itself

echo basalt
#

it's the opposite

#

Bukkit.whatever -> Bukkit.getServer().whatever

tardy delta
#

thats what i said

karmic mural
#

Anyone know how I can properly cancel the event when players move items to/from their off-hand?

I've gone back and forth on this so much. It seems that when I do event.setCancelled(true) it only "half" cancels it. Meaning when a player moves an item from any slot to their off-hand, the item is duplicated. But when they move something away from their off-hand, the item is just deleted. Anyone know what makes it act like this?

kind hatch
#

The PlayerSwapHandItemsEvent should cover your need.

karmic mural
#

Thank you

karmic mural
silent steeple
#

is there a potion expire event

karmic mural
#

I'll test with an older version

chrome beacon
#

InventoryClickEvent should be fired if you're in an inventory

#

What version are you on?

karmic mural
#

It seems the issue persists on 1.19.4. When trying to cancel the InventoryClickEvent after a player moves an item to or from their off-hand, the event is not properly cancelled.


    @EventHandler
    public static void onLeftClick(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        p.sendMessage(String.valueOf(e.getAction()));
        e.setCancelled(true);
  }

This means that, if the player moves an ItemStack to their Off-Hand, and the event is cancelled, the item is now duplicated. If an item is moved from the off-hand to an empty slot, the item is deleted. And when an attempt is made to swap the off-hand slot item with a slot that is not empty, the item in that slot will then replace the item in the offhand, and be duplicated (while deleting the original item in the off-hand). Tested in 1.19.4 and 1.20.1

eternal oxide
#

Event works fine

#

three events can be fired when messing with the offhand. Swop hand, inventory click and inventory drag.

karmic mural
#

I've been printing them, while in an inventory, like a chest, inventory drag will not fire. PlayerSwapHandItemsEvent never triggers. InventoryClickEvent does fire.

eternal oxide
#

drag fires when you are not precise with your click

karmic mural
#

It's a keyboard button (F by default) used to swap an item to off-hand

eternal oxide
#

if items are duplication/deleting its your code doing it. all three events work fine

karmic mural
#

It's literally just e.setCancelled

karmic mural
#

I'll give ClickType another shot if I didn't test properly before.

#

Regardless, the issue here is that when I cancel the event, it's not cancelled properly

wet breach
#

I feel you should probably do updateInventory()

karmic mural
wet breach
#

ghost item is an item that exists in the inventory but disappears upon trying to remove it

#

so it never existed to begin with

#

only the client sees it essentialy not the server

#

but invoking an inventory update should cause the client to clear out any ghost items

wise mesa
#

is there an event for when a dispenser dispenses an arrow? I know of BlockDispenseEvent but that's mainly for dispensing items

karmic mural
#

I executed the dupe and I have relogged, the items are still there.

wise mesa
#

my friend is programming custom arrows

#

blockdispenseevent doesn't let you get any spawned entities

eternal oxide
undone axleBOT
wet breach
karmic mural
# eternal oxide ?paste some code, there is no dupe effect from cancelling those events.

Right now this is literally all I have

    @EventHandler
    public static void onLeftClick(InventoryClickEvent e) {
        Player p = (Player) e.getWhoClicked();
        p.sendMessage(String.valueOf(e.getAction()));
        if (e.getClick() == ClickType.SWAP_OFFHAND) {
            p.sendMessage("SWAP_OFFHAND click-type triggered");
            e.setCancelled(true);
        }
        p.updateInventory();
}

Without the p.updateInventory(); it seems that it will always dupe the items if it is executed correctly. I will test again.

wet breach
#

relogging isn't really a fix for anything. If client and server are out of sync, the server will listen to the client in what it thinks is right

#

not the other way around

wet breach
karmic mural
wet breach
#

creative overrides stuff and causes some events to not fire

#

so there is your issue right there

karmic mural
#

I never knew Creative could make ghost items actual items lol

storm scaffold
#

Is there a way to change the tool used break a certain block and the block breaking speed? Preferably with specific instances of blocks rather than all of the same type, so I can make multiple custom blocks with something like noteblocks

wet breach
#

if the client is in creative and says this item is real

#

the server just goes ok, well you are in creative so it don't matter

karmic mural
#

The more you know, I suppose? Now I don't have to have this frustration again since I'll already know

wet breach
#

Well at least we got to the source of the problem uwu

karmic mural
#

I will cherish this knowledge for the next 5 minutes and then forget about it entirely only to stumble upon it sometime in the future

wet breach
#

lol

karmic mural
#

Or more realistically I will take much less time troubleshooting in the future because I know one thing I need to test for is if it's a creative specific issue

wet breach
#

yeah, creative causes a lot of problems

#

and is why it isn't really advised trying to combine survival and creative for example

karmic mural
#

It is what it is

karmic mural
wet breach
#

the server behaves differently when players are in creative vs when they are not. Some events don't get fired because the client doesn't send the relevant information or vice versa

#

because some things are deemed unnecessary in creative

#

so, when you combine a player who isn't in creative in the same world as someone who is

#

you start encountering issues such as preventing duping. Cause according to the server, if you are in creative this is fine

karmic mural
#

I think I get it. Regardless, letting Creative and non-creative players interact is just goofy, and not something I plan on doing

#

These ghost items are quite frustrating, though. updateInventory doesn't seem to fix it either

wet breach
#

not for someone in creative no

#

you have to actually delete it

#

because it is treated as being real for the one in creative

karmic mural
#

doesn't seem to properly update survival players inventory either

wet breach
#

well it should because updateInventory() if I recall literally resends the inventory packet

eternal oxide
#

Its teh best you'll get

#

However it's creative so you will not be able to control a player in creative.

#

The client is always trusted in creative

karmic mural
#

Still a ghost item, so it doesn't really matter. It's an edge case and has no real impact on gameplay

#

I'll keep InventoryCreativeEvent in mind in case I do anything actually needing to relate to Creative, thank you

eternal oxide
#

== is correct in that instance

#

that is going to equate to true even if the player has no inventory open

tall furnace
#

Why not use getOwner?

eternal oxide
#

your logic always fails here p != player && player.getOpenInventory().getTopInventory() == p.getInventory()

tender shard
#

do not compare objects with ==

eternal oxide
#

if p != player then theres no way p inventory is going to be players inventory

eternal oxide
tender shard
#

i doubt that getTopInventory() returns the same object as Player#getInventory()

#

but I haven't checked

#

just check if the InventoryHolder is the player

tardy delta
#

how will an inventory holder equal a player

ocean hollow
quaint mantle
#

hi everyone, how could I make a LivingEntity (e.g: Zombie) walk to some Location? I was thinking about spawning an invisible entity to that specific Location and make the LivingEntity attack the invisible one. What do u think about it?

quaint mantle
echo basalt
#

even then 500 blocks is quite far

quaint mantle
#

I mean, I'm using Minecraft Development plugin for IntelliJ and I never was able to use nms

#

idk if I'm doing something wrong

full glade
#

Hi! Need help with custom HP for entity.
It doesn't work for some reason:

entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(50D);
entity.setHealth(50D);

Spigot 1.20
P.S. setMaxHealth doesn't work either.

quaint mantle
quaint mantle
#

setMaxHealth or something like that

echo basalt
#

you gotta set the tracking distance to 500

#

also ideally all the chunks would be loaded

full glade
#

It doesn't work.

quaint mantle
#

not really easy supporting 500 blocks haha

echo basalt
#

I had to do something like getBukkitMob().getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(400);

quaint mantle
#

anyways the 500 blocks was just an example, actually I'm doing a test project to practice some AI things and I wanted to make my Zombie to walk to some coordinates

echo basalt
#

custom AI's still better done with nms

#

just grab the mob's navigator and play with it

quaint mantle
#

yeah but by AI I mean in general, like now I will practice some AI related things with Spigot and then practice with other things than Minecraft u know?

tardy delta
#

had an ai exam today

#

im not ready to implement ai in minecraft 💀

quaint mantle
#

lmao

#

but ai fr or ML?

#

or NN?

tardy delta
#

algorithms

quaint mantle
#

ah yeah normal ai

#

those are only algorithms and that's what I wan't to practice everywhere

#

just to train my brain

#

then I will continue with machine learning

tardy delta
#

everything went well till i begun with optimal uniform costs

ocean hollow
#
            for (String uuidString : npcUUIDs) {
                UUID npcUUID = UUID.fromString(uuidString);
                NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(npcUUID);
                if (npc != null) {
                    data.addNPC(npc);
                }
            }
            Bukkit.getLogger().warning(data.getPluginNPCs().size() + " NPCs loaded.");``` how to load npc? list size is always 0
quaint mantle
#

anyways this is not the right channel to talk about this, so to continue with my issue do u think it would be better to use an invisible entity to make my zombie walk on short distances or should I use nms 100% sure? if i should use nms then how could i implement the base of nms in my project?

tardy delta
#

dunno how my A* went

#

couldnt finish half the exercice cuz it was with timing 💀 those bastards

quaint mantle
#

wait come to #general

quaint mantle
full glade
# quaint mantle share full code please
...
        Location loc = conf.getLocation("mobs."+id+".loc");
        LivingEntity entity = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.fromName(conf.getString("mobs."+id+".type")));
        entity.setCustomName(ConfigHandler.improve("mobs."+id+".name")
                .replace("{lvl}", conf.getString("mobs."+id+".level"))
                .replace("{hp}",  String.valueOf(conf.getDouble("mobs."+id+".maxHP"))));
        entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
        entity.setHealth(100D);
zenith gate
#
player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000*20, 1, false, false, false));

Even tho I have icon, and particles set to false, they are still showing. Is there something I am missing?

chrome beacon
#

Are the particles showing?

#

or just the icon

zenith gate
#

yes

#

its both

quaint mantle
# full glade ```java ... Location loc = conf.getLocation("mobs."+id+".loc"); ...

setMaxHealth
@Deprecated
void setMaxHealth(double health)
Deprecated.
use Attribute.GENERIC_MAX_HEALTH.
Sets the maximum health this entity can have.
If the health of the entity is above the value provided it will be set to that value.

Note: An entity with a health bar (Player, EnderDragon, Wither, etc...} will have their bar scaled accordingly.

Parameters:
health - amount of health to set the maximum to

chrome beacon
quaint mantle
#

try using the setMaxHealth, if it still don't work then add next to that line setHealth with the same value

chrome beacon
#

That will ensure the entity is modified before it's spawned

zenith gate
chrome beacon
#

What version are you on?

chrome beacon
zenith gate
#

could it be because they are getting these effects on server join?

chrome beacon
#

I put that code in a join event listener

#

Works just fine

zenith gate
#

Then why is it not working for me

#

well particles dont show no more its just the icon now

chrome beacon
#

icon in the inventory?

zenith gate
#

yeah

chrome beacon
#

You can't hide that one

zenith gate
#

What?

#

why

chrome beacon
#

Well Mojang didn't feel like it was required

#

so they didn't add that feature

zenith gate
#

thats dope. now people can see horrible effects with a time 277:23:21

chrome beacon
#

As the docs say use -1 for infinite effects

#

Also you don't even need potion effects to keep the player fed

subtle folio
#

does anyone know how to use the wagon-ftp plugin to upload my jars over sftp? i know it can do it with ftp but I get a unrecognized sftp error

zenith gate
subtle folio
#

and what if i’m on unix 😅

full glade
# chrome beacon If you want to modify the entity you should do so in a consumer and use the spaw...

It doesn't work.

loc.getWorld().spawn(loc, Slime.class, slime -> {
    slime.setCustomName(ConfigHandler.improve("mobs."+changedMob.getId()+".name")
            .replace("{lvl}", conf.getString("mobs."+changedMob.getId()+".level"))
            .replace("{hp}",  String.valueOf(conf.getDouble("mobs."+changedMob.getId()+".maxHP"))));
    slime.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
    slime.setHealth(100D);
});
chrome beacon
subtle folio
#

But what If I wanna do it through maven

#

that way other people on my team have this?

green prism
#

Hey there! I'm currently working on a RandomTP plugin, but I'm encountering some issues. Sometimes it works perfectly, but other times it doesn't seem to function correctly. I'm quite new to this, so it's my first attempt at creating such a plugin. Could you lend me a hand and help me figure out what might be going wrong? Your expertise would be greatly appreciated!

    public CompletableFuture<Location> findSafeLocation(World world, int x, int z) {
        return CompletableFuture.supplyAsync(() -> findSafeLocationRecursive(world, x, z))
                .thenComposeAsync(loc -> loc != null ? CompletableFuture.completedFuture(loc) : findSafeLocation(world, x, z));
    }

    private Location findSafeLocationRecursive(World world, int x, int z) {
        int maxHeight = world.getEnvironment() == World.Environment.NETHER ? 120 : world.getMaxHeight();
        for (int y = maxHeight; y >= 0; y--) {
            Location loc = new Location(world, x, y, z);
            Location belowLoc = new Location(world, x, y - 1, z);
            Location aboveLoc = new Location(world, x, y + 1, z);

            boolean firstCheck = !unsafeBlocks.contains(belowLoc.getBlock().getType()) && belowLoc.getBlock().getType() != Material.AIR;

            if(!firstCheck) {
                continue;
            }


            boolean secondCheck = loc.getBlock().getType() == Material.AIR && aboveLoc.getBlock().getType() == Material.AIR;

            if(!secondCheck) {
                continue;
            }

            boolean thirdCheck = TeleportDelay.getLastLocation(player) == null || TeleportDelay.getLastLocation(player).getWorld() == loc.getWorld() && TeleportDelay.getLastLocation(player).distanceSquared(loc) >= 1000;

            if(!thirdCheck) {
                continue;
            }

            return loc;
        }
        return null;
    }
chrome beacon
green prism
# subtle folio What's the error?

The first few attempts seem to work flawlessly, but after that, it starts failing consistently. In fact, It attempted finding the location over 100,000 times with no success, before. It's quite perplexing
It works 50/50 lmao

full glade
subtle folio
chrome beacon
subtle folio
#

That's the issue right?

green prism
subtle folio
chrome beacon
#

Yeah it got deprecated in Java 11

#

and removed in 15

#

It's not dead

#

It's just not bundled anymore

tardy delta
#

thats why my js eval() was not working 💀

chrome beacon
#

You can readd it if you need it

#

Dart > JavaScript

tardy delta
#

someone is clearly into dart now

chrome beacon
#

Maybe

full glade
chrome beacon
#
    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Location location = event.getPlayer().getLocation();
        location.getWorld().spawn(location, Slime.class, slime -> {
            slime.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(100D);
            slime.setHealth(100D);
            slime.setWander(false);
        });
    }
#

setWander is just to stop it from moving

#

Works just fine without that

green prism
# subtle folio You can log where you the checks keep failing.

Well, it doesn't even work now

    public CompletableFuture<Location> findSafeLocation(World world) {
        CompletableFuture<Location> future = new CompletableFuture<>();
        CompletableFuture.runAsync(() -> {
            findSafeLocationAsync(world, future);
        });

        return future;
    }

    private void findSafeLocationAsync(World world, CompletableFuture<Location> future) {
        Random random = new Random();
        int x = random.nextInt(25000);
        int z = random.nextInt(25000);

        Location loc = new Location(world, x, world.getHighestBlockAt(x, z).getY(), z);
        Location belowLoc = new Location(world, x, world.getHighestBlockAt(x, z).getY() - 1, z);
        Location aboveLoc = new Location(world, x, world.getHighestBlockAt(x, z).getY() + 1, z);

        boolean firstCheck = !unsafeBlocks.contains(belowLoc.getBlock().getType());
        boolean secondCheck = loc.getBlock().getType() == Material.AIR && aboveLoc.getBlock().getType() == Material.AIR;
        boolean thirdCheck = TeleportDelay.getLastLocation(player) == null || TeleportDelay.getLastLocation(player).getWorld() == loc.getWorld() && TeleportDelay.getLastLocation(player).distanceSquared(loc) >= 1000;

        System.out.println(tries);
        tries++;

        if (firstCheck && secondCheck && thirdCheck) {
            future.complete(loc);
        } else {
            findSafeLocation(world).thenAccept(future::complete);
        }
    }
full glade
fluid river
#

some parts of maven might be painful

#

but the common maven is easy as hell

serene sigil
#

hi, I want to generate an Image file (.png) of a custom Minecraft chat.. what i mean by this is that you enter a text as an argument and an image will be generated with the same text you said but in a minecraft chat... something like this but without the playername... it should just contain the text that is provided

full glade
subtle folio
#

This is simple image maniuplation

serene sigil
#

the thing is that i dont know what other discord server i could ask this...

serene sigil
full glade
next zinc
#

Anyone know how I would grab the player that placed a certain vehicle?

jagged bobcat
#

Does spigot have event for map creation?

subtle folio
#

You'd have to make it yourself

serene sigil
#

so how could i acheive what i wnat to do?

subtle folio
#

You want to create an image with look alike ingame text given?

#

correct?

serene sigil
#

also with a minecraft background

subtle folio
#

Then you need to look into image manipulation

serene sigil
#

what is that?

subtle folio
#

..

#

not a spigot thing, rather its changing an image to what you want it to be

#

Like photoshop, but you could code it yourself as you have very specific rules in mind.

serene sigil
#

i see...

full glade
#

How to make sure that slime does not share after death?

subtle folio
kind hatch
#

Think he means split.

subtle folio
#

You can listen to this event and use #setCount(1)

#

@full glade ^

full glade
hazy parrot
#

print both data in map and id

tardy delta
#

inline records

hazy parrot
#

is it System.out.println("Cached " + cache.get(id)); or System.out.println("Cached " + id);

cinder abyss
#

Hi, any tutorial for using BlockDisplay ?

eager girder
#

Is there a way to check when an item drops?

#

Like when a crop is mined

#

or a mob is Killed

#

Alright so I just have to use multiple

#

got it

zenith gate
#

will blocks still hold PDC data if they are placed down?

undone axleBOT
zenith gate
#

okay, something has to be off with my google. this link should've 100% came up.

robust zenith
cinder abyss
#

hello, how can I set custom model data on a BlockDisplay ?

tall furnace
cedar pine
#

are there any useful tutorials on text display entities?

#

I'm either not looking hard enough or blind

worldly ingot
#

You'll have to use an ItemDisplay instead

#

cc @cinder abyss because I didn't ping in my reply out of habit

zenith gate
#

Could someone explain this a little better for me? is this talking about the lapis that has to be in a enchantment table, or the 2nd item in the anvil ? because an anvil can be used to enchant as well with the books.

remote swallow
#

nerd

#

(aimed at choco)

zenith gate
#

EnchantingInventory

worldly ingot
#

Then it's the lapis

zenith gate
#

how can i get the enchants that are presented in the enchantment table?

eager girder
#

How do I add custom enchants? I extended the enchantment class and have all the lore stuff done

zenith gate
pseudo hazel
#

is there a single function im missing to convert a chatcolor (bungee) to a hex string in the format of like #ffffff? I know I can use String.format but I was wondering if there is a builtin way, since you can also create them using ChatColor.of(hexString)

eager girder
#

Nice just started on this like half an hour ago

noble lantern
#

Is there a way to get the length of a Sound?

#

Or purely client side

eager girder
#

Like do I have to register them or anything? I skimmed through a tutorial but it was ehh

noble lantern
#

you can add them

#

but you cant have them display, its a very odd limitaiton all ae plugins have

zenith gate
#

you cant put the enchant in a enchantment table?

noble lantern
#

you can like part of the way display them

Make a /ce command for your enchantment books and add your Enchantment to the enchantment container of the book

noble lantern
#

its an Enchantment extending class

#

so it will act like one if registered as so

thorn isle
#

If I depend on a plugin (i my plugin.yml) that lists a library in its plugin.yml, are the classes of that library visible to me at runtime?

eager girder
#

So how do I add it to the enchantment table then?

noble lantern
eager girder
#

Alright

zenith gate
#

thank you

thorn isle
#

Yes but what about its libraries at runtime?

noble lantern
#

PrepareItemEnchantEvent -> add your enchantment to the list if the conditions (enchantment table levels) are sufficient

young knoll
#

Libraries loaded with the library feature are only visible to the plugin that loads them

#

If your plugin also needs that library you should declare it too

#

Afaik

thorn isle
#

Alright, thanks

narrow flare
#

hello i want to create a backpack plugin. But i've question what is the must ? create Json file or SQL database to storage the backpack items of players?

eager girder
#

How would I make villagers be able to sell it/add it to their loot tables

young knoll
#

You can also technically use PDC

eager girder
#

Thanks

noble lantern
#

i rly need to make a ce plugin

narrow flare
noble lantern
#

will blow all the others away kek but for now music player

#

?pdc good sir

noble lantern
eager girder
#

How would I make it random like the other trades?

noble lantern
#

can you elaborate not sure i understand

#

ahh random like that

eager girder
#

I'm a little confused
Wouldn't that just overwrite the existing recipes that a villager has?

#

What I want to do is to make randomly spawning villagers be able to do that trade

noble lantern
#

yeah on villager job change -> check if enchanting villager -> if chance <= percentage -> add

eager girder
#

Got it

noble lantern
#

i keep forgetting that villagers have jobs now

eager girder
#

Are all recipes pre determined or would I have to listen for when they upgrade

modern vigil
#

Can AnvilInventory#get(First/Second)Item return an ItemStack of material AIR?

young knoll
#

There’s an event for when they acquire a new trade

#

Use that

modern vigil
noble lantern
#

or colls ^

#

youd prolly use getLevel either way in acquiring new tradew tbf

young knoll
#

I believe it’s VillagerAquireTradeEvent

eager girder
#

Alright thank you

noble lantern
#

just remember that methods set

#

not add

eager girder
#

yep

noble lantern
#

god i hope this developer api gets used kek

modern vigil
#

Also, how would I 'cancel', or do something similar to an AnvilPrepareEvent

young knoll
#

Set the result to null iirc

modern vigil
#

Do I need to update the player's inventory afterwards?

noble lantern
#

if your setting the result of the event you shouldnt have to

#

but if your directly setting the slot in an inventory, i believe so yes

modern vigil
#

Ah, alright

subtle folio
#

can I put null in a string and itll just be ""?

noble lantern
#

depends

subtle folio
#

Because I have a function in some string canconation that could be null

noble lantern
#

isnt like String.empty a thing

subtle folio
#

like " " + mayBeNull() + " is hot!"

noble lantern
#

couldnt you use that when passing null

zenith gate
#

would a registered enchant show up in the /enchant command? one that i would have made.

subtle folio
subtle folio
#

ok

noble lantern
#

so this one maybe

noble lantern
#

you might have to inject into the enchantment map, but no promises it will work

north hornet
#

so i added a config to my plugin, but when i set just 1 value and save it everything gets replaced by that value, and everything else dissapears... anyone know how to fix this?

young knoll
#

You would need to inject into the enchantment registry

noble lantern
#

i dont even think that one re-syncs with the client like the command one does though

#

i vaugely remember that being some issue some years back

young knoll
#

It does not

#

Most registries don’t

zenith gate
#

would it just be easier to make my own /enchant command?

young knoll
#

Yes

zenith gate
#

hmm alright

noble lantern
#

enchantment plugins are lots of work ong

subtle folio
noble lantern
#

and code base behind all of them are dodgy asf r_baby_cry

subtle folio
#

i just use a library i cant be bothered

subtle folio
#

redempt left??

#

damn

noble lantern
noble lantern
noble lantern
north hornet
#

yes one sec

subtle folio
young knoll
#

Redempt left a while ago

unkempt onyx
#

Hey does anyone know how I can get rid of suggested commands that I havent explicitly given permission for?

north hornet
modern vigil
noble lantern
#

seems like your getConfig is empty

#

hence why when you save it only the spawns there

north hornet
#

when the plugin loads it creates a config.yml with the default values

#

and look at img 3

eternal oxide
#

.copyDefaults() does nothing

noble lantern
#

i never even knew options() was still a thing haha

north hornet
#

but how do i fix it then?

#

just saveDefaultConfig()?

#

alr, well it didn't delete the other values now but it still deleted the comments

eternal oxide
#

?nocode

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

noble lantern
# north hornet just `saveDefaultConfig()`?

yeah

And when you add values to your config after an update, use getString(path, defaultValue) (can be getWhatever)

This makes it so if the config value doesn't exist in your config, that it gets created with the default value you provided, the config only needs to be saved afterwards for it to write the new value

north hornet
#

like getConfig().getWhatever() right?

eternal oxide
#

don;t get until you need them

zenith gate
#

for the enchants key, is that just a namespaced key? i see someone people before using just number eg 101 but that was a few years ago and i get errors if i just a number.

eternal oxide
#

comments will only be deleted if you are on an older spigot or you completely replace a section

eternal oxide
#

then you have to be deleting sections to lose comments

north hornet
#

im so confused rn

eternal oxide
#

We can't advise without seeing actual code. Not tiny window snippets you show us

north hornet
#

or do you want code snippets?

green prism
#

ElgarL

noble lantern
#

theres a bunch of keys so not sure specifically what key your questioning about :p

green prism
#

Could you please take a look at my RandomTP code? It's not working at all/properly
I understand it's poorly structured and hardcoded, don't worry, I'll fix it. Thanks for the help

https://paste.md-5.net/iyiqabasut.java

undone axleBOT
#

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

green prism
#

No error, it just never finds a suitable location

#

no location found -> loop -> lag

eternal oxide
#

scaryjava while (true) {

green prism
#

there's a return, it should stop at some point

noble lantern
#

random TP's are really tricky to get without lagging

And why while true lmao

Make it a max x amount of tries instead of while true

eternal oxide
#

This method can return negative valuesjava private int getRandomCoordinate(World world) { return (int) (Math.random() * world.getMaxHeight()) - (world.getMaxHeight() / 2); }

young knoll
#

I think EssentialsX has a pretty solid rtp

#

And is open source

noble lantern
#

wtf essx has a rtp

young knoll
#

Yes but it’s called /tpr

#

Because why not

green prism
#

Exactly

zenith gate
eternal oxide
#

you have to test if negative is allowed not just assume half teh height can be negative

noble lantern
noble lantern
eternal oxide
#

there is a min heigh value

noble lantern
#

i reccomend a seperate method for getting max y

north hornet
#

i still don't know how to fix the issue of the comments dissapearing

green prism
noble lantern
#

punching myself rn

green prism
noble lantern
#

i cant tell you how many rtp plugin ive made/downloaded throughout the years wtf

green prism
eternal oxide
noble lantern
#

or /tprandom

young knoll
#

It’s newish

north hornet
#

like this is before

  onrespawn: true

#Comment
spawn: null

and this is after

  onrespawn: true
spawn:
  ==: org.bukkit.Location
  world: world
  x: -61.511026447244134
  y: 96.0
  z: -42.18768670486722
  pitch: 16.205576
  yaw: 107.56201

and im like so confused why tf the comment is dissapearing

Code:
// setting the location

plugin.getConfig().set("spawn", location);
plugin.saveConfig();
noble lantern
#

i bet /randomtp would work

noble lantern
noble lantern
#

Comments dont override with saveDefaultConfig() on modern mc

green prism
# eternal oxide getMinHeight()

I'm sorry but I don't quite understand where I went wrong, negative values are valid, the height I always go for the highest one in the position

noble lantern
#

so your either overwriting the section the configs in, or using some other saving method thats not right

eternal oxide
north hornet
# noble lantern like elgar said were gonna need to see more code than just snippets try the enti...

there's nothing else about config but sure:

package nl.mnrkaas.elitespawn.commands;

import nl.mnrkaas.elitespawn.EliteSpawn;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class SetSpawnCommand implements CommandExecutor {

    private final EliteSpawn plugin;

    public SetSpawnCommand(EliteSpawn plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
        if (sender instanceof Player p){
            Location location = p.getLocation();
            if (p.hasPermission("elitespawn.set")) {
                plugin.getConfig().set("spawn", location);
                plugin.saveConfig();
                p.sendMessage("§e§lElite§2§lSpawn §7§l| §7The spawn location has been §aSuccessfully §7set to your current location.");
            }else{
                p.sendMessage("§e§lElite§2§lSpawn §7§l| §cYou don't have the correct permissions to perform this action.");
            }
        }else{
            Bukkit.getLogger().info("[EliteSpawn] This command can only be ran by players.");
        }
        return true;
    }
}
noble lantern
noble lantern
#

allows you to use & color signs

north hornet
north hornet
#

ye i know but i didn't know how to do it

noble lantern
#

reguarding comments deleting though - no idea your doing something funky somewhere or your server is old af like 1.8 or smthn

north hornet
#

like this is all the code in the onenable for the config
saveDefaultConfig();

eternal oxide
noble lantern
#

server crasher 3000

#

even better import the static method directly

#

and you can just colorize("")

green prism
remote swallow
#

or be even lazier, make abstract classes for every possible use case and extend it

#

(joke for legal reasons)

eternal oxide
#

You are also looping until the teleport delay expires. If thsi is not async it will freeze your server

noble lantern
#

async would be fine but youll still be in the inifinite loop boat

#
  • need to use chunk snapshots
young knoll
#

You either want a max number of attempts

#

Or a max amount of time

subtle folio
#

So i've got this code for making overhead nametags. And it's working alittle strange. When Player A joins, he is unable to see his nametag customized. When player B joins, Player A is able to see Player B's name customized, but still not his own. and Player B is still unable to see both names customized. Here's my code but I thought I already fixed this? https://paste.md-5.net/ragijawili.java

eternal oxide
#

lastly, pick a random x,y,z, then do a block search upwards until you reach max height. Then fail

noble lantern
eternal oxide
#

loop from y to maxHeight looking for a safe place

#

he doesn;t want highest block at

#

just a safe spawn

noble lantern
#

ah so caves allowed then

eternal oxide
#

I'd assume

young knoll
#

Loop up the the highestY

#

No reason to go all the way to the world limit when most of it is air

noble lantern
#

oh yeh true

eternal oxide
#

pick random x,z then java for (int y = getRandomCoordinate(world); y < world.getMaxHeight(); y++) {

noble lantern
#

if he removes cave rtp's he wouldnt even need to calculate for y tbh

eternal oxide
#

untill you find a safe spawn or the loop ends

noble lantern
#

but myeh

eternal oxide
#

true

green prism
#

What about something like this?

    public Location findRandomSafePlace(World world) {
        Location loc = null;

        for (int i = 0; i < 1000; i++) {
            int x = getRandomCoordinate(world);
            int z = getRandomCoordinate(world);
            
            for(int y = world.getMaxHeight(); y > world.getMinHeight(); y--) {
                Block block = world.getBlockAt(x, y, z);
                Block belowBlock = world.getBlockAt(x, y - 1, z);

                if(TeleportDelay.getLastLocation(player) != null && TeleportDelay.getLastLocation(player).getWorld() == world) {
                    if(TeleportDelay.getLastLocation(player).distanceSquared(block.getLocation()) < 1000.0) {
                        continue;
                    }
                }
                
                
                if (isSafePlace(world, block, belowBlock)) {
                    loc = block.getLocation();
                    return loc;
                }
            }

        }
        
        return loc;

    }
noble lantern
#

pov: you find that line of code you wrote at 3am

eternal oxide
#

you are going to drop players to their death, unless you are checkign the block under their feet

noble lantern
eternal oxide
#

ok

green prism
#

At least it finds something

green prism
#

ElgarL, do you have an idea to avoid doing (getMaxHeight() - 10)?

#

to fix that problem

eternal oxide
#

fix what problem?

green prism
noble lantern
eternal oxide
#

if it's the nether - 10

noble lantern
#

in the nether you might wanna change your y scanning maybe

young knoll
#

You can start at 128 in the nether

#

That’s where the bedrock is

noble lantern
#

since theres only a small area you can ever actually rtp in logically

subtle folio
#

its sucks

eternal oxide
#

just do - ( 10 * (enviroment == NETHER))

noble lantern
young knoll
#

Mhm

#

- 10 isn’t enough

#

The air gap is 128 blocks

green prism
eternal oxide
#

in the nether its 128?

young knoll
#

The nether is 256 blocks tall

eternal oxide
#

then do 128 *

young knoll
#

But 128 of that is just air above the bedrock

noble lantern
#

huh ngl i thought the nether went as deep as the overworld

young knoll
#

Nope

noble lantern
#

guess they skimped out on it when they added new height limits

young knoll
#

The nether never got changed past 128

green prism
#

nether ? 127 : maxHeight

worked

noble lantern
#

also consider using ChunkSnapshot for block checking on the y axis when your scanning for the material type

young knoll
#

Also consider starting at World.getHighestBlockY(x, z)

noble lantern
#

i think he might want cave tps so we didnt go that route

#

oh wait starting at

#

nvm

zenith gate
#

how can I apply the frosty vignette you get from being in powder snow, to a player?

noble lantern
#

packets will be the cleanest way more than likely

eternal oxide
#

isn;t it just a particle?

young knoll
#

No

zenith gate
#

other players dont see it tho do they?

young knoll
#

It’s a screen overlay like the jack O lantern

eternal oxide
#

ah ok

young knoll
#

You can either set their freeze ticks directly or use packets to set them client side

zenith gate
#

hmm okay.

green prism
#

Solved, thank you so much!
Thank you ElgarL
Thank you Burchard37

#

And now, I can finally go back into hibernation

tiny root
#

Oh yeah mb on that, misclicked channel

subtle folio
#

is there a way for a player to have two scoreboards

eternal oxide
#

no

subtle folio
#

fuck

eternal oxide
#

you can create many scoreboards but you can only display one to a player at a time

subtle folio
#

yeah

eager girder
#

Can you use &4 inside components or do I have to do the chatcolor thing?

subtle folio
#

and add on to it?

sullen marlin
#

color/fromLegacyText

eternal oxide
#

anon?

subtle folio
#

like without the object

eternal oxide
#

players join a scoreboard, a scoreboard doesn;t belong to a player

subtle folio
#

the one that player has active

eternal oxide
#

Player#getScoreboard

subtle folio
#

hmm okay

eternal oxide
#

If you create a scoreboard but don;t hold a reference or assign it to a player it will be gc'd (I believe)

#

There is no method to get a reference other than when created or from an assigned player/team

subtle folio
#

mhm mhm

#

L gc tbh

orchid trout
#

is there an insert or replace in mongodb?

cinder abyss
#

Hello, how can I spawn a BlockDisplay who is a note block with a specific instrument ?

quaint mantle
#

Does the annotation handler EventHandler contain something like ignoreCancelled?

young knoll
#

Yes

jagged monolith
#

Pretty sure it does

young knoll
#

Exactly that in fact

quaint mantle
#

Then why am I gettting annotation value not of an allowable type for this @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

noble lantern
#

show the entire class

#

anyone know how can i hide this? Adding the itemflag HIDE_ATTRIBUES doesnt seem to work

young knoll
#

It’s potion effects

#

Don’t question it

noble lantern
#

wtf alright thanks kek

quaint mantle
#
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onClick(InventoryClickEvent e) {
        if (!(e.getWhoClicked() instanceof Player)) {
            return;
        }
        Player player = (Player)((Object)e.getWhoClicked());
        if (player.getOpenInventory() == null) {
            return;
        }
        if (player.getOpenInventory().getTopInventory() == null) {
            return;
        }
        InventoryHolder holder = player.getOpenInventory().getTopInventory().getHolder();
        if (holder instanceof AntiClickHolder) {
            e.setCancelled(true);
        }
        if (!(holder instanceof GuiBuilderHolder)) {
            return;
        }
        GuiBuilderHolder builderHolder = (GuiBuilderHolder)holder;
        GuiBuilder builder = builderHolder.getBuilder();
        if (builder == null) {
            return;
        }
        builder.handleCommandClick(e);
    }
#

and yes its implementing the Listener

noble lantern
#

by the hilarious off chance did it import the java websocket listener

#

if not maybe try revalidating your project files, should be fine from the looks of it

quaint mantle
#

i did not

#

also tried that

#

also getting cannot find symbole class EventPriority for some reason

noble lantern
#

your still getting Player and stuff though?
Sounds like your just missing the import

Do alt + enter while clicking on EventPriority

quaint mantle
#

Does not do anything

noble lantern
#

send your pom.xml?

#

or gradle

#

whichever you use

noble lantern
quaint mantle
#

Am not

noble lantern
#

ah

#

then import

eternal oxide
#

Eclipse is CTRL+SHIFT+O

noble lantern
#

oh neat

quaint mantle
#

Not using eclipse im using the recaf thing

noble lantern
#

oh your the guy doing recompiled stuff

#

forgor

quaint mantle
#

yes

#

I'm the guy

signal kettle
#

I want to make that on certain action from player it take cosmetic id line from config to string and then if in this string there is a word "backpack" eg. "woodcutter_backpack" then run rest of code but it's look like it doesn't give a F and even if there's no world like that then it runs it🤔

                    if (CosmeticUsers.getUser(player).getCosmetic(CosmeticSlot.BACKPACK) != null) {
                        BackpackOnBackString.add(CosmeticUsers.getUser(player).getCosmetic(CosmeticSlot.BACKPACK).getId());
                        if (BackpackOnBackString.toString().contains("backpack")) {
                            player.getInventory().addItem(backpack);
                            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "cosmetic unapply BACKPACK " + player.getName() + " -s");
                            player.playSound(player.getLocation(), "backpack.unwear", 100, 1.0F);
                            event.getPlayer().swingMainHand();
                        }
                    }
#

Any idea guys?

quaint mantle
left pine
#

I have a question why did I change all the file management and spigot libraries in 1.20.1?

sullen marlin
#

?

pseudo hazel
#

idk

#

why did you do that?

noble lantern
#

i thought it worked fine as is tbh didnt know it needed changing

eternal oxide
#

Is there a prize if we guess correctly?

#

you also live in teh far distant future, 1.120.1?

quaint mantle
#

Does Soft dep mean its requireD?

left pine
#

Sorry, I was referring to version 1.120.1 of spigot

drowsy helm
#

regular dependency is required

jagged monolith
noble lantern
left pine
quaint mantle
#

What? This is for something else

#

I'm taking a break from what I was doing

drowsy helm
#

not maven

noble lantern
#

oh my bad

left pine
#

is that I got confused and thought it was this

#

but it was actually this

ember estuary
#

Should i get rid of the Label class and just make a .setText, .setColor, .setTextShadow and so on, directly on the Element itself?
Need some opinions, i wanna make it as easy to use as possible :D

jagged monolith
#

How often are you needing to set labels

ember estuary
#

well, there can only be one per element. and that depends on if you want text in it or not

#

so basically you can make a rectangle and if you want you can put text in it

#

its a gui library

jagged monolith
#

My suggestion would be, if you're calling .setLabel a lot, then use the builder, but if you're only calling it like once or twice, then just do without

#

I can see you've got LabelBuilder atleast 5 times there, so would be better to keep it probably.

ember estuary
#

the alternative would be to have code like this

        Element title = new ElementBuilder(-1,-1, 128,14)
                .setBackgroundImage(obsidianBackground, false)
                .setBorder(1, BLACK, false)
                .setText("Multiplayer XP")
                .setTextShadow(true)
                .setColor(WHITE)
                .build();

So to have it direcly on the element

sullen marlin
#

Clearly you just need to implement a QT/GTK renderer

#

/s

ember estuary
#

xD

#

But that gave me an idea, maybe i should just check out how existing GUI libraries like QT do it.
The only ones i know are HTML+CSS and Tkinter (which sucks)

#

in html its all on one element. text, backgroundcolor, border, textcolor, etc.

sullen marlin
#

Or swing haha

#

Built into java

wide steeple
#

AWT

#

Or actually, LWJGL, write your UI using OpenGL

echo basalt
#

how fun!

#

tfw you don't have original ideas

#

So you remake java swing

ember estuary
#

lol

#

not bad either, hmm

#

does anyone know how i can tell java that the second questionmark has the same type as the first questionmark?

#

for example if the key is a WindowObjectProperty<Byte>, the value must be a Byte

#

or is my only option to use <WindowObjectProperty<?>, Object> ?

#

in functions you can do it like this...

echo basalt
#

you can just define the bounds on your method

#

and do a weird cast

#

I have some projects where I do some cursed generic types

ember estuary
#

ah i see

young knoll
#

Generics are pain

worldly ingot
#

You're a pain >:I

young knoll
#

:0

eager girder
#

How do I remove decorations from lore?

pseudo hazel
#

whats a decoration

eager girder
#

Italics

noble lantern
orchid trout
#

§f

eager girder
#

I just want to reset it

noble lantern
#

maybe im dumb but idk what you mean :c

eager girder
#

See how it's italic

young knoll
#

Use ChatColor.reset

eager girder
#

Its usually purple and italic

#

How do you do that with the adventure system?

noble lantern
#

still can just wrap the string in that

#

then pass it through the component

#

prolly not the right way but it does work

eager girder
#
for ((enchant, level) in enchants)
            lore.add(enchant.displayName(level)
                .color(TextColor.color(170, 170, 170)))
#

How do you combine 2 components?

ancient plank
#

Man

echo basalt
eager girder
rare rover
#

i forget, what's the method for getting an item's nbt data

#

its for 1.19

#

there's a method for it now

noble lantern
#

Are you talking about PDC by chance

rare rover
#

ye

noble lantern
#

?pdc

eager girder
rare rover
#

ty

noble lantern
#

ofcofc

eager girder
#

lore.add(Component.text("${ChatColor.RESET} test"))

echo basalt
young knoll
#

Oh ur on paper

eager girder
#

ye

#

paper discord is so dead

#

Everyone there just asks questions and nobody responds

noble crown
eager girder
#

It's more active earlier in the day

noble lantern
# echo basalt I hate how clunky it is

clunky? idk feels a lot better than adding remapped jars and reflection and whatnot

  • its use for entities is godsend

Maybe just a personal preferance for me but since 1.13 ive rarely touched nms cause of it:p

echo basalt
#

true

eager girder
echo basalt
#

but I just don't like its syntax

#

so I made this

noble lantern
#

oh yeah the long name bothers me

noble crown
#

Using components

echo basalt
#

and for entities

noble crown
#

Also, default lore color is purple, so you need to set it to white or something

noble lantern
# echo basalt so I made this

yep for my plugins i normally make some type of wrapper for em as well

I hate seeing getPersistantDataContainer spammed throughout my main codes logic kek

echo basalt
#

or, for items

eager girder
#

Its that it's italic

noble lantern
#

definatly stealing that one

noble crown
#

component.decoration(TextDecoration.ITALIC, false)

#

Minecraft adds italic by default

echo basalt
#

So I can just

EntityPDCWrapper pdc = new EntityPDCWrapper(plugin, player);
pdc.setString("joe", "mama");
pdc.has("joe") -> true
eager girder
#

Oh you can add a boolean after to toggle state

#

Alright thanks

noble lantern
#

like ik they exist in libs ofc

echo basalt
#

it's not that big of a deal

#

compared to for example uhm

#

packets

vocal cloud
#

This is java gotta make an IFactory

noble lantern
#

i stg some class hierarchies have me ctrl + clicking for 20 seconds

eager girder
#

How do I add stuff into the enchantment table loot pool idrc if it shows up just need to add it

#

I know you linked something earlier but I can't find it

vocal cloud
noble lantern
#

oh NOO

vocal cloud
eager girder
#

How do I check if a villager is a enchanter?

eager girder
#

I can't apply my book in an anvil

sullen marlin
#

where is the book from

eager girder
#

val book = ItemStack(Material.ENCHANTED_BOOK)
book.addEnchantment(Replanting(key), 1)

young knoll
#

Custom enchantments won’t work automatically

sullen marlin
#

you want stored enchants and item meta

young knoll
#

Also you need to add it as a stored enchant

sullen marlin
#

also yeah custom enchants arent a thing

eager girder
#

Alright

#

How do I add a stored enchant?

sullen marlin
#

EnchantmentStorageMeta or something

#

Check the docs

eager girder
#

Still doesn't work with it as a stored enchant

#

This is my replanting class

#
package atk.plugins.dusk.enchantments

import io.papermc.paper.enchantments.EnchantmentRarity
import net.kyori.adventure.text.Component
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.Tag
import org.bukkit.enchantments.Enchantment
import org.bukkit.enchantments.EnchantmentTarget
import org.bukkit.entity.EntityCategory
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.ItemStack

class Replanting(key: NamespacedKey) : Enchantment(key) {
    override fun translationKey(): String {
        return "Replanting"
    }

    @Suppress("OVERRIDE_DEPRECATION")
    override fun getName(): String {
        return "Replanting"
    }

    override fun getMaxLevel(): Int {
        return 1
    }

    override fun getStartLevel(): Int {
        return 1
    }

    override fun getItemTarget(): EnchantmentTarget {
        return EnchantmentTarget.TOOL
    }

    override fun isTreasure(): Boolean {
        return true
    }

    override fun isCursed(): Boolean {
        return false
    }

    override fun conflictsWith(other: Enchantment): Boolean {
        return false
    }

    override fun canEnchantItem(item: ItemStack): Boolean {
        return Tag.ITEMS_HOES.isTagged(item.type)
    }

    override fun displayName(level: Int): Component {
        return Component.text("Replanting $level")
    }

    override fun isTradeable(): Boolean {
        return true
    }

    override fun isDiscoverable(): Boolean {
        return false
    }

    override fun getRarity(): EnchantmentRarity {
        return EnchantmentRarity.UNCOMMON
    }

    override fun getDamageIncrease(level: Int, entityCategory: EntityCategory): Float {
        return 0f
    }

    override fun getActiveSlots(): MutableSet<EquipmentSlot> {
        return mutableSetOf(EquipmentSlot.HAND)
    }
}
quaint mantle
#

How would you disable your plugin in code?

kind hatch
#

JavaPlugin#PluginLoader#disablePlugin()

quaint mantle
#

Any other way?

kind hatch
#

I mean, you could make a boolean and use it everywhere. Although that's a bit of a pain.

cunning roost
#
package org.ecucraft.slimebobplugin;

//import com.mysql.cj.jdbc.MysqlDataSource;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Objects;

public class SlimeBob extends JavaPlugin implements CommandExecutor {
    private JDA jda;

    public String dbAddress = getConfig().getString("dbAddress");
    public String dbUsername = getConfig().getString("dbUsername");
    public String dbPassword = getConfig().getString("dbPassword");

    @Override
    public void onEnable() {


        this.saveDefaultConfig();
        Objects.requireNonNull(getCommand("debugDiscord")).setExecutor(this);
        getLogger().info("slimebob is here");

        String discordBotToken = getConfig().getString("discordBotToken");
        try {
            jda = JDABuilder.createDefault(discordBotToken).build();
        } catch (Exception e) {
            e.printStackTrace();
        }

        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setUser(dbUsername);
        dataSource.setPassword(dbPassword);
        dataSource.setServerName(dbAddress);

        try {
            Connection conn = dataSource.getConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("ERROR");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void onDisable() {
        if (jda != null) {
            jda.shutdown();// Plugin shutdown logic
        }
    }

    private class ReadyEventListener extends ListenerAdapter {
        @Override
        public void onReady(ReadyEvent event) {
            getLogger().info("Discord API Connected");
        }
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        //return discordBotToken in chat
        String discordBotToken = getConfig().getString("discordBotToken");
        if (command.getName().equalsIgnoreCase("debugDiscord")) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                player.sendMessage(discordBotToken);
            } else {
                sender.sendMessage(discordBotToken);
            }
            return true;

        }
        return false;

    }



}




When I try to build it is saying it cannot find the symbol "MysqlDataSource". I have a feeling I have imported sql wrong but im not entirely sure how

#
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Objects;
#

should be all the imports i need right?

#

I have got the connector in the build path, and I believe ive set up the class path correctly

sullen marlin
#

You don't need the connector at all, spigot includes it

#

And jdbc is built into java

cunning roost
#

it does :O?

river oracle
#

how could I bounce a player back. I want to make it kinda smooth

cunning roost
#

so I should be able to delete the conectors I have

young knoll
eager girder
#

So how should I handle it? Since someone earlier said to extend the enchantment class

sullen marlin
river oracle
sullen marlin
#

See code snippet

#

DriverManager.getConnection

cunning roost
#

so when I write in the imports, as soon as I write the line it is dissapearing from the IDE? any idea why this would be happening

#

it ocmes up as an option

#

but as soon as I write the line is vanishes

kind hatch
#

Don't tell me you manually import.

cunning roost
cunning roost
#

plus, every guide ive followed has told me to manually import, so im not sure what you're saying

#

all the above imports I didn't do manually though

kind hatch
#

Ahh, well pro tip. Write the name of the class, then while your cursor is at the end or somewhere in the middle of the text, press ALT + ENTER and then select the option to import.

cunning roost
#

cheers. Im using this module too, is that a good way to do things?

kind hatch
#

There's nothing wrong with using it. People say that it uses a lot of memory though although I haven't ever had that issue.

cunning roost
#

that did all the spigot imports automatically

kind hatch
#

Don't know why the import would be disappearing though.

cunning roost
#

so, if I have everythign configured correctly, this shoudl auto detect what im doing right?

kind hatch
#

Typically when you start typing, you'll also get suggestions.

cunning roost
#

ngl im so lost, i know this should be simple but ive spent so many hours with no luch

#

luck

cunning roost
sterile axle
#

your IDE did not index shared libraries then

#

you may have declined the prompt on accident

#

google how to enable it

cunning roost
#

aight, ill give that a go

cunning roost
# sterile axle google how to enable it

so I dont have the plugin installed and its asking me to pay. could this be because im using the community edition? I did read something a few days ago about JDBC integration only being on the full version

sterile axle
#

No you don't need either of those

cunning roost
sterile axle
#

Oh the fuck it is a paid plugin

#

Okay I guess it's not needed that

#

There's no way intellisense is not included in community

kind hatch
#

They do make life a little easier if you have them though.

#

Don't have to download extra tools.

warm light
#

if a player/mob die for charged creeper, DamageCause will be ENTITY_ATTACK right?

buoyant viper
#

for me at least, the only thing i ever use in it is Mixin autocomplete