#help-development
1 messages ¡ Page 2024 of 1
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
Is the mine a menu or a real mine/room ?
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
Is the ore inside the mine generated randomly?
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
hm
my thoughts exactly đ
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
Yes, you can do that with ItemMeta#setCustomModelData(). You will need a resource pack for this to work though. Otherwise it will just look like the normal item with an extra tag added.
Can I force a server to install a texture pack?
Also any tutorials?
Servers now have the option to force the player to accept the resource pack if they want to play on the server. IIRC, that setting can be found in the server.properties file.
Cool, ty
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.
no setCustomModelData
and how it works
Oh, well that's easy.
i would like to know too
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.
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/
ty
you can use a percentage of how many blocks are of that type in the mine, really it's just up to your creativity of how you'll do interval checks
personally I'd do async tasks
@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
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*
I'm pretty sure this is possible. If there is a way to add a predicate for item amount, then yes. However, I'm currently not aware of one that exists. It might be something even simpler, but you'd have to look into it.
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);```
What line
idk but it says this too at com.Roe.Sharpness.Sharpness.onEnable(Sharpness.java:52) ~[Sharpness.jar:?]
?paste
Send the full stack trace
How can I get a player who clicked on a certain item in inventory?
I think I might be doing it wrong.
Can I send you my texture pack so you can see if its incorrectly configured?
Sure
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?
Whyyy
Ant is so antiquated
^
ant more like atrocious
Antique
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
switches from desktop to laptop
spends an hour setting up dependencies on laptop
Oh yeah good idea 
Just copy all of their classes into your project
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 đ
Eclipse. That explains it
Yeah but generally it's easier to find the maven/gradle imports than the shaded jar lol
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?
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
maven is like 10x faster unless you have to manually import a jar. Then it's suffering.
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
Yeah but that doesnât help other people
https://maven.miketheshadow.ca local as in it's on a server that's local but it's still public. mb
nonono
It's hosted on an apache server.
Here is a better gif of maven's beauty 
It doesn't
I thought you needed one window per project
I usually have like 5 projects open at the same time
How would I make it so that instead of typing /game mode creative I could type /gmc?
use commandpreprocessevent or use aliases using the commands.yml
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
Honestly unless you're using jars not in central just looking through central will give you everything.
and all the properties that get set in the POM
Maven has a + button
are pulled from the Netbeans properties window
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 đ
How do I check if a player is in the overworld, nether, or end?
get their location and then getWorld()
World#getEnvironment
I suppose getEnvironment might work
Returns an enum for the type of world they are in
Usually have their own repos
player.getWorld().getEnvironment()
Pls don't bully me but what is the format for commands.yml? I only know plugin.yml and this is my 3rd day of learning
I will send you a link
I just realized the other day I never added the spigot repo to my build tool
and I don't bully people đ
Final question, how do I set their world?
Because I always have it local
.teleport
Takes a location, location has a world
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...
Tysm
loc.setWorld(WorldType.NORMAL);
doesnt seem to
World doesnt have a variable for the world
then how would I set the world?
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
so Bukkit.getWorld("NORMAL")
would work ??
if its named Normal
it is
Thatâs a weird world name
then that should work then
k
World world = Bukkit.getWorld("NORMAL");
and now you have a valid world object
to stuff into your location object
for teleporting
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)
I think there's one for dropping
i checked those
or maybe item event
wont work
i have a texture pack that if an iron nugget is a coin, it changes to a texture
âWonât workâ how
explaining in a sec
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"
Entity(Drop/Pickup)ItemEvent
nvm
there's one for player
replace Entity with Player
Player pickup event is deprecated
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
No
EntityPickup is the replacement for player pickup
is player drop deprecated
Don't over engineer stuff. Just check for changes to the inventory and modify it from there
No
yes ik coll or whatever told me "KISS"
cant remember directly who
Youâd have to monitor the pickup, drop, and inventory click events
it was earlier today however
I sent that a while back
Which is annoying, but it should work
ah
thats a small stepback but
eh
what can you do
Better than checking every inventory x ticks or so. Make a method that takes in the inventory and you just need to call it in each event.
idk how thats overengineered
however
thats like 15 lines of code
no reason to use a runnable for that
Funny enough vanilla has an event for any inventory change
actually, i COULD just make it so you combine 9 items in a crafting table
But spigot doesnât have an equivalent afaik
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.
yes u should do that
yeah exactly
using events makes sure that the code is only ran when it's needed
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
Cause it overwrites the texture on the same item
its an iron nugget
And
Texture packs donât control recipes
but idkw its not showing now lol
what's a pdv
Do you have the recipe unlocked
i think so?
Persistent data value I assume
^^^
Even though that doesnât control textures
so nbt
Did you craft one
Shrug

Custom recipes are kinda wonky
Easier to just give them to the player on join or something
Player#discoverRecipe iirc
I prefer to make my own crafting inventories to avoid these sorta issues. 
excuse me THATS POSSIBLE??
if so holy shit
i wanna make that now
lol
Why not make a permanent singular item that's a purse that stores the money as a number on it's PDC?
thats what it is
But like 1 item
Wait so whats the issue here?
.
Or make a proper advancement to unlock it
And yes, recipes are unlocked by advancements
@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?
Because with the new MC system they make it so recipes need to be unlocked via various methods
wow
well, all recipes are unlocked by default
but the capability is there for datapack makers
to award recipes by advancements that is
Craftable by default, yes
But unlocked, no
The vanilla game has a fuckload of advancements to unlock recipes
I mean crafting money via items seems like an easy way to enable users to print money with dupes
I mean, as long as I use whats it called
SecurityCore?
cant remember what its called
to track those ppl down
shouldnt be horrible

XSecurity then?
fuck nvm
well shit all those plugins are outdated and gone
LMAO
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.
True, but if they come to you asking for a solution to rampant inflation
IE "your plugin allows for duped currency"
Im positive they cant with my plugin
Also this is a private plugin for my server
God I made a /shop command, /tags
adn etc
Over 40% of the Money US in its history was printed in 2020
jesus
seriously?
inflation
yup
that is how you cause inflation lol
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
i made it a physically item so ppl could give it to others basically, but that is a good idea
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
/ duped
ill pull a gamer move and make it so you dont have an inventory then, which means you cant dupe
win
and yet a hershey bar still costs 1 dollar where i live. what inflation????
i wonder where all of the money is going
about 2.50 for us
lol
well no
halloween sized
1.50
Gas gas gas livin in the past dododoo
but still
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.
recent jenkins updated borked config files.
Yea.
When you have stacks of an item unless you make all of them have a unique id that will cause stacking weirdness
^^^
Cause doesnt even effecting NBT data
make stacking issues
ik for a fact doing most other changes to an item does
Items will not stack if they have different PDC values.
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
Like if you wanted a custom item to only be stacked to 16, but its normally 64, is that possible?
Ill make a poll about it later
I believe there is a method called #setMaxStackSize() that might still exist.
However it only works in certain circumstances.
You can get the max stack size but I don't imagine you can set it
You can set it with janky NMS hacks
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.
Ever seen a stack of 32k water bottles?
what
What
thats possible?
jesus
wait..
so in theory
i can have 0 of an item
or negative
:/
Not anymore.
I thought methods for that were patched.
I wouldn't mess with stuff like that though
Apparently setMaxStackSize is a real method
Obviously not
But itâs on Inventory
so?
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
Just put a random piece of data on that item.
k
Add an ID PDC value generate it using a hash algorithm and some random number
Items that aren't an exact 1:1 match will not stack together.
Just shove a uuid into the pdc
I just realized.. doing that, couldnt I make an item that can be tracked to see how many exist in the world?
Yes.
Yes, that's what I was referring to when I mentioned UUIDs per item.
Although you can use it as an anti dupe
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.
If two items have the same uuid itâs either a dupe or god tier luck
UNLESS you had a value in the config, that as the item was made, it go up by 1
so instead of random, its a single number
slowly going up
in which, it could only be a dupe
Create a hash using the players UUID as a salt and some randomness and you've got a guaranteed unique item id.
Huh, Akrught
A
alright
But the probability is insurmountably low. Plus you can check the DB for said hash if you're that paranoid about it
https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions
1 in a billion chance to get the same UUID.
A universally unique identifier (UUID) is a 128-bit label used for information in computer systems. The term globally unique identifier (GUID) is also used.When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration authority or coordination between the p...
Oh we talking that hash
Alr
Not hashcode
but yea ANY item that has a limit to 1 stack, has a special use
nonono when I say hash I mean the good shiz
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?
Just make a fake limit of one then
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.
And that's only going to get worse over time.
Well, UNLESS I were to do resets every year or smth.
Or used a blockchain like system that would only take into account recent transactions.
Using unixtime linked to the ids, if its older than 2 weeks or smth, it doesnt count
not a hard system to impliment
I CAN USE THE UNIX EPOCH TO GENERATE A TRUELY RANDOM ID
BIG BRAIN
Well you'd want to salt it with the users uuid
obv but still
just to add some flavor
didnt think that id think of THAT
I mean, the unix epoch is predictable. So if I figured out your method for randomization, I could easily predict future outcomes.
Honestly system.currentTimeMills is probably enough
Nano time isnât constantly increasing
doesnt mills reset daily however?
that make it kinda easier wouldnt it
No
So the chances of something being the same
twice
is impossible
UNLESS
it was a duoe
*dupe
Could always slap on some SecureRandom
Well if you add an ID or something unique say goodbye to stacking lol
thats the weird thing
i didnt lol
it only stacks if its crafted
Especially if it's unique.
That likely means that your methods for creating the item are different for those scenarios.
Which is why they aren't stacking.
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
What about your command for giving it manually? Are you creating the item the same exact way?
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
What does Items#getItem() do?
public static Items getItem(String locName){
return itemList.get(locName);
}
public ItemStack returnItem(){return this.item;}
How do you populate that list? Or where do you add the item to that list?
hold on i found the issue i think
it was an oversight
i had a value that prevent items from being used in crafting

nope nvm still isnt after a fix
here is the class
FUCK LINE SPAM
didnt think it was THAT big
just use paste
?paste

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);```
What's line 52 of your Sharpness class?
Bukkit.getServer().addRecipe(recipeProt);
It's probably how you are adding enchantments to your items. Create the item ---> modify the item meta (ItemMeta) ---> apply enchantments. Try that.
I see it
ok
im dumb
That too
i see it too
Granted spigot could have a nicer error there :p
hi bro
java.lang.IllegalStateException: Duplicate recipe ignored with ID sharpness:sharpness
@vocal cloud figured it out, the crafting recipe didnt have the antiCraft value
so it was technically a different item

Called it.
I mean it was obviously a PDC mismatch somewhere
yea i knew that
just took a bit to know the "where"
Gotta make a universal item retrieval mechanism
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.
They have the same namespace of
ah
well im tired as hell
and dont wanna stay up
so yea gn
lol
no they dont
ty for the help tho
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
Wdym by replayblock?
I see this.getDescription().getName() for both
oh
replace sorry
I think it's just you.
You just need to loop over the blocks you want and setType
I have yet to reply to the wrong person. đ
I swear I long pressed the right one
setType will change block?
It's a bit more nuanced than that right? Some blocks require updates don't they?
thx
Or does setType cover that?
I'm going to make a gif to help people 1s
setType covers physics updates
Correct me if I'm wrong, but I thought that you needed to call #update() after you call #setType().
Nope
Then, what's the usecase for that method? Is it even necessary anymore?

We're talking about BlockStates right?
States are what you need it for, yes
it works but it doesnt show in the recipe book anymore
how do i add it?
You can add it with Player.discoverRecipe
thx
the player isnt defined on enable and it isnt in the join event
wait can i just do this?
player.discoverRecipe(NamespacedKey.minecraft("sharp"));
If you are using the minecraft namespace
Which you probably shouldnât be
Thatâs not a namespace key
yes it is
a namespaced key is a string
da hell
Yeah it's how mojang handles backend naming. If you've ever done modding it makes more sense from that standpoint
that's pretty cool
ive just been doing javascript and i like mienecraft so i decided to learn java
i never knew it was like that
im still confuzzled
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
new NamespacedKey(plugin, name)
so if your plugin is registered as TestPlugin
and u put the string as "hello"
is it TestPlugin:hello?
doing it this way, you just need to read each line with the buffered reader now. but spigot has a FileConfiguration class you can use that makes a general config much easier to read from
Almost
lowercase?
i understand that but i dont understand how to implement it into player.discoverRecipe()
if you use FileConfiguration on config.yml, you can get a value as simple as config.getInt("BlocksAboveY"); for example
I usually keep my keys as a static constant somewhere
gotta use a factory smh
Or you can just remake it using new NamespacedKey(plugin, string)
đ
Meh
will it save the attributes/meta/data?
Keys are perfectly fine as a static constant
It doesnât contain those
no like
The key is just that, a key
i was thinking to do that but i thought it wouldnt work
3 hours of my life down the drain
thats learning
bruh "cannot be referenced from a static context"
am i in the wrong file or some
send code
Cool, but what about for other local files, such as a text file?
like the whole function
For a text file youâll need to use standard java file reading systems
you should use yml or json mostly
public static void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.discoverRecipe(new NamespacedKey(this, "sharp"));
}```
no
Also donât make event handlers static
in my event handler
ok
json you can use gson or jackson or import your own dependency, yml you can use bukkit things
yes u cant make them static
Then this wonât be a plugin instance
and add @EventHandler before
otherwise, you can use string manipulation
i did
you cant use the this keyword in static methods
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
this is for instanced objects
but then again just use yml for that if you have things like setting: true since spigot can do that for you
aaaaaa gtg soonm
i dont have player defined in the main class
Or you can pass your main class to the event handler class
What do you mean ânoâ
nvm
Passing your plugin instance around is common
Both are equally efficient
But having your listeners out of you main class is cleaner
what do i do to get it in the recipe book
Give them the recipe in the join event
The join event letâs you get the player
ok
And the player has a discoverRecipe method
i dont know the syntax for player.discoverRecipe
Just takes a namespaced key iirc
or hwo to implement the thing into it
same one as when u registered the recipe
this is the confuzzled part
lemme try rq
when u set the recipe to the namespaced key
its mapped to it
All you need is that same instance
so like when you try to do other stuff with that recipe
new NamespacedKey(this, "prot"); this?
u get it by using that
Or a new instance with the same value
but "this"
doesnt work
Cannot resolve constructor 'NamespacedKey(com.Roe.Sharpness.events.events, java.lang.String)'
it says that
You cannot assign listener to key
Yes
You need an instance of your main class
Pass it to your event class with dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
do u know what a constructor is
yes
ok
so in your events class
you know when u register the event
from your main class?
in javascript i do
yes
you pass in a new Events() object?
pass that in
or whatever ur class is called
like module exports?
tes
and then in the event class
for the constructor
pass in an instance of your main class
whats your main class called?
private Sharpness plugin;
public Events(Sharpness plugin) {
this.plugin = plugin;
}
this is dependency injection
is PlayerQuitEvent still called on a player kick? wondering because PlayerKickEvent exists
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?
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
Final just stops you from accidentally reassigning it
So yeah
I don't think so
I mean-
Check it in docs
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
đ¤
I need to redevelop my MySQL importer for 3 months now and i didn't started yet
mirthium but black
I hate databases so much
mirthium?
you know, those underground crystals
amethyst?
yeah that
Lol
where'd you get mirthium from lmao
mithium or something
Iâve never heard it called mirthium before
back
so
i showered
i have like 5 mins
im still kinda confuzzled
ill just not use recipes
this is too annoying đŚ
yeah mithium
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
right is raw imo, it's like copper
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?
Yes
The result is a full Itemstack
So count should work
Minecraft isnât designed to handle stacked items as input, but output works fine
Should be fine
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?
Depends if you want some default stuff
Although I think you can do default stuff in interfaces now
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
it actually ended with me forgetting to register events again
whats on line 55
Just use reflection to auto register events 
ayo? auto register? where?
Using reflection
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
Maybe I should huh. I've done it a lot
I've seen others do that through reflection, but whats the advantage
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
Don't need to register stuff anymore 
To be fair
you have to write a pretty complex reflection method
I doubt itâs delaying startup by that much
can't this be done on separate method or class (by getting the instance of the plugin)
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
I loop over my jar in several plugins to extract files >:)
To register it's a simple annotation
^
Probably could but I wanted to do it quickly.
you're literally just making it harder on yourself than writing 4 lines
HashMaps are good
thats literally so redundant
in this case if you're tallking about using a hashmap
Imma mess with an auto register system tomorrow
See how fast I can make it
Because why not
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
I've got a 5head idea. Brb lol
I have three plugin files in my plugins folder of my localhost server, 2 plugins are displayed in /plugins but 1 is not
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
send console log, if you arent developing the plugins goto #help-server
There is no error
I'm developing the plugins myself
do they have plugin.yml?
I'm sending the logs
yes
all of them
he said no errors
send screenshot of the directory
yes
one second
while my IDE loads up
2 out of 3 plugins work
and show in /plugins
listen to the entitydropitem event, check if the item is yours, if it is then cancel the event
but only 1 plugin named MyCommandsPlugin doesnt work
I cant use isSimilar with this events
not what he means
you can use PlayerDropEvent can't you?
@quaint mantle gimme a minute, i need to verify myself in order to send images
getItemDrop().getItemStack()
can I dm you instead?
ah
file directory
send console log
is Player#addPotionEffect's duration in ticks?
@quaint mantle I found out the error xD
I had "description : : s "
two :
that was the error
you said no errors...
can i set a shaped recipe ingredient to a custom itemstack
or can it only be a material
RecipeChoice.ExactChoice
how do i use that?
for the argument i pass in RecipeChoice.ExactChoice(itemstack)?
yes
Is there any good free server hosting site on which i can test my plugins
why don't you just host your own one?
My pc wont like it
its not too bad
maybe 20-30% performance hit if you turn down render distance
afaik theres no free website that allows custom plugins
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
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
depends which event you are talking about?
and what exactly you mean bow damage
The bow damag
as in how much damage it will deal or have much damage it will take
how much damage it will deal
you will have to use the methods for arrows
it isn't the bow itself that does the damage, the arrows are
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
why not a 2^n number?
why does everybody replace the . with an #?
Used to show a method isnât static
ohhh
thanks
to calculate change in % you do
new - old
--------- * 100 %
old
``` right?
looks bout right
Hi, why is this happening?
probably missing either an import or a independency
but everything is fine in my ide
You need to shade it
or to also have it on your server
What do you mean?
No no
its a driver it isn't another plugin
well in either case it needs to be present
iirc no declaring scope defaults to 'provided'
but its not
?
well replace provided with the keyword with whatever makes it include
i dont remember what it was
well considering its not greyed out your ide can see the driver
MongoDB Java Driver documentation
try scope compile
nothing changed
?
same error
declaring compile specifically should make sure it is included in the project
did you maybe not copy the target jar to the server?
wdym? sorry i'm new to maven
maven spits out the result in a target folder
you need to copy that file to the plugins folder of the server
oh
i don't think so
Or you can specify an output folder
So it will spit it right into the plugins folder
oh, how can i do that?
Inside maven shade plugin