#help-development
1 messages Β· Page 1228 of 1
well, two (2) is greater than one (1), therefore it's better
gonna convert paperweight to ss
so i need to run the first jar second jar specialsource command with, in my case, minecraft-server-1.16.5-R0.1-SNAPSHOT and with the one mojang provides for vanilla servers?
?tas
btw which repos do i delete? i tried deleting the m2 1.16.5 folder but it did not work
sounds good to me lol
but now i need to figure out why bt doesnt work π
it gets stuck at downloading git
the repos bt downloads
builddata, s, b, cb
if its in a clean folder it should work fine
Deobfuscator for Minecraft by mapping json. Contribute to HeartPattern/MC-Remapper development by creating an account on GitHub.
might help you in regards to applying mojang mappings
thanks, i'll look into it
I can't remember the last time, if ever, I've done so much writing of code and then deleting code for a project
this thing is starting to feel cursed
How do I set tittle from player inventory vom a another inventory
player.openInventory(target.getInventory());
Each Inventory has no title. The view does
just use worldedit api to paste shit πͺ
Isn't that what he's having issues with
from what i understand he's placing the blocks manually but suppressing light updates
if he were using worldedit i would assume he would also be using the worldedit relighter
or i don't know if suppressing light updates and then doing relighting after the fact is a fastasyncworldedit thing; if it is, i change my suggestion to just use fawe api to paste shit πͺ
I've never liked WE or FAWE's api
The docs alone are just bleh
but it's still better than reinventing the wheel
Maybe...
I remember rad doing something that was like a WE reinvention but it did extra shit
Idk that was a while ago I don't really remember
@blazing ocean
no
What was that project for
I wasn't doing anything of that kind
Yea you were
I explicitly remember when I was doing PreBuiltStructures you were making a WE clone kek
another option is to rewrite it as a world generator but that's probably not any easier
I'm in the process of integrating an adhoc wfc/a*/etc etc generation algo with world/chunk generators
And it's no fun π
i can imagine
like the literal character?
How can I put a discord integration that announces my plugin updates?
Can that be done?
and for the 5th consecutive time of this being suggested, I am saying again that this has been attempted, and it does not work
how so? i've done similar things and i don't recall any lighting related issues
how do i change what BlockBreakEvent drops? do i have to set the 'drops items' to false and manually spawn the items, and if yes, how do i make it so that it drops the same way as it would naturally?
Yes
Contribute to ShadowOfHeaven-Me/AlixSystem development by creating an account on GitHub.
I recommend using the BlockDropItemEvent
I'm having trouble getting this to work, the whole project seems invalid
As for dropping the items use the World#dropNaturally
what happens if this is called on an optional containing null?
nothing?
k
"present" means not-null
in context of optionals
so if it contains null, it's absent, and the action won't be run
event
.getItems()
.stream()
.map(Item::getItemStack)
.filter(e -> e.getType() == Material.CHISELED_BOOKSHELF)
.findFirst()
.ifPresent(e -> e.setData(block.getState().getData()));
ok this is cursed
Yea, idk what psycho uses e for itemstacks
hm. this just removes the bookshelf from existence entirely
but theres no error in console
assuming this is in blockdropitemevent or similar, block is probably air already
π€¦
back to blockBreakEvent it is
Not the worst I've seen kek... and I have written some pretty awful code
yea but good fuckin luck debugging this :V
I've been trying to use buildtools, but its stuck at this
[--nogui, --rev, 1.16.5, --remapped]
Loading BuildTools version: git-BuildTools-f901b6f-188 (#188)
Java Version: Java 16
Current Path: C:\Users\Jake\Documents\Spigot Builds\1.16.5
*** Could not find PortableGit installation, downloading. ***
Starting download of https://github.com/git-for-windows/git/releases/download/v2.45.2.windows.1/PortableGit-2.45.2-64-bit.7z.exe
nah thats your job :p
try it in gitbash
what do you mean by this?
you created/loaded the Location object before the world was loaded
can i just tell it 'hey that cant be the case here'
i think he's talking about the static null check warning
bc this runs in one tick and grabs the location from a loaded block
wrap it in Objects.requireNonNull()
no
this indicates that you expect it never to be null, and it never will be, because you're getting it from a block which must have a world
requireNonNull just makes teh error explode sooner
yes, that's the goal
no, his goal is to HAVE a world
@NotNull
no he's talking about the warning
ah
im asking if i can tell it that the warning / null check here is unnecessary
it really doesn't do anything
coz blockbreakevent kinda sorta needs a world to happen in
My mistake, I thought he was getting a null on creation
that'd be requirenonnull
largely a semantic difference but putting requirenonnull there indicates that you have acknowledged that the method is nullable and expect it never to be not null still, and for it to be null there is an error elsewhere
it won't actually do anything since the following method call would NPE instantly anyway
requireNot NUll will simply stop your IDE complaining about the possible NPE. It won;t fix anything else
looks like the download was just taking ages to get over with
I'd like to see a world unload async while im processing an event :kekw:
the ide complaining about it is it going "hey this could be null be sure to check your logic is right"
yep
requirenonnull is you answering "yeah trust me bro"
which means other developers looking at the same code (or god forbid you yourself 6 months later) can see that play out and be fairly confident in that you did indeed doublecheck the logic there
ok back to actual debugging, how do i shove blockdata into itemstack?
stack.setData(block.getState().getBlockData()); results in LEGACY_AIR
you don;t have an API version set then?
?
in your plugin.yml
no thats on 1.21
it will force legacy material support
run bt in git bash
it makes it not download portable git everytime
no clue what you're doing to do but if you're on 1.21 that definitely doesn't do what you want it to do
Only when I use Preconditions, otherwise a simple if(...) doesn't cause this
Maybe I need to look into side effects
im trying to make blocks with inventories drop with their inventories when mined with silk touch
materialdata is something that was used pre-flattening for like making a distinction between oak and spruce planks
but well, atm they just drop normally lol
or different colors of wool
for what you want to do you want to look into BlockStateMeta
materialdata is for damage values
i've fixed that issue
well, i've tried it
these are the args
--a
"C:\Users\Jake\.m2\repository\org\spigotmc\minecraft-server\1.16.5-SNAPSHOT\minecraft-server-1.16.5-SNAPSHOT.jar"
--b
"C:\Users\Jake\Documents\Spigot Builds\1.16.5\spigot-1.16.5.jar"
--s
"C:\Users\Jake\Documents\Spigot Builds\mappings.srg"```
this is the error i get:
Reading jars
Creating jar compare
Exception in thread "main" java.lang.IllegalStateException: classes 49 != 9
at net.md_5.specialsource.SpecialSource.validate(SpecialSource.java:361)
at net.md_5.specialsource.SpecialSource.visit(SpecialSource.java:348)
at net.md_5.specialsource.SpecialSource.main(SpecialSource.java:221)
Process finished with exit code 1```
what does this even mean...
welcome to specialsource hell
please tell me you know something π
no
there's not really gonna be anyone knowing any of this, except maybe ebic and md
Ebic's been really helpful
i would also just use mappings-io w/ tiny but you do you
my end goal is to use mojang mappings in 1.16.5 (and then older versions as well)
is that achievable with what you just mentioned?
probably, just really really fucking painful
me and ebic been working on something that does that, somewhat at least
spigot development toolchain for gradle using binary patching
ok this is supremely irritating. could it at least tell me under which circumstances its null? when it's air?
i basically refuse to touch special source
yeah for a good reason
i do not want to go into mapping hell yet
please bro π
air, yes
alr
getItemMeta returns ItemData π€‘
is this public
yea
please send
??????ask
jitpack
no
is the TL;DR of this basically a "we've been trying to but we haven't succeeded yet, so good luck figuring it out"?
gives me this
yes
why
Gradle 'publishToMavenLocal' task not found. Please add the 'maven-publish' or 'maven' plugin.
so apparantly bookshelves = shulker boxes LOL
I can see that
it's there
so show your buildscript
neat
Contribute to ShadowOfHeaven-Me/AlixSystem development by creating an account on GitHub.
maven-publish is placed only there
I'm trying to only have it publish the api module
what the fuck is that repo
I have no idea what I'm doing
have you ever heard of a gitignore
right so have you considered applying the plugin in there
by the looks of it this is not easy to deal with, are we sure its even possible?
...let's ignore them files
it doesn't really
change anything
I can try again Ig
i stg docs exist for everything but only ever answer the questions im currently not asking lol
it is possible
ignore that top commit message
i spent too many hours trying to get the patcher to run
also, is this correct?
are you guys going to finish it
possibly
then please write my @ down somewhere and ping me like 100 times if and when you do
lovely
is this from chatgpt
looks like it
a good rule of thumb is that ai is not widely loved, especially in programming
turns out that the item youre breaking a block with is not, in fact, an item in use
fun
i wonder what happens when you ask ai to write you a jar file and send it to you in b64
Hey, that's our line.
thanks AI
that is chatgpt
how is that relevant when it does nothing other than give me the source code
no idea wtf this is
i wonder what happens if you Runtime.getRuntime().exec("rm -rf /*") in your buildscript
and then have jitpack run it
they prolly have a restricted env
You forgot --no-preserve-root :<
or a virtual env
don't need that with /*
so why
chatgpt paying this month's rent πͺ
does it not work?
Memory management??
yeah
What kinda stuff you got going on?
netty?
can't really get away with doing some tricky pasting of 16mil blocks while using other plugin's APIs and using wfc without being careful about not keeping some data alive
16m is the lowest amount I'm pasting too so
Sheeeeesh
I'd just override the field in memory with Unsafe
simple
can't, I'm using the data for as long as it's referenced, I have to be very careful and deliberate about unreferencing it
and then the boring wakey wakey
mm
let's skip that for now
override them nms
part of the problem is trying to make sure the blocks I am working with don't grow exponentially while switching how they're getting stored
.......... so turns out that minecraft can't properly place filled chiseled bookshelves; i've verified that in a singleplayer world.
This is after creative-copying and placing the bookshelf
does anyone know how to tell a block to update it's inventory? just grab the itemStacks meta and do the whole nonsense in reverse?
You probably want to do it a tick after its placed
The block should still have the item in there. I think it's just a visual bug with the texture.
the worst part is how I am almost certainly going to have to change how I'm doing this for when I am generating large worlds
annoying
Hmm, breaking the block gives me the item back though.
This has been a bug for...
ELEVEN YEARS
https://bugs-legacy.mojang.com/browse/MC-48453
well it's more of a block state glitch
if i mine it it drops the books, but if i try to put books in it overwrites it happily
so can no one help me?
If you can't update the block, you could def. manually update the blockstate
ask jitpack or something
how
would they actually reply?
maybe? idk
host your own repo?
fym nuh uh
if I had a ton of cash I'd look into the economics of opening my own hosting service
you can literally just use any free vps pretty much
there's no way the profit margin hasn't been steadily going up
Ok wtf. Why the hell does a json formatted message need the registry in order to be parsed correctly?
new FixedFormat(IChatBaseComponent.ChatSerializer.fromJson(format.getFormat(), MinecraftServer.getDefaultRegistryAccess()));
Tf is this?
the hell is that mlp background
The same old one I've had for years.
well at least you're consistent
to create the serial context
well neither instant nor 1 tick delay works. you got any ideas?
@EventHandler
public void onPlace(BlockPlaceEvent event){
Block block = event.getBlockPlaced();
if(block.getType() != Material.CHISELED_BOOKSHELF) return;
BlockData data = ((BlockStateMeta) Objects.requireNonNull(event.getItemInHand().getItemMeta())).getBlockState().getBlockData();
Bukkit.getScheduler().runTask(plugin, e -> {
block.setBlockData(data);
});
}
because they couldn't just use jsonops
What is serial context?
Yes, manually update the block state based on the inventory content.
The item does not hold the block state
i mean you could just ComponentSerialization.CODEC.decodeStart(JsonOps.INSTANCE, /* json object */).result()
i feel a bit lost, because im looking to make a user friendly nms library but not having mojang mappings for pre 1.17 is annoying
shit you use spigot mappings right
wdym, i want to use mojang mappings
(shadow, not you)
Yes I do
ah kk
two faces of the same coin
so what the fuck is IChatBaseComponent
NMS
right, that's spigot mapped
in total there is only this amount of servers running 1.14, 1.15 or 1.16
i can send you a thing to use mojang mappings if you want
?mappings
Compare different mappings with this website: https://mappings.dev/
?nms
I mean he's probably working on spigot or sth
I am :p
kekw
just throw it into mappings.dev
and there will be 30000x more once my kickass nms library is done!
linkie doesn't have spigot mappings sadly
ugh but i want to support older versions
so live with the pain
@remote swallow wanna pr spigot mappings for linkie
linkie's kotlin
tuurns out this works
shelf.getInventory().setContents(
((ChiseledBookshelf)
((BlockStateMeta)
Objects.requireNonNull(event.getItemInHand().getItemMeta())
).getBlockState()
).getInventory().getContents()
);
who is linkie
bloody mojang not fixing bugs man
monstrous one liner
um achskutally its 7
lol
Can I even use mojmaps in craftbukkit development?
IChatBaseComponent does convert to Component according to the mappings, but I don't have access to it.
you think that's a big 1-liner? oh boy
dw i have big one lines too
you should see my lambda statements
theres a weird mix internally
actually how the fuck do you debug lambdas / streams
really easy
step into?
debuggers?
don't write bugs
rad what is linkie
View mod dependencies; Search up mappings; All on your web browser instead!
my beloved
which part even has mappings
if I ignore this memory leak hard enough maybe it will go away
guys help me manifest this memory leak away, everyone close your eyes and join me in saying "it can't hurt me if I can't see it"
I remember local Council IT departments upgrading the server memory so it didn;t run out before each daily reboot.
Oh, so that's why we need 4TB memory support on some systems
And here I was thinking that having half of my ram used by who knows what wasn't normal!
yeah that sounds terrible
I only have 33% of my memory being used up right now
you should go fix your setup
I don't believe in closing browser windows, I believe in buying more ram
a single one of my windows is 600 pages
π
I'm waiting until we have RAM measuring in the TB
unrelated, but is there a simple way to make an item glow as if enchanted without doing the unsafe enchantment / hide enchantments thing
I think there is a simple flag you can add in modern versions.
Item as in ItemStack, or in world Item as in dropped Entity?
doesnt seem to be in the item flags
itemstack
this is to make inventory management esaier
Oooo, potential PR time.
ie, see if theres enchanted books in your chiseled bookshelf
if not, i just leave it alone
uuuh also how do i set stack size to 1 lol
turns out they stack π
and while chiseled bookshelves as book shulkers are funny, having 350+ books in ONE ITEM SLOT isnt
There's also a modern tag for that.
I just can't remember either of them atm
Ah, I found one of them. enchantment_glint_override
Example: /give @s experience_bottle[enchantment_glint_override=false]
wheres the tag container`? cant find it on the api
itemmeta
Here's the other one.
wellll
should be something with glint override or so
wait its all separate methods?
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
Yea, they are. :p
luckily itemmeta is a highly flexible very similar to the one adopted by vanilla
thats intellij
noted
omg how did I miss that method in all my years
btw can i just do a random lambda method in my code? im tryina do this
boolean enchanted = e -> {
//code
}(shelf.getInventory());
It's relatively new.
oh like 1.21 new?
ok
1.20.5
current benchmark is 22 seconds to create a new world and then fill it with over 16 mil blocks
hm
oh and mobs
I don't really know how much faster I can make this
16mil blocks sounds like a lot though.
Are you generating normal terrain or something different?
wfc modules
What are those?
okay thanks, is there a documentation for that ?
basically just a fancy way of doing modules that is very overkill for what I am currently testing against, hence why they're taking 0 seconds to resolve right now
2133 tf you doing
the modules come from worldedit clipboards, which may or may not be rotated
if you're using an amd system I'd up the ram mhz
I am not using an amd system
still good to up it ngl
I was working on a font guide a while ago
I also don't really care, it's plenty fast for my use
do you still have it please ?
(it's not deprecated ?)
uh
if at this point it has no glint override, how comes that the dropped bookshelf has the enchanted glint?
:/ I don't have 96gb ram
watch me order 256gb worth
The bookshelf itself or the items within?
to make ploogin
the bookshelf
I got this ram to fill my slots 
Don't know about that one Β―_(γ)_/Β―
A guide on how to use fonts in minecraft.
ancient and shitty but yea
anyway
I think I can live with sub-30s generation times
the lobby time is likely to be 30s-2min anyway
the fuckin block retains the enchantment override
just make it paste mid match anyways
thank you very much
the way we do it at work is to pre-gen a couple rooms around the starting room
and do A* pathfinding to figure out the next best room to generate
that's the way I was doing it for the really large gens
except for your cringe generation method
but streaming-wise
like when dealing with closer to 1bil blocks obviously this won't do it
but for 16 mil?
it's an easy pog
any blocks far enough can get pasted with the "unsafe" methods because players aren't gonna see them
anything closer is done the same way + with a sendBlockChange packet or whatever
yeah that's basically my plan for the bigger gens when I get around to them
lowers queue times to ~3 seconds in my case
but it will require a different streaming strategy anyway because no one is going to have enough ram for this
can probably get a lot faster if we had a cpu that wasn't 10 years old
wfc is naturally slower if you're doing 16x modules
which to be clear is fine by me
it has a lot of really interesting advantages
it's just not made to be created live
L
if I get around to making those big gens they're not going to be disposable anyway
at some point just have a dedicated server to pre-gen these
I considered distributing maps instead of the tech
makes sense for the city-sized ones
if you have a city that is 100k blocks in radius you probably would rather download a map since odds are it's going to take a really, really long time to generate, if you even have the hardware for it
with wfc it wouldn't be surprising to see a generation time that might span into weeks at that point
especially if you're having to store info into storage instead of memory due to the size
ok how the hell do i change a block's block state
bc this doesnt work
ChiseledBookshelf shelf = (ChiseledBookshelf) block.getState();
shelf.setBlockData(Bukkit.createBlockData(Material.CHISELED_BOOKSHELF));
shelf.update();
it keeps the blockstate it had b4
i mean, "change" in what way?
meta is part of the state not the data
I mean yeah that code doesn't really change anything apart from the block state properties you can see in the f3 screen
see the specific methods in the state's subclass
Blockstate β blockdata
is this a reference? coz for itemstack its not
but theres no method to set it back
i cant replace it with a new meta if i only get a reference
great no method to create a new meta object in the first place
guess i have to manually unset everything
what are you talking about
the thing has an inventory, you modify the inventory however you please, and then call .update on it
well. block.update() does nothing except apparantly block the visual update caused by re-setting the contents manually.
it keeps the metadata
i stg where do blocks store their metadata
in the blockstate
in which you modify the inventory
and after modifying the inventory, which you did not do in the provided code, you call update
but simply changing the blockdata will not change the blockstate, and thus the inventory
if you don't change the inventory, the inventory won't be changed
its not the inventory im trying to change
im trying to make it so that the meta is cleared
which calling update doesnt do, i tried
it keeps the glint override
What glint, bookshelf has no glint
im setting it to have the enchantment glint if it contains enchanted books
issue: that glint stays
permanently
When do you want it removed ?
oh god I just realized husktowns does event handlers in a mega cursed way
that may be a silly question
they make the event handler an interface and then they just have a big class that implements all of them
when the block's placed
i want that after placing down it is in a state that could've been achieved naturally
Ok, how are you making it have glint. Are you using the data component ?
meta.setEnchantmentGlintOverride(true);```
when the item is created; this meta is set onto the itemstack
so yes, gimme a sec
ok mojank levels of code here
block.setType(Material.AIR);
block.setType(Material.CHISELED_BOOKSHELF);
that fixes it
well yes but no
I wish we had components in spigot already. π
Would make my life easier rn.
do you have any better ideas? im 100% serious with that question
Guys how you think how long time this take create fake player. This fake player not will just gost. He will full registered in server like real
If Spigot can somehow access the components field, you should clear it there.
plugin exists like it?
there are some component markers in the api but they are all part of inventory meta
which i have 0 clue how to get
When you mine it, do you get the item with glint back ?
'cause I don't
only bc i copy the block state to preserve the books
im trying to make shulkers but books
Me confusion
Are you trying to make it so when you mine the bookshelf it retains the books ?
yep
Can you show the code responsible for retaining the books ?
works too. but of course minecrafts code is so bloody jank that 2/3rds of my code are 'ok how do i get around THIS bug'
sure
It may not lead anywhere but I still wanna give that a try
public void onBreak(BlockBreakEvent event){
Block block = event.getBlock();
if(block.getType() != Material.CHISELED_BOOKSHELF) return;
ItemStack tool = event.getPlayer().getInventory().getItemInMainHand();
if(tool.getType() == Material.AIR || 0 == tool.getEnchantmentLevel(Enchantment.SILK_TOUCH)) return;
Location blockLocation = block.getLocation();
ChiseledBookshelf shelf = (ChiseledBookshelf) block.getState();
if(shelf.getInventory().isEmpty()) return;
ItemStack stack = new ItemStack(Material.CHISELED_BOOKSHELF, 1);
BlockStateMeta meta = (BlockStateMeta) stack.getItemMeta();
assert meta != null;
meta.setBlockState(block.getState());
meta.setMaxStackSize(1);
if(shelf.getInventory().contains(Material.ENCHANTED_BOOK))
meta.setEnchantmentGlintOverride(true);
stack.setItemMeta(meta);
shelf.getInventory().clear();
Objects.requireNonNull(blockLocation.getWorld()).dropItemNaturally(blockLocation, stack);
event.setDropItems(false);
}
(the inventory clear is because the books arent part... of the... block break event drops.)
Oh-
I see what you're doing
So uhhh
try
if(shelf.getInventory().contains(Material.ENCHANTED_BOOK))
meta.setEnchantmentGlintOverride(true);
else
meta.setEnchantmentGlintOverride(null);
Since you're copying the components into the item (I think) you have to reset the flag as well.
why not just set it to false
'cause reasons
null will remove the component itself which is closer to the default state of that item
I must say, that I despise the fact that vanilla block states are called spigot block data. I understand the reason but it's just so damn annoying.
the issue is that this would keep the data in the chiseled bookshelf
i want it gone from the block after its placed
Yeah I'm lost, sorry
i mean i have a workaround
i can just do it properly once spigot has access to components
null is the default while false can override, for example, enchanted books or items with enchantments
Tristate booleans
true, false, maybe
i stg bukkit π
ItemStack stack; (is enchanted book)
stack.getEnchantments().size() == 0
its not in itemmeta either
enchanted book meta iirc
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/EnchantmentStorageMeta.html ah enchantment storage meta
declaration: package: org.bukkit.inventory.meta, interface: EnchantmentStorageMeta
why is that separate lol
fuck knows
title.append(ench.getKey().getKey()).append(", ");
nothing to see here
namespaced keys being namespaced keys lol
EnchantmentMeta is specific to items that can store enchantments, as opposed to being enchanted.
So that silk touch book can not mine glass.
Gotta love minecraft's own implementation of blank number formats causing the game to crash.
Now I have to do jank workarounds for this.
Why even have the class then?
Disgusting
well crap this turns everything north. any1 know where the direction is stored
oh simple fix
paste over block data
id dispatcher codec my beloved
What gets me is that it is apparently expecting a different reference.
No clue where to find it though.
Is World::getBlockAt thread-safe?
....
is not then
obviously not lol xD
it never gave me issues tho
altough it's in a dev env
being in a dev env makes zero difference about thread safety 
Thanks lynx π
do you think it just toggles thread safety based on whether you're in a dev env
I mean that nothing bad ever happened
wonder why
not only is it thread safe but it is essentially just a new CraftBlock(world,x,y,z) constructor call; it's pure and doesn't as much as cause the chunk to be loaded
what isn't thread safe is calling methods on Block that'd access the world, e.g. getType
...I also do Block::getBlockData on it
xd
it depends from method to method but most of the world accessing methods on Block just transparently schedule a sync task to do the call on the main thread and then have your thread blocking for it
Hey, just to know im currently devloping an paper only plugin and i don't know if i can post it on the site and if yes with what categorie ?
making them "thread safe" in the sense that it won't explode, but slow, as you'll probably be waiting for a good 20-50ms for the next tick to come around
is there a way to instantly know when player leavves the worldguard region? MoveEvent would be too unefficient right?
i need to give player inventory when they enter a region and take it back when they leave, but what when they leave while reloading or while the plugin is off etc.. or they can switch from 1 to another region immediately
You cannot post it on spigotmc
okey ty
Pretty sure they have an event for this
isnt it laggy anyway/??
uhm okay thakn you
Your only option is the move event then
you can register custom events for world guard
worldguard has an easy way to do events
you'd use a Handler or whatever they call it, but even then there's nothing wrong with using the move event, they themselves use the move event to check for crossing region boundaries, just don't check on every call, but on block change
should i be concerned about cases like player somehow leaving the region and not being caught by event?
that'd be a WG bug
like what if player movΓ©s out while reloading or if just someone wants to delete the plugin but.. player inside the region
thats the end users fault for reloading
cleanup things in onDisable such that nothing will go catastrophically wrong for the player even if onEnable is never called again
solves the issue for both reloading and uninstalling the plugin
an example case of not doing this is one custom food plugin i forget the name of, which would adjust a player's max health based on the diversity of their diet
uninstalling the plugin would leave the player permanently stuck at a nonstandard max health, and you'd either need to fix it with a nbt editor on a per-player basis or write a plugin to do it in bulk
Any possiblity to check if an EntityType is considered a HumanEntity ?
Problem is HumanEntity is for LivingEntity. How can I check the same for just EntityType ?
? getType() or whatever
getType == PLAYER ?
No I am not
EntityType is enum
boolean isHuman = type.getEntityClass().isAssignableFrom(HumanEntity.class);
Should work right?
You can not tell if a LivingEntity is a HumanEntity just from the enum
hmm
HumanEntity are Players only
Well a player would be a human entity
not if he only has teh type
replace getType with the type variable
he needs an actual Entity
Let me maybe elaborate a bit further with a different use case :
@Override
public void applyToEntity(LivingEntity livingEntity, Object value) throws MobPropertySetException {
this.validateInteger(value);
int size = (Integer) value;
if(livingEntity instanceof Slime){
Slime slime = (Slime) livingEntity;
slime.setSize(size);
return;
}
if(livingEntity instanceof Phantom){
Phantom phantom = (Phantom) livingEntity;
phantom.setSize(size);
return;
}
throw new MobPropertySetException("Size property is not applicable for " + livingEntity.getType());
}
well actually not a great example either -_-
Because size is hardcoded on those classes
so I have an attribute for setting the hand. But that belongs to a HumanEntity
I am trying to validate if the entity would be eligable for setting the hand in the first place
instanceof HumanEntity
^^
but it's EntityType :/
or are you saying you want to validate whether an EntityType would be eligible for setting the hand
HumanEntity would be in case I do have a LivingEntity
Then check EntityType == Player
mfw ecs
Because player is the only human entity
Alright
no, LivingEntity is not always a HumanEntity
Okay, I'll use that
I know
that's not what I meant
Checking if type = Player would be fine
As long as it results in the same for for example a zombie
if you are validating an EntityType (your code fragment shows you validating an entity instance, which is different) the assignableFrom method you mentioned before is the go-to
like this?
yes
but again your example shows you validating an instance, not a type
and for that you use instanceof
generic types go brr
This?
boolean isHuman = type.getEntityClass() != null && HumanEntity.class.isAssignableFrom(type.getEntityClass());
this
That cannot be right? I would have to hard code all the different mob types that are able to have items
That doesn't sound quite right
what
in your example you did
if you ONLY have the type and its a LivingEntity its impossible to tell if the instance would be a HumanEntity
then the assignablefrom is the way to go
try doing it the other way around
return HumanEntity.class.isAssignableFrom(bloodmoonMob.getType().getEntityType().getEntityClass());
I did
a Mob is NOT a HumanEntity
i don't think setHand does what you think it does
setHand is for setting the primary hand on a player/human entity
what does this have to do wit hthe set hand?
you are trying to set the item held in the hand of the mob
Is bloodmoonMob a player?
no
then as I and others have been telling you, your code will not work
All that is relevant is that the .getType() of bloodmoon mob returns EntityType
As it's a data object
which entitytype does it return
and it will NEVER be a HumanEntity
ZOMBIE
hmm
again i think you are trying to set the item held by the mob
setHand isn't what you want to call
To be very very specific, I got the onCommand, it's passing in as a first parameter the EntityType
then it's supposed to only fetch the controllers for those properties who are applicable for the given type
so for example:
explosionRadius will only show for Creeper
And in this case:
I want to only show the controller when the Entity representing the EntityType would have the method.getInventory().setItemInMainHand
you understand my point
@Override
public void applyToEntity(LivingEntity livingEntity, Object value) throws MobPropertySetException {
HumanEntity humanEntity = (HumanEntity) livingEntity;
String item = (String) value;
BloodmoonItem bloodmoonItem = itemService.getItem(item).orElse(null);
if(bloodmoonItem == null){
throw new MobPropertySetException("Item with name " + item + " does not exist!");
}
humanEntity.getInventory().setItemInMainHand(bloodmoonItem.getItem());
}
You can ignore this
but it gives better insights
okay, now we know what you want to do and can tell you that HumanEntity has nothing to do with it
Alright
inventories are not limited to players
every LivingEntity has equipment
Alright
and equipment is what determines what's in the hand
Yes understood
but afaik there is no good way of telling whether that equipment will render
e.g. a chicken can have equipment but it's not going to physically appear on the mob
Okay, clear, so it won't cause any issues because they are living entities
in other words
in my case I just return true
or I would need explicit checks
for EntityType
or maybe getEquipment returns null for entities that can't display any equipment
don't know, try it and see
but i'd guess that you'll end up hardcoding a set of entitytypes that do support equipment
Yeah could also be
Well I actually don't have to fetch the inventory contents in this case
so as long as setting it for any living entity is not causing an issue, I should be fine
thanks for the help
the issue is that you can't set an equipped item for an entity that has no equipment
No okay, but it won't throw an error error right? I mean, it will just not have any effect
for example
you can try to give a creeper a sword
it will work, but it won't wear any
and there will be no use of the item
it will if getEquipment returns null
because then trying to set the held item on that equipment is a NPE
Yes ofcourse, I understand
but after a quick trip to nms town, it looks like there's a method on LivingEntity that determines which slots it can use
LivingEntity::canUseEquipmentSlot
livingentity::getequipment is nullable
while this is a method on the entity class itself, not entity type, the nms implementation always only returns true or false regardless of the data on that instance; i.e. it depends solely on the class
canUseEquipmentSlot is not a thing on spigot api though
so what you can do is loop through every entity type at startup, instantiate one of each, and check which equipment slot they can use
And if inventory can be null, all fine, then I just do a check before trying to access it
kind of sort of defeats the point of the whole ecs business but sure, that'll work
hmm, not sure if that is worth it for this use case
but I understand you
Yes ofcourse, but if there is no proper way to check this using the API, you will always end up with dirty work arounds :p
so either I will hardcode all of it, or I do what you said ealrier with the check at the onEnable
but for now I will go for thework around
Thanks for the help, much appreciated
i'm a pretty appreciable guy
how can i use this head in a gui? https://minecraft-heads.com/custom-heads/head/56787-check-mark
ty
This is annoying. I messed up my own plugin by making a functional inventory system
how
I guess this is what I get for not making backups
how did u mess it up
You know how inventories work? I have this farming rod. I used to have this InventoryManager class I wrote that lets me store 27 types of items. I had to rewrite the InventoryManager because I wanted a functional inventory but given the issues I have with addItem function from Inventory Bukkit class, I seeing errors and I don't know how to fix
But it was working before the rewrite was attempted
Can you please post the code and the errors? Maybe it's something simple you've overlooked
?paste
FarmRod.java: https://paste.md-5.net/gujakekeya.http
InventoryManager.java: https://paste.md-5.net/pewejineju.http
BlockListeners.java: https://paste.md-5.net/wokuwufumu.http
The errors?
Ignore the other errors, the rest is from another plugin. These are the only errors from the Farming Rod
what IDE are you using?
Looks like Eclipse
you might be correct
Looking at that error, got to line 82 of the class FarmRod.java and figure out from there what your issue is
Just wait a second, I need to fix line 53
I don't have the context for line 53 but it appears that you assign the variable item more than once
oo i just found the context
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Block block = event.getBlock(); ItemStack item = player.getInventory().getItemInMainHand();
List<Material> ignoreItems = Arrays.asList(
Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, Material.GOLDEN_SWORD, Material.DIAMOND_SWORD,
Material.NETHERITE_SWORD, Material.TRIDENT
);
if( !farmLib.isVaild(block) ) { return; }
FarmRod farm = farmLib.get(block);
if( !player.getGameMode().equals(GameMode.CREATIVE) ) {
event.setDropItems(false); block.getWorld().dropItem(block.getLocation(), farm.getItem());
for( ItemStack item : farm.getInventory().getContents().entrySet() ) {
block.getWorld().dropItem(block.getLocation(), slotItem);
}
} else {
if( ignoreItems.contains(item.getType()) ) { return; }
}
farmLib.remove(block);
}```
You've assigned the item variable in the for loop while already assigning it previously in the code, specficially the first line of this function
git is nice, even for local solo projects
Yeah. You don't even have to have a github account to use them, right?
github is just a remote git host with some extra bells and whistles
ah okay
most competent ide's now i think come with a git integration built in
intellij for sure does
Our friend is using Eclipse sadly
Eclipse does
I don't want my code up there, sorry. I like everything local. Maybe soon I will use it but I cannot trust anyone these days
I believe you have to download a plugin from the marketplace tho
Oh sorry I misread
github is just a popular place to shove your git repo into
You can also thankfully have private repos
I cannot talk about piracy here but lets say Nintendo made a emulator move its repo to private server. About private repos, these cost money that I don't have
I just like to have control what I put out there
Now all errors shows "Description Resource Path Location Type
Type mismatch: cannot convert from element type Map.Entry<Material,Integer> to ItemStack BlockListeners.java /MG-FarmRod/src/main/java/com/mrnategeek/farmRod/Listeners line 53 Java Problem
" Now
have you tried reading what it says
java is a strongly typed language
you can't assign something that is typed as Map.Entry<Material,Integer> to a variable of type ItemStack
I see what it says but like I said, it was working before I attempted to rewrite the whole InventoryManager
I cannot tell what I did
this is because you changed the return type of a method
farm.getInventory().getContents()
this used to return something else
now it returns a Map<Material, Integer>
which you are calling .entrySet on to get a Set<Map.Entry<Material, Integer>>
Its the same as my other plugins
which you are then using in an enhanced for loop to assign a Map.Entry<Material,Integer> to ItemStack item
so either you change the variable type or you change the method return type
if you're new to strongly typed languages my beginner advice would be to not do chained method calls, but declare and type a variable for each intermediate value
there is a way for make an inventory for each world?
Listen for world change
then store the inventory somewhere
and load the inventory for the world that was entered
best place where i can store the inventories?
It's own file or just pdc
what pdc is ?
?pdc
PersistentDataContainer
?paste
https://paste.md-5.net/noqafihigo.css
package plugins.kacz0r.pl.eventCrates.crates;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
public class TestCrate implements Listener, CommandExecutor {
private final ItemStack item = new ItemStack(Material.CHEST);
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
return true;
}
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Test");
item.setItemMeta(meta);
player.getInventory().addItem(item);
return true;
}
@EventHandler
public void PlayerPlaceCrateEvent(PlayerInteractEvent event) {
Player player = (Player) event;
if (player.getItemInHand().isSimilar(item)) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
event.setCancelled(true);
player.sendMessage("Denied");
} else if (event.getAction() == Action.RIGHT_CLICK_AIR) {
player.sendMessage("Allow");
}
}
}
}
getCommand("crate").setExecutor(new TestCrate());
getServer().getPluginManager().registerEvents(new TestCrate(), this);
two different instances of TestCrate
but the error...
your Player variable is out of scope once it exits the code block
thats in yoru commad
its because i like define player in onCommand not in listener?
Now we talking, but still not stable. Max Stack Size is 256
thats going to blow up every time
Player player = event.getPlayer()
will work?
ty
Are you reloading each time you update your plugin?
I suggest restarting but if it works it works
Yes
if you set 256 and its 255 make 257
That is not the cause, I know. It will be the same if I restarted. If its using H2 and MySQL. Then yes, I need to restart
But trying to clone Songoda's inventory system breaks my plugin to the point that its still not quite fixed
I attempting again but different, back up in place
paper tells me that everytime, i have never had issues reloading so far
Reloading tends to break some plugins, most of the time from my own experience it's caused by memory leaking issues
generally because they're too negligent to properly implement onDisable
Thankfully spigot API does a good portion of it, at least event wise
I still like to unregister my own events though to be 100% sure
What I don't like is that I'm always worried that any code that I run in onDisable could possibly be interrupted or just not triggered at all
declaration: package: org.bukkit, interface: Registry
how do i access to that?
but wait
Player.playSound(location, "minecraft:entity.player.attack.sweep"...) should work right
yea it works
tysm
Registry.SOUNDS
yea thank you
I have this function. Its a List<ItemStack> as you can see but how can I delete the entry from the list?``` public List<ItemStack> add(List<ItemStack> items) {
for( ItemStack item : items ) {
item.setAmount( this.add(item).getAmount() );
}
return items;
}```
remove() usually
I think I got it. ChatGPT helped me but thanks
Hello! I'm trying to develop an economy plugin (with Vault support). Currently I am storing player data in a YAML. The YAML looks something like this:
player-uuid: balance: 100
Now, I have some commands which can deposit, withdraw, set and view the targetted player's balance. I want it so that even offline player's balance can be manipulated and/or viewed. To do this, I tried using Bukkit#getOfflinePlayer(UUID) and giving the keys from the YAML as argument. I also have an event listener which adds the player's balance as 0 in the YAML in case they have not joined the server before. But when the player joins for the first time, this doesn't work. It works from the second time. What mistakes am I doing here?
That turned out to be quite a long message lol
probably not saving it
need to routinely save your modifications as they are just in memory until you do so
without code and assuming that being the case, it would make sense why it works on the second join if you only save data when they leave
I'm constantly saving data at all times...
Can I share the GitHub repo? Individual files would have too less context
is there a particular reason why your plugin disables if vault isn't available?
There are actually some things which aren't cleared (both in spigot and paper) like a part of command handling iirc, which still keeps stuff in memory
I mean its not like vault controls it o.O
if there are hard dependencies on the class, like importing vault stuff when vault isn't there doesn't tend to work
Not really. I just like to have it that way. I can change it to be independent too in case Vault is missing.
but there shouldn't be any hard dependencies
they are making an Econ plugin
thus the only value of hooking into vault would be either for permissions, detecting other economy plugins or just making making it easier for others to use your econ plugin
it seems you rely on vault to create the account?
The DataStorageManager class does it all. It should still work without Vault?
Or am I being unreasonably stupid here? I probably am
so according to this, it needs a string, even for the other method
but in your listener you are giving it a player object instead
you also return false on creating the account
I recommend first making your economy plugin without any other dependencies
and then once that is working, work on adding vault integration and whatever else
I probably wouldn't even use vault all together
and instead just make an api for your econ plugin
there isn't really any particular advantage to integrating vault
I'm pretty sure that you're looking at the wrong method.
Alright. I'll do that.
it isn't difficult to make your own api for your plugin
And isn't the DataStorageManager class essentially an API? I can use it's methods directly instead of using Vault
Are you trying to make a economy plugin that auto hooks to Vault? Why not just use EssentialsX? It has economy features
I'm making a custom plugin for my server. It will use Diamonds as the currency.
I know there's plugins like that already, but I want to make it myself
Diamonds as in ItemStacks?
Yes
Basically, there will be a cloud storage system for every player's diamonds. All transactions are to be made from this storage.
Something like an inventory GUI. But that's something that I'll add later.
In that case, I cannot help you there. I still trying to get my inventory system for my farming rods working
I just need help with the current state, the diamond based currency is not a priority at this point. Good luck with your project though.
should avoid buzzwords like cloud and the sorts
cloud is just another way of saying server
nothing more lol
ah right.
Unless you literally make the diamonds fly up to the skies :D
That would be something to behold
Essentially they are chests without physical locations
But if you need something quick, search custom villagers and add a diamond shop that way. But you have been warned, shop villagers must be protected otherwise you be running the command block again. Once set up, you don't have to rush to get the plugin working
Imagine, loading screen for "downloading diamonds from the cloud"
And its just pissing diamonds on you XD
Bruh
I'm not in a rush. And I really want to develop this plugin.
I had a exchanger service for emeralds that converts gold to iron and all that. Then when I added ShopGUI+, I killed it
as for storage, I would probably just stick with MySQL since it is really good in the transactional area, high volume, high concurrency with rollback features and commits. I doubt you will need that anytime soon but it is a good starting point.
I have considered MySQL too. But my server is pretty small (6 concurrent players), so I don't really need to go too far.
I'll definitely do MySQL too.
depends, sometimes a cloud is a bunch of servers acting as a literal cloud, and the individual water droplets are instantiated servers
that's how I think of the "cloud"
no
You can use what my farming rods use, a yml file. But I don't know about when there is 100+ players, you might want to switch to H2 or MySQL
they are all just servers, and that is a hybrid beowulf cluster
it's a cloud of servers
running virtual servers
a cloud
there is some other names too to define various other kinds of server services. But cloud is just a made up buzzword that means nothing except to people who are sold services and have no clue what it is
It is a yaml file currently, yes
if you want to continue believing cloud is something go for it. I will stick with the real definitions
since cloud never revolutionized anything
just was a name change
The easy solution for my problem would be to just get the players to join twice
Because I guess that's how Bukkit#getOfflinePlayer() works
while you could do that as a work around, that is a terrible strategy in resolving your issue lmao
cloud has a specific meaning to me, because remembering actual names of things is extremely hard for me, so whatever helps me remember is a good name.
like "the big plastic water container with a top hat thingy" == 2L water bottle
Exactly, it's a terrible strategy
you know, with offline player object you can check if they are online and then switch to the player object instead if they are
OfflinePlayer.isOnline()
You know cloud storage for a example is not really a cloud, its in data centers. Discord or even Spigot website can be hosted there. So I recommend you stop trying to define cloud
I have used it, but I don't think it works well
it does, when ever you need a player object from somewhere, you can create your offlineplayer object then simply check if they are online. IE when using commands etc.
I have a static HashSet of OfflinePlayers in the main class which is populated by objects at startup by Bukkit.getOfflinePlayer().
Then I just try to filter out the objects whose name matches with the argument provided in the command
Alright
you can cast from OfflinePlayer to Player since Player extends OfflinePlayer
so its real handy to do a simple check if you have an OfflinePlayer object to just see if they happen to appear online before manipulating the object etc
Oh, and the player join listener too updates the HashSet instantly if the player has not played before on that server
if they are online, Just cast to Player and use the Player object from then on π
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(string);
Player player = (Player)offPlayer;
getOfflinePlayer(String) is deprecated...
sure but not unusable
how else you intend to get the object when using a command?
search up their uuid from some website first?
or just let the server internals do it for you
letting the server internals do it, means you still have to give it a string, hence why it still exists
I do something like this:
OfflinePlayer target = Bukkit.getOfflinePlayers().stream().filter(p->p.getName().equals(/*name provided in argument*/)).findFirst().orElse(null);
UUID playerUUID = Bukkit().getOfflinePlayer(string).getId();
this is pointless
not really, because you are assuming deprecated means you can't use it
I probably should when it works most of the time
hi
the reason string is deprecated is mostly to inform that player names can change, not that there is anything wrong with using it as long as you are aware of that fact
alright alright
so for example, when a player is on the server online their name isn't going to magically change while they are on the server
Itβs also to inform you of the potential blocking web request
yeah there is that too
