#help-development

1 messages · Page 1998 of 1

elfin pilot
#

spawn an Item with something like Item i = world.spawn(location, Item.class) and i.setItemStack(itemStack);

#

not sure if thats the exact syntax but its pretty close

sly trout
#

thank you very much I found world.dropItem

elfin pilot
#

nice :D

flint coyote
#

Are there any rules that state whether I'm allowed to track which active servers have my plugin that gets published on spigotmc installed?
Like save the server ip and port (since it's unique) and amount of current players that refreshes every hour?
I'd be interested in statistics like that when releasing more plugins.

I saw some premium resources have graphs on their resource page - so I wanna know whether there's any kind of limitation to what data I'm allowed to collect

delicate lynx
#

it would be kinda weird as a server owner

#

bstats does this but keeps it anonymized

flint coyote
#

I thought about anonymizing it. The problem is I still need a "unique key" per server. I would say hashing the ip does the job. But since an ip is 32 bit it can easily be bruteforced and "unhashed". Any idea on how to actually keep it anonymized without mixing up data from different servers?

#

Or in other words: How does bstats do it?

delicate lynx
#

bstats generated a UUID for each server I believe

brave sparrow
#

you could hash the string of the IP instead of the IP itself

flint coyote
delicate lynx
#

not sure, but it saves it into plugins/bStats/config.yml

#

it probably generates a random one I would assume

flint coyote
flint coyote
brave sparrow
#

You could make the salt the hash of the main world UUID

flint coyote
#

That idea also isn't bad. I probably won't use the worlds name since that's 90% "world" but I can probably find something that is more unique. Maybe the seed of the world

brave sparrow
#

The world UUID

#

Not the name

#

But yeah seed would work too

flint coyote
#

Oh worlds have a uuid? Didn't know. That's great for hashing. Guess I'll do it that way. Thanks a lot!

brave sparrow
#

👍

#

The world UUID is also more unique than seed

#

You could in theory do something with the UUID of all the loaded worlds

#

So that way even if they download a map for the overworld, nether and end would probably be different

flint coyote
#

But there's still enough possible seeds that I don't have a way to salt every possible ip with all seeds in a reasonable time. But I think UUID is the better choice

brave sparrow
#

Yeah

#

Also it’s important to note that your plugin has to still work if your backend metrics server goes down

flint coyote
brave sparrow
flint coyote
flint coyote
uneven barn
#

Am I allowed to ask questions about coding plugins here or is this channel only for developing the spigot/bungeecord framework itself?

flint coyote
#

Feel free to ask anything about coding Plugins. That's what the channel is made for

brave sparrow
#

It’s for questions about coding plugins

brave sparrow
#

So if they modify the fingerprint in the config for whatever reason, you can perform the fingerprint algorithm again and figure out if the change was caused by a world UUID shifting or just randomly editing the key

#

Since the IP:port would still be the same

#

All depends on how much you care that the fingerprint is accurate

flint coyote
#

Since I don't know the old fingerprint after they changed it in the config I can't really determine why it changed. I can only recognize that it doesn't match the one from the fingerprint algorithm for whatever reason

#

(unless it was changed while the server was running but I don't have to read it multiple times during runtime anyway)

#

Noticing that it changed (for any reason) gives me the possibility to set a flag inside the database that it might be innacurate atleast. Might implement that aswell

uneven barn
#

@EventHandler public void onMove(PlayerMoveEvent e) { Block fromB = e.getFrom().getBlock(); Block toB = e.getTo().getBlock(); if (fromB == toB) return; Player pla = e.getPlayer(); //rand is a number generator if (rand != null) { if (rand.nextFloat() < 0.1) { pla.sendMessage(fromB.toString()); pla.sendMessage("To:"); pla.sendMessage(toB.toString()); } } } for some reason the messages are sent even when I don't really change the Block my Location is at

flint coyote
#

don't compare objects with ==
You have to use .equals() instead

uneven barn
#

(did i format the code correctly on discord?)

flint coyote
hardy swan
#

unless comparisons with enum constants

hasty prawn
tidal hollow
#

I want to make certain effects when using a totem

this is my code but it doesn't work :(

@EventHandler
    public void totemMessage(EntityResurrectEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player) event.getEntity();
            if (player.getInventory().getItemInMainHand().getType() == Material.TOTEM_OF_UNDYING || player.getInventory().getItemInOffHand().getType() == Material.TOTEM_OF_UNDYING) {
                for (Player all : Bukkit.getOnlinePlayers()) {
                    all.sendMessage(ChatColor.GRAY + "¡El Jugador " + ChatColor.DARK_AQUA + "" + ChatColor.BOLD + player.getName() + ChatColor.GRAY + " ha consumido un tótem!.);
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 300, 1));
hexed hatch
#

This occurs on the entity resurrect event

#

which is after the player consumes a totem and it saves their life, right?

#

If I'm right about that, why would you be checking their inventory for a totem that is already gone?

tidal hollow
#

I'm stupid

#

😢

hexed hatch
#

I might be wrong

#

and looking at the docs, it appears I just might be

#

I would recommend putting some debug lines before and after every if statement to see how far it gets

brave sparrow
tender shard
#

no need to check for the totem, it was already removed

#

unless the event is cancelled

hasty prawn
#

The totem will still be in their hand when the event is fired.

tender shard
#

hm but then their code should work

#

anyway, there is still no need to check for the totem. it's enough to check whether the event is cancelled

hexed hatch
#

Called when an entity dies and may have the opportunity to be resurrected. Will be called in a cancelled state if the entity does not have a totem equipped.

#

This is interesting phrasing

hasty prawn
#

You're calling that method right

#

Send the command class

#

Hm, add some print statements and see where it's not reaching.

#

That's fine

#

Where'd you put it

uneven barn
lavish hemlock
#

^ this applies to strings too btw

#

And uh UUIDs

#

It does not apply to enums since enums are static and therefore only have one memory location

uneven barn
lavish hemlock
#

That's referring to the default implementation

#

By default, equals is the same as ==. Classes must implement it themselves.

uneven barn
#

That kind of thing is hard to tell since I've only been looking through the docs

lavish hemlock
#

The stdlib's javadocs are more

#

intelligent than understandable

#

ig it's fair

#

They pack a lot of precise information

#

(Just not easy for newcomers to read, imo, although most of the time I fail to understand programming docs bc of their big words)

idle kindle
#

hello, I am writing a plugin to add functionality with boilers to dispensers, I need help because when a redstone is supplied to a dispenser, the item is not removed, it is thrown out of it and I don’t understand how to solve it

#

public class EventsList implements Listener {
@EventHandler
public void Cauldron(BlockDispenseEvent e){
Block dispenser = e.getBlock();
BlockState blockstate = dispenser.getState();

    Dispenser dis = (Dispenser) blockstate;

    Inventory inv = ((Dispenser) blockstate).getSnapshotInventory();
    if(dispenser.getBlockData() instanceof Directional){
        Directional dir = (Directional) dispenser.getBlockData();
        Boolean flag_lava = Boolean.FALSE;
        Boolean flag_water = Boolean.FALSE;
        Boolean flag_empty_lava = Boolean.FALSE;
        Boolean flag_empty_water = Boolean.FALSE;

        if(dispenser.getRelative(dir.getFacing()).getType().equals(Material.CAULDRON)){
            ItemStack item = new ItemStack(Material.LAVA_BUCKET);
            for (int i =0; i < inv.getContents().length; i++) {
                if (!inv.contains(item)) {
                    //flag_lava = TRUE;
                    inv.remove(Material.LAVA_BUCKET);
                    inv.addItem(new ItemStack(Material.BUCKET));
                    blockstate.update();
                    dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
                    break;
                }
            }
        }
terse lily
#

also why are you using Boolean object type instead of primitive boolean

idle kindle
#

ok

#

thank

silver shuttle
#

When making a set method for an integer in a specific range for a custom object, is it better to throw an exception if the integer is out of bounds or to simply adjust the integer?

e.g.:

// Throwing an exception:
public void setUses(int uses) throws IntegerOutOfBoundsException {
  if(uses < 1 || uses > 1000) {
    throw IntegerOutOfBoundsExcetion;
    return;
  }
  maxUses = uses;
}

// Adjusting the value
public void setUses(int uses) {
  if(uses < 1) {
    uses = 1;
  }
  else if(uses > 1000) {
    uses = 1000;
  }
  maxUses = uses;
}
chrome beacon
#

I believe an exeption is the correct way

silver shuttle
#

alright, thanks

#

How many items can fit into an itemstack?

tall dragon
tall dragon
dull whale
#

I have a client side entity, how do I listen when its clicked?

earnest forum
#

depends on the material @silver shuttle

quasi flint
#

listen for packets the client sends

earnest forum
#

eggs hold 16, a bed can only hold 1

#

etc

silver shuttle
# tall dragon um, normally 64

I am pretty sure it is changeable, yet I cannot find any info on how to.
There is a plugin called StackableItems which allows for any item to be stacked to any amounts, even unstackable items

quasi flint
#

either protocollib, packet events or just ur own packet injector

tall dragon
quasi flint
#

asm , asm , asm , asm (yoke tho)

silver shuttle
#

mmmmmmmmmmmm

#

ugh

#

Wish there was an easy way like "ItemStack.setSize()"

tall dragon
#

yea i wish alot of thing too about minecraft

quasi flint
#

just write ur own server software

earnest forum
#

there is something like that no?

tall dragon
quasi flint
#

write ur own client

tall dragon
#

:D

quasi flint
#

we kinda got some server things to already work

#

lemme grab the github link

tall dragon
quasi flint
#

wip but yes

#

we currently generating the 1.8 to 1.18 classes from json to kotlin files

#

so build in multiversion support

tall dragon
#

interesting

quasi flint
#

the protocollscraper.kt generates rounda bout 500 classes

#

if i recall correctly

#

the funniest thing is, to get native bukkit plugins to run on that piece of garbage

idle kindle
#

if(dispenser.getRelative(dir.getFacing()).getType().equals(Material.WATER_CAULDRON)){
ItemStack item = new ItemStack(Material.BUCKET);
for (int i =0; i < inv.getContents().length; i++) {
if (!inv.contains(item)) {
//flag_empty_water = TRUE;
inv.remove(Material.BUCKET);
blockstate.update();
inv.addItem(new ItemStack(Material.WATER_BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.WATER_CAULDRON);
e.setCancelled(TRUE);
break;
}
}
}

#

item dont remove

tall dragon
#

please format it

idle kindle
#

how

tall dragon
#

put 3 of these ` on each side of your code

idle kindle
#
                ItemStack item = new ItemStack(Material.BUCKET);
                for (int i =0; i < inv.getContents().length; i++) {
                    if (!inv.contains(item)) {
                        //flag_empty_water = TRUE;
                        inv.remove(Material.BUCKET);
                        blockstate.update();
                        inv.addItem(new ItemStack(Material.WATER_BUCKET));
                        blockstate.update();
                        dispenser.getRelative(dir.getFacing()).setType(Material.WATER_CAULDRON);
                        e.setCancelled(TRUE);
                        break;
                    }
                }
            }```
tall dragon
#

so now whats it supposed to do

idle kindle
#

if there is a bucket of water in the dispenser and an empty boiler opposite, then replace the boiler with a boiler of water, remove the bucket of water and add a bucket

tall dragon
#

so bassically, the dispenser shoots its water into a cauldron?

fickle frost
#

Be a bit more descriptive than "item dont remove" when describing what's going wrong.

idle kindle
#

one minuts

tall dragon
#

huh. why would it add lava when there is water in the dispenser

#

im am confuse

fickle frost
#

That's kinda funny.

tall dragon
#

first of all

fickle frost
#

Anyway:

                    if (!inv.contains(item)) {```
This makes no sense. 
You're looping over the inventory nine times just to perform the exact same check every time.
Moreover, due to your check, you're only attempting to remove the bucket if the inventory doesn't contain a bucket.
tall dragon
#

im pretty sure all of your for loops are useless

fickle frost
#

Remove the loop and invert the bucket check and you'll probably get some better results.

boreal frost
#

I am working on a program that once it moves it never stops again. I added Velocity to X and Z and it stopped falling, so I tried adding Velocity to Y but it doesn't come close to minecraft's behavior. I would appreciate if you could help me.

Here's the code now.

        Location loc = p.getLocation();
        loc.setPitch(0);
        Vector vec = loc.getDirection();
        p.setVelocity(vec.multiply(0.4f));
        p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,10,10));
        if (!fallMap.containsKey(p)) {
            fallMap.put(p,Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
                @Override
                public void run() {
                    if (p.isOnGround()){
                        time = 0;
                        fallMap.remove(p);
                        fallMap.get(p).cancel();
                    }
                    time += 0.25;
                    p.setVelocity(p.getVelocity().setY((Math.pow(0.98, time) - 1) * 3.92));
                }
            },0,1));
        }```
rough drift
#

So i am trying to reload my recipe, however i get "Duplicate recipe ignored with ID"

#

even if i call Bukkit.removeRecipe before

rough drift
tender shard
rough drift
#

yes?

#

oh wait

#

lmao

tender shard
#

hm I doubt it

rough drift
#

i am

tender shard
#

I always loop over all recipes and remove ALL recipes that match my plugin's namespace in onEnable

rough drift
#

the brightest idiot there is

tender shard
#

print out the recipes you are removing and also the ones you are adding

rough drift
#

i have a recipeKey and a headKey, guess which one i was using

tender shard
#

the wrong one, as I said 😛

fickle frost
#

Remove the ! from the if statement which checks the inv for a bucket.

tender shard
idle kindle
#

i removed ! and code dont work

fickle frost
#

Then there are more bugs you need to find.

tall dragon
#

you also need to completely remove your for loops

#

its useless to do the same check 9 times.

idle kindle
fickle frost
#

You're doing that here:
if (!inv.contains(item)) {

tall dragon
#

^

fickle frost
#

You'd only need to loop over the inventory if you were going to use the index to individually check the item in each slot of the inventory.
But you're not checking each slot yourself, you're using the InventoryHolder#contains method to do that check for you. It will return true if any of the slots in the inventory contain the provided item.

#

Downside of that is you don't know which slot contained the bucket and which slot you removed the bucket from, but that's probably unnecessary for your purposes.

idle kindle
#
                ItemStack item = new ItemStack(Material.LAVA_BUCKET);
                    if (inv.contains(item)) {
                        inv.remove(Material.LAVA_BUCKET);
                        blockstate.update();
                        inv.addItem(new ItemStack(Material.BUCKET));
                        blockstate.update();
                        dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
                        e.setCancelled(TRUE);
                    }
                }```
unreal turret
#

Is there a way to prevent EntityDamageByEntityEvent from responding in entity.damage ()?

Or is there a way to reproduce the damage?

tender shard
#

exit

unreal turret
#

I want to skip the processing of the Event caused by damage()

tender shard
#

I don't think you can do that

#

you can instead directly set the health

#
entity.setHealth(entity.getHealth() - yourDamage);
unreal turret
#

ok thanks

novel basin
#

How can i setup a blank plugin in vscode? I read the tutorial thing on the spigot website but i dont understand anything.

rough drift
#

why not use intelli

#

it has the mc dev plugin and it allows you to auto setup

novel basin
rough drift
#

alright

#

anyways what do you not understand

novel basin
fickle frost
#

Have you set up a project in vscode before?

novel basin
rough drift
hardy swan
novel basin
hardy swan
#

mvn generate:archetype iirc

novel basin
rough drift
#

can you check if an item has been renamed in an anvil? (so the input's name does not match the output's name)

#

What i am trying to do:

Whenever my custom skull is renamed, it will set its owner to the name of the skull, now this works, however after a couple times you do this it will go crazy and kick the player for too many packets, here's my current code:

@EventHandler
public void on(PrepareAnvilEvent event) {
    ItemStack result = event.getResult();
    if(result == null) return;
    if(result.getType() == Material.PLAYER_HEAD) {
        SkullMeta meta = (SkullMeta) result.getItemMeta();
        OfflinePlayer player = Bukkit.getOfflinePlayer(meta.getDisplayName());
        meta.setOwningPlayer(player);
        result.setItemMeta(meta);
    }
}
```(I still need to add the check for my skull, however its just easier to test without it)
#

by going crazy i mean the skull keeps changing its owner as soon as i add it to the anvil slot (note: this is for every skull in the inventory, they all keep changing between steve and alex and i have no clue why)

tender shard
#

does anyone know whether the premium resource placeholders also get replaced in normal .txt files, or only in java class files?

rough drift
#

wdym

tender shard
rough drift
#

as it replaces in strings

tender shard
#

:<

idle kindle
tender shard
tender shard
idle kindle
#

I want distributors to be able to take and put water and lava into cauldrons

#

just like they do it without a boiler

crude loom
#

Hey there, any idea what am I doing wrong here?

TextComponent comp = new TextComponent();
player.sendMessage(ChatMessageType.ACTION_BAR,comp);
tender shard
#

when a dispenser is in front of a cauldron, check if the dispensed item is a bucket or a lava bucket. if it is, check whether the cauldron already contains lava or not, and then cancel the event and manually add / remove lava and exchange the bucket with a lava bucket or empty bucket inside the dispenser

idle kindle
#
                ItemStack item = new ItemStack(Material.LAVA_BUCKET);
                    if (inv.contains(item)) {
                        inv.remove(Material.LAVA_BUCKET);
                        blockstate.update();
                        inv.addItem(new ItemStack(Material.BUCKET));
                        blockstate.update();
                        dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
                        e.setCancelled(TRUE);
                    }
                }```
tender shard
#

how does that even compile? wtf is TRUE?

lost matrix
tender shard
crude loom
lost matrix
crude loom
#

What does that mean?

tender shard
#

the method is called Player.spigot().sendMessage

tender shard
tender shard
#

why don't you just use the primitives?

crude loom
#

Ahhh, yeah that works, thank you! :D

idle kindle
#

the program asked me to do

#

how fix bags

tender shard
undone axleBOT
tender shard
#

"the program asked you to" because you used TRUE instead of true

#

print out some debug statements whether it actually cancels the event. I bet one of your if statements returns false

idle kindle
#

do you suggest replacing the former letters with small ones?

tender shard
#

yes of course, but that won't fix your problem

idle kindle
#

how fix

last tulip
#

i want make player can't break specific block event that can be turn on/off by command
can someone check?
https://pastebin.pl/view/7fdbba19
the event still going on even i run /enabledisable disable

crude loom
#

Is there a way I can display a message lower in the screen than what ChatMessageType.ACTION_BAR does?

fickle frost
#

The Minecraft client has limited positions available for displaying text.
Without modifying the client, displaying text outside of those positions isn't feasible.

crude loom
#

I see, thanks for the help!

sharp flare
#

should be break

#

let me know if it works

#

🙂

lean gull
#

does anyone have a good understandable tutorial about protocollib packets for beginners?

#

?

#

i mean protcollib beginners, like someone who hasn't really used it before

#

i know like half of the java basics and i'm learning

#

i'm currently watching this tutorial [https://www.youtube.com/watch?v=2FcnwD2MHOA&t=1491s&ab_channel=KodySimpson]
but it's a bit hard to understand cause he kind of explains words and expects me to understand it as if i know what it means

In this episode, I show you how to listen for and create packets using ProtocolLib. I explain what packets are, how to extract and set data in packets, and more. #Spigot #SpigotTutorial

Packet Reference: https://wiki.vg/Protocol
ProtocolLib: https://www.spigotmc.org/resources/protocollib.1997/
Code: https://github.com/Spigot-Plugin-Development...

▶ Play video
sharp flare
crude loom
#

Don't know if this is necessarily spigot related or java related but it there a way I can schedule a task and cancel it without having the object I used to schedule it in the first place?
(when I reload the plugin I lose the object so I won't to have a command that cancels previously created tasks)

young knoll
#

Reloading the plugin already cancels them

tender shard
lean gull
#

there are a lot of different opinions on nms vs protocol so idk which one to choose but i'll pick protocollib ig

crude loom
tender shard
#

if the plugin gets disabled, tasks are cancelled

#

if you only reload it yourself, of course they won't get cancelled

#

just cancel all your tasks in your reload method

crude loom
haughty storm
#

I want to spawn npcs using my plugin, but for some reason my intellij doesnt give me any imports from net.minecraft. These are the dependencies of my pom.xml:

<dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
        </dependency>
    </dependencies>
tender shard
#

obviously class names are different in remapped-mojang

haughty storm
tender shard
#

did you click the "maven reload" button?

haughty storm
#

yup

tender shard
#

what import are you using for MinecraftServer?

#

it should be "net.minecraft.server.MinecraftServer"

haughty storm
#

That import doesnt exist for me

tender shard
#

do File -> Invalidate Caches, check all boxes then click on "Invalidate & Restart"

haughty storm
#

ok, I'll try that

tender shard
#

it might take a few minutes after restarting until it works again

haughty storm
#

ok

#

Still not working

#

amnd on the right side it gives me an error but doesnt tell me why

tender shard
#

you did run buildtools for 1.18.1 using --remapped though, right?

haughty storm
#

I ran them using ```
java -jar BuildTools.jar --rev 1.18.1

tender shard
#

You must add --remapped behind it

haughty storm
#

ok, give me a sec

ivory sleet
#

Yeah, the entity should get removed the next tick if everything goes as it should (I believe)

haughty storm
tender shard
crude loom
late sonnet
last tulip
#
        if (sender instanceof Player && cmd.getName().equalsIgnoreCase("loottes")) {

            Location loot1 = new Location(Bukkit.getWorld("neweventbow"), 9, 43, -8);
            player.getWorld().getBlockAt(loot1).setType(Material.CHEST);
            
            new BukkitRunnable() {
                public void run() {
                    Block block = player.getWorld().getBlockAt(loot1);
                    if (block.getType() == Material.CHEST) {
                        Chest chest = (Chest) loot1.getBlock().getState();
                        Inventory inv = chest.getBlockInventory();
                        inv.addItem(new ItemStack(Material.STONE, 2));
                    }
                }
            }.runTaskLater(this.main, 1);
        }```
any problem with my code? i want set a chest at specific coordinate with item inside

but i got error` Cannot invoke "org.bukkit.World.getBlockAt(org.bukkit.Location)" because the return value of "org.bukkit.Location.getWorld()" is null`
tender shard
#

you don't have a world called "neweventbow"

last tulip
#

i do have

crimson terrace
#

"neweventbow" != "eventmapbow"

last tulip
#

oh god

#

xD thanks

tender shard
last tulip
#

ya i just remove it, i was copy it from onBlockPlace event and i need a tick so there is no error

hardy swan
#

hello

quaint mantle
#

uh

#

how do I find item textures?

#

like

#

aaa

#

nvm

#

oo

#

found it

#

material: PLAYER_HEAD
texture: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTdjY2QzNmRjOGY3MmFkY2IxZjhjOGU2MWVlODJjZDk2ZWFkMTQwY2YyYTE2YTEzNjZiZTliNWE4ZTNjYzNmYyJ9fX0='

#

the part below materials

#

where do I find it?

crude loom
#

Is there an event that allows me to check if a player is holding an item or do I have to use a runabble for it?

quaint mantle
rough drift
quaint mantle
lost matrix
# quaint mantle 1.8.8

This version is half a decade old and support was dropped years ago. In newer versions there is a LOT of api that you are missing out.
So for you its SkullMeta -> GameProfile -> use reflections to get properties

crude loom
tacit drift
#

or use nbtapi

lost matrix
# quaint mantle its good men 🔫

No its not and nobody uses it. Update to a supported version or live with the horrible drawbacks like having to use reflections to get textures from a skull.

rough drift
#

well i mean, 1.8 is good for joining hypixel

#

thats it

lost matrix
crude loom
quaint mantle
#

imagine using 1.18 to play bedwars

hardy swan
#

imagine developers playing minecraft

lost matrix
rough drift
crude loom
#

What do you mean by squeezing every last bit of performance?

crude loom
#

Ah, this is a smart sollution for that

torn vale
#

How to change the skin of a player?

red sedge
#

packets prob

lost matrix
torn vale
torn vale
#

that the other players receive the change

lost matrix
torn vale
#

wait, you are german? xd

lost matrix
#

lies and deception

sage patio
#

Hi, I have a NPC made with packets, i want to move this npc realistic ( not teleport, walking ), if anyone can help me create a thread thanks.

sage patio
# rough drift use A*

wdym " use A" ?

((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntity.PacketPlayOutRelEntityMove(entity.getId(), (short) (x * 4096), (short) (y * 4096), (short) (z * 4096), true));
lost matrix
#

Although i see a lot of other packets that might be needed for predictive computing by the client like velocities and player position/look

rough drift
#

iirc mc does not have prediction

#

atleast not for players/entities

lost matrix
#

I almost certainly has. 20TPS would look scuffed otherwise.

red sedge
#

it does look scuffed tho

rough drift
#

^

crude loom
#

Is it possible to change the fade out time of the player.spigot().sendMessage() method?

rough drift
#

in chat?

#

no

#

unless you clear chat and resend the msg

red sedge
rough drift
#

if you keep doing it

red sedge
#

...

rough drift
#

chat will keep displaying new msgs

crude loom
rough drift
#

well, you can try resending it after a bit

crude loom
#

But it will take time to fade out

lost matrix
crude loom
#

Ohhh I can send a clear one to remove it, that will work, thanks!

rough drift
patent horizon
#

is the upperbound noninclusive?

#

im guessing thats what the -1 is?

rough drift
#

yes

viral temple
#

Yes

lost matrix
#

Yes. Its X Element [L, U[

#

*And you should use ThreadLocalRandom

rough drift
#

say nextInt(400) its 0 to 399

patent horizon
lost matrix
#

Thread contention and a lot of utility methods

haughty storm
#

Could someone tell me how to spawn a fake player using nms, found some resources, but they were for different versions

rough drift
#

you can try using the Citizens api

chrome beacon
#

^

haughty storm
#

How would I implement that in my intellij project

chrome beacon
#

Maven or Gradle?

haughty storm
#

maven

tribal holly
#

What do you advise to host a public repository ? (What type of service is good to use ?)

lost matrix
#

caugh citizens has abyssmal performance and i consider it a borderline virus

tribal holly
#

Nexus okay thanks i will check this

lost matrix
tribal holly
#

There is so much things, this is why i ask. For which is the most use and the most documented

lost matrix
#

What does this question aim at? Why the performance is abyssmal or why i consider it a borderline virus?

haughty storm
#

thx, I'll try that

tribal holly
#

try to understand it, before using it

lost matrix
#
  1. I dont know why the performance is so bad. Ask the citizens devs.
  2. I consider it a borderline virus because the performance is so bad. (20% tick time with 0 players online)
haughty storm
lost matrix
#

Its been a while since ive used it (about 3 years) and back then it just hogged all the cpu time it could get.

tribal holly
#

btw there is a lot of feature with path finding etc so maybe there is some justification

#

(ore just very bad code optimization)

#

@lost matrix sry for the ping just a question, is Nexus free ?

lost matrix
tribal holly
#

okay, but i wanna make my repo public (so any password and user to set for the user) is it possible and secure ? Or did i need to make it absolutely private ?

lost matrix
tribal holly
#

okay thanks for all infos

lean gull
#

what is it called when someone does something like "void hi();" in an interface

#

is it a function or somethin? idk what it is

lost matrix
lean gull
#

i don't understand

#

could you dumb it down?

lost matrix
#

Nope. Google the words.

lean gull
#

gee thanks

viral crag
#

it is not really a serious programming question - kind of surprised you got an answer

lean gull
#

forgot for a second how annoying everyone is here

vocal cloud
#

"annoying" vs not wanting to teach java concepts to people because you should already know them

lost herald
lean gull
#

im fine with them not wanting to teach me, im annoyed by how they said it

#

and im annoyed on lowonespresso

viral crag
vocal cloud
#

You're annoyed that someone said no they're not going to dumb down important concepts you should know and you're annoyed someone directed you to a page to learn said concepts. I don't know what to tell you

fickle frost
quaint mantle
#

hey how to get a location object with a specific coordinate that I have

eternal night
#

if you have the world and the x,y and z

#

just use the location's constructor

quaint mantle
eternal night
#
final double x = 10, y = 20, z = 30;
final World world = ...; // Whatever world

final Location location = new Location(world, x, y, z);
neon nymph
#

Are there any downsides to having a lot of methods in a class? Say an average method in a class has at least a runnable in it, and there are like maybe 3000 lines of code worth of these methods. How does that affect the program?

hasty prawn
#

The computer doesn't care, but it makes it look awful and hard to debug.

#

And your mouse's scroll wheel :(

lost matrix
#

Pretty sure that there is no chance that you can write code like that without violating clean code principles at least several dozen times.

brave sparrow
#

I would argue having a ton of functionality inside 3-4 methods is harder to read

#

Than having the code broken up into small units

hasty prawn
#

^

quaint mantle
#

sorry to interrupt guys
you can answer after the current queries have been resolved
how to summon a mob at a given location

lost matrix
quaint mantle
#

also is there any way in which entity size can be increased?

brave sparrow
#

Not programmatically

raw ibex
#

just saying that in future @quaint mantle you should use javadocs for simple stuff like that

lost matrix
quaint mantle
#

have a good day guys
thanks for helping me
Byyeee

raw ibex
#

why is he ignoring me

neon nymph
#

Hmm, I see. So follow-up question, how would one efficiently and optimally write/store multiple unique instances of an object? Basically like enums, but for objects. I'm planning to write my own GUI lib and I figured I'd be creating a lot of items as buttons of these GUIs with their own trigger methods (runnables I mentioned earlier) and that was my earlier concept, multiple methods that return a specific itemstack. I figured if I were to create a new item, I can simply add another method

dull whale
#

how can I stop the sitting animation?

lost matrix
hybrid spoke
dull whale
#

sit but stand one with packets

lost matrix
#

The button class:

@Builder
@AllArgsConstructor
public class GUIItem {

  @Getter
  private final Function<Player, ItemStack> iconCreator;
  @Getter
  private final Consumer<InventoryClickEvent> eventConsumer;

}

Then inside your GUI object there should be something similar to a

  private final Int2ObjectMap<GUIItem> buttonMap = new Int2ObjectOpenHashMap<>();

Then you can fill this map with buttons

    GUIItem item = GUIItem.builder()
            .iconCreator(player -> new ItemStack(Material.RED_WOOL))
            .eventConsumer(event -> event.getWhoClicked().sendMessage("You clicked red wool"))
            .build();
    buttonMap.put(10, item);
#

There is quite a bit more to that but those are the core concepts.

neon nymph
#

Okay, I'll look into this further. Thanks for introducing it to me!

dull whale
crimson terrace
#

keep teleporting them to the same position every tick or 2?

tall dragon
#

or just set their movespeed to 0?

crimson terrace
tall dragon
#

true

dull whale
#

I thought i could just make them sit on something

#

that wouldnt seem laggy too

#

because if they dismount, thats no problem for me

lost matrix
#

Oh so you want to cancel them dismounting? Just cancel the EntityDismountEvent then.

torn yarrow
#

Hi.. I'm trying to update an old abondoned plugin and it has these import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; import net.minecraft.server.v1_13_R2.NBTBase; import net.minecraft.server.v1_13_R2.NBTCompressedStreamTools; import net.minecraft.server.v1_13_R2.NBTTagCompound; import net.minecraft.server.v1_13_R2.NBTTagList; ... trying to find the right imports for gradle.. for 1.18.. not even sure that stuff is in the same place in this version now though

dull whale
fading lake
lost matrix
lost matrix
fading lake
#

so import net.minecraft.server.NBTTagCompound (might not be exactly like that I'm a 1.8 dev)

dull whale
fading lake
#

you want to make a player sit down without sitting down?

lost matrix
fading lake
#

rip

#

what did they change it to, all I know is its not version mapped anymore

lost matrix
torn yarrow
#

what is the gradle import for net.minecraft.server. ... I can't find even that

fading lake
#

in every other version its buildtools spigot but it mightve changed

lost matrix
dull whale
lost matrix
lost matrix
fading lake
viral crag
# torn yarrow what is the gradle import for net.minecraft.server. ... I can't find even that
repositories {
    mavenLocal()
    mavenCentral()
    // Spigot
    maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }

   // maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
    // maven { url = 'https://oss.sonatype.org/content/repositories/central' }
}

dependencies {

    compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
    // Spigot Annotations Support - Replaces plugin.yml
    compileOnly 'org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT'
    annotationProcessor 'org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT'

}
dull whale
fading lake
#

cancel the move event like smile said, make them fly about 0.01 blocks off the ground, make it so they cant disable it (PlayerToggleFlightEvent) and set their fly speed to 0

#

Either that or set their walkspeed to 0 and give them negative knockback to kill jumping

dull whale
#

so canceling the sit animation isnt posibble?

lost matrix
fading lake
#

not effectively, how would a player just randomly decide they want to sit?

#

unless you're doing it through packets

lost matrix
dull whale
#

but not the player himself?

fading lake
#

no thats client side

#

because minecraft

dull whale
#

thanks then Ill just loop set walkspeed 0

idle kindle
#

can you write a plugin that will allow dispensers to pour liquids into boilers?

fading lake
#

I mean you shouldn't need to loop it, their walkspeed wont increase on its own

torn yarrow
fading lake
#

modded?

idle kindle
#

I'm tired my code doesn't work in practice

idle kindle
lethal python
#

oh ok

crude loom
#

In order to grant a specific permission to a player, should I do it in my own plugin , or find a plugin that will handle that?
Or it doesn't matter

idle kindle
lost matrix
fading lake
lost matrix
crude loom
crude loom
fading lake
#

so its recommended

lost matrix
lethal python
#

how to get intellij to build my plugin

crude loom
#

Ah, thank you I'll look into this

haughty storm
#

I'm getting this error msg when loading my plugin.

java.lang.NoClassDefFoundError: net/minecraft/server/level/ServerPlayer
        at de.firecreeper82.naruto.TestPl.register(Naruto.java:27) ~[?:?]
        at de.firecreeper82.naruto.TestPl.onEnable(Naruto.java:17) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:521) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:435) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at java.lang.Thread.run(Thread.java:833) [?:?]

It says it couldnt find the ServerPlayer class but I imported in my code

import net.minecraft.server.level.ServerPlayer;

And in my pom.xml arent any errors but on the right hand side it gives me an error at the dependencies

tall dragon
haughty storm
#

how?

tall dragon
#

open it with something like winrar

rough drift
#

is there an event when a player clicks on an item and it goes to cursor? so far InventoryClickEvent#getCursor only returns the item in the slot after it clicked

tacit drift
#

the jar class paths are not like that

#

for the server

haughty storm
#

ok, gimme a sec

lost matrix
# idle kindle https://pastebin.com/sLYiE9DM

Try this and show me the result:

    @EventHandler
    public void onDispense(BlockDispenseEvent event) {
        Block block = event.getBlock();
        if (!(block.getBlockData() instanceof Dispenser dispenser)) {
            return;
        }
        Block target = block.getRelative(dispenser.getFacing());
        if (target.getType() != Material.CAULDRON) {
            return;
        }
        ItemStack dispensedItem = event.getItem();
        if (dispensedItem.getType() == Material.LAVA_BUCKET) {
            event.setCancelled(true);
            Levelled levelled = (Levelled) target.getBlockData();
            levelled.setLevel(7);
            Inventory dispenserInv = ((BlockInventoryHolder) block.getState()).getInventory();
            dispenserInv.remove(Material.LAVA_BUCKET);
        }
    }
haughty storm
# tall dragon open it with something like winrar

I didnt put the class in my project but imported with my pom.xml I think (if that makes sense if not correct me xD)

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

You’re trying to reference the deobfuscated class

#

That doesn’t exist in the server

misty current
#

iirc there is a maven plugin that auto remaps to obfuscated code

idle kindle
lost matrix
haughty storm
idle kindle
#

idk

torn yarrow
idle kindle
#

i dont know

misty current
#
<plugin>
                <groupId>net.md-5</groupId>
                <artifactId>specialsource-maven-plugin</artifactId>
                <version>1.2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>remap</goal>
                        </goals>
                        <id>remap-obf</id>
                        <configuration>
                            <srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
                            <reverse>true</reverse>
                            <remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
                            <remappedArtifactAttached>true</remappedArtifactAttached>
                            <remappedClassifierName>remapped-obf</remappedClassifierName>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>remap</goal>
                        </goals>
                        <id>remap-spigot</id>
                        <configuration>
                            <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
                            <srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
                            <remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

i have this in my pom and the code works fine at runtime with a remapped jar

#

i don't remember where i got it tho

#

spigot 1.18.1

torn yarrow
#

ah i've set things up with gradle

idle kindle
misty current
lost matrix
misty current
#

^ 1.18 doesnt even run on java versions under 17

misty current
#

so no point in using old versions

haughty storm
misty current
idle kindle
viral crag
lost matrix
idle kindle
# lost matrix wrong import

import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.data.Levelled;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

vague swallow
#

How can I check the name of a block?

misty current
#

you mean the type?

lost matrix
#

Done a bit of testing. This is the resulting code that works.

            @EventHandler
            public void onDispense(BlockDispenseEvent event) {
                Block block = event.getBlock();
                if (!(block.getBlockData() instanceof Dispenser dispenser)) {
                    return;
                }
                Block target = block.getRelative(dispenser.getFacing());
                if (target.getType() != Material.CAULDRON) {
                    return;
                }
                ItemStack dispensedItem = event.getItem();
                if (dispensedItem.getType() == Material.LAVA_BUCKET) {
                    target.setType(Material.LAVA_CAULDRON);
                    event.setCancelled(true);
                    Inventory inventory = ((BlockInventoryHolder) block.getState()).getInventory();
                    Bukkit.getScheduler().runTask(SpigotSandbox.this, () -> inventory.removeItem(dispensedItem));
                }
            }
lethal python
#

bucket gone

vague swallow
idle kindle
#

what should i import?

lost matrix
#

Then you can just add an empty bucket

misty current
lost matrix
misty current
#

don't think theres another way

lost matrix
misty current
#

incase you mean the name of a chest/shulkerbox i think you can just get the blockstate and the inventory

#

and from the inventory the name

lost matrix
#

Inventories dont have names

vague swallow
lost matrix
misty current
#

or something similar

#

kinda weird

idle kindle
haughty storm
lost matrix
idle kindle
#

dont work

round gale
#

hey guys, does someone know how to shorten this code or make it cleaner?
somehow i don't like those tower of dooms with else if else if, ...
Help would be appreciated!

if(!(sender.hasPermission("CustomVersionSeedCommand.allowtabcomplete"))) {
   if (buffer.startsWith("/version")) {
     e.setCancelled(true);
   } else if (buffer.startsWith("/ver")) {
     e.setCancelled(true);
   } else if (buffer.startsWith("/icanhasbukkit")) {
     e.setCancelled(true);
   } else if (buffer.startsWith("/?")) {
     e.setCancelled(true);
   } else if (buffer.startsWith("/seed")) {
     e.setCancelled(true);
   } else if (buffer.startsWith("/about")) {
     e.setCancelled(true);
   }
sleek pond
#

Or whatever the command is

hybrid spoke
idle kindle
vague swallow
idle kindle
waxen plinth
#

Get rid of that import then

round gale
waxen plinth
#

Don't just copy paste your errors here without any thought, pay attention to what it's telling you

#

You already have a Dispenser import

#

There are two Dispenser classes

#

One has the method you want

#

The other doesn't

#

You can't import two classes of the same name

lost matrix
misty current
hasty prawn
#

He loves being pinged, im not sure once every min is constant enough.

misty current
#

i'd speed it up, half the time each ping

#

1min, 30 seconds, 15...

tardy delta
#

i think every second would be better

viral crag
idle kindle
#

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData and org.bukkit.block.data.Levelled are in unnamed module of loader java.net.URLClassLoader @2e5d6d97)

at me.leizd.pluugin.EventsList.onDispense(EventsList.java:28) ~[?:?]

misty current
#

np

idle kindle
#

@lost matrix

lost matrix
idle kindle
#

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData and org.bukkit.block.data.Levelled are in unnamed module of loader java.net.URLClassLoader @2e5d6d97)

at me.leizd.pluugin.EventsList.onDispense(EventsList.java:28) ~[?:?]

lost matrix
#

Look at the corrected code ive sent above the gif

idle kindle
#

Cannot resolve symbol 'SpigotSandbox'

lost matrix
idle kindle
#

?

lost matrix
viral crag
#

The new Case L Switch still has some quirks I dont quite understand

idle kindle
idle kindle
#

how fix

lost matrix
#

Pass the right objects to the method call

idle kindle
#

what object i need to pass i don't understand

haughty storm
dire salmon
#

Does anyone know how can i make a lib?

idle kindle
waxen plinth
#

You using gradle? Maven?

dire salmon
#

Maven

tardy delta
waxen plinth
#

Okay

#

Then you can just export a jar using maven

round gale
waxen plinth
#

And add it locally from another project

#

If you want to not need to add it locally then you need to publish to a repo

dire salmon
#

Ok

round gale
lost matrix
dire salmon
#

Isnt for now tho

lost matrix
waxen plinth
#
Bukkit.getScheduler().runTaskLater(plugin, () -> {
    // Stuff here
}, delay);```
idle kindle
#

public class EventsList extends SpigotSandbox implements Listener {

#

this&

#

?

viral crag
idle kindle
#

import org.bukkit.plugin.java.JavaPlugin;

public final class Main extends JavaPlugin {

    @Override
    public void onEnable() {
        System.out.println("Plugin NewDispensers enable!");
        getServer().getPluginManager().registerEvents(new EventsList(), this);

    }

    @Override
    public void onDisable() {
        System.out.println("Plugin NewDispensers disable!");
    }
}
undone axleBOT
idle kindle
#

what should i do in the code to make it work?

idle kindle
tardy delta
#

?main too

rotund glade
#

Hello, could someone help me understand how I can create a custom entity using the NMS with armorstands in 1.18.1? I have several problems: The name of the fields with the obfuscation are difficult to identify, and for example is it possible to change the size of an armorstand, if so what is the property to modify?

#

and if you know an api that could simplify all this?

quiet ice
#

Read the 1.17 update post or something like that

#

?nms

#

eh

#

You get it

tender shard
#

and for the size: you can only set an armorstand to be a marker or sth like that to make the hitbox smaller, I think there's nothing else you can do to its size

rotund glade
#

Ok thank i try it

vague swallow
#

lmao

#

I can't use PlayerProfiles

#

because required methods of the PlayerProfile are depreciated and marked as error

#

but if I remove them the full PlayerProfile is marked as error

viral crag
#

update them to the new method?

round gale
#

So, how do you assign a non-primitive Short in java?
Short.valueOf("1");?

vague swallow
# viral crag update them to the new method?

No like

This is a PlayerProfile:

PlayerProfile profile = new PlayerProfile() {

};

But between the brackets there are a lot of methods like This one:

@Override
public @NotNull PlayerTextures getTextures() {
     return null;
}

or

@Override
public void setTextures(@Nullable PlayerTextures textures) {

}

But 2 of them are depreciated. Without them the PlayerProfile is marked as error and with them the methods are marked as error

These methods are implemented

#
@Override
public @NotNull String setName(@Nullable String name) {
     return null;
}
``` and ```
@Override
public @Nullable UUID setId(@Nullable UUID uuid) {
     return null;
}

Are marked as depreciated

viral crag
#

update()

vague swallow
#

where do I have to put that?

viral crag
#

hmm, creates new profile does not change existing ...

viral crag
# vague swallow where do I have to put that?

no i am wrong, those two you can no longer change without creating a new one:
"A player profile always provides a unique id, a non-empty name, or both. Its unique id and name are immutable, but other properties (such as its textures) can be altered."

vague swallow
#

So what do I need to do now?

viral crag
#

either use update to async create a new player profile or clone - UUID and name are now immutable to prevent conflicts?

viral crag
elfin steppe
#

Can someone tell me how I can disable a player losing HP when they get hit, they are still supposed to be able to hit someone n the person who gets hit needs to take knockback but without losing any hp.

crimson terrace
#

entityDamageEvent, give the hp they lose back to them

#

not sure if they would take knockback when you cancel that event

grim ice
#

give lib ideas uwu

ivory sleet
#

Hmm, its quite unfortunate the comment pr to the configuration api was directly merged into FileConfiguration and such

#

If anyone has any suggestions on how perhaps one could handle sth like JsonConfiguration with the existing api, please lmk 🙂

terse lily
#

how to import some .java file from work/decompile-XXXXX/ to CraftBukkit/src/main/java/<...>?

#

I know there is dev-imports.txt on forks but I don't see anything like this on spigot

lean gull
#

can someone explain to me how to make a player hold an item like a loaded crossbow with protocollib packets? like when you hold a crossbow it is held up, and i would like to make that but with non crossbow items

haughty storm
#

I'm getting this error msg when loading my plugin.

java.lang.NoClassDefFoundError: net/minecraft/server/level/ServerPlayer
        at de.firecreeper82.testpl.TestPl.register(TestPl.java:27) ~[?:?]
        at de.firecreeper82.testpl.TestPl.onEnable(TestPl.java:17) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:521) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:435) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
        at java.lang.Thread.run(Thread.java:833) [?:?]

It says it couldnt find the ServerPlayer class but I imported in my code

import net.minecraft.server.level.ServerPlayer;

And in my pom.xml arent any errors but on the right hand side it gives me an error at the dependencies

chrome beacon
#

Replace every 1.18 with 1.18.1 in the second screenshot

haughty storm
#

thx

chrome beacon
#

Also make sure to actually use maven when compiling

haughty storm
#

ok

#

It works thx

eternal needle
#

can some one make a smal thing that do so i can't shot arows on others i overworld? and not nether and the end? pls and tag me

grim ice
#

do u wanna code it urself

vocal cloud
#

Can't shoot arrows at others at all? What

grim ice
#

or do u want others to do it for you

#

@eternal needle

eternal needle
grim ice
#

what

#

so you wanna code it yourself

eternal needle
#

No

grim ice
#

then who is supposed to code it

eternal needle
#

I Ask if sone one want to do it

grim ice
#

dont expect people to make stuff for free

trail pilot
#

which better

String.format StringBuilder MessageFormat.format

#

or default like
"LOL." + player + ".IDK"

ivory sleet
#

"LOL." + player + ".IDK" compiles to some efficient concats, only reason you'd use StringBuilder would be in a loop

trail pilot
#

wating for cool answers

ivory sleet
#

String.format() is slow but readable

river oracle
ivory sleet
#

if you cache the string, then its doable

#

MessageFormat is similar to String.format

trail pilot
#

oh, so default its the best option?

ivory sleet
#

depends on situation

trail pilot
#

world x y z yaw pitch

ivory sleet
#

what does that have to do with string concatenation and string formation

trail pilot
#

and utils classes need to have all static methods?

ivory sleet
#

yes

#

the idea is that every utility is pure and stateless

trail pilot
#

oh ok

#

and should be initialized?

ivory sleet
#

well

#

no

trail pilot
#

like Utils utils = new Utils;

#

ah ok

ivory sleet
#

basically for any utility function, given the same input, the same output

#

thats useless

#

as its stateless and pure

#

so having an instance of it would just be useless

trail pilot
#

alright

ivory sleet
#

int square(int i) {
return i * i;
}

#

this is a utility function

#

regardless of circumstance

#

if I send in 2, I always get 4

trail pilot
#

oh

next stratus
#

hey, I had to shade some more things into my plugin and because of the file size it won't let me? What should I do?

ivory sleet
#

tho these would be stateful functions thus cant be utility functions:
Object getOwner() {
return this.owner;
}

void setOwner(Object newOwner) {
this.owner = newOwner;
}

next stratus
ivory sleet
#

it depends on some state, right

#

and then we have methods like

#

Collections.shuffle()

#

and they are not utility functions either

#

just static helper functions

trail pilot
#

yea

ivory sleet
#

as they manipulate state

glossy venture
# next stratus ?

i dont know how it would work exactly but maybe create a file libs.txt with urls, parse it and download all jar files from the urls and then load them dynamically

#

there should be a library for that

next stratus
#

but I use gradle

#

people are saying that obfuscating it makes it smaller but I don't wanna do that

ivory sleet
#

you just leaped from strings to sth completely else

glossy venture
trail pilot
next stratus
#

I can't even set a 3rd party link

ivory sleet
glossy venture
ivory sleet
#

concatenation means basically joining/merging

next stratus
glossy venture
#

?

ivory sleet
#

so "a" + "b" is string concatenation as you're joining/merging strings

next stratus
elfin steppe
#

like it gets me to 8.5 then it stays there then i regen to 9 then it goes back to 8.5 etc

#

while he keeps hitting me

crimson terrace
#

just put it back to the Attribute.GenericMaxHealth.getBaseValue() maybe?

elfin steppe
#

if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
}

#

so j like that?

#

well dont really need the variable but anyways

raw ibex
#

the easiest way i've thought of making a bedwars plugin is using a togglable event handler, but i don't know if that is the way to go (i have started this). any suggestions??

trail pilot
#

an other question

what's is the best option:
HomeUtils.saveHomesFile();
or
import static dir.HomeUtils.saveHomesFile;

#

I never understood what changes

elfin steppe
undone axleBOT
ivory sleet
#

usually it causes a lot of confusion as you don't see the caller

trail pilot
ivory sleet
#

(its fine in some very special cases but generally avoid it)

#

nw :]

elfin steppe
#

Conclure can you help me out?

ivory sleet
#

Sure, what's the issue?

elfin steppe
#

I need a player to take knockback on a hit but to not lose any health

raw ibex
#

can't you just set damage to 0

elfin steppe
#

But i can't just do sethealth 20 on entitydamage event

lost matrix
elfin steppe
#

7smile7 then they wont take knockback either

#

or

#

am i dumb

raw ibex
#

no

#

just set the damage to 0

elfin steppe
#

Alrighty

trail pilot
#

an other good question how i can save data when player quit in this case his home

#

so the server dont need to debug always

raw ibex
lost matrix
ivory sleet
#

xnotro yeah tho I'd suggest to eagerly save data if possible

trail pilot
#

because this plugin create home when you do the command and instaly save it

ivory sleet
grim ice
#

any lib idea

next stratus
#

hey, how can I only compile certain modules fro mthe XSeries?

trail pilot
#

because of the method

saveHomesFile();

lost matrix
trail pilot
#

really simple

ivory sleet
#

OrlaDev of course you could unregister and re-register the given listener

#

but that comes with some drawbacks

raw ibex
#

is that the best way though

#

i was just wondering

ivory sleet
#

mainly that you probably want to rebake the handlers after re-registering to achieve better performance

elfin steppe
#

Just EntityDamageEvent?

raw ibex
ivory sleet
#

which if there are many listeners and event executors registered will probably halt the server

elfin steppe
# raw ibex EntityDamage Event

@EventHandler
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.ge();
p.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(0);
}
}
Can u tell me what i'm forgetting

ivory sleet
#

so go with what smile said

ivory sleet
signal meteor
#

how can i make a function in java ?
i dont understand the articles in the internet :/ i want to teleport a player to a location, but thats too many code to use everytime. so i want to create a function like "player.resetlocation()" :D

elfin steppe
raw ibex
#

e.setDamage() iirc

elfin steppe
raw ibex
#

@elfin steppe

elfin steppe
#

so no need to do attribute

lost matrix
raw ibex
undone axleBOT
lost matrix
#

Spigot is not beginner friendly

raw ibex
haughty storm
#

how would I make a ServerPlayer behave like a dog, so it would follow you around and attack enemies

lost matrix
ivory sleet
#

OrlaDev do it like

boolean shouldRunSomeEvent;

@EventHandler void onSomeEvent(SomeEvent event) {
  if (shouldRunSomeEvent) {
    //TODO: ACTUAL LOGIC
  }
}

void shouldRunSomeEvent(boolean toggle) {
  shouldRunSomeEvent = toggle;
}```
#

tho ofc that design isnt particularly scalable

#

but you get the gist of it

haughty storm
elfin steppe
haughty storm
ivory sleet
#

or at least nms

lost matrix
#

Means you cant just throw all the AIGoals of Wolfes at it.

haughty storm
trail pilot
#

IJ IDEA its suggest to add @NotNull to my Utils Methods

lost matrix
trail pilot
lost matrix
#

Just disguise a Wolf as a player.

haughty storm
quiet ice
trail pilot
quaint mantle
#

How can I change the radius and damage of a fireball's explosion thrown by a custom item?

raw ibex
raw ibex
#

well we don't know anything about your custom item

#

what item is it?

glad radish
#

Should be able to modify the explosion power of it directly

#

Fireball is what they said

#

Not charge

quaint mantle
raw ibex
#

ok

#

how are you firing the fireball

tall dragon
haughty storm
quaint mantle
lean gull
#

anyone have a good tutorial on creating a 1.18.2 plugin with maven? i usally use the Minecraft Development plugin in IntelliJ but it doesn't have 1.18.2

glad radish
#

Looks like the method call you need is setYield() and should be able to run that off any explosive thing

lean gull
eager sapphire
#

Does anyone know if there is an event for when a shulker box, as a dropped item, is destroyed and then it vomits out its contents?

raw ibex
viral crag
# lean gull huh?
   <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>
raw ibex
#

i didnt know that

quaint mantle
tall dragon
tall dragon
#

you would need to listen to EntityExplodeEvent and set the damage yourself probably

quiet ice
quaint mantle
quiet ice
#

And it sure isn't a particle (those are usually smaller) and isn't a block at all

raw ibex
tall dragon
#

well, its like geol explained

raw ibex
#

i thought that they didn't exist in vanilla

#

im dumb :)

quiet ice
#

Pretty sure the dragon throws them too

tall dragon
#

dragon throws other things

raw ibex
#

yea

tall dragon
#

not sure the name is rn

quiet ice
#

Yeah idk

raw ibex
#

they throw particles

tall dragon
#

no

#

pretty sure he throws something similar

#

yea

#

DragonFireball

#

aperantly

raw ibex
#

ok

quiet ice
#

Well, close enough ;)

raw ibex
#

didn't realise that

tall dragon
#
public interface DragonFireball extends Fireball {}

which is. well... haha

raw ibex
#

being the idiot i am

lean gull
#

how do i open buildtools to look at all the craftbukkit, bukkit, spigot stuff? i forgor

raw ibex
#

it's basically a fireball

tall dragon
#

yup

quiet ice
#

?stash

undone axleBOT
tall dragon
#

i think its purple instead of flamy

quiet ice
#

Yeah

#

Stash is fine as long as you don't want to see nms

eager sapphire
#

Sorry for the immediate-reask, I got kinda drowned but also guessing this is just not a thing:

Does anyone know if there is an event for when a shulker box, as a dropped item, is destroyed and then it vomits out its contents?

eager sapphire
#

if you throw a shulker box in lava is the easiest way

next stratus
eager sapphire
#

but also if it explodes while dropped

tall dragon
eager sapphire
#

like from a creeper or fireball or whatever

#

no

#

well yes, in lava

#

unless they are netherite

#

but in the creeper/fireball/explosion case, the items inside the box survive regardless

#

it's a very specific/weird behavior I only just learned about but is causing me some dupe exploit headaches.

#

It seems like there's no real way to catch it

viral crag
#

in what version?

eager sapphire
#

1.18, but I think it's been like this since 1.17 or maybe 1.16

tall dragon
#

@eager sapphire you could test if EntityDeathEvent is fired

eager sapphire
#

I want to say Mojang changed it specifically to avoid netherite tools burning when inside a shulker box thrown in lava 😐

eager sapphire
tall dragon
#

im not sure. but i think it should be called when a shulker box item gets destroyed

#

you can get the item being destroyed

#

& get its contents?

eager sapphire
#

true, then again scan for the dropped items, check if it was something in the shulker box, etc

#

still very messy, an event would be nice but I'm guessing it doesn't exist

quiet ice
#

It's interesting as I have never heard about this feature, but is plausible and it makes fully sense that this would yield exploits

tall dragon
#

well, no dedicated event no.

eager sapphire
#

I had never heard about this feature either, until someone came complaining to me about exploits 😂

tall dragon
#

yea i never heard of this either

quiet ice
#

It should def. get an event however

eager sapphire
#

it is very much true though

#

I spose I could PR one 😄

vocal cloud
eager sapphire
viral crag
#

public static final GameEvent BLOCK_DESTROY should fire as a shulker is listed as a block

velvet minnow
#

Hi ! 😄
There is a way to set nbt to an item without use NMS ?

quiet ice
#

Bukkit unsafe

eager sapphire
#

If you want to use NBT to store your own custom data

viral crag
#

true

eager sapphire
#

not to hack up vanilla tags, there will probably never be an API for that 🙂

quiet ice
#

But beware, the bukkit unsafe is ... unsafe - better use NBT APIs

tall dragon
#

very good api in my experience

eager sapphire
#

Possible X/Y problem why do you want NBT access? 😄

vocal cloud
#

You use the PDC if you're using a modern spigot version

velvet minnow
quiet ice
#

Just note that there is literally 0 documentation on this method so you are on your own when using it

eager sapphire
#

What tags? ItemMeta should cover just about evrything

#

Really better to use the API unless you have an extremely exceptional case

velvet minnow
#

CustomModelData
Or may be i'm wrong and it's not a nbt ? 😛

vocal cloud
#

Ah good old xy problem strikes again

tardy delta
velvet minnow
#

Thanks for your responses 😛

tardy delta
eager sapphire
eager sapphire
tall dragon
#

ah really

viral crag
#

then try GameEvent BLOCK_DESTROY will be noisy though

tall dragon
#

continue;

trail pilot
#

X: 358.2213934122428

uhm why its save like that?