#help-development

1 messages · Page 2251 of 1

red sedge
#

IDK IM STUPID OKAY 😭

lost matrix
red sedge
#

and well um... the unwillingness to learn that knowledge

river oracle
#

7smile7 out here with the wise words

lost matrix
#

For a circle its even simpler because spigot already has methods that let you rotate a vector around an axis.

red sedge
#

i feel like going from 2d to 3d i know absolutely nothing

river oracle
grim ice
#

stuff like this u just copy paste from google my friend

#

even if u know how to do it i cant be bothered to

lost matrix
# red sedge i feel like going from 2d to 3d i know absolutely nothing
  public List<Location> horizontalCircleAround(Location center, double radius, int points) {
    List<Location> locations = new ArrayList<>();

    Vector cursor = new Vector(radius, 0, 0);
    double deltaPhi = (2 * Math.PI) / points;
    for (int i = 0; i < points; i++) {
      locations.add(center.clone().add(cursor));
      cursor = cursor.rotateAroundY(deltaPhi);
    }

    return locations;
  }
red sedge
#

i mean yeah that is pretty 2d still

#

i can do thart

lost sedge
#

What do I use instead of ChatComponentText in 1.19

lost matrix
lost sedge
quaint mantle
#

Okay so I'm making a plugin right now about Ranks, and I need help about the permission part.

I wanna use "parents", and the problem is idk how to loop thru the ranks untill the rank has no parent.

chrome beacon
simple silo
#

java.util.UnknownFormatConversionException: Conversion = '%'
huh? it breaks my AsyncPlayerChatEvent listener

viral pike
#

Hello I have a question for the performances

Is looking at a player’s coordinates all the time really advisable ?

chrome beacon
#

Depends on what you're making

viral pike
#

I want to see if any players are approaching the coordinates on their teleport

chrome beacon
#

Then yeah you will have to track player movement

#

You can minimize lag by only tracking players in a specific world and using the scheduler instead of a movement listener

viral pike
chrome beacon
#

No

#

Just use the scheduler to check every few ticks

#

?scheduling

undone axleBOT
viral pike
#

Okay thank u ❤️

lost sedge
chrome beacon
#

Yeah Component.literal would be that in 1.19 mojmaps

lost sedge
chrome beacon
#

Are you using Mojmaps

#

You should be

lost sedge
#

no just spigot

chrome beacon
#

It's annoying to have method names like a()

#

Why make it hard for yourself

lost sedge
#

its more like im updating someone elses code

#

its an nms thing

chrome beacon
#

Then add mojmaps to the project

lost sedge
#

yeah whats the repo?

lost sedge
#

thanks

chrome beacon
#

Replace 1.18.2 with 1.19 and update special source to 1.2.4

quaint mantle
#

What is the best way to add or remove a permission from a player ?

chrome beacon
#

You can use Vault

quaint mantle
#

Wdym ?

chrome beacon
ornate patio
#

🙏 thanks

heavy marsh
#

Hi, what is the updated way to check if an ItemStack is dye and get the DyeColor for that dye? Don't want a massive switch statement checking all 16 dyes

worldly ingot
#

You're gonna have to use the switch statement

#

Else you can create a Map but tbh, the switch statement might actually be faster lol

lime moat
#

Hello, how could I make my tab completer have online players? java public class GamemodeSurvival implements TabExecutor { private static final String[] COMMANDS = {"players"};

heavy marsh
worldly ingot
#

No because they're all separate materials now

heavy marsh
#

I saw..

worldly ingot
worldly ingot
#
public static DyeColor getDyeColor(ItemStack itemStack) {
    return switch (itemStack.getType()) {
        CASE RED_DYE -> DyeColor.RED;
        CASE BLACK_DYE -> DyeColor.BLACK;
        // etc.
        default -> return null;
    }
}```
#

Just a good ole static util method is good enough

lime moat
#

private static final String[] COMMANDS = null; just this?

river oracle
#

why is it static?

worldly ingot
worldly ingot
river oracle
#

mb thought it was public for a second

heavy marsh
worldly ingot
#

I mean... I'd avoid it

heavy marsh
#

ok, util it is

worldly ingot
#

It's like 20 lines of code ;p It's really not bad

river oracle
#

I'm surprised there is no DYE tag

lime moat
#

Sorry, I'm still very confused with the null thing. I currently have java @Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { return null; }

river oracle
#

thats exactly how you do it lol

#

just return null

lime moat
#

I appear to get this on startup: [15:53:39 ERROR]: Error occurred while enabling RaidTheMine-Core v1.0 (Is it up to date?) java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.jordanhaddrick.rtm.Main.getCommand(String)" is null at com.jordanhaddrick.rtm.Main.onEnable(Main.java:23) ~[RaidTheMine-Core.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:536) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[paper-1.19.jar:git-Paper-39] at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[paper-1.19.jar:git-Paper-39] at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:633) ~[paper-1.19.jar:git-Paper-39] at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:419) ~[paper-1.19.jar:git-Paper-39] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.jar:git-Paper-39] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1121) ~[paper-1.19.jar:git-Paper-39] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-39] at java.lang.Thread.run(Thread.java:833) ~[?:?]

#

My main.java has this: java getCommand("gms").setExecutor(new GamemodeSurvival(this));

worldly ingot
#

You don't have gms defined in your plugin.yml

#

Everything else is fine

lime moat
#

Thank you, that worked haha

heavy marsh
#
Block block = event.getClickedBlock();
if (block == null || !block.getType().equals(Material.CAULDRON)) return;

Levelled cauldron = (Levelled)block.getBlockData();

getting CraftBlockData cannot be cast to class Levelled anyone know why?

#

Surely it should be able to be cast since Levelled extends BlockData

quaint mantle
#

If I did Mob mob = (Mob) event.getRightClicked(); How would I get the whole Mob type based off of event.getRightClicked() off of PlayerInteractEntityEvent instead of just that specifically clicked Mob

lost matrix
lost matrix
heavy marsh
#

oh

#

thanks

quaint mantle
#

Why won't my PlayerInteractEntityEvent ever fire

lost matrix
quaint mantle
#

When they right click an entity

lost matrix
quaint mantle
#

I'm going to kill myself

lost matrix
#

Dont. Thats a classic one.

ancient plank
#

It's fun

heavy marsh
#

Looking for some advice, so: I have a resource web server that has all the resource packs that my plugins use, this server when requested will combine all of the resource packs needed for a server given the plugins that are installed. Each player has their resource pack set through Player#setResourcePack where the url is the one that will return the combined resource pack, however if I make changes to any of the packs it won't update without deleting server-resource-packs. How would I either: get the sha1 from the resource server to pass into the method, or, generate a sha1 within the plugin for the resource pack sent?

lost matrix
#

This however means that the user will have to download a new resourcepack after each restart.

heavy marsh
lime moat
#

How could I check a player's gamemode?

lost matrix
lost matrix
heavy marsh
quaint mantle
#
mobbystick.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&6Mob Stick"));
            mobbystick.addEnchant(Enchantment.PROTECTION_FALL, 1, true);
            mobbystick.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            mobstick.setItemMeta(mobbystick);
            player.getInventory().addItem(mobstick);

So I created an item meta for a Mob Stick that I need to use but whenever I check in my Listener, I use if (item == mobstick) and it never works even though that's the item I'm holding. (The variable item is the item in Player's main hand that's already working). How would I get it to work or how would I check to see if it's the mob stick?

lost matrix
#

But that was back then for 1.16

quaint mantle
#

Console prints this

ItemStack{BLAZE_ROD x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=º6Mob Stick, enchants={PROTECTION_FALL=1}, ItemFlags=[HIDE_ENCHANTS]}}
compact haven
#

the hash should be generated on the resource server, then held in a file within the pack & available from the zip directory

#

so like packs/yourpack.zip & packs/yourpack.sha1

lost matrix
#

?pdc

compact haven
#

and 7smile, are you positive the hashes were different?

#

if the hash is the same it'll use the old version

#

never tested it myself but just seems illogical

lost matrix
compact haven
#

ah interesting

echo basalt
#

^ FYI, using == for enums is fine because their memory addresses are linked to their ordinal() position, so == automatically checks one.ordinal() == two.ordinal()

heavy marsh
# compact haven so like packs/yourpack.zip & packs/yourpack.sha1

storing the sha1 in the .zip, how would I access that sha1 without complicating the plugin side?
This is my current plugin-side:

String resources = ResourceManager.getResources();
player.setResourcePack("http://ADDRESS/spigot-resource-combine?resources=" + resources, null, true);
echo basalt
#

ZIP files are openeable via code, rar are not

compact haven
#

well no, I wouldn't advise unpacking the zip for the hash

#

that was just for the client incase they wanted to compare, but on second thought you can't really calculate a hash of the zip without adding the file, but then you can't ad dthe hash

lost matrix
#

I dont get why you would need a hash file... why cant you just lazily calculate it once on the first request?

echo basalt
#

I wonder if it's possible to make a function that predicts its own hash

compact haven
heavy marsh
echo basalt
#

Like I always imagined a class that could have unbreakable DRM because it would store its own hash and compare it

compact haven
#

Maybe it is the servers job to calculate the hash

#

and it’s only once on load

#

it’s really up to you how you want to design it

lost matrix
heavy marsh
lost matrix
heavy marsh
#

ic

lost matrix
#

This allowed for dynamic texture generation. We had every single texture as a font character as well.

heavy marsh
#

Not sure if I quite want to go that elaborate

#

But sounds very powerful

lost matrix
#

Man i miss some of the stuff i made back then. Was really pushing what you could do without mods...

sand vector
#

I have a hologram using armorstands, but I need to make a part change each second. Do I remove the hologram and then replace it or can I rename it?

#

Also 7smile7 thats sick

spring minnow
#

i have a boss plugin and i want to make player death message display boss name instead of entity name when boss kills him

#

in the player Death event i can't get the entity who killed the player that's the issue

heavy marsh
# lost matrix That was not a real problem really. The resourcepack was tightly coupled with th...

Ok, here is my solution. The resource web server keeps a cache of the combined resource pack buffers and another cache for the sha1's, a sha1 will be generated using the buffer if it is not in the cache. The manager plugin then makes a request to the web server, which sends the sha1 as base64, this then gets decoded and passed into the Player#setResourcePack method.

String resources = ResourceManager.getResources();
String packUrl = "http://ADDRESS/spigot-resource-combine?resources=" + resources;

byte[] sha1 = null;
try {
    URL url = new URL(packUrl + "&sha1=true");
    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("GET");

    int status = connection.getResponseCode();
    if (status < 300) {
        BufferedReader receive = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        sha1 = Base64Coder.decode(receive.readLine());
        receive.close();
    }
    connection.disconnect();
} catch (Exception err) {
    err.printStackTrace();
}
player.setResourcePack(packUrl, sha1, true);

It does work in getting the client to download a new version of the resourcepack, however it doesn't then load that new pack unless the player rejoins.

#

It sends this request for every player since the resourcepacks might have changed (though this does mean current players may have different packs but I don't think this matters since new content cannot be added without a server restart)

sinful rapids
#

how do i like:
if the player has cobblestones in his hand;

mortal hare
#

i had never realised anvils can be renamed

spring minnow
mortal hare
#

not all inventories are renameable

#

even if they extend inventory

spring minnow
#

really?

mortal hare
#

due to how client handles them

spring minnow
#

oh

mortal hare
#

for example cartography table cant be renamed iirc

heavy marsh
mortal hare
#

nvm

#

it works

#

oh boy

#

how this one thing

#

will change my api for good

#

i thought some GUIS are not renameable just because they are not renameable via the anvil

#

it seems all inventories are renameable except client ones (player, crafting player, etc.)

#

Man I was trying to build something which doesnt exist

mortal hare
#

but not in the anvils

heavy marsh
#

🤦

mortal hare
#

thats what I did too in the first place

#

and I wasted 7 days of building proper api wrapping around this nonsense

#

for no reason

#

🙃 🙃 🙃 🙃

sinful rapids
#
        if (sender instanceof Player) {
            Player player = (Player) sender;
            Player target = player.getServer().getPlayer(args[0]);
            if(player.hasPermission("convoca.use"));
            if (args.length == 1) {
                player.sendTitle("§9Sei atteso in questura....");
            }
        }else {
            sender.sendMessage("§Non sei un giocatore!");
        }
        return true;
    }
}

not work player.sendTitle("§Sei atteso in questura....");
why?

dusk flicker
#

?notworking

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.

sinful rapids
#

ok

sinful rapids
dusk flicker
#

hover over it

#

what does it say

kind hatch
#

#sendTitle has multiple arguments.

sinful rapids
#

I just want the title, not even the sub etc. Which one should I use?

kind hatch
#

Player#sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut)
Player#sendTitle(String title, String subtitle)

dusk flicker
#

its nullable per the JavaDocs, so you can just set it to null

heavy marsh
dusk flicker
#

fun

lost matrix
# heavy marsh *pain*

I mean you only register it once so it would be fine to stream through all Materials and map, filter them to only those containing "DYE"

eternal oxide
#

_DYE

heavy marsh
lost matrix
#

oh yea

eternal oxide
#

did you shit the bed 7smile7?

humble tulip
lost matrix
humble tulip
#

I was the bed

eternal oxide
#

its 3:30am where you are. I assume you did something nasty in teh bed to make you get up at this time.

lost matrix
#

I studied all day because i got exams in a week. My sleeping schedule is preparing for my semester break afterwards.
Time has no meaning there.

heavy marsh
ornate patio
#

what are some good angry mob particles

#

other than villager angry

vocal cloud
#

Red firework particles?

ornate patio
#

how would you even make it red though

buoyant viper
#

spawn a red firework ezpz

ornate patio
#

uh

humble tulip
ornate patio
#

how

#

its fine i've already settled on another particle

alpine coral
#

So, I am suspicious of a player using a server crashing method

#

Anytime he'd join these errors started showing up

#

and eventually, the server would crash

#

Now that I already banned him

#

no more errors

nocturne cedar
#

am i allowed to ask plugin development related questions here?

#

because I'm very lost currently

#

I just needed to recompile an old plugin for my server and I'm getting a guava related error it seems

eternal oxide
#

?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!

nocturne cedar
#

well I didn't know if it had to be explicitly spigot related

#

anyways

#

this is the line i'm having trouble with:

this.brokenBlocks = (Multimap<String, Location>)ArrayListMultimap.create();
#

and this is the error I'm getting:

Cannot cast from ArrayListMultimap<Object,Object> to Multimap<String,Location>
eternal oxide
#

So this is decompiled code?

nocturne cedar
#

well it was open source at one point

#

the guy deleted his github though, and I couldn't find the source

#

the plugin's from 2014, but still works

#

so that's why I'm using it

lime moat
#

I'm quite new to java, how would I make java sender.sendMessage(MiniMessage.miniMessage().deserialize(prefix_message + ' ' + gms_other, Placeholder.component("player", Component.text(target)))); target work here?

#

It's supposed to be a string, but I just need target there.

eternal oxide
nocturne cedar
#

damn

eternal oxide
#

Just try java this.brokenBlocks = ArrayListMultimap.create();

#

it shoudl not need any cast

nocturne cedar
#

sweet

#

it works now

#

thanks a ton

analog whale
#

every coding community is so sweet man

#

and this is also a reminder to go and atleast give a hug or a kiss for the people u care about ❤️

lost matrix
ivory sleet
echo saddle
#

is there a way with recent versions of BungeeCord and VersionConnector to get multiple clients to route to appropriately versioned servers?

minor otter
#

is it possible to run particles along a raytrace

analog whale
lost matrix
minor otter
lost matrix
minor otter
lost matrix
# minor otter that'd help
  public List<Location> march(Location location, Vector direction, double distance, double delta) {
    List<Location> path = new ArrayList<>();
    direction.normalize().multiply(delta);
    int steps = (int) (distance / delta);
    for(int i = 0; i < steps; i++) {
      path.add(location.add(direction).clone());
    }
    return path;
  }

With this you can specify a location, a direction, how far you want to march and which distance
you want to have between each step.

minor otter
#

sick dude, thanks alot 😄

lost matrix
#

This however does not stop when a block or entity is hit.

#

Do you need that? Because then you would have to do small ray traces between each point.

minor otter
#

I do want that

lost matrix
# minor otter I do want that

To be honest i would actually just ray trace from A to B, get the distance and direction between those two points
and then use the method above to draw a line between them.

minor otter
#

alright that makes sense to me

#

thanks

lost matrix
# minor otter thanks

This should actually do it

  public List<Location> march(Location location, Vector direction, double distance, double delta) {
    List<Location> path = new ArrayList<>();
    direction.normalize().multiply(delta);
    int steps = (int) (distance / delta);
    for(int i = 0; i < steps; i++) {
      path.add(location.add(direction).clone());
    }
    return path;
  }

  public List<Location> marchTrace(Location location, Vector direction, double maxDistance, double delta, RayTraceResult rayTrace) {
    if(rayTrace == null) {
      return march(location, direction, maxDistance, delta);
    }
    Vector hitVec = rayTrace.getHitPosition();
    double hitDistance = hitVec.subtract(location.toVector()).length();
    return march(location, direction, hitDistance, delta);
  }

You just need to decide what to do with null ray traces. Either march to max or do nothing.

minor otter
#

sick dude thanks so much for the help this makes things infinitely easier

undone ruin
#

How do I make a Vector "point/aim" to a location?

lost matrix
lost matrix
undone ruin
#

man I can't believe that I tried literally everything but this

#

thank you very much

ruby swift
#

is this the place where i can commission a plugin?

eternal oxide
#

?services

undone axleBOT
ruby swift
#

oh god

#

is there any way to do it without having to deal with forums?

eternal oxide
#

No, forum is safest

ruby swift
#

its a pretty simple plugin

eternal oxide
#

there is a record of what you do

ruby swift
#

also

#

do plugins need to be custom made for say a papermc server or other types of servers

real yacht
#

hi :), im trying to do a bot in discord to automatizate my server on and off, there is any easy whay of tipping in the console? Srry for my english

vocal cloud
ruby swift
#

how difficult would it be to make a plugin that adds a /rotation command that functions exactly the same as /tp, just without the coordinates bit

eternal oxide
#

very simple

glass mauve
#

lmao

#

here I am 👀

#

nah I think its not allow on this server

ruby swift
#

im tryna make a vanilla recoil system and mf /tp creates so many issues when im just tryna use it to change rotation

glass mauve
ruby swift
#

if someone helps me for free, to code the plugin, i will donate them cash

glass mauve
#

but I also quite didnt understand wym by this:

just without the coordinates bit

ruby swift
#

so like

#

you would be able to do

#

/rotation @p facing entity @r feet

#

like that

#

or /rotation @p 0 90

#

ya know

glass mauve
#

I think there are enough people which would help you not for money
the only requirement is basic Java

ruby swift
#

cuz im not making 20 posts and waiting a week on the forum just for tthis basic plugin

river oracle
#

?services

undone axleBOT
ruby swift
#

AAAAAAAAAAAAAAA

glass mauve
ruby swift
#

squid

glass mauve
#

didnt know this cmd exist

ruby swift
#

do you know "basic java"

glass mauve
#

yea

river oracle
#

do you know basic java?

glass mauve
#

yea thats the actual question

river oracle
#

Also I like how he said do it for free and donate you cash in the same sentence

#

like its not completely contrary

lime moat
#

How could I get a player's max health into a variable?

lost matrix
eternal oxide
# ruby swift do you know "basic java"
    public void setFacing(Player player, Location target) {
        
        Location loc = player.getLocation();
        Vector direction = target.toVector().subtract(loc.toVector());
        
        loc.setDirection(direction);
        player.teleport(loc);
    }```
ruby swift
eternal oxide
#

give that to whoever you get to write your plugin

#

it will make a Player face teh location you provide

ruby swift
#

wait

#

i need it to work like

#

/rotation @p facing entity @e feet

#

like that

#

wait

eternal oxide
#

Yep, the command is the easy bit

#

The code I just gave you is where most devs will get stuck

ruby swift
#

oh

ancient plank
#

math is hard

ruby swift
#

hey @ancient plank

lime moat
#

How could use an if check to determine if a player's flight is enabled/disabled?

vocal cloud
lime moat
#

Thank you very much!

boreal seal
#

hey guys

glass mauve
#

hi :D

boreal seal
#

i run into an issue

#

an unique one

#

i read the docs and etc

#

but it just dont work

glass mauve
#

what are you trying to do

boreal seal
#

event.setFormat

#

from ASyncChatEvent

#

now i even went maniac mode after 2 hours and decomplied half of the plugins on spigot

#

and they didnt do anything different from mine

glass mauve
boreal seal
#

why when i do it just doesnt work?

#

ig.equals?

glass mauve
#

i guess

boreal seal
#

no i use normal spigot

#

not a fork out of spigot

#

i tested other plugin

#

and it worked

glass mauve
#

there is no ASyncChatEvent in spigot

#

only AsyncPlayerChatEvent

#

AsyncPlayerChatEvent is deprecated in Paper, bc you should use AsyncChatEvent

boreal seal
#

oh i cant send pictures

glass mauve
#

np I saw it

boreal seal
#

so

glass mauve
#

yeah you use Asyncplayerchatevent, but said AsyncChatEvent

boreal seal
#

i need to implement a library?

glass mauve
#

there is a difference

boreal seal
#

hm ll try to use them both

#

i have no idea what the other event does then

glass mauve
#

the other event doesnt exist in Spigot

#

so you dont need to care about it

#

but I thought that you use Paper instead of Spigot bc you said you use AsyncChatEvent which only exists in Paper

boreal seal
#

oh

#

i mean like what did i do wrong there?

glass mauve
#

whats happening and what should happen

subtle folio
#

?paste your code

boreal seal
#

it should be the format

undone axleBOT
boreal seal
#

i realized

#

i think its all because i missed @EventHandler

#

lmao

glass mauve
#

💀 💀 💀 💀

boreal seal
subtle folio
#

gg

boreal seal
#

but ill test it now

#

i spend on it

#

so many hours

#

so many

#

i decomplie so many resources to see how they done it

#

and it was the saem

#

like

#

.

subtle folio
#

did you register i

#

it

glass mauve
#

oof that hurts

boreal seal
#

ofcourse Ntdi

glass mauve
#

"ofcourse"

boreal seal
#

the thing in the same class i have more 20 listeners + -

glass mauve
#

but forgot EventHandler 👀

boreal seal
#

the rest did work

subtle folio
#

lmao

#

imagine not diff class for each listener 🤓

boreal seal
#

it really depends on what i do sometimes i put all of them in a single class

#

some times in sperate

#

but i dont go all in into mainclass

#

lol

glass mauve
#

I always make a new class for each listener, but sometimes 2-3
never used 20 in one class

boreal seal
#

idk whats the problem of doing it

subtle folio
#

reminds me of using if else for each of ur commands in the same class

subtle folio
boreal seal
subtle folio
#

kinda frowned apon in spigot

boreal seal
#

and find quickly what i need

subtle folio
boreal seal
#

like i know eyes will hurt

#

but all the 20 events have a common goal

#

beside the chat events

stoic vigil
#

commandexecutor --> gets called correctly but the item frame doesn't gets deleted

public class ConfirmDeletePosterCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        World world = sender.getServer().getWorld(args[3]);
        Location location = new Location(world, Double.parseDouble(args[0]), Double.parseDouble(args[1]), Double.parseDouble(args[2]));
        Collection<Entity> entities = world.getNearbyEntities(location, 0,0,0);
        for (Entity entity : entities) {
            if (entity instanceof ItemFrame) {
                entity.remove();
            }
        }
        return true;
    }
}

itemframe break listener --> only possible problem

public class PosterBreake implements Listener {
    @EventHandler
    public void blockBreak(HangingBreakEvent e) {
        if (e.getCause() == HangingBreakEvent.RemoveCause.DEFAULT) { return; }
        e.setCancelled(true);

        Entity entity = e.getEntity();
        Location location = entity.getLocation();
        Collection<Entity> entities = location.getWorld().getNearbyEntities(location, 10, 10, 10);
        for (Entity nearbyEntity : entities) {
            if (nearbyEntity instanceof Player) {
                nearbyEntity.sendMessage("§cDo you really want do destroy this mapart?");
                TextComponent clickableYes = new TextComponent("[Yes]");
                clickableYes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/confirmdeleteposter %d %d %d %s".formatted(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld().getName())));
                nearbyEntity.spigot().sendMessage(clickableYes);
            }
        }
    }
}

thx already for helping!

undone axleBOT
stoic vigil
boreal seal
#

i would say this format way better then the paste one

subtle folio
#

no

#

floods chat 😦

stoic vigil
glass mauve
subtle folio
stoic vigil
glass mauve
stoic vigil
subtle folio
glass mauve
#

also you need to scroll after a while to get back to your code/read messages

stoic vigil
subtle folio
#

like args[0-3] ?

stoic vigil
#

nope, but the arguments are correct

#

[07:59:54] [Server thread/INFO]: Schwerthecht issued server command: /confirmdeleteposter 112 66 -59 world

subtle folio
#

lickEvent.Action.RUN_COMMAND, "/confirmdeleteposter % no /

#

oh wait

#

its working?

#

oh wait i see

stoic vigil
#

yee, command is executed correctly

subtle folio
#

some weird way of doing it

#

ok

stoic vigil
subtle folio
#

print out all the Collection<Entity> entities = world.getNearbyEntities(location, 0,0,0);

subtle folio
#

ig for u its fine

#

i just didnt understand

stoic vigil
stoic vigil
subtle folio
#

locations are weird

#

u could try uping the radious

#

radius*

stoic vigil
#

okee ^^ so i'll try 0.5, thy! ❤️

humble tulip
#

Why u wanna do 0,0,0?

#

That's a volume of 0

#

You can't have anything in nothing

#

Ur removing itemframes?

stoic vigil
#

jee, that makes sense, but with 1 it deletes all around too

humble tulip
#

Why just around the player may i ask?

stoic vigil
stoic vigil
subtle folio
#

a command gets called from the event of breaking itemframes ^

#

confused me aswell

stoic vigil
#

i just want a clickable text confirmation and you just can react in code to this with a command (afaik)

humble tulip
#

Yeah

#

Makes sense

stoic vigil
#

just cant find the issue 😭

undone temple
#

Why PlayerItemConsumeEvent when using potion returns in the method "getReplacement()" null?

i need replace GLASS_BOTTLE when player use potion

#

@alpine urchin can u help me?

chrome beacon
#

Well that's a random ping

vocal cloud
#

That's why you don't put your GitHub in your bio /s

alpine urchin
#

@md5 can you help me

vocal cloud
#

Get pinged kek

torn oyster
#

how should i use OOP to get the most efficient sql connection and usage

grand glade
torn oyster
#

rn i am creating one called "SQLSetup" and one called "SQLUtil" but i don't know if that is the best (SQLSetup is for establishing the connection and basic queries and SQLUtil is a class full of queries that i use often)

grand glade
#

Using singletons is always the best approach to minimize useless resource requirements

subtle folio
grand glade
#

Then you’re lucky or more than me 😀

#

I sent him a mail but didn’t get any reply

subtle folio
#

is it possible to get a method from a string

#

like rs.get + "kills"() or rs.get + "deaths"()

#

or is valueOf only an enum thingy

#

ig no easy way

torn oyster
subtle folio
#

its not an enum 😦

torn oyster
#

instead of getKills() and getDeaths() being separate

torn oyster
#

using a switch statement in getStat

subtle folio
#

its more of a getInt() and getFloat() that im tryna combine two functions into one

torn oyster
#

hm

#

you could make getStat return an object and use instanceof and casting

subtle folio
#
private static int getInt(String name, ResultSet rs) {
        try {
            int num = rs.getInt(name);
            rs.close();
            return num;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    private static float getFloat(String name, ResultSet rs) {
        try {
            float num = rs.getFloat(name);
            rs.close();
            return num;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }```
#

if you wanna see the code 😛

torn oyster
subtle folio
#

ooo maybe

subtle folio
# torn oyster you could make getStat return an object and use `instanceof` and casting

beautiful, ```java
private static int getInt(String name, ResultSet rs) {
return (int) getObject(name, rs)
}

private static float getFloat(String name, ResultSet rs) {
    return (float) getObject(name, rs);
}

private static Object getObject(String name, ResultSet rs) {
    try {
        Object obj = rs.getObject(name);
        rs.close();
        return obj;
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return 0;
}```
humble tulip
subtle folio
#

like i dont need a rs.close()?

humble tulip
#

Nope

#

As long as the statement is closed

subtle folio
#

i read on a forum that it was better practice to keep it

humble tulip
#

No

subtle folio
#

but that brings down alott of the lines

#

so thank you ❤️

#

@humble tulip what are your thoughts on this code? java public static boolean isInDatabase(UUID uuid) { try { ResultSet rs = stmt.executeQuery("SELECT * FROM STATS WHERE ID='" + uuid.toString() + "';"); if (rs.next()) { return true; } } catch (SQLException e) { e.printStackTrace(); } return false; }

humble tulip
#

What's the point in checking if it exists?

#

Like specifically

#

It's fine tho

grand glade
humble tulip
#

There will be no next so retun null

grand glade
#

Maybe some misunderstanding 🙂
You could also check that there is any existing result matching to the query, you check is the result null or maybe the size of the result also could help

#

Oh and one more trick, in most cases there isn’t required to use the semicolon on the end of the query

subtle folio
#

I shouldn't do mysql thingys on the main thread, right?

humble tulip
#

Nope

#

You should not

subtle folio
#

got it 😛

#

Should I make a new connection each time I want to update smt in the sql db or do I just keep one alive?

humble tulip
#

Do u use hikari?

#

If not, keep one connection

subtle folio
tardy delta
#

Connectionpool like hikaricp ^^

subtle folio
#

what?

flint coyote
#

Hikari creates and handles a connection pool. It is not a database. It handles the pool and hands you an open connection when you need one

subtle folio
#

I see

#
  Position: 53
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:329)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:315)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:291)
    at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:265)
    at world.ntdi.postgayy.Stats.SQLRapper.updateValue(SQLRapper.java:74)
    at world.ntdi.postgayy.Stats.StatsManager.setKills(StatsManager.java:27)
    at world.ntdi.postgayy.Stats.StatsManager.addKills(StatsManager.java:30)
    at world.ntdi.postgayy.PostGAYY.main(PostGAYY.java:27)
#

How can a uuid cause errors?!?!?

#

UUID uuid = UUID.fromString("e985173d-f10f-4bc0-95cc-613cd49e5573");

#

the bc0 is in the middle

river spear
#

Why do I get null entity with this one Entity entity = player.getTargetEntity(10); when this player of target is in creative mode?

chrome beacon
#

That's not Spigot API is it?

summer scroll
#

Also @subtle folio check out try-with-resources.

opal juniper
river spear
#

oh okay thanks

rotund pond
#

Hey everyone !
I'm trying to check if a player is vanished (using Essentials, so using Player#hidePlayer method), but I can't find out how ...
Does anyone know something about it please ? 🙂

next stratus
rotund pond
quaint mantle
#

where did u guys learn coding?

next stratus
rotund pond
next stratus
#

I'd advise learning object oriented programming aka OOP first before learning spigot big mistake me not learning that first

quaint mantle
#

public class TeleportBow implements Listener {
public void whatever(ProjectileHitEvent event) {
if (event.getEntity().getShooter() instanceof Player) {
Player player = (Player) event.getEntity().getShooter();
if (player.getInventory().getItemInMainHand().getType().equals(Material.BOW)) {
if (event.getHitBlock() == null) {
player.teleport(event.getHitEntity());
} else if (event.getHitEntity() == null) {
player .teleport(event.getHitBlock().getLocation().add(0,1,0));
}
}
}
}
}

#

how can i add recipe

rotund pond
quaint mantle
#

for the teleport bow

#

i made teleport bow but idk how can i make it craftable

rotund pond
quaint mantle
#

wait

#

i know that

#

i know how to create recipes

rotund pond
#

😅

quaint mantle
#

but i want to add the recipe into this code

quaint mantle
rotund pond
#

I don't understand you request tbh
Why would you add a recipe in this code ?
It's just a listener, there's no point in using a recipe
So I don't know how I could help you

quaint mantle
#

listen.

#

i want to make it craftable

rotund pond
#

Ah I know how I could: You should use early returns to make your code easer to maintain

quaint mantle
#

so people can craft it

rotund pond
quaint mantle
#

i want the teleport bow to be craftable so people can craft it but i dont know how to make it

rotund pond
quaint mantle
#

yesssssssssssssssssssssssssssssssssssssssss

#

i know that

rotund pond
#

🤨

quaint mantle
#

but i want the way to make THIS code as recipe

public class TeleportBow implements Listener {
public void whatever(ProjectileHitEvent event) {
if (event.getEntity().getShooter() instanceof Player) {
Player player = (Player) event.getEntity().getShooter();
if (player.getInventory().getItemInMainHand().getType().equals(Material.BOW)) {
if (event.getHitBlock() == null) {
player.teleport(event.getHitEntity());
} else if (event.getHitEntity() == null) {
player .teleport(event.getHitBlock().getLocation().add(0,1,0));
}
}
}
}
}

#

please anser my qestion

rotund pond
#

But this code isn't a recipe

#

This code is a Listener

quaint mantle
#

extends JavaPlugin ?

rotund pond
#

You can't make a cat barking, as much as you can't transform a Listener in a recipe

mortal hare
#

🙃

rotund pond
rotund pond
#

Aaah

quaint mantle
#

just coding for my smp

rotund pond
#

So you should learn OOP first, before trying spigot

mortal hare
#

Composition or Inheritance hmm

quaint mantle
#

u have video tutorial

rotund pond
#

You will earn so much time

quaint mantle
#

i need a tutorial

rotund pond
#

If we could learn everything with videos, university wouldn't exist

quaint mantle
#

so how can i learn java

glossy venture
#

?learnjava

undone axleBOT
glossy venture
#

some good resources

quaint mantle
#

thx

#

i will check it out

mortal hare
#

rest of 20% is just still unknown for me

rotund pond
mortal hare
#

Im wondering if I should use composition for NMS classes or do inheritance and implement NMS things as a subclass for the base class

#

and then use a Builder design pattern to build it without client using NMS class level constructors

#

both approaches seem logical

rotund pond
#

The second one sounds easier to maintain to me, especially if you need to handle a lot of versions 🤔

hushed spindle
#

i just realized that getting a living entity's eye location doesn't work properly when they're riding another entity

#

their eye location will be where they would be if they werent riding said entity

#

is there any workaround to where i can get the true eye location of a riding entity

mighty pier
#

is it possible to get entities when theyre unloaded?

old sail
#

How can I open a toolbox without opening any inventory?

buoyant viper
hushed spindle
# old sail

what do you mean toolbox without opening inventory

agile anvil
tardy delta
#

But how does that box show up?

hushed spindle
#

what does toolbox mean here

#

do you mean just a custom gui

#

in which case yeah the custom char solution will work

tardy delta
#

The Oriental bench thing ^^

agile anvil
hushed spindle
#

i know but i still dont understand what hes asking

agile anvil
tardy delta
#

How to show that thing i guess

hushed spindle
#

oh you mean the little indicator, yeah an action bar or title custom char will work

#

one character for the whole outline, and offset characters to bring the regular text into position

agile anvil
#

N.B: you have to be in 1.13+ (or 1.16+ i don't remeber)

hushed spindle
#

1.13 i believe works

#

if you want this indicator to be positioned relative to where you're looking at the block you'll have to do some complex math magic to get it to look nicely i think, thats probably possible, but i dont do enough mathamfetamine to know how to

agile anvil
tardy delta
#

what do they mean with red-black?

echo basalt
tardy delta
#

uh oh i dont know any of that

echo basalt
#

it just means that it won't get too nested apparently

tardy delta
#

hmm ye

keen star
#

Hi

echo basalt
#

load balancing type of thing

keen star
#

i want to get distance between 2 location but i found in bukkit have Distance and Distance squared

echo basalt
#

distance returns the distance

#

distanceSquared is slightly faster, but returns distance*distance

echo basalt
#

only difference is that distance(Location) calls sqrt(distanceSquared)

tardy delta
#

¯_(ツ)_/¯

hushed spindle
#

yeah you dont wanna call distance too much

tardy delta
#

any chance that someone wrote a valuesorted treemap impl lol

#

rewriting the whole thing myself scares me

subtle folio
#

I have a linked map one 😦

tardy delta
#

i guess thats not what i want

#

i mean wtf

subtle folio
#

yep nope

golden turret
#

is there a way to simulate the EntityDamageByEntityEvent to get the final damage?

heavy marsh
#

Anyone know what could be causing the client to throw a FAILED_DOWNLOAD status when the sha1 changes in the #setResourcePack method?

#

But then when they rejoin it downloads and loads fine?

quiet ice
#

That is as long as the value is mutable

#

If the value is not mutable, then it is possible

sterile token
#

Mutable is that can be changed right?

tardy delta
#

yes

#

uh oh pain

sterile token
#

And why do you need that fourten?

quiet ice
#

Though at that point I prefer having something like TreeSet<Map.Entry<Key, Value>> with a custom comparator

sterile token
#

What do you want to do fourteek?

quiet ice
#

Probably leaderboard-like functionality

sterile token
#

Hmn

quiet ice
#

It's been far too often that I have needed something like this but I always came back to the TreeSet<Map.Entry>

sterile token
#

Is it a table for displaying player status?

tardy delta
#

uhh well uhh i was thinking about performance
so im currently having a HashMap<K, RemoveQuery<K>> where record RemoveQuery<K>(Consumer<K>, Instant) and i wanted to sort those entries based on the time of the instant

#

so when i want to execute all the queries in the map which instant is now in the past, i could just iterate thro it and break when those instants arent longer in the past

#

instead of looping thro a whole map

#

i guess it works with a normal map too but i was just thinking

quiet ice
#

How large is the map and how much retrieval needs to be done?

river oracle
tardy delta
#

its basically used as some internal stuff in a usermap so in my server that map wouldnt be large

#

but ye

heavy marsh
tardy delta
#

retrieval is done like every five minutes with a runnable

river oracle
# heavy marsh nope

So when you open the zip you don't have to open another folder to get to the contents

heavy marsh
river oracle
#

Invalid McMeta bad download link are the other two that come to mind

quiet ice
heavy marsh
#

download link works, I just used it

#

here is the generated mcmeta: {"pack":{"pack_format":9,"description":"Backpacks+Netherite Shield"}}

quiet ice
#

And how often do you expect to insert something to the map?

#

Right now it really seems like a TreeSet<Map.Entry> linked with a regular HashMap should suffice

tardy delta
#

this is the code
https://paste.md-5.net/qemozemero.java
and ye its looping thro it every five minutes
and in the stuff im currently using it for, it inserts an entry whenever an user joins the server

river oracle
dire marsh
#

@heavy marsh check your .minecraft/latest.log

heavy marsh
#

I am not sure what the problem is tbh since the pack does work, but not on the first join, you rejoin and it loads fine

tardy delta
#

a deque is only <E> right, so no keys values?

heavy marsh
# dire marsh <@255733848162304002> check your .minecraft/latest.log

[Netty Client IO #20/WARN]: Pack application failed: java.lang.RuntimeException: Hash check failure for file C:\Users\#\AppData\Roaming\.minecraft\profiles\Vanilla\server-resource-packs\053bbbf81781d3d464f7d617ea6325991d46baaa, see log, deleting file C:\Users\#\AppData\Roaming\.minecraft\profiles\Vanilla\server-resource-packs\053bbbf81781d3d464f7d617ea6325991d46baaa

tardy delta
#

yep but i need keys values to be able to run the consumer

hybrid spoke
#

then put it into your map

quiet ice
heavy marsh
# heavy marsh `[Netty Client IO #20/WARN]: Pack application failed: java.lang.RuntimeException...
[01:06:11] [Render thread/INFO]: Connecting to localhost, 25565
[01:06:12] [Netty Client IO #20/WARN]: File C:\Users\#\AppData\Roaming\.minecraft\profiles\Vanilla\server-resource-packs\053bbbf81781d3d464f7d617ea6325991d46baaa had wrong hash (expected 622002d125fd3089142504df7b618526f6e3f8bf, found e8d528156403330d396ed70acf24b8327ce05f37).
[01:06:12] [Netty Client IO #20/WARN]: Pack application failed: java.lang.RuntimeException: Hash check failure for file C:\Users\#\AppData\Roaming\.minecraft\profiles\Vanilla\server-resource-packs\053bbbf81781d3d464f7d617ea6325991d46baaa, see log, deleting file C:\Users\#\AppData\Roaming\.minecraft\profiles\Vanilla\server-resource-packs\053bbbf81781d3d464f7d617ea6325991d46baaa
[01:06:12] [Render thread/INFO]: [CHAT] SyntheticDev joined the game
tardy delta
#

whats a pr

heavy marsh
hybrid spoke
#

public relation dankfingers

tardy delta
#

thats what google showed me smh

dire marsh
#

whatever hash you're telling the client it should be, the client is not receiving the same from the download

quiet ice
#

I can also mail in a regular git patch if needed

#

Doing it the good ol' way

heavy marsh
dire marsh
#

yes

heavy marsh
#

should the hash be static?

dire marsh
#

no

heavy marsh
#

🤔

river oracle
#

Delete your server pack cache in .minecraft it should resolve your issues

dire marsh
#

what have you set the hash to

tardy delta
#

uhhh ok ig

river oracle
#

If it's incompatible hashes could be an issue with a cache

quiet ice
#

It would take too much time to explain my idea to you, you'll get what I mean when I'm done - sorry

tardy delta
#

👀

heavy marsh
dire marsh
#

what are you setting the hash to

#

and the url

heavy marsh
# dire marsh what are you setting the hash to

one sent by my server that handles resource packs, here is the code:

String resources = ResourceManager.getResources();
String packUrl = "http://ADDRESS/spigot-resource-combine?resources=" + resources;

byte[] sha1 = null;
try {
    URL url = new URL(packUrl + "&sha1=true");
    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("GET");

    int status = connection.getResponseCode();
    if (status < 300) {
        BufferedReader receive = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String base64 = receive.readLine();
        receive.close();
        sha1 = Base64Coder.decode(base64);
    }
    connection.disconnect();
} catch (Exception err) {
    err.printStackTrace();
}
player.setResourcePack(packUrl, sha1, true);
dire marsh
#

well that complicates things

heavy marsh
#

I have confirmed through logging that the sha1 is received and properly decoded and is equal to the one on the web server

bold solstice
#

Can someone help me understand why it sends me this error in the console multiple times when I try to damage an entity for example
Could not pass event EntityDamageByEntityEvent to Races v1.0.0
org.bukkit.event.EventException: null

dire marsh
heavy marsh
#

yep

#

they match equally (to the one generated on the server)

heavy marsh
dire marsh
#

and the hash is 622002d125fd3089142504df7b618526f6e3f8bf?

heavy marsh
#

yep

#

wait

#

no it is e8d528156403330d396ed70acf24b8327ce05f37

golden turret
#

is there a way to simulate the EntityDamageByEntityEvent to get the final damage?

heavy marsh
dire marsh
#

according to the client, you're sending it 622002d125fd3089142504df7b618526f6e3f8bf whilst it's expecting what you said is the current hash e8d528156403330d396ed70acf24b8327ce05f37

heavy marsh
#

expected 622002d125fd3089142504df7b618526f6e3f8bf, found e8d528156403330d396ed70acf24b8327ce05f37?

dire marsh
#

yes

heavy marsh
#

well of course because the pack has changed

#

feels like we are going round in circles a little bit 😅

dire marsh
#

🤔

#

the found part is the file hash that it downloaded

#

the expected is what you sent it

heavy marsh
#

hmm

dire marsh
#

what if you delete your server-resource-packs folder like ysk said?

heavy marsh
#

then it downloads fine

#

it just doesn't initially work if a client has an old version of the pack (aka the sha1 changes)

dire marsh
#

what's your client version?

heavy marsh
#

1.19

river oracle
#

I've never had this issue when changing packs in the past

#

What fork are you on

dire marsh
#

and applying it works the 2nd time?

heavy marsh
#

and not passing a sha1 is obviously problematic since the client will not download the new version

clever musk
#

Can NamespacedKeys have dots? like a maven artifact

heavy marsh
dire marsh
#

you could be right that it's a bug then

#

"I am having a similar issue, but it is not failing to delete the file, it just fails to apply the new pack. This seems to be new 1.17 behavior:"

river oracle
#

Hmmm MC bug hopefully they fix thag with 1.19.1 release

subtle folio
#

1.19 chat bans crying

river oracle
#

Never know

dire marsh
#

it's been open since 2019 and is low priority

river oracle
heavy marsh
#

here is my janky solution for now then 😕

@EventHandler
public void onResourcePackStatus(PlayerResourcePackStatusEvent event) {
    Player player = event.getPlayer();
    if (event.getStatus().equals(PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD)) {
        player.kickPlayer("Server resource pack has changed or resource pack failed to download.\nPlease rejoin.");
    }
}
dire marsh
#

you can try changing the url

#

as that will make it work

heavy marsh
dire marsh
#

Yeah

heavy marsh
#

ok let me try that

subtle folio
#

===

dire marsh
#

at least according to the bug report that should work

heavy marsh
#

give me like 15 minutes, gotta change the web server behaviour

undone axleBOT
bold solstice
chrome beacon
#

Your trying to use a value that doesn't exist on LifeSteal.java:135

subtle folio
tardy delta
#

yes sure

#

lmao

subtle folio
#

alr

tardy delta
#

idk actually lmao

subtle folio
#

ill try and seee

tardy delta
#

i'd do CompletableFuture.runAsync(dbThread::start).thenRun(...)

subtle folio
#

?tryitandsee

#

thenRun()?

tardy delta
#

wouldnt that freeze the server tho?

subtle folio
#

what goes in there

tardy delta
#

Runnable

subtle folio
subtle folio
sterile token
#

?tryandsee

undone axleBOT
subtle folio
#

do I have to give it anything

ivory sleet
#

A runnable

#

But that looks extremely weird

subtle folio
#

oh, right

#

wdym?

tardy delta
#

dunno what you want to do if the thread is completed?

ivory sleet
#

you probably wanna use a single thread executor and pass it to the future instead

sterile token
subtle folio
sterile token
#

No the one that allow to see the methods

subtle folio
#

or the theme..?

#

not a plugin, vanilla intelliJ

sterile token
#

Oh

#

Cool nines doesnt do that

subtle folio
#

im on 2022

sterile token
#

Ultimate versión?

subtle folio
#

nope

sterile token
#

Oh ok

#

I will try

subtle folio
#

community baby

sterile token
#

Thanks

#

Oh me too

tardy delta
#

2021.1.1 smh

subtle folio
#

2022.1.3 🆒

sterile token
#

And also your theme is really yup

quaint mantle
#

How to get config data?

check:
    killaura:
         enable: true
         range: 4.5
         aps: 7
         notify: "e"

This is a config and I would like to know how to get each value from it.

Paper, MC 1.18.2

sterile token
#

Han

subtle folio
quaint mantle
#

Why

quaint mantle
quiet ice
sterile token
#

I think there is a getter for the config

subtle folio
sterile token
#

Here is spigot support tho

#

Thanks ndi for the tele

#

Theme,

ivory sleet
sterile token
#

Its looks pretty amazing

ivory sleet
#

There’s a config wiki page

#

Which might help you regardless of platform

quaint mantle
sterile token
#

I didnt see you since 1 month

quaint mantle
#

Where a config wiki page?

sterile token
ivory sleet
quiet ice
quaint mantle
ivory sleet
#

^

quiet ice
#

Those maps shouldn't be particularly huge

subtle folio
ivory sleet
#

Mostly cause I was learning Rust :>

tardy delta
#

owo

quiet ice
#

Having a LinkedList that is only iterated partially is far more optimal than having a HashMap that has to be fully iterated upon or even sorted

quaint mantle
#

If the setting is set, how to get it?

tardy delta
#

hmm i understand what youre doing

tepid thicket
#

Reading blocks from unloaded chunks causes a massive lagspike.

#

Is there a way to perform the loading async and then react sync to the result?

quiet ice
#

You might even be okay with just having two collections, an DelayQueue and a Map but that system would be a lot more finicky to implement

tepid thicket
#

How?

ivory sleet
#

Perform the task on another thread and then subsequently take the result and consume it with BukkitScheduler::runTask

#

(I assume by sync you mean server thread)

tepid thicket
#

So it is safe to load chunks from another thread?

tardy delta
#

dunno what a delayqueue is

quiet ice
#

Basically something that does what you want, but just for adding and not for removal iirc

tardy delta
#

hmm i seem to understand the principle

ivory sleet
tardy delta
#

An unbounded blocking queue of Delayed elements, in which an element can only be taken when its delay has expired.

ivory sleet
#

But iirc doesn’t have anything regarding loading chunks

tepid thicket
#

I want to get the chunk object to read the block states.

ivory sleet
#

Yeah

#

ChunkSnapshots are capable of doing that async iirc

#

Idk how up-to-date they are due to thread safety

#

But up-to-date enough unless you do stuff atomically etc

quiet ice
#

It is likely going to be less efficent anyways

#

DelayQueue is concurrent, which you seem not to care about

tepid thicket
#

A ChunkSnapshot seems to be able only capable of proving materials, not block states.

#

I'm looking for something like world#getChunkAt() but in an async fassion.

#

As I think, it's not safe to call this method from another thread, right?

snow compass
#

I´m confused abut this error https://pastebin.com/LmzLeV9M I know the error, but not way it print error. Look more like the method spigot/bukkit use ignore the if check I have and try load every class in the method i have.

ivory sleet
#

Might even be caught

eternal oxide
snow compass
subtle folio
#

added it as a depencicy in project strucutre aswell

eternal oxide
#

you are building with maven. If maven doesn;t know about that jar it will not include it

lost matrix
subtle folio
#

hmph, i cant find the maven repo for Postgres sql JDBC

subtle folio
lost matrix
subtle folio
#

oh sweet

lost matrix
subtle folio
eternal oxide
#

no

subtle folio
#

just a dependcy

#

ok

#

blood eko what are you doing

tepid thicket
#

Sorry, misstyped. Hold on.

subtle folio
#

editing exists ..

tepid thicket
#

Eventually this would be up then to a feature request. As Paper seems to have a getChunkAtAsync() method.

#

Alright thanks guys.

tardy delta
#

CompletableFuture.supplyAsync(getChunkSync) kekw

tepid thicket
#

No, I think calling getChunk() async is still not safe.

lost matrix
#

Thtats what the "kekw" was for

tardy delta
#

doing your mom async isnt safe too

#

smh

lost matrix
tardy delta
#

doesnt async mean another thread?

#

away from some main thread

eternal oxide
#

not always

lost matrix
tardy delta
#

aaah

quiet ice
#

For me async just means "not now"

lost matrix
#

First mistake im seeing:
Never compare objects with == unless you want to check for identity (exact memory address)
For primitives and enums its good but you dont want to use this for Objects like Strings.
So someString == "" will always be false.

hybrid spoke
#

if its unloaded

#

and you cant load the chunk async

lost matrix
#

Next mistake: You are using something else than the PDC to check for custom or tagged items.
You should always use the PDC to tag an ItemStack. Never use the name, lore or other properties.

#

?pdc

agile anvil
#

The display name is just, by its name, something you display

subtle folio
lost matrix
#

Something like this looks fine to me

public class ItemLocker {

  private final NamespacedKey lockKey;

  public ItemLocker(JavaPlugin plugin) {
    this.lockKey = new NamespacedKey(plugin, "item-lock");
  }

  public void toggleLock(ItemStack itemStack) {
    ItemMeta meta = itemStack.getItemMeta();
    if(meta == null) {
      return;
    }
    PersistentDataContainer container = meta.getPersistentDataContainer();
    if(container.has(lockKey, PersistentDataType.BYTE)) {
      container.remove(lockKey);
    } else {
      container.set(lockKey, PersistentDataType.BYTE, (byte) 1);
    }
  }

  public boolean isLocked(ItemStack itemStack) {
    ItemMeta meta = itemStack.getItemMeta();
    if(meta == null) {
      return false;
    }
    PersistentDataContainer container = meta.getPersistentDataContainer();
    return container.has(lockKey, PersistentDataType.BYTE);
  }

}
gritty urchin
#

hey

#

how do I update a GUI Inventory's items

#

without closing it

#

tried Player#getInventory

#

but that gets their own inventory not the chest/gui inventory

lost matrix
gritty urchin
#

but it does not update for the player

#

when I change it

paper falcon
#

How would I make an ItemStack have limited uses? E.g. I'm making a lightning Blaze rod and want to put 100 uses max.
The lore would also update itself with the uses left.

eternal oxide
gritty urchin
#

and when it reaches the maximum

#

remove from their inventory

#

e.g. playerinteractevent

#

check for the specific item

#

add player to a hashmap with player and uses

snow compass
gritty urchin
#

and deduct each time

lost matrix
lost matrix
gritty urchin
#

ah thanks

#

this is what I was looking for

#

Inventory guiInv = player.getOpenInventory().getTopInventory()

paper falcon
charred blaze
#

itemmeta.setdisplayname("s");

#

maybe?

lost matrix
#

This is expected behavior. If you rename an ItemStack like that in minecraft then it becomes cursive. You need to specify a styling to change the appearance.

eternal oxide
#

If you are using Components in naming you are not using Spigot

heavy marsh
#

As 7smile7 said: #setDisplayName(ChatColor.RESET + name) or the component equivalent should work

charred blaze
#

most of times im ignoring deprecated things... just use it

#

thats same but with chatcolor

lost matrix
#
    ItemStack itemStack = new ItemStack(Material.IRON_AXE);
    ItemMeta meta = itemStack.getItemMeta();
    meta.displayName(Component.text("Mithril Axe").color(NamedTextColor.AQUA));
    itemStack.setItemMeta(meta);

This also works

meta.displayName(Component.text("§eMithril Axe"));

Or RGB:

meta.displayName(Component.text("§eMithril Axe").color(TextColor.color(240, 200, 90)));
snow compass
heavy marsh
lost matrix
eternal oxide
lost matrix
#

Bleached wood for that matter

heavy marsh
snow compass
eternal oxide
#

Thats because DustOptions is not ConfigurationSerializable

charred blaze
#

wasnt are you talking about display name change? xd

heavy marsh
snow compass
eternal oxide
#

You have to do the same for DustTransitions

hidden kestrel
#

I'm attempting at a multi-world plugin - I have 2 separate worlds with each of their own nether & end dimensions.

I'm having some issues with the end.

  1. I use PlayerPortalEvent#setTo() to teleport to the correct end world. Here I use #getSpawnLocation() of that world. The spawn location of said world appears to also be the spawn location of the fountain. How do I get the correct location where you would normally spawn after entering an end portal?

  2. I use the same event for when leaving the end, making sure the player goes to the correct dimension, with the player's respawn point. I checked for the TeleportCause if it was == END_PORTAL, but it appears the fountain is actually an END_GATEWAY, as I ended up in the void upon entering it. How can differentiate the player from entering the fountain's portal, and using an actual gateway with enderpearls?

eternal oxide
#

Because extends Particle.DustOptions

charred blaze
#

does anyone know?

snow compass
clever musk
#

Are there plans to make org.bukkit.block.Biome abstract?

lost matrix
# charred blaze does anyone know?

Advancements have to be known when the player joins. So you should be able to just create a bunch of advancements (in a resourcepack) and
change the description, icon, title and type however you please.

charred blaze
#

resourcepack?

hidden kestrel
#

Related to advancements, is there a way to list the player's advancements??

charred blaze
#

it needs resourcepack?

somber sequoia
#

is there any way to refresh the inventory in the InventoryClickEvent? I need to get what item has been put into the menu

lost matrix
quiet ice
ornate heart
#

I'm using this to set the player's max health. It's changing the attribute value in the code. I know this because I'm printing out the value right after I change it, but it's not changing my heart amount. Any reason for this?

quiet ice
#

However right now it still stays an enum due to backwards compat

charred blaze
lost matrix
lost matrix
ornate heart
lost matrix
ornate heart
#

Ok so how would I just have the player have 5 hearts. I thought doing

player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setbaseValue(10);

would do that. Do I have to do something else?

lost matrix
#

setHealthScaled(boolean) -> defines if the health should scale automatically

ornate heart
#

Is this new? I didn't even know this was a thing

lost matrix
#

Cant remember if it every wasnt a thing.

lost matrix
charred blaze
#

i think playing with packets is pretty hard

#

i dont know i can go on this

lost matrix
#

Because you set it to a fixed location. It doesnt follow the player.

rough drift
#

How can I move a location forward based on it's direction?