#help-development

1 messages · Page 939 of 1

dawn flower
#

the Block one is getState tho

chrome beacon
#

you don't need the block you can get it directly from the world

dawn flower
#

wait why do people fork spigot for certain servers, wouldn't you have the same stuff as using NMS

shadow night
#

yeah, why

dawn flower
#

i mean you can do some extra stuff like crash detection unlike spigot but that's pretty much all that i can think of

#

nvm u prob cant do crash detection\

shadow night
#

why

#

tyr {}

#

sec

nova bolt
#

it worked in the past

dawn flower
shadow night
#
try {
    new MinecraftServer().run();
} catch(Exception err) {
    LOGGER.error("Crash detected!", e);
}
``` looks like a bad idea but it's a crash detection lol
lost matrix
shadow night
#

what

dawn flower
#

smartest person in the world

shadow night
#

bukkit is an API, craftbukkit is the implementation of bukkit, spigot is a fork of bukkit, paper is a fork of spigot

dawn flower
#

paper = bukkit + spigot

lost matrix
dawn flower
#

i mean i know worldguard is pretty old but it was written for spigot?

lost matrix
#

I mean originally it was written for bukkit. They made it platform agnostic after a while.

peak jetty
#

why does this not work?

shadow night
#

mm, hardcoding locations

lost matrix
#

Because you didnt get the BlockState.
Also getting a World like that is dangerous

shadow night
#

everything in this screenshot is dangerous

worldly ingot
#

It's not the Block that's a Chest, it's its state

peak jetty
#

oh so like this? Chest chest1Level1 = (Chest) l.getBlock().getState();

nova bolt
#

problem*

lost matrix
#

Think about Block just describing a position in the World.
It has no actual properties.

lost matrix
remote swallow
peak jetty
#

i changed it to this but it still didnt work:

Location l = new Location(getWorld("poi"), 67, 137, 79);
Chest chest1Level1 = (Chest) l.getBlock().getState();
chest1Level1.getInventory().setItem(1, new ItemStack(Material.DIRT));```
lost matrix
#

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

peak jetty
#

like it doesnt make the item in the chest dirt

shadow night
#

have you tried the magical thing called debugging

lost matrix
#

You need to call update(true) on the Chest after changing the state

shadow night
lost matrix
peak jetty
scenic sigil
peak jetty
#

wait ima try use some loggers

lost matrix
worldly ingot
#

Not when editing a state's inventory

#

Inventories are a bit special :p

lost matrix
#

Yea realized as well

nova bolt
remote swallow
lost matrix
# nova bolt yep

Then check the logs. If the plugin is red then there is a stack trace.

peak jetty
#
 else if (cmd.getName().equalsIgnoreCase("reloadpoiloot")) {
            getLogger().info("reload poi loot command called");
            // If it's a player and has plutotools.reloadpoiloot or if it's console
            Player p = ((Player) sender).getPlayer();
            if ((sender instanceof Player && p.hasPermission("plutotools.reloadpoiloot")) || sender instanceof ConsoleCommandSender) {

                getLogger().info("player has all permissions");

                Location l = new Location(getWorld("poi"), 67, 137, 79);
                Chest chest1Level1 = (Chest) l.getBlock().getState();
                chest1Level1.getInventory().setItem(1, new ItemStack(Material.DIRT));
                chest1Level1.update(true);

                getLogger().info("works");

            }
            return true;
        }```

still doesnt work for some reason
lost matrix
#

Are the debug statements being printed?

peak jetty
lost matrix
dawn flower
#

does getInventory return a copy

peak jetty
dawn flower
#

CraftInventory inventory = new CraftInventory(chest);

and

// The logic here is basically identical to the logic in BlockChest.interact

#

in CraftChest

lost matrix
peak jetty
#

and it doesnt let me set the slot number

lost matrix
#

Try it out pls

dawn flower
#

try Chest#getBlockInventory

#

instead of getInventory

peak jetty
peak jetty
dawn flower
#

and update

lost matrix
peak jetty
peak jetty
# dawn flower and update

yeah im doing that

Location l = new Location(getWorld("poi"), 67, 137, 79);
Chest chest1Level1 = (Chest) l.getBlock().getState();
chest1Level1.getBlockInventory().addItem(new ItemStack(Material.DIRT));
chest1Level1.update(true);```
lost matrix
dawn flower
#

try to print a filled slot from the chest's inventory to make sure you have the correct instance

lost matrix
#

What does your PlayerInteractListener do?

peak jetty
peak jetty
worldly ingot
#

I'm not 100% certain but wouldn't the update() override the inventory change?

lost matrix
#

That might be possible

worldly ingot
#

It's really the only thing I can think of causing issues

worldly ingot
#

block states are a bit finnicky

nova bolt
#

it says this

lost matrix
#

There you go

nova bolt
#

do i need to change the server version

chrome beacon
#

yes

lost matrix
#

Or use an older version of wg

chrome beacon
#

^^

nova bolt
lost matrix
#

Why are we giving server help in the development channel btw?

chrome beacon
#

no idea

lost matrix
nova bolt
#

k

worldly ingot
#

You're also using Paper 😛

#

So in the future, even if it's not specifically server software dependent, it's best you ask for support in the Discord server of the server software you're actually using

agile hollow
#

how can i brodcast all the args after the 0?

lost matrix
agile hollow
#

like a done a command that work like /brodcast alert - - - - i want all the args after the "alert" then after the args[0] to show up in the brodcast

peak jetty
#

how should i make a list of contenents (multiple items) to go into a chest?

lost matrix
peak jetty
lost matrix
#

Alterantive would be setContent() by passing an ItemStack[] to the Inventory.
But this expects an array of the exact size as the inv

lost matrix
peak jetty
#

well i want to have multiple chests with the same contents so i dont really want to repeat setItem() for all of them

lilac dagger
#

have a method that takes an inventory as parameter

lost matrix
lilac dagger
#

we all like WET code around here

#

||I hope nobody's offended haha||

lost matrix
twin venture
quiet ice
lilac dagger
#

lol, chatgpt found the best answer 'Write Everything Twice'

peak jetty
lilac dagger
#

it can't be bigger than 54

#

but the inventories have to be the same since the content is?

peak jetty
#

so if this is my content say:

public void contents1Level1(Inventory i) {
        i.setItem(1, new ItemStack(Material.ENDER_PEARL));
    }```

how do i set it to be in the chest? `chest1Level1.getBlockInventory().setContents();`
lost matrix
#

You pass the chests inventory to the method...

lilac dagger
#

exactly ^

#

now it depends if that's the correct inventory, blockstate usually works differently than you'd assume

peak jetty
#

like this? contents1Level1(chest1Level1.getBlockInventory());

lilac dagger
#

yeah

peak jetty
#

alr

worthy star
#

whats best way to check when player enters a region with worldguard api?

rough ibex
#

I suppose you should ask enginehub people.

worthy star
#

whats that?

rough ibex
#

The people who make worldedit and worldguard

worthy star
#

oh you mean the creators of it

rough ibex
#

Yes; they would know their API more than us collectively.

worthy star
#

ok

rough ibex
#

good luck

agile hollow
#

When i try to start the server with a plugin where i put mysql database it gave me that error:


[21:16:01 WARN]:        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:708)

[21:16:01 WARN]:        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:253)

[21:16:01 WARN]:        at org.giutv.gkitutils.database.DataBase.<init>(DataBase.java:12)

[21:16:01 WARN]:        at org.giutv.gkitutils.Gkitutils.onEnable(Gkitutils.java:44)

[21:16:01 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)

[21:16:01 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)

[21:16:01 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)

[21:16:01 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357)

[21:16:01 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317)

[21:16:01 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414)

[21:16:01 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378)

[21:16:01 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333)

[21:16:01 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263)

[21:16:01 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525)

[21:16:01 WARN]:        at java.base/java.lang.Thread.run(Thread.java:1623)```
eternal oxide
#

Running 1.8 means you have to init your driver Class.forName(...

agile hollow
#

i do it

        this.connection = DriverManager.getConnection("jdbc:sqlite:"+file);
        Class.forName("org.sqlite.JDBC");
        createTable();
    }
eternal oxide
#

class forName BEFORE you try to use it

spare hazel
agile hollow
rough ibex
#

1.8....

#

please

agile hollow
rough ibex
#

1.8 is what, 8 years old

#

why are you still targeting it

agile hollow
rough ibex
#

not for anything else lol

agile hollow
#

10y ago

rough ibex
#

yeah legacy

agile hollow
rough ibex
#

yes

#

1.20 is latest and updated

agile hollow
remote swallow
spare hazel
#

and their custom drops

remote swallow
#

a) dont use new BlockData but Material.VALUE.createBlockData() and b) why do you even need block data here, just use a material to material map for drops

bleak moth
#

Hi, my plugin has a big problem, i write to a file to get information about a score, the score is binded to a player and saved to the file. I have a command to set the score of the player, but when i do that or edit the file myselfe it doesnt change on save or it seeems to get it old value back after some time. I use a .yml file

echo basalt
#

Show code

#

solid chance you aren't saving the file

spare hazel
#

and the BlockData is class of my plugin

bleak moth
echo basalt
#

Go for it

lost matrix
spare hazel
#

question:

static private
private static

which one is better

lost matrix
#

latter

eternal oxide
#

better?

lost matrix
#

Access modifier always comes first

spare hazel
bleak moth
echo basalt
#

Repo's private

bleak moth
#

oh sry wair

bleak moth
inner mulch
#

when i want to have placeholders, but they all can have completely different parameters. How would I implement that, an interface doesnt work as the placeholders all have different params?

echo basalt
lost matrix
echo basalt
#

if you want a good data structure for placeholders keep in mind they're basically like a little scripting lang

inner mulch
astral scroll
#

i need the actual durability of a picaxe, but ItemStack#getDurability is deprecated, whats the new method to get that?

echo basalt
inner mulch
#

in code it would work

#

but not in a config

bleak moth
lost matrix
# inner mulch but not in a config

Example:
Your separation char is #
Your placeholder key is chance
It has one parameter:
%chance#<value>%
Then a placeholder in a config could be:
"%chance#15.25%"

In your implementation your simply parse for all Strings between two %. Then you split it at #.
The first entry is your placeholder key, the other entries are your String[] args like you would have in a command.

inner mulch
lost matrix
inner mulch
#

what?

#

placeholder needs player specific input, how am i gonna get player specific details

astral scroll
echo basalt
#

getDamage on the itemmeta damageable yeah

inner mulch
#

Damageable idk = (Damageable) itemmeta;

echo basalt
#

.damage is probably a method from the entity damageable

astral scroll
#

ohh

#

inventory.meta

#

cool

lost matrix
astral scroll
#

do people like kt around here?

inner mulch
alpine urchin
#

i dont

#

but im closed minded

inner mulch
lost matrix
#

Remember that your placeholder always has the viewer as its first context:

public String evaluate(Player viewer, String placeholder, String[] args)

And then you simply treat it the same way as bukkit commands

river oracle
#

Anyone know how to fix MockBukkit just like not running 🥲
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.Server.getRegistry(java.lang.Class)" because "org.bukkit.Bukkit.server" is null
This is my setup for gradle

plugins {
    id("crown-module")
}

repositories {
    maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
    testCompileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
    testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
}```

https://paste.md-5.net/egoteqizug.m
astral scroll
#

whats MockBukkit for?

slender elbow
#

mocking bukkit

slender elbow
#

you're welcome

river oracle
#

someone should give you an award

slender elbow
lost matrix
inner mulch
lost matrix
inner mulch
#

what does a entity with no ai does in its tick method, and how expensive is it compared to a entity created with packets?

astral scroll
#

to set durability what can i do?

lost matrix
lost matrix
inner mulch
lost matrix
#

Depends a bit on what you are doing
Salvatíoné

astral scroll
#

i just wanna

#

subtract

#

10 from the actual durability

#

so i can do

#

setDamage(getDamage+10)

inner mulch
radiant vessel
#

I am trying to rework a plugin called "FactionMobs" which is deprecated, and the point of it is to allow players to spawn mobs are allied with their Nation in Towny, now I have no problem with any of that except one part, and it is how do I make mobs attack a specific player yet be friendly to another? Does anybody know of a Library made for controlling mobs and their behaviors? If not, then I would appreciate if I was given a simple Idea from one developer to another on how to do something like

#

I can know who is the enemy, and I can know who is supposed to be friendly, and I know how to do everything else it's just the mob control part I can't get

young knoll
#

EntityTargetLivingEntityEvent

#

Iirc

radiant vessel
#

Like this seems like it just readjusts the pathfinding

#

ahh whatever I will try it

#

Thanks for the idea

#

I appreciate it

young knoll
#

You can cancel it under certain conditions

short pilot
#

Intellectuals, i require your help once again
how can you get generic attack damage attribute from an entity? I want to get the total damage a player can deal with their main hand plus effects and enchants, but i'm not sure if generic attack damage alone gets this

young knoll
#

It does not

#

There is no api to get that easily

short pilot
#

ok so getattribute works

#

and i'm grabbing GENERIC_ATTACK_DAMAGE

astral scroll
#

can i send kt code or i will not receive support

short pilot
young knoll
#

Get the held item and get the level of sharpness

#

Then do the maths

frail wave
#

good evening I am looking for a java developer for minecraft server for the pvp factions theme with a price of £86.21

#

is it possible to redirect me to a developer

hazy parrot
#

?services

undone axleBOT
young knoll
#

Very specific price

hazy parrot
#

Also, where did u find that 0.21 xd

frail wave
remote swallow
#

conversion rate?

frail wave
#

100euro=86.21£

astral scroll
#

this is my code

#

and the picaxe durability isnt changing

#

what could be going wrong?

spare hazel
#

i feel guilty not pulling before pushing on a repo that only i have access to. should i pull before pushing on a fully private repo?

astral scroll
#

why

#

only you make pushes

#

lol

#

even in pubhlic repos i make push request without pulling

remote swallow
#

unless you modified any files on github your fine

astral scroll
#

and then i get flamed

spare hazel
#

and what is the difference between commiting and pushing

astral scroll
#

commiting is stored in ur local machine

remote swallow
#

you cang push without committing

astral scroll
#

pushing just passes all the commits in ur local machine to the remote repo

spare hazel
#

oh thanks

glad prawn
astral scroll
#

kt has integrated getters and setters

#

:/

glad prawn
#

it looks really strange 😭

astral scroll
#

yeah it does

#

but it isnt that

#

i just dont know what else to doo

young knoll
#

Are you setting the meta back

spare hazel
#

i wanted to die looking at that kotlin code

spare hazel
astral scroll
#

but it does changes the stuff

#

btw

#

item.durability = (amount you want to subtract)

#

that works

#

lol

#

strangely but works

glad prawn
#

deprecated method im pretty sure

young knoll
#

You have to set the meta back

spare hazel
#

why is the author name BuildTools when i push? i want it to be my github name

lilac dagger
#

there's a file

spare hazel
#

where

young knoll
#

Buildtools used to override your global git name

#

That’s fixed now, but you’ll have to fix your global stuffs

spare hazel
#

where and how

sullen marlin
#

*set it by default, it never overrode settings

spare hazel
#

no way md_5 is here

young knoll
#

Ah

spare hazel
#

thanks

topaz cape
#
player.launchProjectile(ThrownPotion.class, new Vector(0, 0, 0)).setItem(this.healItem);
#

anybody know a way that makes it look if i threw the actual potion not a water bottle

remote swallow
# astral scroll

that damageable varable can be defined as just item.itemMeta s Damageable

#

without any parenthesis

drowsy helm
lilac dagger
drowsy helm
#

yeah what is healItem

topaz cape
#

it is defined, and its a heal potion whenever it hits the ground

#

however when its shot its visually is still a water bottle

topaz cape
drowsy helm
#

can you show the whole code snippet

topaz cape
#

        if (this.shouldHeal()) {
            if (NPCUtil.consumeItem(npc, this.healItem)) {
                if (healItem.getType() == Material.POTION) {
                    final int heal = healItem.getDurability() == 16453 ? 2 : 4;
                    bot.setHealth(Math.min(bot.getMaxHealth() + heal, bot.getMaxHealth()));
                    bot.launchProjectile(ThrownPotion.class, new Vector(0, 0, 0)).setItem(this.healItem);
                }
            }
        }
lilac dagger
#

i remember the colors of the potions were off for me

#

i had to do something weird to make them work

topaz cape
#

I think creating the NMS entity would fix it

#

but im asking if there is a bukkit api for it

spare hazel
#

how can i convert a Material[] to an ArrayList<Material>

topaz cape
#

maybe somehow convert the potion to an entity

young knoll
spare hazel
#

oh thanks

topaz cape
#

xd

#

but yes im testing on 1.8 upwards

drowsy helm
#

yeah but that looks fine with me tbh

#

might have to fuck with packets

topaz cape
#

nah i think its just creating an NMS entity

#

no need to get to packets

drowsy helm
#

lmk how it goes

topaz cape
#

alright

spare hazel
#

how can i get the friendly name of a material

drowsy helm
#

the friendly name?

spare hazel
#

and if your hand is empty, will player.getInventory().getItemInMainHand().getType() return null

spare hazel
remote swallow
#

split on _ get first char, uppercase and replace

drowsy helm
#

and yeah, no method for it, either use the itemstack to get displayName from meta or do waht Epic say on material

remote swallow
#

display name wont exist for un renamed items

spare hazel
#

guess its time to get googling

#

or use chatgpt that might be a better aproach

remote swallow
#

make something using what i said

#

using chatgpt for everything wont help learning

drowsy helm
#

you didnt google before you asked on here?

spare hazel
#

i barely know how to format text in java

spare hazel
remote swallow
#

you really should be googling before coming here

echo basalt
#

blocked.

remote swallow
#

because thers a solid chance sometimes the answer you are looking for takes 1 second to find

spare hazel
#
 public static String getFriendlyText(String text){
        //Credits To My Bro ChatGpt
        String[] words = text.toLowerCase().split("_");
        StringBuilder result = new StringBuilder();

        for (String word : words) {
            if (!word.isEmpty()) {
                result.append(word.substring(0, 1).toUpperCase())
                        .append(word.substring(1))
                        .append(" ");
            }
        }

        String finalText = result.toString().trim();
        return finalText;
    }```
glad prawn
#

just return then, why temp var

spare hazel
final wharf
#

how can i get the block under the player and set it to a random block?

sand spire
final wharf
#

thanks

obsidian wolf
#

anyone know how to code on java? need help with a simple custom item

tawdry echo
drowsy helm
obsidian wolf
#

im trying to make a custom item and I coded everything for it using a tutorial

#

however for some reason when i load into minecraft the actual texture doesn't load.

drowsy helm
remote swallow
obsidian wolf
#

can I send you my code and show you what i mean?

drowsy helm
#

?paste

undone axleBOT
drowsy helm
#

put it on that

obsidian wolf
#

Alright

#

then what

final wharf
obsidian wolf
#

like.. how

#

lmfao

#

{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "minecraft:item/diamond_sword"
},
"overrides": [
{"predicate": {"custom_model_data": 40000}, "model": "minecraft:item/kingsword"}
]
}

and

{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "minecraft:item/kingsword"
}
}

#

separeted into 2 files ofc

tawdry echo
lost ledge
#

Is there some better way of checking if the server runs raw bukkit, spigot or any other fork than doing Class#forName?

obsidian wolf
#

i made the texture for it as well if you need me to send that

drowsy helm
#

@tawdry echo

                inv.getListeners().stream()
                        .filter(listener -> listener.getEvent() == InventoryDragEvent.class)
                        .forEach(listener -> ((GuiListener<InventoryDragEvent>) listener).run(e));

could be replaced with a for loop and if statement, will be a lot more performant

The use of the gui map is good

but yeah, move that static listener bs elsewhere

hazy parrot
drowsy helm
#

and it breaks bukkit conventions

obsidian wolf
spare hazel
drowsy helm
final wharf
obsidian wolf
remote swallow
obsidian wolf
#

supposed to show a png of a sword i made

tawdry echo
obsidian wolf
#

but its just a normal diamond sword

remote swallow
spare hazel
drowsy helm
#

just an fyi this has nothing to do with java, it's minecraft resourcepack stuff.

but you're 100% the custom model data is applied to the item?

remote swallow
#

calling println will tostring it for you

drowsy helm
#

and is kingsword in the item directory

final wharf
obsidian wolf
#

i believe so

remote swallow
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

drowsy helm
obsidian wolf
#

alright

spare hazel
#

wird

#

weird*

#

its {}

#

how would that be

remote swallow
#

double check you are actually registering the join event

#

and make sure your restarting

spare hazel
#

oh

final wharf
#

also forgot a ;

#

so i did that

#

but

#

i dont know what else to put

spare hazel
#
//Register Stuff
        getServer().getPluginManager().registerEvents(new BlockBreakHandler(), this);```

Proof That Im Blind:

```java
public void registerHandlers() {
        getServer().getPluginManager().registerEvents(new BlockBreakHandler(), this);
        getServer().getPluginManager().registerEvents(new PlayerConnectionHandler(), this);
    }```
#

thanks btw Epic

final wharf
#

nvm

#

i think i did it

#
    @EventHandler
    private void onPlayerMove(PlayerMoveEvent event){

        List<Material> blocks = new ArrayList<Material>();
        for (Material block : Material.values()) {
            if (block.isBlock()) {
                blocks.add(block);
            }
        }
        Material randomBlock = blocks.get(new Random().nextInt(blocks.size()));

    }```
drowsy helm
#

pre-bake the list/array

#

orelse you are calling that each time ap layer moves

sand spire
spare hazel
final wharf
#

eh

#

its just for fun

#

and it also doesnt work

#

do i have to register the event even if its in the main class?

glad prawn
#

private method 🤔

drowsy helm
#

you have to register the main class itself

final wharf
drowsy helm
#

even if it is JavaPlugin

spare hazel
final wharf
#

oh

drowsy helm
#

but that code is gonna lag your server

final wharf
#

im a begineer and a friend of mine who knows java told me to try and do this

#

to learn

spare hazel
#

alright

#

but make sure to prebake the list and change the block only if he switched to a new rounded xyz location

sand spire
final wharf
#

i just didnt register it

drowsy helm
final wharf
#

still not working

#

lol

spare hazel
#

if you are learning you need to also learn to optimize your code @final wharf

glad prawn
#

?notworking btw

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.

final wharf
#

but for a few minutes it doesnt hurt

sand spire
lilac dagger
#

java 8 i assume?

spare hazel
final wharf
spare hazel
#

bump it up

final wharf
glad prawn
#

Point to it and see what it says?

spare hazel
#

check the problems tab of your editor

lilac dagger
#

then you imported the wrong List

spare hazel
#

and right click on it

final wharf
spare hazel
#

yeah that

lilac dagger
#

it is the wrong version

final wharf
#

How?

spare hazel
#

click on it

final wharf
#

i created the plugin with java 21

final wharf
spare hazel
sand spire
# final wharf "of" is underlined

You can try List<Material> blocks = Material.values(); then check the error and see what intellij suggests, for me it suggested List.of

glad prawn
#

can use Arrays.asList

final wharf
#

still not working

#

what

sand spire
remote swallow
#

thats some spoonfeeding and a half

final wharf
#

i kinda understand better from spoonfeeding(personally)

sand spire
#

xdd

final wharf
astral scroll
#

how can i destroy an itemstack?

#

like just

#

disappear it?

pseudo hazel
#

I mean sure, you understand just this very specific usecase and way to do this very thing, but its not really applicable to find your own solutions later down the line 😛

sand spire
glad prawn
final wharf
#

Oh yes

#

Sorry

#

I can fix it from now(maybe)

#

Thanks

sand spire
#

i got it to work xd

#

if you can't figure it out I can send you

spare hazel
#

you also need to make sure the block is solid with isSolid

sand spire
spare hazel
#

yeah right

sand spire
spare hazel
#

were turning this guys random project to a full on minecraft gamemode XD

sand spire
#

xdd

spare hazel
#

and maybe use mfnalex's PDC for blocks so we dont replace already randomized blocks

sand spire
#

😳

spare hazel
#

and maybe replace the block with its original block after like 100 seconds

sand spire
spare hazel
#

an make sure the player cannot break non random blocks

sand spire
#

was fun to code something that doesn't give me a headache 💀

flint coyote
sand spire
#

both would work, one would just be persistent on restart

spare hazel
flint coyote
#

If they stay randomized forever I'd agree on using pdc. But if you wanna reset them after a short time it's not required to make it persistent

sand spire
#

that would be cool if they turn back like disco floor

spare hazel
#

gotta put random blocks smp on my game mode todo list for my server

#

time to push to master and rest

sand spire
#

probably very bad for performance xd

spare hazel
#

i cant understand anyhting, somehow

#

maybe im stupid idk

sand spire
#

its just messy

spare hazel
#

nah im stupid

spare hazel
# sand spire its just messy
Bukkit.getScheduler().runTaskLater(CustomItems.getINSTANCE(), () -> {
            if (list.isEmpty()) {
                return;
            }
            
            BlockState block = list.get(0);
            list.remove(0);
            block.getLocation().getBlock().setType(block.getType());
        }, 100);```
#

what is this supposed to do

sand spire
spare hazel
#

oh cool

sand spire
#

it breaks randomly but whatever lmao

spare hazel
#

make sure the chunk is loaded

#

@sand spire

sand spire
#

ah

valid burrow
#

anyone got a code snipped for testing if a (list of) itemstack(s) fit in a players inventory

sullen marlin
#

you could clone inventory and then check addItem.isEmpty

valid burrow
#

oh sure

#

thx

young knoll
#

getINSTANCE

#

Cursed method naming

sand spire
#

i've got worse

remote swallow
river oracle
#

I am

#

I do MockBukki#mock

#

in BeforeEach

remote swallow
#

double check that that is actually being called

river oracle
#

itis b

#

because the error is happening in the BeforeEach method

#

when I call MockBukkit#mock

remote swallow
#

idk if mock bukkit has registries

river oracle
#

It does otherwise stuff would break lol

remote swallow
#

also maven central where

river oracle
#

its not on maven central

#

its in Papers repo

remote swallow
#

ah

#

i was just looking at mock bukkits github

sullen marlin
#

?whereami

river oracle
#

it is a spigot and Bungeecord programming/development related topic

#

would you prefer if I said it was on jitpack?

sullen marlin
#
testCompileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
#

nothing to do with where it is hosted

river oracle
#

oh I just did that to see if it was the issue I use spigot its just implemented as an API source if you look at my gradle paste

valid burrow
#

getting "where am i"d by md_5 himself must be a traumatic experience

solemn meteor
#

difference between #addDefault and #set in FileConfiguration

#

I assume addDefault doesn't overwrite existing data, and set does

#

right?

ivory sleet
#

Default is like a default value

cinder abyss
#

bump

agile anvil
solemn meteor
#

Oh

river oracle
warm forge
#

Hello there, I was wondering how I could update the victim's scoreboard inside the if (killer != null) in my onPlayerDeath script. I tried importing the code below into it but it won't work.

        int victimKillStreak = killStreaks.getOrDefault(victimId, 0);
        int limitedVictimKillStreak = Math.min(victimKillStreak, 5);
        ChatColor victimKillStreakColor = getColorForKillStreak(limitedVictimKillStreak);
        String coloredVictimKillStreak = victimKillStreakColor + String.valueOf(limitedVictimKillStreak);
        victim.setPlayerListName(victim.getName() + " " + victimKillStreakColor + "[" + coloredVictimKillStreak + "]" + ChatColor.RESET);
        updatePlayerScoreboard(victim);```





Full  onPlayerDeath script: https://pastebin.com/ZCfYshw8
lost matrix
drowsy helm
cursive kite
#

How can I detect when a player interacts with a hologram (packet armorstand)

warm forge
wet breach
#

also known as touch holograms unless you meant something different

lost matrix
wet breach
#

I can point you to a project that actually does implement touch holograms, not sure if you will be able to understand it though

lost matrix
#

Ah wait. Probably not a bukkit listener but a packet listener

#

ffs github

wet breach
#

Lol

wet breach
#

you wanted to know where it was implemented, that is where it starts

#

then you found the event for it

lost matrix
#

I just wanted to look for "new HoloTouchEvent" and this would lead me to the actual impl

wet breach
#

there is no event in the Bukkit API that lets you listen for touches with holograms

#

so it has to all be implemented using some clever tricks 🙂

lost matrix
#

This is your own event you bob

#

I wanted to see where you fire it so that i can backtrack what you are doing

wet breach
lost matrix
#

Thats all i wanted to see 🙂
Why is this tightly coupled to the hologram?
Anyway thats what i did as well before Interaction entities where a thing. Slimes are most suitable for this.

wet breach
#

but that is the implementation which plugins shouldn't need

#

This API allowed you to do quite a lot of stuff

#

wihtout having to worry about implementing it yourself 😄

#

you could also let the API handle your holograms for you if you wanted, or do the opposite

#

either was acceptable

#

sadly 1.8 kind of killed it and I haven't had time to update this code base mainly because of how large it it is it took 3 devs to make this XD

cursive kite
#

Probably will use the fake slime

#

Or i guess real slime

proud badge
#

InventoryOpenEvent isnt triggered when the player opens their own inventory, anyone know a solution or a different event for it?

proud badge
#

rip

drowsy helm
#

player inventory is completely client sided

#

next best thing is detecing when they click it, thats the closest you will get

wet breach
#

isn't the new way now that the players inventory is considered to always be opened?

#

if so, just check the inventory type they are interacting with

worthy star
#

whats best way to make a help cmd without putting each command? like
when player does a command without putting argument it sends the list of commands

tall dragon
#

if you have a proper command system that should be fairly easy

#

since each subcommand can then define its usage, & u can simply fetch the usage of each command and print it to the user

worthy star
#

i have a CommandsHandler interface that has

#

is it a proper command system?

tall dragon
#

yea so surely you have a collection of those somewhere

#

so u can just loop over that collection and get each commands usage right?

worthy star
#

okay

lilac dagger
#

could be better @worthy star

worthy star
#

but uhm well

#

i don't have a collection for them 🙂

#

should i like have a set map like Map<String, String> and put the command with usage in it?

tall dragon
#

how ru even invoking commands then

worthy star
#

i have a class that i extend in my commands classes and it has the stuff like execute() and checking permission,args,permission message,usage

tall dragon
#

how ru calling execute()

worthy star
#

not done yet

tall dragon
#

so the handler is just hardcoded in a command? ;d

worthy star
#

no?

#

i just put @CommandsHandler(stuff) at top and use the execute()

peak jetty
tall dragon
#

i would have a commandmanager that has a map<String,CommandHandler> that maps the main commands to a command handler, then u can easily invoke the command by checking the main command & u can also get all commands usages

shadow night
peak jetty
# shadow night Caused by: java.lang.ArrayIndexOutOfBoundsException

so whats the problem here:

// contents1Level2
                contents1Level2(((Chest) new Location(w, 111, 126, 102).getBlock().getState()).getBlockInventory());
                contents1Level2(((Chest) new Location(w, 107, 126, 110).getBlock().getState()).getBlockInventory());
                contents1Level2(((Chest) new Location(w, 103, 126, 110).getBlock().getState()).getBlockInventory());
                contents1Level2(((Chest) new Location(w, 111, 126, 52).getBlock().getState()).getBlockInventory());
                contents1Level2(((Chest) new Location(w, 107, 126, 48).getBlock().getState()).getBlockInventory());
                contents1Level2(((Chest) new Location(w, 103, 126, 48).getBlock().getState()).getBlockInventory());```
with
```java
public void contents1Level2(Inventory i) {
        i.setItem(0, new ItemStack(Material.IRON_INGOT, 8));
        i.setItem(3, new ItemStack(Material.COBWEB));
        i.setItem(5, new ItemStack(Material.COBWEB));
        i.setItem(7, new ItemStack(Material.SANDSTONE));
        i.setItem(8, new ItemStack(Material.DEAD_BUSH));
        i.setItem(10, new ItemStack(Material.ENDER_PEARL));
        i.setItem(11, new ItemStack(Material.SANDSTONE));
        i.setItem(14, new ItemStack(Material.ENDER_PEARL, 2));
        i.setItem(17, new ItemStack(Material.SANDSTONE, 10));
        i.setItem(18, new ItemStack(Material.IRON_INGOT, 8));
        i.setItem(19, new ItemStack(Material.DEAD_BUSH));
        i.setItem(20, new ItemStack(Material.EYE_ARMOR_TRIM_SMITHING_TEMPLATE));
        i.setItem(21, new ItemStack(Material.IRON_INGOT, 8));
        i.setItem(22, new ItemStack(Material.COBWEB));
        i.setItem(23, new ItemStack(Material.ENDER_PEARL));
        i.setItem(25, new ItemStack(Material.COBWEB));
        i.setItem(26, new ItemStack(Material.SANDSTONE));
        i.setItem(27, new ItemStack(Material.ENDER_PEARL));
    }```
lilac dagger
#

well, what item isn't working well?

wet breach
#

to your plugin

#

server will take care of generating a help map for you 🙂

peak jetty
#

how do i make a chest empty?

wet breach
wet breach
#

yeah has existed for quite a long time actually

tall dragon
#

never known

wet breach
#

naturally, its the same how people don't know about the conversation api

tall dragon
#

oh i know about that

#

i just think it isnt very good

wet breach
#

Well I think people know a bit more about the conversation api since I keep telling people about it when I get a chance 😛

#

however this is the first I have gotten the chance to talk about the help stuff

#

now, once this becomes a bit more known, it will be back to waiting on spreading some other unknown thing of the api 😄

tall dragon
#

how does he know it all!

wet breach
#

Well, I been around since the beginning of MC and nearly the beginning of Bukkit 😉

peak jetty
#

im getting this warning:

> reloadpoiloot
[10:52:43 WARN]: Unexpected exception while parsing console command "reloadpoiloot"
org.bukkit.command.CommandException: Unhandled exception executing command 'reloadpoiloot' in plugin PlutoTools v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:987) ~[paper-1.20.1.jar:git-Paper-196]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchServerCommand(CraftServer.java:972) ~[paper-1.20.1.jar:git-Paper-196]
        at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:500) ~[paper-1.20.1.jar:git-Paper-196]
        at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.20.1.jar:git-Paper-196]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1393) ~[paper-1.20.1.jar:git-Paper-196]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1170) ~[paper-1.20.1.jar:git-Paper-196]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.20.1.jar:git-Paper-196]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassCastException: class com.destroystokyo.paper.console.TerminalConsoleCommandSender cannot be cast to class org.bukkit.entity.Player (com.destroystokyo.paper.console.TerminalConsoleCommandSender and org.bukkit.entity.Player are in unnamed module of loader java.net.URLClassLoader @759ebb3d)
        at net.plutocraft.plutotools.CommandExecutor.onCommand(CommandExecutor.java:489) ~[PlutoTools-1.0.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 9 more```
wet breach
#

and you are assuming all commands are players

#

you can't cast console to player, so you should be checking if the sender is consolesender

peak jetty
#

this is what i have to check if its a console if ((sender instanceof Player && p.hasPermission("plutotools.reloadpoiloot")) || sender instanceof ConsoleCommandSender)

#

and then inside that if statement i got this:

if (sender instanceof Player) {
                    p.sendMessage(ChatColor.GREEN + "All POI's loot has been reloaded!");
                } else {
                    getLogger().info("All POI's loot has been reloaded!");
                }```
wet breach
#

well you are casting somewhere

#

IE you are doing (Player) sender somewhere

#

most likely before this check

peak jetty
#

oh yeah i am

wet breach
#

you need to do the casting after the check

peak jetty
#

alright 👍

#

wait but then i cant check if the player has the permission in the first if statement

#

since im using p.hasPermission()

wet breach
#

you can, you first do your check to see which sender is which. Once you know its a player, then do your casting and then do your permission check

#

you just have the order in the wrong arrangement is all

peak jetty
#

alr

peak jetty
#

why is this if statement not getting called when im moving from the world "world" to the world "poi" witha multiverse portal?

if (e.getTo().getWorld().equals("poi")) {
            getLogger().info("if statement called");
            Inventory savedInv = p.getInventory();
            getLogger().info(savedInv.toString());
        }```
lost matrix
lilac dagger
#

getworld get name

#

pretty sure the ide shows this as yellow

peak jetty
#

ohh ok thanks

#

how do i check if the location he tp'ed FROM was in a boundingBox?

lost matrix
fair breach
#

Hi, I want to store enchantment into my config (like this):
enchantment:
-SHARPNESS:2
-LUCK:3

But when getting enchantments from an ItemStack i found that Enchantment.getName()' is deprecated and i should use use Keyed.getKey() witch returns an NamespacedKey. I have no idea how NamespacedKeys work, please help

chrome beacon
#

A namespaced key contains two values

#

a namespace and a key

#

The namespace would be minecraft and the key sharpness

#

so minecraft:sharpness

fair breach
#

thank you i think i understand it now

icy monolith
#

I have these particles spawning at a block with an offset, how do i make them offest above the block and not both ways

#

nvm i just added to the default y position

peak jetty
#

do i have to clear a players inventory before setting it's contents?

sand spire
#

Hello, so I'm trying to make an input GUI with fake (packet based) signs, I've tried a lot of different things for over 10 hours, but with ProtocolLib I never figured out how to change the text on the sign and with player.sendBlockChange + player.openSign i got the issue that the sign has to be real. All the information on google is outdated because signs have 2 sides now and the TILE_ENTITY_DATA packet takes different parameters, and everyone with same issue in this discord never figured it out.

My last idea is to have a real sign to open at some location far away which solves the issue of not being able to add default text to the sign but now I got the problem that if the sign is like 5+ blocks away it instantly closes.

So my question is if there is a way to cancel the closing of a sign when you move too far and if anyone has a solution for one of my other problems it would be amazing.

Stuff that doesn't work:
||player.sendBlockChange + player.openSign: https://pastes.dev/VKQNnbwnLQ Issue: java.lang.IllegalArgumentException: Sign must be placed||

||ProtocolLib player.sendBlockChange + (packets server to player) OPEN_SIGN_EDITOR & TILE_ENTITY_DATA: https://www.spigotmc.org/threads/signmenu-1-16-5-get-player-sign-input.249381/ Issue: signData doesn't hold a varInt anymore https://wiki.vg/Protocol#Block_Entity_Data||
This seems very complicated so thank you in advance to anyone who even tries to help me

peak jetty
#

why does getLogger().info("left after completion"); and getLogger().info("left before completion"); not get triggered in this event?

@EventHandler
    public void onPlayerTeleport(PlayerTeleportEvent e) {
        getLogger().info("player teleported");
        Player p = e.getPlayer();
        if (e.getTo().getWorld().getName().equals("poi")) {
            savedInv = p.getInventory().getContents();
            p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GREEN + "You entered the POI!"));
        } else if (e.getFrom().getWorld().equals("poi")) {
            getLogger().info("from poi");
            Vector fromLoc = e.getFrom().toVector();
            if (leavePyramid.contains(fromLoc)) {
                getLogger().info("left after completion");
                p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GREEN + "Congratulations! You completed the POI!"));
            } else {
                getLogger().info("left before completion");
                p.getInventory().setContents(savedInv);
                p.sendMessage(ChatColor.RED + "You exited the POI without completing it so your items didn't save.");
            }
        }
    }```
sand spire
rapid vigil
peak jetty
tall dragon
final wharf
#

how do i get the block under the player?

solemn meteor
#

Whats a secure way to store data on a file and it not be changed by the user

final wharf
#

so like this java @EventHandler private void onPlayerMove(PlayerMoveEvent event){ Player player = event.getPlayer(); Block blockAtFeet = player.getLocation().getBlock(); Block blockUnderFeet = blockAtFeet.getRelative(BlockFace.DOWN); Location location = event.getPlayer().getLocation(); List<Material> blocks = Arrays.asList(Material.values()); Material material = blocks.get(0); //random logic location.getBlock().setType(material); }

sand spire
solemn meteor
#

I'll just do that nvm

icy kelp
#

Hello I just started my spigot plugins development and I need help I really don't know what I'm doing wrong

remote swallow
#

ask ur questions

icy kelp
#

Okay nevermind idk how to show it without screenshots

chrome beacon
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

chrome beacon
#

if it's text:

#

?paste

undone axleBOT
chrome beacon
#

?conventions

chrome beacon
#

^^ name your methods correctly

icy kelp
#

I just started and that tutorials from youtube or somewhere are just making my brain getting crazy

#

import com.sun.org.apache.xpath.internal.operations.Bool;
import org.cheese.naukaconfigu.NaukaConfigu;

public class Zmienne {

    public static String join_message(NaukaConfigu plugin) {
        String join_message = plugin.getConfig().getString("join_message");
        return join_message;
    }

    public static Boolean allow_Heal(NaukaConfigu plugin) {
        Boolean allow_Heal = plugin.getConfig().getBoolean("allow_Heal");
        return allow_Heal;
    }
}``` That is working but If I want to use allow_Heal
chrome beacon
#

If you've never worked with Java before I recommend doing that

#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

icy kelp
#

    @Override
    public boolean onCommand(@NotNull CommandSender Sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
        Boolean allow_Heal = Zmienne.allow_Heal(this.plugin);





        Player player = (Player) Sender;

        Double hp = player.getMaxHealth();

        player.setHealth(hp);

        return false;
    }
}```
#

but about that error is in the Boolean allow_Heal = Zmienne.allow_Heal(this.plugin);

#
        Boolean allow_Heal = plugin.getConfig().getBoolean("allow_Heal");
        return allow_Heal;
    }``` that is the class
chrome beacon
#

yeah you have no idea how static works

tall dragon
#

@sand spire managed to get this to work. but im pretty sure in 1.20+ its inpossible to have the sign be non visible, since the 1.20 client actually started immediately closing out of the sign if its far away.

chrome beacon
#

Take the time and go through a Java course or two

icy kelp
icy kelp
echo basalt
#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

echo basalt
#

I recommend jetbrains academy, but they're all decent

inner mulch
#

how do i hide an entity on defautl?

sand spire
tall dragon
#

idk what ur using rn

sand spire
tall dragon
#

ru using mojang mappings?

sand spire
tall dragon
#

bassically its a set of names that converts obfuscated methods to non obfuscated methods. then when you compile it automatically converts it all back to the obfucated version

#

ur will need that if u want to use my version

sand spire
sand spire
#

does that mean I need to import with maven or is it already in spigot just less beginner friendly

tall dragon
#

it would fk up any nms already present in ur plugin tho

sand spire
#

this is the first time i'm consciously working with packets so doesn't really matter i guess

tall dragon
#

ur ide will tell u ;d

#

cuz mojang maps just changes how stuff is named

sand spire
#

alright tysm I'll let you know when i got it to work

EDIT: it works!

sand spire
#

do i need to put it in my plugin folder or something

#

or is it my new server folder cause when I click on the spigotjar it starts generating stuff

#

or how do I forceupdate

quaint mantle
#

is someone help me with ClientboundSetEntityDataPacket

chrome beacon
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

chrome beacon
quaint mantle
#

i dont know how to do the DataValue part

#

i am trying to make a armor stand invisible

sand spire
chrome beacon
#

yeah like that

kind hatch
#

Yes

sand spire
#

yeah but where

chrome beacon
#

in cmd

sand spire
#

oh in here <classifier>remapped-mojang</classifier> <!-- Important! -->

chrome beacon
#

or just open the BuildTools GUI if you can't figure it out

kind hatch
#

The GUI has an option called Generate Remapped Jars

#

It'll also show you the command preview when you switch back to the main page.

#

You can always run java -jar BuildTools.jar --rev 1.20.4 --remapped if you have the jar file as well. :p

sand spire
#

oh so I should make it compile again with this on

kind hatch
#

Yes

sand spire
kind hatch
#

It should be quick compared to the first run.

quaint mantle
#

how can i set the datavalue part in ClientboundSetEntityDataPacket

chrome beacon
#

Take a look at how Mojang uses it

quaint mantle
#

where can i do that?

chrome beacon
#

In the nms code

#

Just read the decompiled code

sand spire
#

It works now thanks yall!

quaint mantle
shadow night
#

You already have

quaint mantle
#

o?

chrome beacon
quaint mantle
#

oh ok

quaint mantle
chrome beacon
#

if you can't find what you need keep digging through other classes

quaint mantle
#

mmm

#

any paticular thing to look for?

#

idk honestly

chrome beacon
#

if you can't figure it out you can always work with a packet library like ProtocolLib and PacketEvents

quaint mantle
#
        SynchedEntityData data  = stand.getHandle().getEntityData();
        data.set(new EntityDataAccessor<Byte>(0, EntityDataSerializers.BYTE), (byte) 0x20);

        ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(id, data.packDirty());``` is it just this?
#

yk imma test it

#

omg yes

#

i am pro

#

this feels soo goood

#

whatt happens to a packet entity when i leave?

young knoll
#

It gets removed

echo basalt
#

nvm you figured it out

echo basalt
grim hound
#

somebody help me out

echo basalt
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

grim hound
#

I send a buffer with a message

#

and the client

grim hound
echo basalt
#

Show code

grim hound
grim hound
#
@SuppressWarnings("UnstableApiUsage")
    public static ByteBuf createBuffer(PacketWrapper<?> wrapper, int initialCapacity) {
        if (wrapper.buffer != null) throw new AlixException("Incorrect invocation of NettyUtils.createBuffer - buffer exists ");
        wrapper.buffer = Unpooled.buffer(initialCapacity);
        wrapper.writeVarInt(wrapper.getPacketTypeData().getNativePacketId());
        wrapper.write();

        return (ByteBuf) wrapper.buffer;
    }

    public static ByteBuf constBuffer(PacketWrapper<?> wrapper) {
        return Unpooled.unreleasableBuffer(createBuffer(wrapper, 1));
    }
#

I create my static final ByteBufs using constBuffer

#

and the PacketEvents PacketWrapper

#

I do this mainly because I need to send packet "silently" so without the interceptor knowing

#

so I get the silent context the same way PacketEvents does:

@SuppressWarnings("UnstableApiUsage")
    public static ChannelHandlerContext getSilentContext(Channel channel) {
        return channel.pipeline().context(PacketEvents.ENCODER_NAME);
    }
#

I then invoke silentContext.writeAndFlush(somePacketByteBuf.duplicate())

grim hound
grim hound
#

but upon investigating that just uses the default ByteBufAllocator

#

there's no console errors

echo basalt
#

Have you tried asking the man himself? @alpine urchin

grim hound
#

but I also don't know where to find the client-side decoder code, which could help me out

grim hound
#

he said contact netty

echo basalt
#

lmfao rip

grim hound
#

and netty said contact the api

grim hound
#

and engaging with netty

spare hazel
#
public void increaseXP(int amount){
        xp += amount;

        TextComponent textComponent = new TextComponent();
        textComponent.setText(ChatColor.DARK_AQUA.toString() + "+" + amount + " ("+ xp + "/" + (xp * 100) + ")");
        Bukkit.getPlayer(uuid).spigot().sendMessage(ChatMessageType.ACTION_BAR, textComponent);
        
        if(xp > level * 100){
            xp -= level * 100;
            level++;
            Bukkit.getPlayer(uuid).sendTitle(
                    ChatColor.AQUA.toString() + ChatColor.BOLD + "LEVEL UP!",
                    ChatColor.DARK_AQUA.toString() + (level-1) + " ➡ " + level,
                    4, 35, 7);
        }
    }```

am i doing anything wrong releated to the TextComponent?
echo basalt
#

Appending colors like that is icky

spare hazel
#

let me do something else

#

wait

young knoll
#

You should be using the component builder

spare hazel
#

well textcomponent inherits from component builder

#

so whats the problem

#
public void increaseXP(int amount){
        xp += amount;

        TextComponent textComponent = new TextComponent();
        textComponent.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
        textComponent.setBold(true);
        textComponent.setText("+" + amount + " ("+ xp + "/" + (xp * 100) + ")");
        Bukkit.getPlayer(uuid).spigot().sendMessage(ChatMessageType.ACTION_BAR, textComponent);

        if(xp > level * 100){
            xp -= level * 100;
            level++;
            Bukkit.getPlayer(uuid).sendTitle(
                    ChatColor.AQUA.toString() + ChatColor.BOLD + "LEVEL UP!",
                    ChatColor.DARK_AQUA.toString() + (level-1) + " ➡ " + level,
                    4, 35, 7);
        }
    }```
quaint mantle
young knoll
#

You can't use legacy string colors in components

grim hound
#

I send a buffer with a message

spare hazel
echo basalt
quaint mantle
#

thing is

echo basalt
#

There's a visible field in the metadata and there's the remove packet

#

CustomNameVisible is also part of the metadata

#

But not part of the bitmask 0

quaint mantle
#

i had stand.setVisible(false); b4 too but it didnt work...this time i had both packet and .setVisible soo idek which one did it

#

i will removing .setVisible in next compile

echo basalt
#

I need more context

spare hazel
echo basalt
#

no

spare hazel
#

wait imma trry something else

echo basalt
#

homie you can't use legacy color codes like that

quaint mantle
spare hazel
#

Bukkit.getPlayer(uuid).spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder(textComponent).create());

echo basalt
#

nvm that looks right

#

just

#

?tryandsee

undone axleBOT
spare hazel
#

alright

worldly ingot
#

No it does nothing

spare hazel
#

or should i remove the componentbuilder part

#

alr

grim hound
#

do you know netty

#

or rather client-side decoding?

#

of bytebufs into packets

young knoll
#

I've manually made some packets via bytebuff and sent them to the client

young knoll
#

Pretty easy as long as you follow the format Mojang uses

grim hound
#

tell me

quaint mantle
grim hound
#

czu I also do it

#

and it just

grim hound
young knoll
#

Idk how the header would be messed up

spare hazel
young knoll
#

afaik the game handles that

grim hound
young knoll
#

Just a normal FriendlyByteBuf wrapping Unpooled.buffer

grim hound
#

maybe I should wrap mine as well

#

and did you have some constant packets?

young knoll
#

Well you need to pass something to FriendByteBuf constructor

young knoll
#

And it has a bunch of nice write methods

quaint mantle
#
        stand.setCustomName("something");
        SynchedEntityData data  = stand.getHandle().getEntityData();
        data.set(new EntityDataAccessor<Byte>(0, EntityDataSerializers.BYTE), (byte) 0x20);
        ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(id, data.packDirty());
```can the name part be working cause i got the data after i set the name?
grim hound
#

FriendlyByteBuf

#

not a class

remote swallow
#

mojank class

grim hound
hushed scaffold
#

yall know how if a player dies after getting hit by another player , for example a player a hits player b , and then player b dies from example fall damage , and it says that player b died while trying to escape player a ? is it possible to get who got kill credit or do i have to reimplement that myself

young knoll
#

getKiller in the death event

hushed scaffold
#

wouldnt that only get if the kill was direct ? like killing them with a melee weapon?

#

or does it get even if they died from natural causes after a player hits them

young knoll
#

No

#

It gets whoever would get the kill credit

#

(Or null)

hushed scaffold
#

oooh ty

echo basalt
#

Try and see but that should work

quaint mantle
#

alr i will add the name setter after i send the packet

echo basalt
young knoll
#

I hate that a bunch of the synced data fields for entities are private

quaint mantle
#

yea my theory was correct

#

since i set the name before it set the name

#

wait so i can just do the normal methods ands send a data packet at the end

#

good to know

alpine urchin
#

nms would be analogous

#

the more you tamper around with NMS, the less help you can expect from the Bukkit community

#

since you’re doing some additional netty stuff, it’s not really my responsibility to help you use those features

alpine urchin
#

i also mentioned its fair for you to use those netty things as an addition to my library

grim hound
#

but it's not like you help out of responsibility

alpine urchin
#

good

#

but saying im against you not fully using my api is reaching too far

#

since i mentioned i understand why you’re doing it

grim hound
#
public static ChannelFuture writeAndFlushConst(ChannelHandlerContext context, ByteBuf constByteBuf) {
        ByteBuf send = context.alloc().buffer().writeBytes(constByteBuf);
        return context.writeAndFlush(send);
    }
``` I changed it to this like ViaVersion does it
#

still doesn't help

alpine urchin
#

i might look at this again

grim hound
#

and also cache the silent context

#

then I'd really appreciate it

alpine urchin
#

make a github issue

grim hound
#

I'm so close

#

like I remade my whole plugin

#

and all of this stuff

alpine urchin
#

focus on ur plugin

#

and not this specific feature

#

lol

grim hound
#

to solve this

grim hound
#

rewriting the core mechanics

#

or rather I already finished it

#

it's just that it kicks me out

alpine urchin
#

you can make an issue, and leave it in our hands

#

i’m generally not against it

#

once all other things have been solved, im down to add this little addition

grim hound
#

and also create like PacketCreationUtil

#

so that you don't have to create a new packet for each version by yourself

#

so methods like newPlayerInfo or newMessage and stuff

alpine urchin
#

nah

#

you have no idea of the work it takes to maintain this bad boy already

elder wren
#

Hello,

I'm looking to serialize the contents of players' inventories using a HashMap<UUID, ItemStack[]>.

I manage to store this via JSON in the following way:
{"568d365a-5fb2-4169-8e64-fb33b8c108ef":[{"type":"STONE","amount":1,"meta":{"repairCost":0,"hideFlag":0,"unbreakable":false,"damage":0,"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2975}},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1}]}

It seems that you're having trouble loading the data back into a HashMap; it always ends up being null.

#

public static File onStaffModeFile;

@Override
public void onEnable() {

    try {

        getDataFolder().mkdir();
        onStaffModeFile = new File(getDataFolder(), "staffmode.json");
        if(!onStaffModeFile.exists()) {
            onStaffModeFile.createNewFile();
        }

        Gson gson = new Gson();
        Writer writer = new FileWriter(onStaffModeFile, false);
        BufferedReader reader = new BufferedReader(new FileReader(onStaffModeFile));

        HashMap<UUID, ItemStack[]> map = gson.fromJson(reader, HashMap.class);

        if(map!=null) {
            StaffCommand.setInStaffMode(map);
            reader.close();
        } else {
            gson.toJson(new HashMap<UUID, ItemStack[]>(), writer);
            StaffCommand.setInStaffMode(new HashMap<>());
            writer.flush();
            writer.close();
        }
lilac dagger
#

paste bin?

undone axleBOT
chrome beacon
#

Is there a reason why you're using gson instead of the yaml config api?

rapid vigil
#

or

lilac dagger
#

gson doesn't serialize it properly

chrome beacon
#

^^ you'll need to fix your serializers

tawdry echo
#

someone have idea why dont work?

@Override
    public CompletableFuture<Void> insertArena(Arena arena) {
        System.out.println("insert");
        return CompletableFuture.runAsync(() -> {
            run("INSERT INTO arenas (id, name) VALUES (?, ?);", statement -> {
                System.out.println("insert 1");
                statement.setString(1, arena.getId().toString());
                System.out.println("insert 2");
                statement.setString(2, arena.getName());
                System.out.println("insert 3");
                statement.execute();
                System.out.println("insert " + arena.getName());
            });
        });
    }
[18:00:07 INFO]: [Duels] [STDOUT] insert
[18:00:07 INFO]: [Duels] [STDOUT] insert 1
[18:00:07 INFO]: [Duels] [STDOUT] insert 2
[18:00:07 INFO]: [Duels] [STDOUT] insert 3
chrome beacon
#

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

tawdry echo
#

everything already i send

#

thers no errors

chrome beacon
#

No you did not send what the run method is for example

tawdry echo
#

but last dont print

chrome beacon
#

what you expect it to do, and what actually happens

tawdry echo
#
void run(String sql, ThrowingConsumer<PreparedStatement, SQLException> consumer) {
        try (Connection connection = this.database.getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) {
            consumer.accept(statement);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
#

last check dont log

#

statement#execute block but why

chrome beacon
#

Where's the throwing consumer from

wet breach
chrome beacon
#

My guess would be that it's throwing an error

#

and that consumer is catching it

wet breach
#

I don't see any other possible error it could be unless its some weird NPE

grim hound
#

oh wait

#

I was supposed to make an issue

alpine urchin
#

i said issue

#

wtf

tawdry echo
#
@Override
    public CompletableFuture<Void> insertArena(Arena arena) {
        System.out.println("insert");
        return CompletableFuture.runAsync(() -> {
            run("INSERT INTO arenas (id, name) VALUES (?, ?);", statement -> {
                System.out.println("insert 1");
                statement.setString(1, arena.getId().toString());
                System.out.println("insert 2");
                statement.setString(2, arena.getName());
                System.out.println("insert 3");
                System.out.println(statement);
                statement.executeUpdate();
                System.out.println("insert " + arena.getName());
            });
        });
    }
[18:11:01 INFO]: [Duels] [STDOUT] insert
[18:11:01 INFO]: [Duels] [STDOUT] insert 1
[18:11:01 INFO]: [Duels] [STDOUT] insert 2
[18:11:01 INFO]: [Duels] [STDOUT] insert 3
[18:11:01 INFO]: HikariProxyPreparedStatement@1401976472 wrapping INSERT INTO arenas (id, name) VALUES (?, ?);
[18:11:01 INFO]:  parameters=[77f58b16-ca87-4991-a02e-28bed0ad8586, test]
alpine urchin
#

bros tryna commit xd