#help-development

1 messages Β· Page 56 of 1

slate delta
glossy venture
#

can you send the code you have

quaint mantle
#
    public void sendRequest(Player player, String request) {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeUTF("Message");
        out.writeUTF("ambmt");
        out.writeUTF(request);
        player.sendPluginMessage(this, "Bungeecord", out.toByteArray());


    }
#

Ignore the debugs lol

glossy venture
#

How do you listen to the messages

#

did you register the listener

#

oh its BungeeCord

#

not Bungeecord

#

its case sensitive

#

thats the problem

slate delta
#

any ideas?

quaint mantle
#

Nah no shot its that dumb

#

ill get back to you @glossy venture

glossy venture
#

it prob is

quaint mantle
#

brooo if its that

glossy venture
#

lmao

quaint mantle
#

im not doing that

glossy venture
#

heheheha

quaint mantle
#

tbf this was coded in like 10 mins

#

i lost my plugin progress when my pc broke😭

glossy venture
#

damn that sucks

quaint mantle
#

watch it not be that rofl

glossy venture
#

remember to change it in the listener too

quaint mantle
#

it was correct in the listener

#

this goes to show

glossy venture
#

ah

quaint mantle
#

always copy and paste kdis

glossy venture
#

yes

#

and quadruple check

#

strings

#

and constants

quaint mantle
#

im checking it now

#

fingers crossed

#

please

glossy venture
#

πŸ™

quaint mantle
#

i love you

glossy venture
#

lets goo

quaint mantle
#

big dubs thank you man πŸ™

glossy venture
#

np

weary cobalt
#

Is it possible to request data from a bungeecord plugin via a spigot plugin? Such as receiving a variable, or other piece of information upon request. I havent found any examples of this online, and most tutorials that I have found haven't really explained this. If someone has any code examples or could push me in the right direction it would be greatly appreciated πŸ˜ƒ

azure hawk
#

how can i ban players with a reason?

civic solar
#

.ban Playernam Reason

azure hawk
#

not in mc you idiot xd

#

in java

#

lol

floral drum
dim bronze
#

Bukkit.getBanList(BanList.Type.NAME)

#

Why not, I honestly think threads are the way to go?

#

Apart from like one word answers

#

Which is usually just linking to a thread someone could have found on google

#

for in depth problems I think forcing the use of threads tidies things up. But most of the questions in this channel probably don't fit the use case I guess

flint coyote
#

Also there already is a forum. I would use the forum for complex questions and discord for small questions with like up to three sentence answers

#

I'm aware not everyone does that tho

#

which one?

#

Yeah so that's basically the same as spigotmc forum on the web then

#

So unless it's synced in some way I would say that isn't a great idea. Especially since you can't find those threads in google. So we will get the same questions day by day

#

I read my own message wrong and changed something that was correct before. oops

#

changed it back

weary cobalt
#

Thank you, I'll look into it!

true shuttle
#

Hey does anyone know how I could detect if a player opens a villager's inventory, but doesn't trade? meaning they close the inventory without making a trade

#

my first thought was playerInteractEntityEvent, but i'm not sure how to see if they don't make a trade and how to run it once they close the inventory

#

I've searched google and found nothing

#

probably InventoryCloseEvent

weary cobalt
#

You could try something like this, there may be a better way to do it though.

@EventHandler
    public void onOpenInventory(InventoryOpenEvent e) {
        Player player = (Player) e.getPlayer();
        InventoryType inventoryType = e.getInventory().getType();
    }

And then check if the inventory is a villagers inventory.

#

InventoryType seems to have a lot of options, not sure which one would be a villager trading menu

true shuttle
#

it's Merchant

floral drum
# true shuttle I've searched google and found nothing

Idea - listen for when a player interacts with a villager with trades. Store them in a List for example if they do this.
Listen for InventoryClickEvent for when a player clicks on the result slot (aka the slot where the traded item is). If it's empty, then ignore it. If it's not empty, that means the player has traded with the villager - and at that point you can remove them from the list.
When they close the inventory, you can then check if they're still in the list. If they aren't, that means they have traded and you can ignore it. If they are, that means they haven't traded and you can execute your code.

#

tell me if you understand

true shuttle
#

good idea, thanks!

true shuttle
floral drum
#

❀️

floral drum
# true shuttle understood

If you're using paperspigot/any server jar forked from paper, there is an api inside of the paper-api dependency to detect wether or not the player trades with a villager (PlayerTradeEvent)

ancient plank
#

πŸŸͺ

floral drum
#

hello adelemphii ❀️

#

love you

true shuttle
#

i am using paper!

#

sweet! that makes it way easier, thanks!!!!

true shuttle
#

:(

#

i usually use spigot

#

but i just realized that im using paper for my newest project

#

lol

#

cya

vale veldt
#

this still works? i'm using it and the events are not working.

TextComponent message = new TextComponent("Click me");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org"));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Visit the Spigot website!").create()));
sender.sendMessage(message.toLegacyText());``` 

https://www.spigotmc.org/wiki/the-chat-component-api/
chrome beacon
#

toLegacyText will remove hover and click events

#

Use sender.spigot().sendMessage(message)

vale veldt
#

thanks, in versions 1.8 for example there is no spigot() method, how could it be done?

dim bronze
vale veldt
#

I'm stupid, I was sending the message as CommandSender not as a player πŸ€¦β€β™‚οΈ

floral drum
#

owo

vale veldt
#

and the HoverEvent is there another way to do it now? I see that in recent versions it is deprecated

chrome beacon
#

There is another hover method you should use

#

Check Javadocs

vale veldt
#

thx πŸ™‚

cobalt tinsel
#

guys

#

how do i spawn a thunder

vocal cloud
#

?jd-s

undone axleBOT
cobalt tinsel
#

there's nothing there related to summoning only one

vocal cloud
#

Define summoning only one?

cobalt tinsel
#

well

#

like a death animation

#

on kill it makes a thunder spawn on the death location

#

i forgot how to make one

rapid aspen
#

help me please

cobalt tinsel
#

like how to make the thunder appear on death.getLocation();

cold tartan
#

death.getLocation.getworld.spawnEntity()

cobalt tinsel
rapid aspen
#

i dont see that

#

bruh

cobalt tinsel
#

how do i spawn the lightihng πŸ’€

#

that's what im askin

vocal cloud
cold tartan
cobalt tinsel
#

OOOOOOOOOO

#

THE FUCK

#

IM DUMB

vocal cloud
#

Or you can just use strike lightning (location)

cobalt tinsel
#

I WAS WRITING LIGHTING

cold tartan
#

oh lol

cobalt tinsel
#

NOT LIGHTNING

#

that's why xD

#

thx

cold tartan
#

how do i get the entity that was spawned in the SPAWN_ENTITY packet through ProtocolLib?

cobalt tinsel
#

oo im dumb didn't saw the getWorld().strikeLightning();

vocal cloud
#

The docs are nice for that

cobalt tinsel
#

what'd happen if i cancel the LightningStrikeEvent

#

like i want it to cause no damage

#

but

cold tartan
worldly ingot
#

ProtocolLib doesn't refer to the protocol specification

#

It pulls from the fields of the packet class

#

You should be able to getUUIDs().readSafely(1)

vocal cloud
#

Yo Choco any word from md_5 or should I ping him

worldly ingot
#

No he's been relatively quiet lol, though I really don't think since tags would be accepted

ancient plank
#

you can't milk those?

vocal cloud
#

I'll wait a few days hes_UwU

worldly ingot
ancient plank
#

idk anymore

#

I'm so lost

vocal cloud
#

If it exists you can milk it

cold tartan
#

πŸ‘€

cold tartan
wide robin
#
        Player p = e.getPlayer();
        Block targetBlock = p.getTargetBlock(null, 5);
        if (p.isSneaking() && String.valueOf(targetBlock.getType()) == "CHEST") {
            FileConfiguration config = plugin.getConfig();
            String coordination = targetBlock.getLocation().getBlockX() + " " + targetBlock.getLocation().getBlockY() + " " + targetBlock.getLocation().getBlockZ();
            if(targetBlock instanceof Chest) {
``` why is the last if won't return true even though i am looking at a chest?
#

I can't use the targetBlock as a chest even though it is a chest

delicate lynx
#

wtf is this String.valueOf(targetBlock.getType()) == "CHEST"

worldly ingot
#

Creative

#

That is creative

#

Anyways, getType() returns a Material, which is a constant you can check against. So targetBlock.getType() == Material.CHEST

dry forum
delicate lynx
#

why are you using 1.18.1 is the real question

dry forum
#

im using 1.18.2 but same issue

delicate lynx
#

have you tried new EntityArmorStand(EntityTypes.ARMOR_STAND, world);?

dry forum
#

that works but ARMOR_STAND doesnt exist, did you mean Type or?

quaint mantle
#

how would i add & to the start of the pattern?

#

because its just #FFFFFF instead of &#FFFFFF

#
    private static final Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
    
    public static String color(String text) {
        for(Matcher match = pattern.matcher(text); match.find(); match = pattern.matcher(text)) {
            String color = text.substring(match.start(), match.end());
            text = text.replace(color, ChatColor.of(color) + "");
        }

        return ChatColor.translateAlternateColorCodes('&', text);
    }```
delicate lynx
#

EntityTypes.ARMOR_STAND doesn't exist?

quaint mantle
delicate lynx
#

oh my bad lol

dry forum
#
EntityTypes
<? extends net.minecraft.world.entity.decoration.EntityArmorStand>
Provided:
EntityType``` it seems like nms does use Types but armor_stand doesnt exist
lost matrix
dry forum
#

how would i spawn an armorstand using that then i cant find it on the nms website

lost matrix
dry forum
#

ArmorStand stand = new EntityArmorStand(EntityTypes., s); none of the auto complete things for that make sense

lost matrix
#

EntityArmorStand is from the old mappings. Dont use them. Since 1.17 you should always use mojang mappings

delicate lynx
#

ArmorStand stand = new ArmorStand(EntityType.ARMOR_STAND, world);

#

this works for me

dry forum
#

'ArmorStand' is abstract; cannot be instantiated

delicate lynx
#

what are your imports?

lost matrix
dry forum
#
import net.minecraft.network.chat.ChatMessageType;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
import net.minecraft.world.level.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;```
delicate lynx
#

there is the problem

dry forum
#

there is only the bukkit import i see

lost matrix
delicate lynx
#

remove

import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
lost matrix
delicate lynx
#

that too, was wondering why your imports are versioned

dry forum
#

huh?

lost matrix
delicate lynx
#

I thought they weren't versioned anymore?

lost matrix
#

Also happens with the mojang mappings. CraftBukkit is independent.

dry forum
#

wdym im not using mojang mappings

delicate lynx
#

did you run buildtools to get a remapped jar?

lost matrix
delicate lynx
#

ah

dry forum
#

i run buildtools im using 1.18.2 spigot maven

delicate lynx
#

well, did you?

lost matrix
#

You need to run BuildTools with the remapped flag. Its all covered in this thread.

#
java -jar BuildTools.jar --rev 1.18.2 --remapped
dry forum
#

oh? shouldnt it be updated on the buildtools then

lost matrix
#

After that you need to setup the special sources plugin for maven

dry forum
#

umm i just ran it and now the only import that works is for armorstands <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> <classifier>remapped-mojang</classifier> </dependency>

lost matrix
dry forum
#

no

lost matrix
#

Ok then make sure that this is your only spigot dependency and that you have set up the special sources plugin

dry forum
#

special sources pluugin?

lost matrix
dusk flicker
#

i wonder

#

?maven

undone axleBOT
dusk flicker
#

oh shit

dry forum
#

i added that to my pom and it still doesnt work same issue

kind hatch
#

?paste your pom

undone axleBOT
harsh rose
#

Hey guys, I have a question. I created a Class that uses the Listener but I want to add a delay to it after the event has been triggered.

I tried implementing the Bukkit scheduler within the class file but I can't seem to use it properly.
Any ideas?

The code:

package listeners;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;


public class miscEvents implements Listener {
    @EventHandler
    public void onPlayerStep(PlayerMoveEvent event) {
        event.getPlayer().sendMessage("You have stepped");
        //Add delay here
        event.getPlayer().getLocation().subtract(0, 1, 0).getBlock().setType(Material.AIR);

    }

}
lost matrix
kind hatch
#

Bukkit#getScheduler#runTaskLater()

harsh rose
#

Would that be in the same class file or different?

lost matrix
harsh rose
#

like do i put the bukkit get scheduler in the same code?

#

wait, i'll try it again first before anything

lost matrix
#

This sounds like you jumped into spigot before learning the very basics of java. Not a good idea.

harsh rose
#

Yeahh. I have experience with Python, javascript and OOP

#

Im still new to Java

lost matrix
#

Then the question should be trivial to answer for yourself

harsh rose
#

Hmm idkk. im not familiar with the Spigot stuff

#

So what I want to do is:
Whenever a player walks, the block that they walked on will dissapear after 3 seconds

lost matrix
#

That is really hard to achieve properly. What if they break and then place a another block there? You need to keep track of everything.

harsh rose
#

yeah ik

#

but i just want to get something working first

lost matrix
#

?scheduling

undone axleBOT
ornate heart
#

Are YamlConfiguration values cached in memory or is it reading the disk every time?

lost matrix
#

yaml config is just a glorified hashmap

ornate heart
#

gotchu

harsh rose
#
public class miscEvents implements Listener {
    @EventHandler
    public void onPlayerStep(PlayerMoveEvent event) {
        event.getPlayer().sendMessage("You have stepped");
        BukkitScheduler scheduler =  Bukkit.getScheduler();
        scheduler.runTaskLater(plugin,()-> System.out.println("Hello"),20);
    }
}

I almost have it but not sure what plugin is supposed to refer to. Is it supposed to refer the Class that im trying to use?

#

Is the scheduler supposed to be in a separate class and I import the other class in?

lost matrix
#

An instance of your JavaPlugin

harsh rose
#

like the actual plugin that runs it all?

kind hatch
#

Use a proper map? They've been around for quite a while.
Map#put()
Map#get()

I'm surprised your code compiled with that lowercase method. (Assuming that's the bukkit scheduler)

harsh rose
#

Update: I fixed my problem πŸ₯³

glossy lily
#

how do you get a list of uuids that are online on the server/world

glossy lily
#

yes

kind hatch
#

Iterate over Bukkit#getOnlinePlayers(), get the player's UUID, and put them in a list.

glossy lily
#

how would you iterate over it

kind hatch
#

A for loop?

glossy lily
#

im just curious since im relatively new to java

#

how would you structure said for loop

#

i know i could just do a normal one

#

but do you have any specific ways of doing it

modest garnet
#

so i know that

javac <filename.java>

converts it to a .class

however my system runs java 17
how can i javac in java8?

kind hatch
worldly ingot
modest garnet
#

you got an example for me

worldly ingot
#

The reason javac works is because your PATH environment variable points to Java 17, but really it's equivalent to just calling a J17 javac

#

D:/Program Files/AdoptOpenJDK/jdk-8.0.275.1-hotspot/bin/javac whatever.java

#

You change that to wherever you have your JDK 8 installed

modest garnet
worldly ingot
#

Depends on what script you're using. Powershell, Command Prompt, Bash, etc.

modest garnet
#

cmd

worldly ingot
#

You can surround Program Files in quotation marks

#

e.g. C:/"Program Files"/whatever

kind hatch
#

I don't think it actually does. You can just surround the path with quotation marks. It works for most languages too.

modest garnet
kind hatch
#

Surround the entire path with quotation marks.
"C:/path/to/your/file"

harsh rose
#

hey guys, I have my Listener registered but it breaks when I extend JavaPlugin like this:

public class miscEvents extends JavaPlugin implements Listener {
    @EventHandler
    public void onPlayerStep(PlayerMoveEvent event) {
        event.getPlayer().sendMessage("Message");
    }
}
modest garnet
#

thanks

harsh rose
#

but when I remove the extend, it works fine

worldly ingot
#

Your listener should just implement Listener

harsh rose
#

ohh I see

#

so then if I have something like this: ```java
public class miscEvents implements Listener {
@EventHandler
public void onPlayerStep(PlayerMoveEvent event) {
event.getPlayer().sendMessage("You have stepped");
new BukkitRunnable(){
@Override
public void run() {
event.getPlayer().getLocation().subtract(0, 1, 0).getBlock().setType(Material.AIR); }
}.runTaskTimer(this, 0, 5);
}
}

worldly ingot
#

If you need JavaPlugin methods, you can pass through an instance of your class in the constructor and assign it to a field

public class MyListener implements Listener {

    private final MyMainClass plugin;

    public MyListener(MyMainClass plugin) {
        this.plugin = plugin;
    }

}```
#

Then you can refer to plugin instead

harsh rose
#

oohhhh

#

I seeee. Thank you thank you!

worldly ingot
#

When you create an instance of your listener, you'll need to give it an argument now. The instance of your plugin class

#

If you're constructing it in the plugin class, you can just pass this

lime moat
#

How could I get the player's uuid from Player player = event.getPlayer();?

kind hatch
#

Player#getUniqueId()

lime moat
#

Thank you!

#

One more question, I have Map<UUID, Boolean> resourcePackStatus = new HashMap<>(); set in an event class, how could I get the boolean in a command?

#

I've never worked with this type of stuff before, so this is all quite new to me haha

kind hatch
#

Map#get() will return the value of the given key.

#

So if your player UUID is the key, use Map#get(<playerUUID>) and you will get the boolean tied to them.

lost matrix
#

Create a manager class of which only one instance exists that contains the map. Pass this manager to both the listener and the command.

astral isle
#

Not sure if this is against the rules like papermc but I am looking for someone that may be able to help me make the core for my Minecraft server what I need done is here https://trello.com/b/XwDZh9gy/ve-core. If you are able to do any of it DM me for more info. I can also pay a tad.

lime moat
#

So, I couldn't just do something like Map.get(player.getUniqueId());?

#

I need a manager class that somehow passes it to my command?

lost matrix
lime moat
#

Yeah, I didn't really get around to arrays and that sort of stuff before doing this :P

lost matrix
# lime moat Yeah, I didn't really get around to arrays and that sort of stuff before doing t...

Its more an issue of object orientation. So your manager class should look something like this

public class ResourcepackManager {

  private final Map<UUID, Boolean> resourcepackStatusMap = new HashMap<>();

  public boolean getStatus(UUID playerId) {
    return resourcepackStatusMap.get(playerId);
  }

  public void setStatus(UUID playerId, boolean status) {
    resourcepackStatusMap.put(playerId, status);
  }

  public void remove(UUID playerId) {
    resourcepackStatusMap.remove(playerId);
  }

}

And in your onEnable you create one instance of that class and pass the same instance to all objects that need it.

  @Override
  public void onEnable() {
    ResourcepackManager resourcepackManager = new ResourcepackManager();
    
    // Pass the manager to a listener
    // Pass the manager to a command
  }
#

And never create a new instance again. Every new instance has its own new HashMap. Use the same instance everywhere.

lime moat
#

Okay, so to pass the manager to a command, would it look similar to this? getCommand("god").setExecutor(new GodCommand(this, resourcepackManager));

lost matrix
desert frigate
#

how do i check if a water is flowing?

#

or lava

lime moat
#

Okay maybe two more questions... sorry!

I have ```java
public class ResourcePackManager {

private final Map<UUID, Boolean> resourcepackStatusMap = new HashMap<>();

public static boolean getStatus(UUID playerId) {
    return resourcepackStatusMap.get(playerId);
}

public void setStatus(UUID playerId, boolean status) {
    resourcepackStatusMap.put(playerId, status);
}

public void remove(UUID playerId) {
    resourcepackStatusMap.remove(playerId);
}

}``` in my ResourcePackManager.class, it's telling me that I should make it static. Non-static field 'resourcepackStatusMap' cannot be referenced from a static context

#

Would this hurt anything? Just so I don't mess anything else up πŸ˜…

lost matrix
lost matrix
lime moat
#

Wait, now I'm getting a few mixed things. public static boolean getStatus I remove static from this too?

quaint mantle
#

@lost matrix could you code me a plugin for $$. Not too hard

river oracle
#

?services

undone axleBOT
lost matrix
lime moat
#

Gotcha, okay, thank you! I'll finish what I'm trying to do :D

lime moat
#

One more thing, I'm so sorry πŸ˜… java Boolean test = ResourcePackManager.getStatus(player.getUniqueId()); is how I would assume to get the status, but I'm now receiving this error: java Non-static method 'getStatus(java.util.UUID)' cannot be referenced from a static context

modest garnet
#

anyone know of a plugin which converts vault 1000000 to 1m
ofc for k, m, b, t, q, qt etc

lost matrix
quaint mantle
#

any tips and tricks on making guis?

modest garnet
quaint mantle
#

i feel like i can improve it

quaint mantle
#

i rlly gotta remake it

#

want that?

modest garnet
#

why is it "bad"?

severe oak
quaint mantle
#

the formatting it bad

lime moat
#

I see, I'm just dumb, took a small bit of playing around to get it, thank you guys very much for your help :D

quaint mantle
# severe oak What specifically are you looking for?

well im doing java inv.setItem(0, blank); inv.setItem(1, blank); inv.setItem(2, blank); inv.setItem(3, blank); inv.setItem(4, blank); inv.setItem(5, blank); inv.setItem(6, blank); inv.setItem(7, blank); inv.setItem(8, blank); inv.setItem(9, blank); inv.setItem(17, blank); inv.setItem(18, blank); inv.setItem(26, blank); inv.setItem(27, blank); inv.setItem(35, blank); inv.setItem(36, blank); inv.setItem(37, blank); inv.setItem(38, blank); inv.setItem(42, blank); inv.setItem(43, blank); inv.setItem(44, blank); and there has to be a way of improving this

#

maybe adding numbers to a list and looping that list?

lost matrix
#

Let me introduce you to for loops

drowsy helm
#

use a for loop dude

quaint mantle
# modest garnet why is it "bad"?
public static String format(Double value) {
        DecimalFormat decimalFormat = new DecimalFormat("0.##");
        if (value > 0) {
            String data = "NGTN,,90\\.OTGN,,87\\.STGN,,84\\.HNGT,,81\\.QTGTN,,78\\.QTGT,,75\\.TGT,,72\\.DGT,,69\\.UG,,66\\.V,,63\\.NVD,,60\\.OD,,57\\.SPT,,54\\.HD,,51\\.QTD,,48\\.QTW,,45\\.TD,,42\\.DD,,39\\.UD,,36\\.D,,33\\.N,,30\\.OCT,,27\\.SP,,24\\.HT,,21\\.QT,,18\\.Q,,15\\.T,,12\\.B,,9\\.M,,6\\.K,,3";
            for (String str : data.split("\\.")) {
                String[] output = str.replace("\\", "").split(",,");
                if (value >= Math.pow(10, Integer.parseInt(output[1]))) {
                    return decimalFormat.format(value / Math.pow(10, Integer.parseInt(output[1]))) + output[0];
                }
            }
        }
        return decimalFormat.format(value);
    }``` ik it ain't the best im going to remake this some time in the future but it works
quaint mantle
#

Like you code a plugin that I pay u for?

severe oak
quaint mantle
lost matrix
drowsy helm
# quaint mantle ```java public static String format(Double value) { DecimalFormat decima...
    public static String formatDouble(double value) {
        String[] suffixes = {"K", "M", "B", "T", "Qad", "Qin", "Sext", "Sept", "Oct", "Non", "Dec", "Und", "Duod", "Tred", "Quat", "Quind", "Sexd", "Septe", "Octo", "Nov", "Vigin"};
        if(value > 1000) {
            for (int pwr = 3; pwr <= 63; pwr += 3) {
                int index = (pwr / 3) - 1;

                double powVal = Math.pow(10, pwr);
                if (value < powVal) {
                    String str = String.format("%.2f" + suffixes[index - 1], value / Math.pow(10, pwr - 3));
                    str = str.replace(".00", "");
                    return str;
                }
            }
        }

        String str = String.format("%.0f", value);
        str = str.replace(".00", "");
        return str;
    }```
this is mine if you want it
#

much more readable

quaint mantle
lost matrix
#

Then hell no. Who even uses that version anymore?

quaint mantle
#

lmao everyone

#

pvpers/hypixel players

modest garnet
quaint mantle
#

a lot of ppl

lost matrix
#

?1.8

undone axleBOT
compact haven
#

xd

#

"everyone"

quaint mantle
#

lmao

severe oak
#

1.8 bad

quaint mantle
#

non

crisp steeple
quaint mantle
drowsy helm
quaint mantle
#

for hypixel kinda'

stoic oar
#

why not just practice in hypixel

lost matrix
quaint mantle
#

you got one?

#

i couldn't find one that satisfied me πŸ˜†

compact haven
#

cufp are you actually looking for a developer?

drowsy helm
#

if you wanna get good at oop making your own inv system is good

lost matrix
#

Its decent

quaint mantle
lost matrix
#

I personally dont use any libs

quaint mantle
#

thanks i'll try it out

quaint mantle
lost matrix
#

Thats a good plan

quaint mantle
#

how big is the dependency. i dont want my plugin super big

lost matrix
#

Its not too bad i think.

#

But it depends on adventure chat

quaint mantle
#

one sec, let me build the plugin and see

#

800kb

#

with minimizeJar as true it went down to like 50kb

#

what does that even do

#

ik it works but does it remove any essentials

drowsy helm
#

removes common dependencies

#

well, merges them

quaint mantle
#

I c

vale veldt
#

In which version of spigot does the ComponentBuilder() change to Text() of the TextComponent?

quaint mantle
#

Why the hate amongst protocollib?

glossy scroll
#

typically if you use a sql driver you can't use minimizeJar without some extra maven config, maven cant detect all use cases

glossy scroll
#

except i cant completely say i do the same lol

#

i use protocollib, libsdisguises mostly

#

and then i have like an nbt thing i forked

quaint mantle
#

why is it making 2 original ones

#

but not the one that i need

lost matrix
desert frigate
#

is it possible to set data for a block like persistentDataContainer?

quaint mantle
lost matrix
lost matrix
fading lake
#

Does anyone know how to get (in spigot) or how minecraft creates the DAT files created for itemstacks in saved inventories?

compact haven
#

You mean the method MC uses to turn ItemStacks into NBT?

lost matrix
#

The format is called nbt

glossy scroll
#

do you mean the NBT data or the file itself?

fading lake
compact haven
#

there's methods for it in CraftItemStack iirc

#

let me see if I can get it

lost matrix
#
    net.minecraft.world.item.ItemStack item = ...;
    CompoundTag nbtTag = new CompoundTag();
    item.save(nbtTag);
    String data = nbtTag.getAsString();
glossy scroll
#

(thats nms itemstack btw)

#

`

#
    public static final class ItemStackJsonSerializer implements JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {
        @Override
        public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
            return new JsonPrimitive(CraftItemStack.asNMSCopy(src).save(new CompoundTag()).getAsString());
        }

        @Override
        public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            try {
                String asString = json.getAsJsonPrimitive().getAsString();
                CompoundTag compoundTag = TagParser.parseTag(asString);
                net.minecraft.world.item.ItemStack nmsStack = net.minecraft.world.item.ItemStack.of(compoundTag);
                return CraftItemStack.asCraftMirror(nmsStack);
            } catch (CommandSyntaxException e) {
                throw new IllegalArgumentException(e);
            }
        }
    }```
#

a gson deserializer i made

#

using that concept

lost matrix
glossy scroll
#

how so

lost matrix
#
class ItemStackAdapter : JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {

    override fun serialize(src: ItemStack, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
        val outputStream = ByteArrayOutputStream()
        val dataOutput = BukkitObjectOutputStream(outputStream)
        dataOutput.writeObject(src)
        dataOutput.close()
        return JsonPrimitive(Base64Coder.encodeLines(outputStream.toByteArray()))
    }

    override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): ItemStack {
        val inputStream = ByteArrayInputStream(Base64Coder.decodeLines(json.asJsonPrimitive.asString))
        val dataInput = BukkitObjectInputStream(inputStream)
        val itemStack = dataInput.readObject() as ItemStack
        dataInput.close()
        return itemStack
    }
}

Using BukkitObjectOutputStream

compact haven
#

yep, all of these work

glossy lily
#

how does one get multiple worlds on one server

glossy scroll
#

well first of all kotlin (ew) and second of all base64 (ew)

glossy lily
#

(i dont want to use a 34d party plugin)

glossy scroll
#

yea but i dont like using it

glossy lily
#

yea it needs a little improvement

glossy scroll
#

well i dont care about any of that its just personal preference

#

i find it to be hard to understand and read haha

lost matrix
glossy scroll
#

Bukkit.getWorlds

glossy lily
#

how would you force a player into that world

lost matrix
#

lol

#

Trivial example

    Player player = ...;
    World world = Bukkit.createWorld(WorldCreator.name("CoolWorld"));
    player.teleport(world.getSpawnLocation());
glossy lily
#

can you specify maps for that world?

glossy scroll
#

maps?

glossy lily
#

sorry

#

like

#

have it copy the map of a previous world

#

like

glossy scroll
#

i maen sure

lost matrix
#

Just copy a world folder

glossy scroll
#

you just need to get rid of the uid and session.lock

lost matrix
#

^ And that too.
I would delete them on your template worlds in the first place.

glossy scroll
#

yes

#

i wish world loading was async...

#

its my lifelong dream

lost matrix
#

Yeah. Spigot does a lot of IO on the main thread.
Ive gotten it to 20 - 30ms by disabling loading the spawn chunks and having a decent nvme ssd on my root server.
But still...

glossy scroll
#

20-30ms ?

lost matrix
#

Best case

#

Sometimes the hard drive is working then it can get up to 150ms

glossy scroll
#

by disabling spawn chunks

#

u mean

#
    @EventHandler
    public void onWorldInit(WorldInitEvent event) {
        World world = event.getWorld();
        world.setKeepSpawnInMemory(false);
        world.setAutoSave(false);
    }
lost matrix
#

yeah

lost matrix
glossy scroll
#

oh

#

thats good to know

#

idts @lost matrix unless thats paper

lost matrix
#

Might be fork

glossy scroll
#

is that 1.19.1+

#

im on 1.19

lost matrix
#

Nah i thinks its paper stuff

glossy scroll
#

oh i realized

#

that code snippet...

#

was not in a listener

#

now that i moved it, i do see a performance boost

desert frigate
#
Inventory chestInventory = ((Chest) chest).getInventory();
                             for(final ItemStack item : chestInventory) {

                             }``` would i need to use chestInventory.all() or would this work as well?
lost matrix
desert frigate
#

awesome

harsh rose
#

PlayerMoveEvent keeps getting triggered. Whats best way to check if player moved to a new block? My idea was to store the int of blockX and blockY but that'll disappear immediately since the code will finish running

#

or is there something better than PlayerMoveEvent for my case?

glossy scroll
#

There’s a from and to method

#

You can compare the from and to locations

harsh rose
#

ooh?

#

thanks! I'll try that

lost matrix
# harsh rose PlayerMoveEvent keeps getting triggered. Whats best way to check if player moved...

This is the best performing way i came across so far

  @EventHandler
  public void onMove(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();

    if(to == null) {
      return;
    }
    
    int fromX = from.getBlockX();
    int fromY = from.getBlockY();
    int fromZ = from.getBlockZ();

    int toX = to.getBlockX();
    int toY = to.getBlockY();
    int toZ = to.getBlockZ();

    if(fromX == toX && fromY == toY && fromZ == toZ) {
      return;
    }

    // Player moved from one block to another
  }
harsh rose
#

Thanks!

#

I'll try that

quaint mantle
#

Why is getLogger().log(Level.FINE, "text"); not working in some cases in my onEnable?

drowsy helm
lost matrix
#

Wouldnt work and would also be very expensive

drowsy helm
#

yeah fair

lost matrix
#

you can move very slowly from one block to another. 0.000001 per tick.
You only want to detect when movement crosses a block border. Doesnt matter at which speed.

drowsy helm
#

ah yeah you're right

obsidian drift
#

What would be the best way to implement a feature where when wearing, for example, a diamond helmet it would give the player an extra heart? And when they take it off they loose the heart.

lost matrix
obsidian drift
#

What's the attribute modifier called?

#

I was thinking GENERIC_MAX_HEALTH but I thought that was only for entities

lost matrix
#

One moment

lost matrix
# obsidian drift I was thinking `GENERIC_MAX_HEALTH` but I thought that was only for entities
    ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
    ItemMeta meta = helmet.getItemMeta();
    meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier("move-boost", 0.2, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
    meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("damage-boost", 0.35, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
    meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, new AttributeModifier("health-boost", 4, AttributeModifier.Operation.ADD_NUMBER));
    meta.setDisplayName("Β§6Helmet of rush");
    helmet.setItemMeta(meta);

Usually you would specify an equipment slot for the AttributeModifier

obsidian drift
lost matrix
#

Usually you would specify an equipment slot for the AttributeModifier

obsidian drift
#

Okay thanks

quaint mantle
#

how would i set a placeholder?

#

because im getting the placeholder

#

but how do i remove like 2500 from it

lost matrix
quaint mantle
#
double economy = Double.parseDouble(PlaceholderAPI.setPlaceholders(e.getPlayer(), GenCorePlus.getYaml().getString("money.type")));```
#

but it could be any placeholder if its a number

#

so how would i remove from it?

lost matrix
#

A placeholder is not a number. You cant just subtract a number from a placeholder...

quaint mantle
lost matrix
quaint mantle
#

okay, how would i get a variable from another plugin then. Because i need a way for them to have configurable balance. Some people might not wanna use vault's api for that

lost matrix
#

Question: "how would i get a variable from another plugin"
Answer: Use their API or if they dont provide one then dig through the code and find the right places to retrieve values from.

quaint mantle
#

hmm, any way to make that more user friendly?

lost matrix
#

Question: " i need a way for them to have configurable balance"
Answer: Who is "them"? This sentence is out of context.

quaint mantle
#

or should i just use vault's api

quaint mantle
lost matrix
#

Some people might not wanna use vault's api for that
For what? What is "that" refering to? And are "Some people" other developers or server administrators?

quaint mantle
#

i would like more configuration since people like that

lost matrix
quaint mantle
#

ima just stick with vault's api ig

#

ain't the worst

lost matrix
#

I am still confused as to what you are trying to achieve in the first place...

oblique geyser
#

How Can I instance inventories per world?

river oracle
#

Database item serialization preferably you could also store the contents in a json file

lost matrix
# oblique geyser How Can I instance inventories per world?

You need to serialize the inventories, store them somewhere and when a player changes a world you simply
set his inventory contents. A Map<UUID, ItemStack[]> for each player that maps the world id to the inventory contents should do just fine.

#

I would load all inventories as soon as the player joins in a Map<UUID, ItemStack[]>. Loading them
when he changes a world means you need to load them on the main thread.

#

Or you need to give him the inventory with a small delay of a few hundred ms. Then you can also do it on world change but async.

boreal sparrow
#

If I created a team like this

ScoreboardManager sm = Bukkit.getScoreboardManager();

Scoreboard scoreboard = sm.getNewScoreboard();

Team DinoMine = scoreboard.registerNewTeam("Map1");

//ADD PLAYER TO TEAM
player.setScoreboard(scoreboard);

DinoMine.addEntry(player.getName());

And I check if the player is in that team with
player.getScoreboard().getEntryTeam(player.getName()).equals()
What exactly should I check for

river oracle
#

Ahhh bukkit scoreboard api the most horrific thing on earth.

#

Well based on your code it looks like the team is the player name

boreal sparrow
#

doesnt getEntryTeam return the team/s the player or thing is on?

river oracle
#

Tbh I'd have to recheck the docs I suck at this stuff gimme a second lol

boreal sparrow
#

lol thanks

river oracle
boreal sparrow
#

yea, thats how I got it too

river oracle
#

So all you want to do is check if it's null or not then proceed with the knowledge you have the team

boreal sparrow
#

yea

river oracle
#

Personally I use a api called fastboard and constructed my own teams api lol I hate bukkit scoreboards so much

boreal sparrow
#

ikr

#

i might use that

#

why is it so complex

#

to make a team

river oracle
#

It's likely mojangs fault

boreal sparrow
#

yea propobly

#

ill use a better apii think

#

thanks

river oracle
#

Fastboard is all packets if your looking for something light weight

#

Otherwise there are some other neat options outbthere

boreal sparrow
#

yea

#

fastboards sounds good

#

ill try it, thanks for your help

river oracle
#

For teams you can just apply a scoreboard and add logic for each team

#

Could be achieved via a team object

weary cobalt
#

Im having some issues using getOfflinePlayer() to get a Player Head. Keep in mind, the player has not joined the server previously. Is there a better way to do this?

The code:

public void addPlayer(UUID player, Tripair<String,Double,Integer> tripair) {
        
        // Put player and information into a Hashmap (key: UUID)
        players.put(player,tripair);
        
        // Get the time remaining from minutes
        String time = tripair.getThird() != -5 ? ((int) (Math.floor(((double) tripair.getThird()))) / 60) + "h:" + (tripair.getThird() % 60 > 9 ? "" : "0") + tripair.getThird() % 60 + "m" : "Β§4No bids yet";
        
        // Get player head
        ItemStack head = Heads.get(player,
                "Β§a" + Bukkit.getOfflinePlayer(player)..getName(), 
                List.of("Β§eActive Bid: Β§7$" + tripair.getSecond() + "m Β§8(" + tripair.getFirst() + ")", 
                        "Β§eTime Left: Β§7" + time, 
                        "   ", 
                        player.toString()));
        
        // Add ItemStack to GUI
        freeAgencyGUI.gui.addItem(head);
        
        // Add to config
        FreeAgents.addFreeAgent(player,tripair);
        
    }

The issue is "Bukkit.getOfflinePlayer(player)..getName()" returning null. I'm not sure how to get around this, as I know the player exists. Is there better way to get a player head from someone who hasent joined?

river oracle
#

If my code wasn't proprietary I'd gladly Share it maybe one day I'll release something

river oracle
#

I don't bother with the offline player bs

#

If you want a certain skin to always display highly reccomend using Bukkits PlayerProfile api

weary cobalt
#

Yeah the offline player stuff seems pretty dumb, just didnt know a better way of doing it

river oracle
#

Bukkit#createPlayerProfile iirc you can add a skin url and then apply it to the skull

#

I need to make a resource on this I feel like this is still relatively unknown that It exists

weary cobalt
#

Yeah, I had tried using getOfflinePlayer(player).getPlayerProfile() previously, but obviously that did nothing as the offline player was null.

Should it work just like this?

PlayerProfile playerProfile = Bukkit.createPlayerProfile(player);
String name = playerProfile.getName();

Or would doing it via url still be better for this

river oracle
#

Don't provide a player

#

Than provide skin data to it

weary cobalt
#

"player" is a uuid, I had just named it player

river oracle
#

Is it random

weary cobalt
#

no it's not

river oracle
#

You shouldn't use a players uiid just make a random one

weary cobalt
#

Alright so-

create a PlayerProfile with a random uuid, attach the player skin via a url, then attach that skin to the head?

river oracle
#

Yep

river oracle
weary cobalt
river oracle
#

Not well but that's just good for custom gimmicky stuff

viral marten
#

hello everyone

#

opinions on java

river oracle
#

We all code in it so

#

Idk what you expect

weary cobalt
#

Yea i dont think we have a choice but to use java lmfao

river oracle
viral marten
#

or technically kotlin can be used

river oracle
drowsy helm
viral marten
#

idk

#

for me java hurts my brain a lot

river oracle
viral marten
#

i prefer rust

river oracle
#

Unless it was updated

viral marten
#

o-o

drowsy helm
#

its always been like that

#

create a fake player profile

#

apply base 64 texture and signature

#

done

river oracle
#

Bukkits player profile api is relatively new

drowsy helm
#

you're talking aobut GameProfile right

river oracle
#

No

#

PlayerProfile from bukkit api

#

It's new

drowsy helm
#

ah

river oracle
#

Again why I should make a resource it's super useful

river oracle
drowsy helm
#
 public ItemBuilder skullTexture(String base64Texture, String sign) {

        SkullMeta headMeta = (SkullMeta) this.item.getItemMeta();

        GameProfile profile = new GameProfile(UUID.randomUUID(), "");
        profile.getProperties().put("textures", new Property("textures", base64Texture, sign));

        Field profileField = null;

        try {
            profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
            e1.printStackTrace();
        }

        this.item.setItemMeta(headMeta);
        return this;
    }
    }```
you can use that if you need Tias
weary cobalt
#

Alright, thank you! What do I put in for the sign parameter?

drowsy helm
#

pretty sure you can leave signature out iirc

lost matrix
weary cobalt
#

I've just figured out quite the odd workaround since I was having a bit of a hard time understanding the profile stuff. Copy and pasted my playerdata folder from a server that the players I wanted had joined before, and put it into my 'world' playerdata folder. It worked. Although, it would probably be useful to figure this stuff out, in the case it decides to break at some point

boreal sparrow
#

Anyone know how to create a team with Fastboards?

lost matrix
# lost matrix You can do that with the spigot api now
  public ItemStack texturedSkull(URL skinUrl) {
    ItemStack head = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta meta = (SkullMeta) head.getItemMeta();
    PlayerProfile profile = Bukkit.createPlayerProfile("_SOME_NAME_");
    PlayerTextures textures = profile.getTextures();
    textures.setSkin(skinUrl);
    meta.setOwnerProfile(profile);
    head.setItemMeta(meta);
    return head;
  }
river oracle
#

But teams are easy enough to make

eternal oxide
#

You must be careful not to create too many, although they do expire in three? months.

#

they still remain in teh cache

lost matrix
weary cobalt
lost matrix
boreal sparrow
#

Becuase if i do, i’d die

river oracle
#

Classes and events

#

Teams are a simple concept

boreal sparrow
#

Bukkit doesnt seem to think so

chrome beacon
#

What's the problem?

#

Teams aren't hard

river oracle
#

The scoreboard api sucks and i reccomended an alternative option is all

boreal sparrow
#

Yea

#

Thats true

#

Except i just cant find a good api for that

#

and i have no clue how to make my own lmao

chrome beacon
#

Did your team break another plugin?

river oracle
#

I'm a minigame dev lol so I guess it's easier said then done

boreal sparrow
river oracle
#

Oh if you want teams only

#

Just make it yourself don't bother with fastboard even

chrome beacon
#

Blame Mojang

boreal sparrow
#

Yea so thats why im looking to create a api

boreal sparrow
#

Ill check what and how to make an api

#

Thanks for your help

river oracle
#

Well each player can have a profile cache the profile and store what team the player is on you could also use these classes to store other game info

#

A more longterm solution is a file storage or pdc

chrome beacon
#

Making your own api will still need that scoreboard

river oracle
#

Not really

chrome beacon
#

It will

river oracle
#

If you just ditch bukkit completely and set up your own teams and logic no bullshit

#

It's what I do

chrome beacon
#

So you use nms

river oracle
#

Nope

#

I use events

#

I don't even use nms teams

boreal sparrow
#

.-.

chrome beacon
#

Somethings require teams

river oracle
chrome beacon
#

Events can't do it all

#

Messing with nametags, collision

#

Etc

boreal sparrow
#

im just trying to divide players into three maps

chrome beacon
#

Then skip the Teams API

river oracle
chrome beacon
#

So they use teams

river oracle
#

Collision is math not teams

chrome beacon
#

Collision is clientside

#

(For players)

#

Which is why you need teams

river oracle
#

If I ever need them I'll go use nms and figure out a better abstraction but thus far haven't needed them

#

Everything I need is managed by my custom team object

chrome beacon
#

I've done teams with packets and spigot api before

#

Just make a system that uses the spigot api

#

It will be easier to maintain

boreal sparrow
#

True, but then u still need to use the spigot api

river oracle
#

I'll die by considering that scoreboard api horrific at best

chrome beacon
#

Well you still need to do the same things just without the spigot api

river oracle
boreal sparrow
#

Yes

chrome beacon
#

And then make sure you don't break spigot plugins

#

It's more work than just using the existing one

cosmic fjord
#

why do some dependencies that worked in 2017 do not work anymore for the same plugin?

chrome beacon
#

If you want to make an api do that but use the spigot api internally

river oracle
river oracle
#

New versions

#

Removal of old versions

cosmic fjord
#

what can I do?

river oracle
#

Nothing

chrome beacon
river oracle
chrome beacon
#

We have no info to work with

#

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

echo basalt
#

well

#

you can update the outdated code by yourself

chrome beacon
#

^

shadow zinc
#

Anyone use tabnine and does it help your workflow?

chrome beacon
#

Yes and no

#

Use github co-pilot or nothing

rotund ravine
shadow zinc
rotund ravine
#

Worthy investment

onyx fjord
#

override fun 😭

supple elk
#

is onDisable() called on reload?

onyx fjord
#

including yours

rotund ravine
supple elk
#

ok ty

shadow zinc
#

Does setdefaults set comments for config files?

#

Also can anyone recommend come good data managers for config files

boreal sparrow
#

Will all players have access/permission to execute my command is I didn’t specify any permission needed?

shadow zinc
#

normally yes

#

unless you defined a default permission in your config file

#
default-permission: op```
boreal sparrow
#

Nah, ok thanks

tender shard
#

copilot is the only thing that properly works and is actually helpful

shadow zinc
#

damn, I might have to get a job

tender shard
#

lol

shadow zinc
#

nah jk, github copiot is basically an auto stackoverflow copy and paste tool.

quaint mantle
#

I tried something with Raytrace but failed. How can I find where an item or entity thrown with the Dispenser will end up?

tender shard
shadow zinc
#

rip, just cancel the event and spawn it a location

tender shard
#

it's really not that easy lol

shadow zinc
#

that might be a lib out there that simplifies that

#

have a look

tender shard
#

well another idea would be to make the item invisible, wait until isOnGround is true, and then you know where it ends up lmao

quaint mantle
# tender shard

even if i find the trajectory the trajectory may contain obstructions.

#

how to check?

tender shard
#

yeah you'd have to scan every full block that's on that path

shadow zinc
#

wait just detect the item being dropped and start a runnable

#

test every second to see if its on the ground or not

tender shard
#

what are you actually trying to do anyway?

quaint mantle
#

There are things that have a very long range. (fireball)

tender shard
#

why do you need the hypothetical end location in the moment when it's dispensed?

quaint mantle
#

What I'm trying to do is prevent items or fireballs from entering the chunk I want.

eternal oxide
#

a simple timer will do then

quaint mantle
#

Won't it cause lags?

shadow zinc
#

no?

tender shard
#

I'd add all currently thrown entities to a set or something. then check every tick if that entity is in your chunk, if yes, kill it. after 5 seconds or so, remove them from the set again

eternal oxide
#

unless you are going to track 10's of thousands of items in motion over multiple chunks, no

shadow zinc
#

it shouldn't if you aren't calculating the mass of the sun

tender shard
#

its funny how people always think "this might cause lag"

#

they should just look at the Entity#tick method

shadow zinc
#

nvm that would still be fine

tender shard
#

or ServerLevel#tick

quaint mantle
#

The reason I'm thinking about this is because there will be a lot of fireballs going towards infinity.

shadow zinc
#

how many fireballs are you thinking there will be?

eternal oxide
#

Short lived and not thousands

tender shard
#

they cant go to infinity

shadow zinc
#

yeah they despawn after a while

quaint mantle
#

Then I will listen for the spawn event and loop the item until it drops

tender shard
tender shard
shadow zinc
#

hmm, I'm not sure, I wouldn't put that in a timer tho

eternal oxide
#

we would instantly be crushed by gravity, I guess

shadow zinc
#

The sun is about 1,000 times more massive than Jupiter, and I know for a fact that jupiter would crush you

eternal oxide
#

the world would also flood as all land mass would be hyper compressed

shadow zinc
cosmic fjord
#

I dont know how to explain it correctly. I want to add a dependency but maven cant resolve the dependency. its a plugin so can I use the jar and put it in the lib directory to get it work?

eternal oxide
#

no

#

wel, you can, but you will break it

shadow zinc
#

install it using maven

eternal oxide
#

what dependency?

cosmic fjord
#

ProtocolLib-API

eternal oxide
#

thats in maven, add it properly

cosmic fjord
#

trough dependencies?

shadow zinc
#

did you add the repo?

eternal oxide
#

yes

cosmic fjord
#

Im getting the error Cannot resolve com.comphenix.protocol:ProtocolLib-API:4.4.0

shadow zinc
#
<repositories>
  <repository>
    <id>dmulloy2-repo</id>
    <url>https://repo.dmulloy2.net/repository/public/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.comphenix.protocol</groupId>
    <artifactId>ProtocolLib</artifactId>
    <version>4.7.0</version>
    <scope>provided</scope>
  </dependency>
</dependencies>```
#

Have you got that?

cosmic fjord
#

I only got the dependency

shadow zinc
#

you need the repository

cosmic fjord
#

ok thx

#

is that the correct one or an example?

shadow zinc
#

its the official one

cosmic fjord
#

ok thank you

shadow zinc
dry forum
#

saying this is a craftworld and not a level Level s = ((CraftWorld)loc.getWorld()).getHandle() in 1.18.2 it works fine this is 1.19.2 but i cant find anything that says how id fix this

quaint mantle
#

java.lang.ClassCastException: class [Lorg.bukkit.inventory.ItemStack; cannot be cast to class java.util.List ([Lorg.bukkit.inventory.ItemStack; is in unnamed module of loader java.net.URLClassLoader @515f550a; java.util.List is in module java.base of loader 'bootstrap')

#

tf am i supposed to do

cosmic fjord
#

getting this error Could not find artifact com.comphenix.protocol:ProtocolLib-API:pom:4.7.0 in paperspigot-repo (https://repo.destroystokyo.com/repository/maven-public/)

quaint mantle
#

playerConfig.getList returns null even tho ive got a check for playerConfig.contains

eternal oxide
#

it searches all repos in order, for every dependency

shadow zinc
eternal oxide
#

no

#

other than change teh order of warnings

tender shard
onyx fjord
#

btw use 5.0

cosmic fjord
#

I add this one

<repository>
     <id>dmulloy2-repo</id>
     <url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
shadow zinc
#

Lol the planets knew what was coming and got the fuck out of there

tender shard
#

lmao yeah

dry forum
eternal oxide
onyx fjord
quaint mantle
#

it should be a list.

tender shard
#

Mokang Mappings, it's called ServerLevel

dry forum
#

yeah ik but the code i sent it says its a worldserver not a serverlevel

eternal oxide
dry forum
#

so idk how to fix that

tender shard
cosmic fjord
#

I really have no idea what to do

onyx fjord
#

i think its 5.0-SNAPSHOT

#

or 5.0.0-SNAPSHOT

onyx fjord
shadow zinc
tender shard
#

there is no 5.0-SNAPSHOT

#

there is 5.0.0-SNAPSHOT though

onyx fjord
cosmic fjord
tender shard
#

it's pointless to look into that folder, just use the correct version

#

anyway it's in your home folder/.m2/repository

shadow zinc
#

C:\Users\{your-username}\.m2\repository.

#

assuming you use windows

onyx fjord
#

why delete it ...

shadow zinc
#

I had to delete mine because my school corrupted all the server certificates. I deleted all the server certificates but the error persisted until I deleted the .m2

#

Could be another cause for their case, good to cover all bases.

tender shard
#

you could also just have done mvn clean package -U to retry to download snapshots

#

it's simply not working for this dude because they keep using 5.0 instead of 5.0.0

shadow zinc
#

Intellij does recommend that with a link in the errors sometimes

#

Also could you recommend a good data manager for config files

#

I want to create my own but I need some inspiration

tender shard
#

is there anything that's missing in the builtin YamlConfiguration class?

shadow zinc
#

proper error handling

tender shard
#

I usually just extend YamlConfiguration

#

then I just do new("someFile.yml")

#

it loads the defaults from the plugins resources, then saves it as default config if not done yet, and tries to load it. if there's an error, ofc it also can't do much

#

I mean what do you mean with "proper error handling"

onyx fjord
#

something ignores my gradle home 😭

tender shard
#

if a yaml is broken, you can't read it

shadow zinc
#

I don't know much about how YamlConfiguration operates in that regard but personally I like to throw a couple things at an error to try to remedy it for a throw an exception

#

Also a config manager makes life a bit easier for some

tender shard
#

but wdym with "config manager"?

shadow zinc
#

config/data manager

tender shard
#

yeah what is it supposed to do

shadow zinc
#

manage setting defaults, getting strings, constructing the file if it doesn't exist etc

tender shard
eternal oxide
#

cast it

shadow zinc
#

Mojang mapping will save you a lot of bother if you do a lot of work with NMS

onyx fjord
#

why do they obfuscate the fking game

shadow zinc
dry forum
#

alrighjt that works thanks is there anyway to check what a method changed to in a version?

eternal oxide
#

just common sense

tender shard
#

set the search to "Spigot", then you can enter the "old" class name and it will show you the new names

dry forum
eternal oxide
#

you are not using Mopjang mappings

tender shard
#

yeah, that's because you didnt use mojang mappings in 1.18.2

dry forum
#

when i use mappings all the net. imports dont work

shadow zinc
#

run build tools

dry forum
#

also i am

shadow zinc
#

for 1.18.2

dry forum
#

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>

eternal oxide
#

they are all fine, you just use teh Mojang mapped ones

tender shard
#

for example, check out the ServerLevel information:

#

you can see that the getRecipeManager() is called q() in spigot

#

and getTagManager() in mojang mappings, is r() in spigot/obfuscated mappings()

dry forum
#

when i put setPosition in on the website nothing happens

#

*pos

tender shard
tender shard
#

where setPosition is declared

dry forum
#

how am i gonna know where that is

tender shard
#

how could you not know that when you use it? o0

#

you can't just do .setPosition randomly

#

you must have an object to call this on

dry forum
#

oh i thought u mean minecraft class on the website?

tender shard
#

yeah, that's what I mean

boreal sparrow
#

Is there a way to constantly check a boolean? Like a while true loop?

dry forum
#

how am i gonna know what class mojang put the setPos method in

tender shard
dry forum
#

you said i need to know the class the method is called in

tender shard
#

you currently have a class, let's say BlockPos. You use getPos on it. So you know that the class is called BlockPos and that's what you enter on that site

#

there are probably like 200 classes that have a setPos method

#

how am I gonna know which one you are talking about

dry forum
#

i dont understand why would i type my class name in on the website how is the website gonna know what classes i use

boreal sparrow
shadow zinc
#

Player move event is fine

tender shard
#

bro

shadow zinc
#

The alternative would be a runnable, but that would actually not great compared to player move event

boreal sparrow
tender shard
#

you wanna switch from obfuscated/spigot to mojang mappings. so e.g. you used WorldServer right now. Then you enter WorldServer on that site, and click on it. now it tells you "WorldServer is actualled called ServerLevel, and the method "WorldServer#a()" is actually called "ServerLevel#addEntity()" etc

dry forum
#

yes

boreal sparrow
shadow zinc
#

a place block event maybe, but water spreads so that wouldn't work

dry forum
#

oh wait i get it now sorry

boreal sparrow
#

Dumb question (new to java) why cant you just use a while true loop

dry forum
tender shard
#

yeah, that's because setPos isn't declared on the ArmorStand, but on the Entity class itself. If you don't find it there, click on "extends LivingEntity" at the top. it won't be there too, so keep going to the super class until you find it (it should be in "Entity")

shadow zinc
boreal sparrow
#

Ok that makes sence

#

Thanks

dry forum
#

ahh ok ty

shadow zinc
# boreal sparrow Ok that makes sence
new BukkitRunnable() {
            @Override
            public void run() {
                if (((Player) player).isInWater()) {
                    ((Player) player).setHealth(0);
                }
            }
        }.runTaskTimer(NeoPerformance.getInstance(), 0, 1);```
tender shard
#

np! I know it's annoying, that's why you should always use mojang mappings in the beginning, and not switch to it later πŸ˜›

azure dirge
shadow zinc
#

An example

dry forum
#

so i should be using a and not setpos?

tender shard
#

noooo, you should be using setPos of course

dry forum
#

oh ok ty

tender shard
#

and the "remapping" part in your pom.xml will then translate it back to a() so that it actually works on the server

dry forum
#

ohh

tender shard
#

so you can use the "fancy names" while coding, but make it still work on the server

#

because the server .jar itself uses the weird, fucked up names

dry forum
#

ok ty for explaining it lmao i havent really used nms

tender shard
#

np!

quaint mantle
#

java.lang.ClassCastException: class [Lorg.bukkit.inventory.ItemStack; cannot be cast to class org.bukkit.inventory.ItemStack ([Lorg.bukkit.inventory.ItemStack; and org.bukkit.inventory.ItemStack are in unnamed module of loader java.net.URLClassLoader @515f550a)

#

i am losing my sanity

tender shard
#

you shaded the bukkit api into your plugin

quaint mantle
#

huh

tender shard
#

so you now have two different ItemStack classes

#

once the server's, once your plugin's

shadow zinc
#

I remember my first time when I did that

tender shard
#

do not shade bukkit api πŸ˜›

quaint mantle
#

unshade it.

shadow zinc
#

Boy that was not fun

tender shard
#

i've did so many stupid mistakes so many times, that meanwhile I can tell people instantly what they did wrong by just guessing it lol

shadow zinc
# quaint mantle huh

If you are confused send your pom file in paste and we can point out which part is shading it

quaint mantle
#

<goals>
<goal>shade</goal>
</goals>

#

is this why

tender shard
#

no

#

?paste your whole pom

undone axleBOT
drowsy helm
#

Put scope provided

#

On your dependency

shadow zinc
#

Thats probably the problem

#

Also why do people reupload your plugins to black spigot when it is free to begin with?

#

And then not update it to the latest version.

tender shard
#

probably to get likes there

shadow zinc
#

Well their account is banned now so I hope the likes was worth it

dry forum
#

cannot find symbol w h a t
nms.spawnArmorstand(e.getPlayer().getLocation(), e.getPlayer(), true, true);

dry forum
#

huh

tender shard
#

what is "nms"?

dry forum
tender shard
#

then you didnt define a "spawnArmorstand(Location, Player, boolean, boolean)" method there

dry forum
#

void spawnArmorstand(Location loc, Player p, boolean gravity, boolean visible); i did

tender shard
#

check your imports

#

did you import the NMS player in your interface?

dry forum
#

yeah

tender shard
#

but you are passing a bukkit player

#

your interface should of course take a bukkit player, not an NMS player

dry forum
#

yeah i do that in my method

#

(CraftPlayer)p

tender shard
#

?paste the full code, including imports, of your interface

undone axleBOT
dry forum
#

of the class im using spawnarmorstand?

eternal oxide
#

your nms interface

dry forum
#
import org.bukkit.entity.Player;

public interface NMS {
    void spawnArmorstand(Location loc, Player p, boolean gravity, boolean visible);
}```
tender shard
#

?paste the whole class where you are using that interface. the one where you get the "symbol not found" message

undone axleBOT
dry forum
eternal oxide
#

did you get a Loading NMS message at startup?

dry forum
#

its when i package the plugin

quaint mantle
#

I wanna know if you can check if a chest is accessible without breaking blocks (in an open area) that surrounds it?

shadow zinc
#

why does her photo look like she died 20 years ago

onyx fjord
#

whats diamond sword GENERIC_ATTACK_SPEED?

compact cape
#

I'm using packets to update my GUI Inventories but recently I found some issues...

        PacketPlayOutOpenWindow packet = new PacketPlayOutOpenWindow(player.bU.j, container, title);
        if (player.b != null) player.b.a(packet);

First issue was calling player#closeInventory() does not work...
But having it sent in a task will fix the issue... Till plugin is disabling... When plugin is going to disable it tries to close all open GUIs (To prevent item stealing) but I can not use tasks to close the GUIs...

Any idea how can I fix this?

#

Oh hey πŸ™‚

onyx fjord
#

we cross our paths again πŸ˜‚

compact cape
#

yep

ornate mantle
#

is there a bukkit to mojang nms mapping translator

compact cape
#

Yes there is a quite good one πŸ™‚ wait a second

compact cape
#

Well that's it 🀷

ornate mantle
#

wait

#

are you the

#

angelchest dev

tender shard
#

yes

ornate mantle
#

lmao

quaint mantle
slate delta
#

How to convert that Mon Sep 12 12:23:07 CEST 2022 in a Date object ?

dry forum
#

cannot find symbol w h a t

tardy delta
#

Datetimeformatter?

slate delta
#

@tardy delta