#help-development

1 messages ¡ Page 2024 of 1

tall dragon
#

its a mine with tons of upgrades

#

not player related at all, apart from its owner

#

& i want the minions to generate money inside that mine which the player can later collect

#

but if ur saying it will be fast enough i can always give it a try first

quaint mantle
#

Is the mine a menu or a real mine/room ?

tall dragon
#

its a real mine

#

the player can mine as well

#

the minions are additional so it can also generate cash while the player is offline

#

but for performance reasons i thought to not make the minions actually mine

#

they just pretend

#

i just need some way to calculate how much they have made in a certain timeframe

quaint mantle
#

Is the ore inside the mine generated randomly?

tall dragon
#

yes

#

with a weight system

#

pretty much like mc does its loot tables

#

and thats exactly one of the things that makes this difficult

#

cuz each ore has different worth

#

ofc i could make it so each block would be worth the average of all the blocks. but idk if thats a good idea

#

cuz if i do that alot of rng will be lost

quaint mantle
#

hm

tall dragon
#

my thoughts exactly 😂

quaint mantle
#

Any way to make custom textured items IF it has a spesific NBT data or smtgh

#

like iron ingots would have the same texture

#

but if it had a value called Coin

#

it be retextured to a coin

kind hatch
quaint mantle
#

Also any tutorials?

kind hatch
quaint mantle
kind hatch
# quaint mantle So... is there tutorials on that?

On forcing the resource pack? No, as it's just a simple setting that you can toggle. It does imply that you need a resource pack in the first place in order to enforce one. If you need a tutorial for a resource pack, there are plenty of videos out there for making one. There is also the minecraft wiki which, for the most part, has updated information about them. Things like resource pack version, file structure, etc.

quaint mantle
#

and how it works

kind hatch
#

Oh, well that's easy.

round finch
#

i would like to know too

kind hatch
#

Custom modle data only works with integers. So, once you set it, you then have to update your resource pack with that data. I forget which tag it is, but it will be the same number that you set in your code.

#

It could also be as simple as having the directory the asset is placed in named as the integer. (E.G. the folder is named 1)

#

It's been a while since I last touched resource packs.

#

Here's how you would set the custom model data.

ItemStack item = new ItemStack(Material.WOODEN_AXE);
ItemMeta meta = item.getItemMeta();

meta.setCustomModelData(1); // <-- This part here.

item.setItemMeta(meta);
#

Let me see how one of my "recent" resource packs did this. Cause the file structure is starting to come back to me.

kind hatch
# quaint mantle Huh

Here's a tutorial made fairly recently. It covers both the resource pack making and setting the custom model data.
https://www.spigotmc.org/threads/advanced-resourcepack-mechanics-how-to-create-custom-items-blocks-guis-and-more.520187/

ancient jackal
#

personally I'd do async tasks

quaint mantle
#

@kind hatch Any way to make the texture change based on how many of the item the player has stacked in 1 pile?

#

EX: If you have 33 or higher coins stacked on eachother, it turns into a pile texture

young knoll
#

Sure

#

You’d need to just change the cmd

#

Not super easy to do as there isn’t an event for items stacking tho

#

In the inventory*

kind hatch
young knoll
#

Hmm forgot about that possibility

#

Nope

nimble torrent
#

im getting Cannot invoke "[Ljava.lang.String;.clone()" because "this.rows" is null

        //Sharpness
        ItemStack sharp = new ItemStack(Material.ENCHANTED_BOOK, 1);
        sharp.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6);
        EnchantmentStorageMeta metaSharp = (EnchantmentStorageMeta)sharp.getItemMeta();
        sharp.setItemMeta(metaSharp);

        NamespacedKey keySharp = new NamespacedKey(this, this.getDescription().getName());
        ShapedRecipe recipeSharp = new ShapedRecipe(keySharp, new ItemStack(sharp));
        recipeSharp.shape(" D ", "NSN", " N ");
        recipeSharp.setIngredient('N', Material.NETHERITE_SCRAP);
        recipeSharp.setIngredient('S', Material.DIAMOND_SWORD);
        recipeSharp.setIngredient('D', Material.DIAMOND);

        Bukkit.getServer().addRecipe(recipeSharp);

        //Protection
        ItemStack prot = new ItemStack(Material.ENCHANTED_BOOK, 1);
        prot.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 5);
        EnchantmentStorageMeta metaProt = (EnchantmentStorageMeta)sharp.getItemMeta();
        prot.setItemMeta(metaProt);

        NamespacedKey keyProt = new NamespacedKey(this, this.getDescription().getName());
        ShapedRecipe recipeProt = new ShapedRecipe(keyProt, new ItemStack(prot));
        recipeSharp.shape(" D ", "NCN", " N ");
        recipeSharp.setIngredient('N', Material.NETHERITE_SCRAP);
        recipeSharp.setIngredient('C', Material.DIAMOND_CHESTPLATE);
        recipeSharp.setIngredient('D', Material.DIAMOND);

        Bukkit.getServer().addRecipe(recipeProt);```
young knoll
#

What line

nimble torrent
# young knoll What line

idk but it says this too at com.Roe.Sharpness.Sharpness.onEnable(Sharpness.java:52) ~[Sharpness.jar:?]

young knoll
#

?paste

undone axleBOT
young knoll
#

Send the full stack trace

nimble torrent
#

k

pliant oyster
#

How can I get a player who clicked on a certain item in inventory?

quaint mantle
#

Can I send you my texture pack so you can see if its incorrectly configured?

dense shoal
#

If I do

        event.getPlayer().setAllowFlight(true);
        event.getPlayer().setFlying(true);```
 to myself when I log in, I expect to stay where I am in the air. Why do I fall to the ground, but I can fly?
quaint mantle
#

try it

#

ANT 😍

dense shoal
#

Whyyy

wet breach
#

Ant is so antiquated

dense shoal
#

^

hexed hatch
#

ant more like atrocious

young knoll
#

Antique

vocal cloud
#

Ant is good if you're a programming hermit whose code will never see the light of day

#

Naw not jars just source. Since to use your source they'd need to manually import everything

hasty prawn
#

switches from desktop to laptop

spends an hour setting up dependencies on laptop

young knoll
#

Just never switch computers

#

Easy

hasty prawn
#

Oh yeah good idea 5Head

young knoll
#

Just copy all of their classes into your project

hasty prawn
#

I used to do this too, thought Gradle/Maven wasn't worth it

#

Boy was I wrong

#

You'll realize eventually that you're nerfing yourself 😉

vocal cloud
#

Eclipse. That explains it

hasty prawn
#

Yeah but generally it's easier to find the maven/gradle imports than the shaded jar lol

vocal cloud
#

Alright but how do you get the jar?

#

You download it right?

#

So you download it then import it?

#

and maven is somehow more work?

young knoll
#

Yes

#

You just shove the dependency in your pom

#

Usually the resource will give you them

#

On the GitHub page or a wiki or whatever

vocal cloud
#

maven is like 10x faster unless you have to manually import a jar. Then it's suffering.

young knoll
#

Yeah people that don’t have repos suck

#

Including me

vocal cloud
#

I have a local one now. It's so nice to publish it to my own repo then just access it in my other projects

young knoll
#

Yeah but that doesn’t help other people

vocal cloud
young knoll
#

Ah

#

I thought you meant mavenLocal

vocal cloud
#

nonono

#

It's hosted on an apache server.

#

Here is a better gif of maven's beauty happy

#

It doesn't

young knoll
#

I thought you needed one window per project

vocal cloud
#

I usually have like 5 projects open at the same time

quaint mantle
#

How would I make it so that instead of typing /game mode creative I could type /gmc?

wet breach
#

probably better if you use the aliases

#

since it doesn't require a plugin

#

I personally use Netbeans

#

but I don't use Ant

#

not unless there is some specific reason to do so

#

also for Maven projects in netbeans you can just right click on the dependencies and add new ones

#

without ever opening the pom

#

only time you need to open the pom is if you need to setup some stuff like shading

#

or add repository where to pull dependencies from

#

yep and you can even install dependency

#

if you already downloaded the jar

#

and it will add it to both the project and local maven repo

#

I never liked IntelliJ anyways

#

I just don't like how it has its menus setup or how it does things

#

yes

#

idk about for minecraft

#

but they do have a plugin repository

#

and API to make your own plugins if you want

#

I don't know of an automatic way

#

there might be a tool out there that does it

vocal cloud
#

Honestly unless you're using jars not in central just looking through central will give you everything.

wet breach
#

and all the properties that get set in the POM

vocal cloud
#

Maven has a + button

wet breach
#

are pulled from the Netbeans properties window

young knoll
#

Aren’t a lot of minecraft resources

#

Not on central

wet breach
#

not all minecraft resources have their own repo's as well

#

so its a mix of the 3

#

some are on central, others have their own repos and then what is left are not in either of them 😛

quaint mantle
#

How do I check if a player is in the overworld, nether, or end?

wet breach
#

get their location and then getWorld()

young knoll
#

World#getEnvironment

wet breach
#

I suppose getEnvironment might work

young knoll
#

Returns an enum for the type of world they are in

vocal cloud
wet breach
#

player.getWorld().getEnvironment()

quaint mantle
young knoll
#

I just realized the other day I never added the spigot repo to my build tool

wet breach
#

and I don't bully people 😛

quaint mantle
young knoll
#

Because I always have it local

young knoll
#

Takes a location, location has a world

wet breach
# quaint mantle Pls don't bully me but what is the format for commands.yml? I only know plugin....
BukkitWiki

commands.yml is a configuration file that houses custom defined aliases and command block overrides for your CraftBukkit server.
The command block override system provides a quick and easy way to force the server to use the commands provided by Mojang (as opposed to the ones built into Bukkit) for command blocks specifically, leaving all other c...

quaint mantle
quaint mantle
#

doesnt seem to

#

World doesnt have a variable for the world

young knoll
#

Why would that work

#

You need a World instance

#

Not a world type

quaint mantle
#

then how would I set the world?

wet breach
#

you grab it from the list of worlds the server has loaded currently or knows about

#

each world has a name and UUID

#

you can fetch them with either, generally recommended to fetch with UUID, but using the name for the defaults is just fine usually

#

or use the enums

quaint mantle
#

would work ??

wet breach
#

if its named Normal

quaint mantle
#

it is

young knoll
#

That’s a weird world name

wet breach
quaint mantle
wet breach
#

World world = Bukkit.getWorld("NORMAL");

#

and now you have a valid world object

#

to stuff into your location object

#

for teleporting

quaint mantle
#

ah alr

#

ty

#

it works

#

Any events for detecting inventory changes?

#

EX: Picking an item up, dropping it, etc

#

(aka items being added/removed from the inventory)

earnest forum
#

I think there's one for dropping

young knoll
#

There’s a pickup event

#

And a drop event

earnest forum
#

Just go to javadoc

#

search up inventory event

quaint mantle
#

i checked those

earnest forum
#

or maybe item event

quaint mantle
#

wont work

#

i have a texture pack that if an iron nugget is a coin, it changes to a texture

young knoll
#

“Won’t work” how

quaint mantle
#

I want it so that if the player has more than X stacked up on 1 item

#

AKA they have 32+ of an item stacked together, in a coin

#

it changes its texture

#

to a "large stack"

earnest forum
#

Entity(Drop/Pickup)ItemEvent

#

nvm

#

there's one for player

#

replace Entity with Player

young knoll
#

Player pickup event is deprecated

earnest forum
#

there's an inventory pickup even

#

?

#

is that the updated one

quaint mantle
#

Should I just make a task that for every player, check their inventory, if the item is a coin and is bigger amount then 32, it changes the texutre?

#

or smth

young knoll
#

EntityPickup is the replacement for player pickup

earnest forum
#

is player drop deprecated

vocal cloud
young knoll
quaint mantle
#

cant remember directly who

young knoll
#

You’d have to monitor the pickup, drop, and inventory click events

quaint mantle
#

it was earlier today however

vocal cloud
#

I sent that a while back

young knoll
#

Which is annoying, but it should work

quaint mantle
quaint mantle
#

eh

#

what can you do

vocal cloud
quaint mantle
#

however

#

thats like 15 lines of code

earnest forum
#

no reason to use a runnable for that

young knoll
#

Funny enough vanilla has an event for any inventory change

quaint mantle
#

actually, i COULD just make it so you combine 9 items in a crafting table

young knoll
#

But spigot doesn’t have an equivalent afaik

quaint mantle
#

and it combines to a stack of coins?

#
  • vise versa
vocal cloud
#

The issue is with writing a task that runs every x ticks is every tick it's run with no updates is a waste of resources.

earnest forum
#

yes u should do that

earnest forum
#

using events makes sure that the code is only ran when it's needed

quaint mantle
#

Also, why does a texture pack not show the custom recipe now for coins?

#

Before it would show it in the guide or whatever

#

Now it doesnt

young knoll
#

What does a texture pack have to do with that

#

I’m confused

quaint mantle
#

its an iron nugget

young knoll
#

And

quaint mantle
#

if it has a PDV that states its a coin

#

texture changes

young knoll
#

Texture packs don’t control recipes

quaint mantle
#

but idkw its not showing now lol

earnest forum
#

what's a pdv

young knoll
#

Do you have the recipe unlocked

quaint mantle
young knoll
#

Persistent data value I assume

quaint mantle
#

^^^

young knoll
#

Even though that doesn’t control textures

earnest forum
#

so nbt

young knoll
#

Mhm

#

Recipes aren’t unlocked until you craft them

#

By default

quaint mantle
#

yea no its still not showing lol

#

and it is craftable

young knoll
#

Did you craft one

quaint mantle
#

yes

#

with a crafting table

young knoll
#

Shrug

vocal cloud
young knoll
#

Custom recipes are kinda wonky

#

Easier to just give them to the player on join or something

#

Player#discoverRecipe iirc

vocal cloud
#

I prefer to make my own crafting inventories to avoid these sorta issues. kek

quaint mantle
#

if so holy shit

#

i wanna make that now

#

lol

young knoll
#

Sure but it’s a pain

#

Gotta watch for them dupe glitches

vocal cloud
#

Why not make a permanent singular item that's a purse that stores the money as a number on it's PDC?

vocal cloud
#

But like 1 item

quaint mantle
#

that litterally is what it is

#

it saves it to a class

vocal cloud
#

Wait so whats the issue here?

quaint mantle
#

Its not showing the recipe in the guide

#

After installing a texture pack

young knoll
#

Or make a proper advancement to unlock it

#

And yes, recipes are unlocked by advancements

quaint mantle
#

@young knoll your idea worked

#

awarding the player with the crafting recipe unlock

#

shows it now

#

:P

#

ty

#

kinda dumb tho, why make it like that?

vocal cloud
#

Because with the new MC system they make it so recipes need to be unlocked via various methods

hexed hatch
#

well, all recipes are unlocked by default

#

but the capability is there for datapack makers

#

to award recipes by advancements that is

young knoll
#

Craftable by default, yes

#

But unlocked, no

#

The vanilla game has a fuckload of advancements to unlock recipes

vocal cloud
#

I mean crafting money via items seems like an easy way to enable users to print money with dupes

young knoll
#

I mean

#

You could just dupe the money item

#

Why bother duping the ingredients

quaint mantle
#

SecurityCore?

#

cant remember what its called

#

to track those ppl down

#

shouldnt be horrible

vocal cloud
quaint mantle
#

fuck nvm

#

well shit all those plugins are outdated and gone

#

LMAO

kind hatch
#

As long as users can't dupe items due to the plugin itself, then don't worry about it. It's up to server owners to handle dupe exploits on their own.

vocal cloud
#

True, but if they come to you asking for a solution to rampant inflation

#

IE "your plugin allows for duped currency"

young knoll
#

Call it a feature

#

It’s like the ruble

#

Russian economy simulator

quaint mantle
#

"Its a feature not a bug"

#

ez

quaint mantle
#

Also this is a private plugin for my server

#

God I made a /shop command, /tags

#

adn etc

vocal cloud
#

Over 40% of the Money US in its history was printed in 2020

quaint mantle
#

seriously?

#

inflation

vocal cloud
#

yup

quaint mantle
#

that is how you cause inflation lol

vocal cloud
#

If you made it so money was consumed on craft or something then you could monitor how much a user makes per week/day/hour etc and that would be an easy way to monitor for people cheating the system

quaint mantle
vocal cloud
#

The issue with that is once something becomes an item it has all the issues that come with being an item
lost/stolen/deleted by autocleanup kekw / duped

quaint mantle
#

win

quaint mantle
#

i wonder where all of the money is going

quaint mantle
#

lol

#

well no

echo saddle
#

halloween sized

quaint mantle
#

1.50

vocal cloud
quaint mantle
#

but still

kind hatch
#

There are ways to work around dupes. Unique IDs per item are one way, but a pain in the ass to keep track of on something like currency. You would still have the other aforementioned issues though.

echo saddle
#

recent jenkins updated borked config files.

vocal cloud
#

When you have stacks of an item unless you make all of them have a unique id that will cause stacking weirdness

quaint mantle
#

^^^

#

Cause doesnt even effecting NBT data

#

make stacking issues

#

ik for a fact doing most other changes to an item does

vocal cloud
#

Items will not stack if they have different PDC values.

quaint mantle
#

Called it :/

#

Question, can you force set how much an item can be stacked?

vocal cloud
#

Solution is to de-physicalize it and make it a purse or something and add send/receive commands. That way the flow of cash can be monitored easily and cheaters who send to alt accounts can be banned along with the original offender

quaint mantle
#

Like if you wanted a custom item to only be stacked to 16, but its normally 64, is that possible?

quaint mantle
kind hatch
#

I believe there is a method called #setMaxStackSize() that might still exist.

#

However it only works in certain circumstances.

vocal cloud
#

You can get the max stack size but I don't imagine you can set it

quaint mantle
#

I guess I could do constant checks for it idk

young knoll
#

You can set it with janky NMS hacks

kind hatch
#

IIRC, it works a little something like this. You can set the max stack size to anything lower than it's max stack size. Meaning an item that normally stacks to 64 can be set to anything below that. Same thing can be said for items that only stack up to 16.

young knoll
#

Ever seen a stack of 32k water bottles?

quaint mantle
young knoll
#

What

quaint mantle
#

thats possible?

#

jesus

#

wait..

#

so in theory

#

i can have 0 of an item

#

or negative

#

:/

kind hatch
#

Not anymore.

young knoll
#

You can

#

But it won’t render properly

kind hatch
#

I thought methods for that were patched.

young knoll
#

Idk

#

Maybe

vocal cloud
#

I wouldn't mess with stuff like that though

young knoll
#

Apparently setMaxStackSize is a real method

quaint mantle
#

Obviously not

young knoll
#

But it’s on Inventory

quaint mantle
vocal cloud
#

The first caveat is probably the most important

young knoll
#

It’s also global

#

Not per item

quaint mantle
#

Well.. then is there a way I can force an item to only be set to 1, like if they attempt to stack it it doesnt work?

#

cause i noticed all items that dont stack, have a special use case

kind hatch
#

Just put a random piece of data on that item.

vocal cloud
kind hatch
#

Items that aren't an exact 1:1 match will not stack together.

young knoll
#

Just shove a uuid into the pdc

quaint mantle
#

I just realized.. doing that, couldnt I make an item that can be tracked to see how many exist in the world?

vocal cloud
#

Yes.

young knoll
#

Kinda of

#

Until it gets duped

kind hatch
young knoll
#

Although you can use it as an anti dupe

vocal cloud
#

I have this with my weapon/shield/armor crafting plugin. If more than one of an item exists than I can issue an alert to staff to warn them that someone somehow has created another of an item.

young knoll
#

If two items have the same uuid it’s either a dupe or god tier luck

quaint mantle
#

so instead of random, its a single number

#

slowly going up

#

in which, it could only be a dupe

vocal cloud
#

Create a hash using the players UUID as a salt and some randomness and you've got a guaranteed unique item id.

young knoll
#

Well

#

Not guaranteed

#

Hashes collide just like UUIDs

vocal cloud
#

But the probability is insurmountably low. Plus you can check the DB for said hash if you're that paranoid about it

young knoll
#

Mhm

#

UUIDs are just easier

#

But also bigger in PDC

kind hatch
vocal cloud
young knoll
#

Oh we talking that hash

quaint mantle
#

Alr

young knoll
#

Not hashcode

quaint mantle
#

but yea ANY item that has a limit to 1 stack, has a special use

vocal cloud
#

nonono when I say hash I mean the good shiz

quaint mantle
#

I cant find ANY item that doesnt have 1

#

Well.. except for clocks and compasses.

#

Can I overwrite its texture without having to make it update?

young knoll
#

Just make a fake limit of one then

vocal cloud
#

The only issue with say having an easy-to-make currency that would require a hash per coin is that you'd have to check each coin redeemed against a massive list of hashes eventually.

kind hatch
#

And that's only going to get worse over time.

quaint mantle
kind hatch
#

Or used a blockchain like system that would only take into account recent transactions.

quaint mantle
#

not a hard system to impliment

#

I CAN USE THE UNIX EPOCH TO GENERATE A TRUELY RANDOM ID

#

BIG BRAIN

young knoll
#

Not quite

#

But mostly

quaint mantle
#

well id do Unix-Random numbers

#

to make it even harder

vocal cloud
#

Well you'd want to salt it with the users uuid

quaint mantle
vocal cloud
#

just to add some flavor

quaint mantle
#

didnt think that id think of THAT

kind hatch
#

I mean, the unix epoch is predictable. So if I figured out your method for randomization, I could easily predict future outcomes.

young knoll
#

Honestly system.currentTimeMills is probably enough

vocal cloud
#

Nano time

#

😉

young knoll
#

Nano time isn’t constantly increasing

quaint mantle
#

that make it kinda easier wouldnt it

young knoll
#

No

quaint mantle
#

what so

#

its the milliseconds sinec the unix epoch basiaclly>

#

*basically

#

jesus

young knoll
#

Yes

#

nanoTime is system based

#

So it can reset

#

currentTimeMills is epoch based

quaint mantle
#

So the chances of something being the same

#

twice

#

is impossible

#

UNLESS

#

it was a duoe

#

*dupe

vocal cloud
#

Could always slap on some SecureRandom

quaint mantle
#

well screw me now im having stacking issues

#

with iron coins

#

awesome

vocal cloud
#

Well if you add an ID or something unique say goodbye to stacking lol

quaint mantle
#

i didnt lol

#

it only stacks if its crafted

kind hatch
#

Especially if it's unique.

quaint mantle
#

if i give it to myself, or in other means, it doesnt stack

#

weird

kind hatch
#

That likely means that your methods for creating the item are different for those scenarios.

#

Which is why they aren't stacking.

quaint mantle
#
Items ironCoin = Items.newItem("ironCoin", null, true);

        item = new ItemStack(Material.IRON_NUGGET, 1);
        meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.GRAY + "Iron Coin");
        key = NamespaceKeyList.getKey("coin");
        meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "iron");
        lore = new ArrayList<>();
        lore.add(ChatColor.DARK_GRAY + "An iron coin. Right click to gain 1 coin.");
        meta.setLore(lore);
        meta.setCustomModelData(1);
        item.setItemMeta(meta);
        ShapedRecipe recipeD = new ShapedRecipe(NamespacedKey.minecraft("ironcoin"), item);
        recipeD.shape(" I ","IBI"," I ");
        recipeD.setIngredient('I',Material.IRON_INGOT);
        recipeD.setIngredient('B',Material.IRON_BLOCK);

        ironCoin.setItem(item);
        ironCoin.addRecipe(recipeD);
#

I mean, this seems fine

#

nothing about this is unique whatsoever

kind hatch
#

What about your command for giving it manually? Are you creating the item the same exact way?

quaint mantle
# kind hatch What about your command for giving it manually? Are you creating the item the sa...
public class SpecialGiveCommand implements CommandExecutor{
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
        if (sender instanceof Player p){
            if(p.getName().equalsIgnoreCase("AnEmerald")){
                if(args.length > 0){
                     String user = args[0];
                     String item = args[1];
                     if(EmeraldsPlugin.jp.getServer().getPlayer(user) != null && Items.getItem(item) != null){
                         ItemStack foundItem = Items.getItem(item).returnItem();
                         EmeraldsPlugin.jp.getServer().getPlayer(user).getInventory().addItem(foundItem);
#

you tell me

#

it grabs the item directly

kind hatch
#

What does Items#getItem() do?

quaint mantle
#
public ItemStack returnItem(){return this.item;}
kind hatch
#

How do you populate that list? Or where do you add the item to that list?

quaint mantle
#

hold on i found the issue i think

#

it was an oversight

#

i had a value that prevent items from being used in crafting

vocal cloud
young knoll
#

Hey

#

Who made an emoji of me

#

Smh

quaint mantle
#

here is the class

#

FUCK LINE SPAM

#

didnt think it was THAT big

vocal cloud
#

just use paste

quaint mantle
#

?paste

undone axleBOT
quaint mantle
#

@vocal cloud here

vocal cloud
nimble torrent
#

https://paste.md-5.net/atihibowex.bash

im getting Cannot invoke "[Ljava.lang.String;.clone()" because "this.rows" is null

        //Sharpness
        ItemStack sharp = new ItemStack(Material.ENCHANTED_BOOK, 1);
        sharp.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 6);
        EnchantmentStorageMeta metaSharp = (EnchantmentStorageMeta)sharp.getItemMeta();
        sharp.setItemMeta(metaSharp);

        NamespacedKey keySharp = new NamespacedKey(this, this.getDescription().getName());
        ShapedRecipe recipeSharp = new ShapedRecipe(keySharp, new ItemStack(sharp));
        recipeSharp.shape(" D ", "NSN", " N ");
        recipeSharp.setIngredient('N', Material.NETHERITE_SCRAP);
        recipeSharp.setIngredient('S', Material.DIAMOND_SWORD);
        recipeSharp.setIngredient('D', Material.DIAMOND);

        Bukkit.getServer().addRecipe(recipeSharp);

        //Protection
        ItemStack prot = new ItemStack(Material.ENCHANTED_BOOK, 1);
        prot.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 5);
        EnchantmentStorageMeta metaProt = (EnchantmentStorageMeta)sharp.getItemMeta();
        prot.setItemMeta(metaProt);

        NamespacedKey keyProt = new NamespacedKey(this, this.getDescription().getName());
        ShapedRecipe recipeProt = new ShapedRecipe(keyProt, new ItemStack(prot));
        recipeSharp.shape(" D ", "NCN", " N ");
        recipeSharp.setIngredient('N', Material.NETHERITE_SCRAP);
        recipeSharp.setIngredient('C', Material.DIAMOND_CHESTPLATE);
        recipeSharp.setIngredient('D', Material.DIAMOND);

        Bukkit.getServer().addRecipe(recipeProt);```
kind hatch
nimble torrent
#

Bukkit.getServer().addRecipe(recipeProt);

kind hatch
#

It's probably how you are adding enchantments to your items. Create the item ---> modify the item meta (ItemMeta) ---> apply enchantments. Try that.

young knoll
#

I see it

nimble torrent
#

ok

young knoll
#

You use recipeSharp a bunch

#

Instead of recipeProt

nimble torrent
#

im dumb

kind hatch
#

That too

nimble torrent
#

i see it too

young knoll
#

Granted spigot could have a nicer error there :p

errant narwhal
#

hi bro

nimble torrent
#

java.lang.IllegalStateException: Duplicate recipe ignored with ID sharpness:sharpness

quaint mantle
#

@vocal cloud figured it out, the crafting recipe didnt have the antiCraft value

#

so it was technically a different item

vocal cloud
kind hatch
#

Called it.

vocal cloud
#

I mean it was obviously a PDC mismatch somewhere

quaint mantle
#

just took a bit to know the "where"

vocal cloud
#

Gotta make a universal item retrieval mechanism

kind hatch
#

It'd probably be beneficial to have methods to create each unique item, then populate your hashmap with those the return value of those methods.

nimble torrent
#

oh

#

im actaul;ly autistic

quaint mantle
#

well im tired as hell

#

and dont wanna stay up

#

so yea gn

#

lol

nimble torrent
quaint mantle
#

ty for the help tho

errant narwhal
#

i have an idea for making interact event on leaves then the leaves will turn to iron_block but i don't know how to make replaceblock in area can someone help please

young knoll
nimble torrent
#

oh

errant narwhal
young knoll
#

Dangit wrong reply

#

Why does discord do that now

#

Blah

kind hatch
#

I think it's just you.

young knoll
kind hatch
#

I have yet to reply to the wrong person. 😛

young knoll
#

I swear I long pressed the right one

errant narwhal
vocal cloud
#

Yup

#

?jd-s

undone axleBOT
kind hatch
#

It's a bit more nuanced than that right? Some blocks require updates don't they?

errant narwhal
kind hatch
#

Or does setType cover that?

vocal cloud
#

I'm going to make a gif to help people 1s

young knoll
#

setType covers physics updates

kind hatch
#

Correct me if I'm wrong, but I thought that you needed to call #update() after you call #setType().

young knoll
#

Nope

kind hatch
#

Then, what's the usecase for that method? Is it even necessary anymore?

vocal cloud
#

?jd-s

undone axleBOT
vocal cloud
kind hatch
#

We're talking about BlockStates right?

young knoll
#

States are what you need it for, yes

smoky vapor
#

How would I access a local file I created?

#

(highlighted in blue)

nimble torrent
young knoll
#

You can add it with Player.discoverRecipe

nimble torrent
#

thx

nimble torrent
#

wait can i just do this?

#

player.discoverRecipe(NamespacedKey.minecraft("sharp"));

young knoll
#

If you are using the minecraft namespace

#

Which you probably shouldn’t be

#

That’s not a namespace key

nimble torrent
#

oh

#

im dumb

nimble torrent
young knoll
#

“Sharp” is just a string

#

Which is what you had posted

nimble torrent
#

a namespaced key is a string

young knoll
#

Not quite

#

It’s technically two strings

#

Connected with a :

nimble torrent
#

da hell

young knoll
#

<namespace>:<key>

#

ie
minecraft:stone
myplugin:cool_thing

vocal cloud
#

Yeah it's how mojang handles backend naming. If you've ever done modding it makes more sense from that standpoint

earnest forum
#

that's pretty cool

nimble torrent
#

ive just been doing javascript and i like mienecraft so i decided to learn java

earnest forum
#

i never knew it was like that

nimble torrent
#

im still confuzzled

young knoll
#

The main way to make one within a plugin takes your plugin instance as an argument

#

But actually just uses the name from said instance

earnest forum
#

new NamespacedKey(plugin, name)

#

so if your plugin is registered as TestPlugin

#

and u put the string as "hello"

#

is it TestPlugin:hello?

ancient jackal
young knoll
earnest forum
#

lowercase?

young knoll
#

It gets lowercased

#

Ye

nimble torrent
ancient jackal
#

if you use FileConfiguration on config.yml, you can get a value as simple as config.getInt("BlocksAboveY"); for example

young knoll
ancient jackal
young knoll
#

Or you can just remake it using new NamespacedKey(plugin, string)

young knoll
#

Meh

nimble torrent
young knoll
#

Keys are perfectly fine as a static constant

young knoll
nimble torrent
#

no like

young knoll
#

The key is just that, a key

nimble torrent
#

oh

#

so itll still work if i remake it?

young knoll
#

Yes

#

It’s mapped to your recipe inside spigot somewhere

nimble torrent
#

i was thinking to do that but i thought it wouldnt work

#

3 hours of my life down the drain

#

thats learning

nimble torrent
#

am i in the wrong file or some

earnest forum
#

send code

smoky vapor
earnest forum
#

like the whole function

young knoll
#

For a text file you’ll need to use standard java file reading systems

ancient jackal
#

you should use yml or json mostly

nimble torrent
#
public static void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        player.discoverRecipe(new NamespacedKey(this, "sharp"));
    }```
young knoll
#

Mhm

#

Is that in your main class

nimble torrent
#

no

young knoll
#

Also don’t make event handlers static

nimble torrent
#

in my event handler

nimble torrent
ancient jackal
#

json you can use gson or jackson or import your own dependency, yml you can use bukkit things

earnest forum
#

yes u cant make them static

young knoll
earnest forum
#

and add @EventHandler before

ancient jackal
#

otherwise, you can use string manipulation

young knoll
#

You actually can make them static

#

But don’t

nimble torrent
earnest forum
#

you cant use the this keyword in static methods

ancient jackal
#

like saving each line to a list and then getting the value out of each setting by splitting at ":" and trimming and then attempt to parse or something

earnest forum
#

this is for instanced objects

ancient jackal
#

but then again just use yml for that if you have things like setting: true since spigot can do that for you

nimble torrent
#

aaaaaa gtg soonm

nimble torrent
young knoll
#

Well yeah

#

You get it from the event

nimble torrent
#

yea

#

so what do i do

young knoll
#

Or you can pass your main class to the event handler class

nimble torrent
#

no

#

so waht do i do

young knoll
#

What do you mean “no”

nimble torrent
#

nvm

young knoll
#

Passing your plugin instance around is common

nimble torrent
#

should i do that?

#

what is more efficient

#

to

#

get it in the recipe

#

book

young knoll
#

Both are equally efficient

#

But having your listeners out of you main class is cleaner

nimble torrent
#

what do i do to get it in the recipe book

young knoll
#

Give them the recipe in the join event

nimble torrent
#

how

#

i dont know how to implement it

#

into

#

the

young knoll
#

The join event let’s you get the player

nimble torrent
#

ok

young knoll
#

And the player has a discoverRecipe method

nimble torrent
#

i dont know the syntax for player.discoverRecipe

young knoll
#

Just takes a namespaced key iirc

nimble torrent
#

or hwo to implement the thing into it

earnest forum
nimble torrent
nimble torrent
earnest forum
#

its mapped to it

young knoll
#

All you need is that same instance

earnest forum
#

so like when you try to do other stuff with that recipe

nimble torrent
#

new NamespacedKey(this, "prot"); this?

earnest forum
#

u get it by using that

young knoll
#

Or a new instance with the same value

nimble torrent
#

doesnt work

#

Cannot resolve constructor 'NamespacedKey(com.Roe.Sharpness.events.events, java.lang.String)'

#

it says that

tardy flame
#

You cannot assign listener to key

young knoll
#

Yes

#

You need an instance of your main class

#

Pass it to your event class with dependency injection

#

?di

undone axleBOT
earnest forum
nimble torrent
earnest forum
#

ok

#

so in your events class

#

you know when u register the event

#

from your main class?

nimble torrent
#

in javascript i do

nimble torrent
earnest forum
#

you pass in a new Events() object?

nimble torrent
#

pass that in

earnest forum
#

or whatever ur class is called

nimble torrent
#

like module exports?

earnest forum
#

yes

#

so basically

#

as an argument

#

u pass in this

nimble torrent
earnest forum
#

and then in the event class

#

for the constructor

#

pass in an instance of your main class

#

whats your main class called?

nimble torrent
#

sharpness

#

ok i have to go i will read this chat when i wake up

earnest forum
#
private Sharpness plugin;
public Events(Sharpness plugin) {

  this.plugin = plugin;
}
nimble torrent
#

you can send the message

#

thx

earnest forum
#

this is dependency injection

ancient jackal
#

is PlayerQuitEvent still called on a player kick? wondering because PlayerKickEvent exists

earnest forum
#

it should

#

but kick event is also called

#

im not 100% tho u should search it up

#

or test it

#

is it that much of a difference?

tardy flame
#

Based

#

If you will be using it in lambda expression then you need it as final to use it as value

#

But you should also remember to use styles that language imports

young knoll
#

Final just stops you from accidentally reassigning it

tardy flame
#

So yeah

tardy flame
#

I mean-

#

Check it in docs

ancient jackal
#

do you ever hate yourself when it comes to code? been stuck on a utility class. it only writes a hashmap in gson. not a problem, right? right?
it all started with creating the config...
it ends with me forgetting to close a writer

tardy flame
#

🤔

earnest forum
#

whats a good item for titanium in the base game

#

cbf making a texture

tardy flame
#

I need to redevelop my MySQL importer for 3 months now and i didn't started yet

ancient jackal
tardy flame
#

I hate databases so much

earnest forum
#

mirthium?

ancient jackal
#

you know, those underground crystals

earnest forum
#

amethyst?

ancient jackal
#

yeah that

young knoll
#

Lol

earnest forum
#

where'd you get mirthium from lmao

ancient jackal
#

mithium or something

young knoll
#

I’ve never heard it called mirthium before

nimble torrent
#

back

#

so

#

i showered

#

i have like 5 mins

#

im still kinda confuzzled

#

ill just not use recipes

#

this is too annoying 😦

earnest forum
ancient jackal
earnest forum
#

should i use the one on the left as the ore, and the ones on the right as refined or other way around?

#

i feel like the right looks more oreish

ancient jackal
#

right is raw imo, it's like copper

earnest forum
#

can i make like 1 item smelt more than 1 shard?

#

say if i wanted the large crystal to smelt into like 3 shards

#

can i do that with furnace recipes?

young knoll
#

Yes

young knoll
#

The result is a full Itemstack

#

So count should work

#

Minecraft isn’t designed to handle stacked items as input, but output works fine

earnest forum
#

this ok?

#

ima just try it

young knoll
#

Should be fine

earnest forum
#

yes

#

thanks

#

also

#

if im making a class for each kind of custom block i want

#

should i use an abstract class as a base or an interface?

young knoll
#

Depends if you want some default stuff

#

Although I think you can do default stuff in interfaces now

earnest forum
#

thing is

#

i only want like a brokenBlock method as a default

#

and then when i want to use like canBreak

#

i have to get an instance of the actual class that extends the abstract

#

which i dont want

#

nvm im talking nonsense

#

im using abstract rn and its working alright

ancient jackal
vocal cloud
#

Just use reflection to auto register events dogekek

ancient jackal
vocal cloud
#

Using reflection

young knoll
#

Just scan for classes containing methods with the annotation

#

And then let spigot scan them again

#

Meta

#

Has no one made a library to do this yet

vocal cloud
#

Maybe I should huh. I've done it a lot

sharp flare
#

I've seen others do that through reflection, but whats the advantage

vocal cloud
#

becomes

young knoll
#

Not sure the best way to go about it

#

You’d have to create an instance of the handler class, which could be complicated if it has a non-empty constructor

quaint mantle
#

i mean you dont have 200 listeners

vocal cloud
young knoll
#

To be fair

quaint mantle
young knoll
#

I doubt it’s delaying startup by that much

quaint mantle
#

maybe

sharp flare
# vocal cloud becomes

can't this be done on separate method or class (by getting the instance of the plugin)

ancient jackal
#

I just store all of my listeners into a HashMap with a key of their name that maps to an instance of each listener, then iterate through the HashMap entries using an enhanced for loop and registering each event individually

young knoll
#

I loop over my jar in several plugins to extract files >:)

vocal cloud
young knoll
#

Ew reflections

#

Big dependency

quaint mantle
#

^

young knoll
#

I’ve done it without

#

And yes it’s probably not the fastest but shh

vocal cloud
#

Probably could but I wanted to do it quickly.

quaint mantle
#

you're literally just making it harder on yourself than writing 4 lines

quaint mantle
#

in this case if you're tallking about using a hashmap

ancient jackal
#

😱

#

take it back

young knoll
#

Imma mess with an auto register system tomorrow

#

See how fast I can make it

#

Because why not

tardy delta
#

Register them in constructor and make new objects lol

#

🧐

ancient jackal
#

can someone make a saving interval for me because I need to sleep

#

just a bukkit runtasklaterasynchronously and then using a dbutil method with a hashmap as argument

vocal cloud
#

I've got a 5head idea. Brb lol

sullen fox
#

I have three plugin files in my plugins folder of my localhost server, 2 plugins are displayed in /plugins but 1 is not

kindred valley
#

Hello, I asked a question about the item drop event yesterday, but I could not get an answer. I created an itemstack and I want to prevent this item from dropping to the ground

quaint mantle
sullen fox
earnest forum
sullen fox
#

I'm sending the logs

sullen fox
earnest forum
#

all of them

quaint mantle
quaint mantle
sullen fox
#

yes

#

one second

#

while my IDE loads up

#

2 out of 3 plugins work

#

and show in /plugins

quaint mantle
sullen fox
#

but only 1 plugin named MyCommandsPlugin doesnt work

kindred valley
earnest forum
#

.equals

#

also

quaint mantle
#

not what he means

earnest forum
#

you can use PlayerDropEvent can't you?

sullen fox
#

@quaint mantle gimme a minute, i need to verify myself in order to send images

quaint mantle
sullen fox
#

can I dm you instead?

quaint mantle
sullen fox
#

oh

#

sec

#

@quaint mantle

quaint mantle
#

not that i mean of the directory itself

#

where the plugin jars are at

sullen fox
#

ah

earnest forum
#

file directory

sullen fox
quaint mantle
#

send console log

sullen fox
#

lemme run the server again

#

one sec

earnest forum
#

is Player#addPotionEffect's duration in ticks?

sullen fox
#

@quaint mantle I found out the error xD

#

I had "description : : s "

#

two :

#

that was the error

quaint mantle
#

you said no errors...

sullen fox
#

bro

#

I checked out the log

#

but

#

it wasnt there before

#

😅

earnest forum
#

can i set a shaped recipe ingredient to a custom itemstack

#

or can it only be a material

quaint mantle
#

RecipeChoice.ExactChoice

earnest forum
#

how do i use that?

#

for the argument i pass in RecipeChoice.ExactChoice(itemstack)?

quaint mantle
#

yes

dark arrow
#

Is there any good free server hosting site on which i can test my plugins

earnest forum
#

why don't you just host your own one?

dark arrow
#

My pc wont like it

smoky oak
#

its not too bad

#

maybe 20-30% performance hit if you turn down render distance

#

afaik theres no free website that allows custom plugins

dark arrow
#

But

#

I have only 8 gb ram

#

when i run both together is becomes too laggy to play

#

oo

#

And my ide starts lagging too

valid solstice
#

if a player is holding a bow, does Player#getDamage() get the bow damage?

#

or does it get the fist damage

#

how do i get the bow damage?

#

ah that's pain i gotta make another event handler

#

alr thanks

wet breach
#

and what exactly you mean bow damage

valid solstice
#

The bow damag

wet breach
#

as in how much damage it will deal or have much damage it will take

valid solstice
#

how much damage it will deal

wet breach
#

you will have to use the methods for arrows

#

it isn't the bow itself that does the damage, the arrows are

valid solstice
#

oh alright i see what you mean

#

alrighg thanks ill try entitydamagebyentity

glossy venture
#

is custom model data an integer?

#

does it accept the full range?

#

why isnt there a way to just change a model based on any nbt tag

#

you want

young knoll
#

I think it’s capped at like

#

999,999

smoky oak
#

why not a 2^n number?

young knoll
#

I lied

#

9,999,999

dapper ether
#

why does everybody replace the . with an #?

young knoll
#

Used to show a method isn’t static

dapper ether
#

ohhh

young knoll
#

As Player.setHealth looks like a static method

#

Even though it is not

dapper ether
#

thanks

glossy venture
#

to calculate change in % you do

new - old
--------- * 100 %
   old
``` right?
smoky oak
#

looks bout right

midnight shore
smoky oak
#

probably missing either an import or a independency

midnight shore
#

but everything is fine in my ide

smoky oak
#

ide yes

#

you havent declared scope

young knoll
#

You need to shade it

smoky oak
#

or to also have it on your server

midnight shore
#

What do you mean?

midnight shore
#

its a driver it isn't another plugin

smoky oak
#

well in either case it needs to be present

#

iirc no declaring scope defaults to 'provided'

#

but its not

midnight shore
smoky oak
#

well replace provided with the keyword with whatever makes it include

#

i dont remember what it was

midnight shore
#

no no i added this now

#

is it ok?

#

nothing really changed

smoky oak
#

well considering its not greyed out your ide can see the driver

midnight shore
smoky oak
#

try scope compile

midnight shore
#

nothing changed

smoky oak
#

?

midnight shore
#

same error

smoky oak
#

declaring compile specifically should make sure it is included in the project

midnight shore
smoky oak
#

did you maybe not copy the target jar to the server?

midnight shore
midnight shore
smoky oak
#

maven spits out the result in a target folder

#

you need to copy that file to the plugins folder of the server

glossy venture
#

do you shade the dependency

#

include it in the jar?

midnight shore
worn tundra
#

Or you can specify an output folder

#

So it will spit it right into the plugins folder

midnight shore
worn tundra
#

Can you paste your entire pom

#

Please

midnight shore
#

everything else does work

#

except from that

worn tundra
#

Inside maven shade plugin