#help-development
1 messages · Page 454 of 1
Eyes
cant you just use Bukkit.getConsoleSender and fake the logger tag
is there a way to check a doublechest witch side i clicked left or right?
i tried it with.`
1.
Chest chest = e.getClickedBlock();
if(chest.getType().equals(Type.RIGHT){
2.
Chest chest = e.getClickedBlock();
if(chest.getBlockData().equals(Type.RIGHT){
Lowest you want to support
^^
Otherwise you risk using methods that don't exist on older versions
One way is to modularize ur project tho morice
org.bukkit.block.data.type.Chest chest = ...;
if(chest.getType() == Type.RIGHT) {
}
Maven multiproject is a thing I think
Sth like that
well yeah, but i cba to go through the effort just to debug something
gradle mulitmodule smh
morice you dont need every version tho
But just the versions where you encounter breaking changes
if its 1.17 plus higher just use teh versions my spigot lib uses
Ah yeah then it might be a bit redundant
https://github.com/The-Epic/EpicSpigotLib if you need names + spigot vers
it has the nms change versions
When was the StructureGenerateEvent added to spigot?
and how do i get
org.bukkit.block.data.type.Chest```
this? because the chest i saved is a block and i can't cast this
BlockData -> cast to Chest
I think it's something like block#getData or block#getBlockState
okay thx
getBlockData gets the BlockData and getBlockState gets the BlockState
You can imagine which one you need
yo discord came back with the pfp outlines
As a nitro user I do concur
having more options to decorate your pf would be neat!
is it possible to use the ids from heads like when I want to get a from hdb like this {SkullOwner:{Id:[I;-2106185644,754142373,-1110652435,-1241422363] to use it in a plugin
Sure, they all need a value and a signature
yeah but what is it is it a name or an UUID like who do I get the owner of it
Name and uuid dont matter. All that matters are the texture value and signature
how to damage an entity naturally (meaning that if he has armour on, it deals less damage)
well but how do I do that
- Create PlayerProfile
- Apply textures on it
- Apply profile on Skull
wdym?
No
Use Damageable#damage(damage,source)
what in the source?
wdym
yea, but i dont have a player
What do u have
only the livingevtity i want to damage
but that is a player
Doesnt matter
Is there a way to check for when a structure is being generated on the server and what type of structure? I need it on 1.14 and spigot only has an event for that in the new 1.19 versions
player has 20 health right?
By default, yes
Can somebody tell me what happen to ChatColor.translateAlternateColorCodes?
How to do it now?
Why is it depricated?
Yes I am using Paper API
well there is your answer
But you don't know what else to use, do you?
I do
you have to use components
you most likely would be better to use fabric
instead of mcp
forge is just mahem
you dont need a new launcher with fabric, but with a fabric project you could build directly to mods folder
then you just reboot the game
like normal
Architectury :)
and way more people know fabric and fabric support is so much better than forge
fabric 💀
Huh why the skull emoji :(
ban therm
epic have you pr'd spigot before
I need help setting this up lol
is there a way to clone from my fork or do I gotta clone the official one
ahhh Ic
I’m having an issue where peopel are speed running my survival server any suggestions on how to counter this?
ban the hackers
ban them for a bit or tell them to calm down
if your just talking about normal vanilla speed I suppose you could make a plugin to remove the speed effect
they mean like speed running the game, completeing it in 30 min
can i check if the uuid of a livingentity is equal to a player uuid? cuz players are also livingentities
oh smh I hate when server owners give a shit about this stuff
What r u comparing roxy
some people are just good at the game and wanna get to the building part
does this work?
so does it?
Don't forget that you cannot share any jars you make with MCP
do you know how I could save my credentials with git somewhere so I don't have to authenticate every time
For players yes
use source tree or something like that
It may not work for complex entities but thats another story
its like the legal loop hole buildtools is using
You cannot share the Spigot jar
Since MCP generates a workspace with decompiled classes
You cannot share that either
You would have to make a runtime injector system like Optifine or just do the sane thing and use Fabric which already handles all of that for you
You can make an installer that installs fabric and then your mod
61 = java 17
wrong java version
how do I test my stuff when I'm done lol I just realized I'll have to manually build spigot without buildtools
You gotta start your server with Java 17
Then compile with Java 17
and make sure the shade plugin isn't ancient
what does "L" stand for in "20L"? (it's in a timer)
long
f also
Okay thank you
val world = Bukkit.getWorld("world")!!;
val fallingBlock = world.spawnFallingBlock(sender.location.add(0.0, 20.0, 0.0), Bukkit.createBlockData(Material.POINTED_DRIPSTONE))
fallingBlock.setHurtEntities(true)
fallingBlock.fallDistance = 200.0f
i dont get damage why?
compil bukkit, then craft bukkit
you can run just craftbukkit if you really want
what are the exclamation marks doing there
alr I suppose that works
Is there a way to check whether a player is standing inside a structure?
Or an event when a player enters a structure?
ah kotlin
Use the spawn method with a consumer if you're planning on modifying the entity. This will ensure the entity is modified before it's spawned
can i use switch case for Inventory?
how to make it so PlayerInteractEvent only calls when u right click air once
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
Is there a way to check whether a player is standing inside a structure (preferrably without nms)?
you'd need some form of timed cache
check the action
event.getAction
ur mu-
How can I create a FallingBlock in the code?
Higher ordered functions basically
usually just to provide functions
A function that takes another function as an argument
Anyone?
Then its convenient to pass a lambda
nms
this won't be backported by spigot so you'll need to replicate the code yourself
So I need to see how it is being done in spigot 1.19.4 and do it myself?
someone have circle on full chat line height?
you might have to fork spigot
If hes anywhere inside a specific structure
Essentially i want to run code once a player enters an ancient city
was wondering why CraftBukkit was coming up with errors :( Forgot to run buildtools 😭
how to make "schedulesyncrepeatingtask" stop after it runs for a time
I saw the for loop on the "delayedtask" version but it's just not working
it just makes it happen suddenly
just save the task and cancel it when you need
you shouldnt be using that varient
How can I check if it repeated the task for like ... 5 times
Anyone know why I keep getting method not found after I cloned CraftBukkit. I'm so confused I just ran buildtools too
did you run the apply or make patches
idfk tbh lmao
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
ahhh i see
in git or whatever do bash applyPatches.sh /path/to/buildtools/decompile-xxxxxxx/
what is a good way to save a hashmap to a file and load it back in when the server starts
can databases work without having to have access to files outside of the minecraft server folder?
like as in if you uploaded the plugin to a server host would it work
are there any simpler options like can you load a hashmap to a .yml file or something, i tried that and it didn't work
What do u define as good?
like a way that works well and doesn't bug out etc
things do not tend to "bug out" unless you do something stupid
ok just what methods are there then
I mean you arent gonna find something SUPER easy to use with a database unless you use some sort of ORM. Otherwise you are gonna be writing some sort of SQL
you would be better doing sqlite, but you could use json or yaml
do databases require setup outside of the minecraft server or can they work using spigot code and java
Yeah, if you want a cheap and cheerful simple db, go sqlite
I don't understand how to create a FallingBlock without spawning it how is that possible so what do I have to do for that?
Is that what you mean?
val fallingBlock = FallingBlock
^
Someone should take the time and write "virtual" entities in to the api ;/
It's quite annoying that it's missing
I can't bother
same
I just do them manually
There is kind of a PR for that right now
👀
when I do
Player carrier = ...
Player passenger = ...
carrier.setPassenger(passenger);
the carrier player has an ass at its face and cannot see nothing .-.
that does not happens at old versions like 1.7
is there a way to fix that? like putting the passenger player some distance above
Spawn an entity in between
what?
Carrier > ArmorStand > Passenger for example
given you're calling setPassenger instead of addPassenger
something tells me you're in <1.12
oh sorry, i am using addPassenger haha

i'm at 1.19.3
suspicious
for that, i just need to make the dummy entity invisible for all players?
Yeah
ok, thanks :>
Delay is the initial time before it starts
period is between each run
If you only want it to run once don't run a timer
Im gonna be annoying now but there is no such word or shortcut as wan’t, the right word is want without apostrophe
?scheduling
wasn't
That is fine
fuck that word actually exists
Lmao
Totally not me <<
which happens first when the server stops: the players are disconnected | the plugins are disabled
^
alright thanks
and when that happens does the Plugin#isEnabled() already false?
Its still true
hm
I don't think it's possible for isEnbled to ever be false from inside your plugin
Unless async
should I be doing this?
it checks if the server is stopping, if so it will use the CompletableFuture#join() to make the updates
well then, any clue of how do am i block passengers for escaping the carrier?
Try catch the join
It might throw an unchecked exception
(To be on the safe side) cuz else database might not close properly in ur case
I never handle exceptions properly so that is not a problem for me lol (don't blame me pls I am with a short deadline)
Ah alr best of luck in that case
oh that's going to cause problems in the future
but I guess you'll meet the deadline 🤷♂️
Just wrap the entire plugin in a try catch
😔
I will improve, I promise!
ehh not exactly
I'd return the future regardless
and just join it onDisable
I couldnt create the code in my head. Could you explain that
uhh
here's an example of how we do it at work
So instead of making my unloadAll method a void
I make it return a future
that I can then join
// Plugin shutdown logic
we love our mc dev
And then here illusion is very disciplined such that all exceptions are handled inside the future (hopefully)
// Iterate modules
// Code
very useful comments
// sysout josh should do my asnyc for me
When people even put // to comment why they put curly brackets 
IJ annoyed me way too much again today, I think I'll give netbeans another try
What happened
Shout out to // CraftBukkit
Netbeans 16 and 17 have been great releases
Best since the Oracle days
Do recommend
// PaperFork // Paper // Spigot // CraftBukkit moment
I still have NB 13 installed lol
// Yatopia :)
Can’t say I’ve seen that…
Yet
Lol
That’s even a nice rhyme
I believe it is in the file that sets the server's implementation name
Someone go start a yoghurt company
well
lol I like yoghurt
Kinda like Bukkit#getVersion but NMS
I actually have a class that extends CF and handles exceptions automagically
Does it just throw them as a runtime exception
Alr I was mainly referring to wizardly
Why would one extend cloudflare?
Since a lot of people use join w/o handling possible exceptions that can actually occur
nah CF stands for canned food
Oh

Still makes no sense
Understandable
Can you just wrap the entire JVM in a
try {
} catch (Exception ignored) {
}```
nah I log it
Catch Throwable instead
dawg you ain't even verified
Its what I do when trying to login to state security networks, I ignore the login errors and bypass security
🧠
Never
Developers hate this one simple trick!
Like why use pattern matching when try catch can technically do the work
how cna open inventory in asyncchatevent?
don’t
you schedule a synced task and open it there
developers hate this one trick
thx
public void onChat(AsyncPlayerChatEvent event) {
Bukkit.getScheduler().runTask(plugin, () -> {
event.getPlayer().openInventory(...);
});
}
Audacious
One day we will be able to run tasks without a plugin instance
How
i confuse every time using "T" for the PR for the changes in ban system for CraftBukkit waste many time fixing things with this xd
not tie them to a plugin
Determine the current plugin from stacktrace
Effishunsy
Muh cpu cycles
so, cancelling PlayerInteractEvent stops players from putting flowers into flower pots, but doesn't stop them from taking flowers out? How do you stop the latter?
I can so relate to this one lol
sure its not a cliend side bug where the flower still in pot?
i use the T thing so little times.. here in a few PR and in a D4J BOT for a interface for handle Interactionns.. not the best thing but works xd
how would I test that?
reconnect
a test plugin, and like olije reconnect or move things of inventory (the two things) if its not a client bug then you can report to JIRA, its not a Jukebox issue then Choco can handle :3
Flowers still missing, lol
Oh yeah, so I was working on this greenfield project, and my friend started using actual names for type parameters, so he had stuff like Registry<Key, Value, DerivativeRegistry extends Registry<Key,Value,DerivativeRegistry>> so holy confusing
I use it quite often
The second, and what issue show the IDE?
eh... looks like the same (ignoring the red)
Invalidate Caches is the button i click most often in IJ lol
nah
gg invalidate caches and restart
fuck tomorrow's easter and everything's closed
Tomorrow is sunday anyway
Lol for real gg go next
netbeans not has this issues but dont remember why i move to IJ years ago...
probably worldedit or some other stupid dep that shades stuff
you have something else that has bukkit deps
Windows?
its more "fast" using WSL2
yeah windows
1.13 is probably a transitive dependency. Move 1.19 to the top of your dependencies
1.13 moment
too stupid to do anything abt it thouh
Yes
That’s not supposed to happen unless u have slow internet speed
maybe a bit exaggerated but like for a paper project with a shit ton of dependencies and a mediocre internet speed
paperweight
You can also exclude the 1.13 dependency from the dependency that declares it as transitive dependency
Emphasis on the weight
its the first run so it takes a whil
Sou can see where it comes from using mvn dependency:tree @last temple
Player carrier = ...
Player passenger = ...
carrier.addPassenger(passenger);
how do i stop passenger from leaving carrier?
Paper likes to brick my pc everytime i start a new project with userdev
Is there any way of identifying a seed?
Whenever I have to reload my gradle files when modding I just go do something else
so:
if(e.getClickedBlock().getType() == Material.FLOWER_POT) e.setCancelled(true);
should stop PlayerInteractEvent taking flowers from flower pots? Just being thorough.
Cancel event
EntityDismountEvent -> cancel
Lol yeah same, it takes forever
ok, but what event?
No
Ever flower pot is a different material now
Md told u
i remember like 5min for build... this in windows xd with WSL2 reduced to 1.. and for this not a big fan of gradlew... this or i dont know how to use... then maven FTW xd
Oh???
what event is fired when a player leaves a vehicle?
Oh, fabulous, thank you
At least you're not on a 10 year old midrange CPU :kekw:
Tags are the stupidest concept
declaration: package: org.spigotmc.event.entity, class: EntityDismountEvent
What if I use a data pack to put grass in Tags.FLOWER_POTS
What you gonna do about it game
What you gonna do huh
Ah, I just believe gradle can lead to some tricky project structures, like I almost needed to write a gradle setup to test my original gradle setup
It just makes no sense to be data driven for 95% of the tags
but havent had issues regarding speed
It changes then
need more whats this xd
i mean allow vanilla change things with tags sounds great i never use...
Fun
if i remember the tags check the IRegistry then i think affect this too (?
I see people use new tags a lot in datapacks
Why are datapacks even a thing
But they never really change existing ones
Who thought modding in JSON is a good idea
Should have used HTML
or lua
php
makes modding easier
Only c++ is an option
Java is quite accessible
and java isnt as slow at ppl think
But you know what’s more common
.net lmao
C#
Also remember about platforms
jvm is superior
With graal u can even compile java to native
Imagine calling it windows 10 edition
You trolling or smth
if u want features use kotlin
It runs slower than Java edition and looks aweful
Haha kiss in what
Chef was kissed in the wrong place
it feels sloppy as fuck
Bedrock edition has micro transactions 🫢
i got crispier gameplay on java with a shitty laptop
Yeah exploiting children on money!!!
pretty sure the lighting is fucked
Why do bedrock animations feel 15 fps
Bedrock does have a better datapack system though
ambient occlusion is very different from java or something
Bedrock is a buggy mess
Bugrock
On bedrock by placing a chain u could x-ray in lava
Immersive portals >
Hey I need help with a spawner plugin similar to the one on the donut smp where you can right click the spawner and can sell the generated itme
I think they refused to fix it
I remember a video of someone on bedrock nerd poleing in the nether
And then they just died
is any way to remove it from spawner itemstack
You can also randomly die instantly fron fall damage
i'll go to bed now and play bioshock 1, good night everyone
#help-server if you need found a plugin.
Like 1 block fall = death
Math
not sure but you can try a few hide tag for itemmeta
Good night
Dave's garage made a vid comparing performance with a prime finding program and jvm had ~70 more passes/sec than .NET. also he used an old jdk version i think it might be faster now
Is there any examples for PersistentDataContainer because I am trying to store string in container, but it gets deleted after one method. (Doesn't save to next method in the line)
.net is such a stupid name
?paste your code
anyway, here's how to use PDC: https://blog.jeff-media.com/persistent-data-container-the-better-alternative-to-nbt-tags/
you never set back the changed itemmeta to the itemstack
Oh true
Get item meta returns a copy
ItemMeta meta = myItemStack.getItemMeta();
meta.getPersistentDataContainer().set(...);
myItemStack.setItemMeta(meta);
this should fix it
I believe that’s client side, but you can try the various item flags
I had that issue like year ago on itemmeta should have known
Pretty sure minecraft doesn't have flag to hide creative tags
Dave tests almost 100 different languages to find the ultimate champion in generating the fastest code. Feeling a little bit autistic? Check out the free sample of my book: https://amzn.to/40HUwgu
Primes Code on Github: https://github.com/PlummersSoftwareLLC/Primes
PrimeView: https://plummerssoftwarellc.github.io/PrimeView/?rc=30&rs=0&fr=&sc=d...
tf java is the nr 5 fastest
Is the title in order?
declaration: package: org.bukkit.block, interface: CreatureSpawner
Every benchmark will have a different winner @glossy venture
You can easily manipulate it to your liking
only has one benchmark in the vid right
itemstack can have type?
Hi someone does know where i can find the replace of this class in 1.19.2
ItemStacks have BlockStateMeta
this is in 1.17.1
well he let independent developers work on optimizing the solutions for a year
he didnt have anything to do with it
except management
The most impartial way would be to average a bunch of different use cases
I can probably find a benchmark that shows python being faster than java
Since some languages handle certain things better than others
do it
Bruh
Lol
Can't you just trust my word
u know how do it??
what do you need it for?
If you want to get a text component, use Component.literal(String)
so?
got the enchant thingy to work ty
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
maybe regex as i think python might outsource it to C but java implements it in java like a chad
more a matter of the stdlib than the language or vm though
Maybe one of the item flags can get rid of it like mentioned earlier
yes
nope
it's POTION_EFFECTS
in 1.19.4 it's potion effects, I just looped over all flags
For the placed on tag
^^
Ufff this need a rename or mojang add more flags and not reuse others xd
I think yeah, the Material not has deprecated things?
mojang's name is ItemStack.HideFlags.ADDITIONAL
Ah
at least I think it's that one
Yeah
thx bro
is there a way of check if an item is type of a specific tool live an axe without checking for over the all 6 types of axe?
@young knoll i have a basic search system, when you search a player he cannot move (putting it into a List and canceling move event) but i don't know when and how remove him from the List while the searching is done.
yea i know that part
but how i can find out the search is done
its a simple player.openInventory(target.getInventory);
what are your players searching for
i can't find those tags, i am using 1.19.3
other players inventories
by using a stick and right clicking on them
i see, well the search would be done when the controlling player closes the menu right?
yes
wanna my code?
Well it’s linked to vanilla tags
Idk when vanilla added those tags
Tags being modifiable is good for modders
But it’s kinda weird with just datapacks
private static final Set<Material> ITEM_TOOLS = EnumSet.of(Material.STOOF)
Yes but you have to update that
Material.STOOF
Also you shouldn’t use EnumSet anymore
new material just dropped
dont care
ill update when the enum gets removed
Performance concerns
no idea how?
use the InventoryCloseEvent
Can anyone take a look at this thread?
https://www.spigotmc.org/threads/launch-firework-in-direction-player-is-looking.599883/
Trying to figure out a way to make fireworks launch in direction player is looking. Thanks!
well then you are doing it wrong, both the open and close events should fire when an inventory is opened or closed
are you listening to the events correctly?
yes, it is not working
tried before several times
^
also chatgpt ^
very helpful
Insightful as always lol
To be fair I’ve only had one question I asked it that it could not handle
And to be fair I’m not sure anyone really has a good answer to it so it’s fair
no it does not, i fixed that too
Wait really?
players used that bug to duplicate items
search player > target leaves > pickup items > target gets back with hes items > both happy
I thought they just synced a dummy copy
At least invsee++ does
Because it has a custom layout to show offhand and armor slots
okay well if the events arent fired in that case I have no idea
i got this idea rn, player searches some one with right clicking on them, so i add a left click with the same stick for them to stop searching
this is the only way ig
i have the players being searched in a list already
so i remove them while the searcher left clicks on them
and it can be a HashMap instead of a List
Map<Player (who searches), Player (Target)>
thanks all guys for help and ideas
does that matter?
hmm, make sense
yea server will create a new player object when a player rejoins
Yeah keeping the player instance around is technically a memory leak
btw i remove the player from the list while he leaves, but ok i change it into UUID
if you take good care to manage it correctly, by cleaning up on leave and stuff u can do it but still not really recommended
yea fine
but one thing, is there any event or something for "left clicking on a player"?
ow it works for both right and left click
Left clicking on a player is the damage event
Since yknow, that’s how you attack
I don’t remember if it calls the interact one too
what if the player does not take damage (creative)
how i can find out its Right / Left click?
i can't understand
hand is hand at all
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
That tells you which hand triggered the event
Nothing to do with left vs right click
no i can understand that part
So you’ll need the damage event instead
i mean so what i should do to find out its Right or LEft click
what is the player is in creative game mode?
doesnt matter
I think it’s still called
yea lemme tryandsee
Good old tas
you use the damage for left click and interact for right click
Sorry to interrupt but I have a really quick question. When including an external library, is it considered better practice to shade the jar right into your plugin or to include it as a library in plugin.yml?
shade if its small, libraries feature only works for maven central
aight thanks
I mean all this talk about creative is fine, but who cares about your player inventory if you are in creative
https://paste.epicebic.xyz/qomucureqi.java this should also work mysql right? making the connection not singular with connection pool
I assume it’s hikariCP
correct
yeah
sqlite no pool so i just made 1 connection for it all
okay so you know how i needed to do stuff asnyc
theres only 1 method that actually is required to do sql
and its the increment method
the rest i can cache
You can use hikariCP for both
i am
It’ll handle SQLite fine
Alright well, if only one method needs to interact with the db
you wanna know the funny part
Then you can only have it be a future
its a void method
i dont even have to change stuff
i was complaining over nothing
How do you load the data
do it on startup
For every player?
Why not load it when the player joins
true
You even have an event you can use for that
i did actually think about that
my only issue is this method
for the leaderboard
Cache it
thats what i do
And refresh it every X minutes
i load it all on startup
so everyone can be checked
im gonna make my load data async
what event is fired when a player tries to take equipment from an ArmorStand?
PlayerArmorStandManipulateEvent
there's an event for everything...lol
Sadly not...
7smile why are you awake
Hey if you have suggestions :p
Fell asleep 5h ago and my dog nuzzled me awake. Now ill just do some programming/cleaning until i feel like sleeping again 😄
Good thing we have no lectures for a few days
dogs are fun
Thats just event... You can literally do that with a bit of hacking
Ur a void
i was complaning i would have to recode everything over nothing
Make sure your modified collections are thread safe if you do it like that
gotta love waking up at like 2am
How do i get those flowers
it all worked so
yeah
Yes, i want to have... drip or whatever
💀
tis is profile settings 7smile
but I can't bother learning how to do stuff
I am frog
im also frog
layeth your eyes on my indignant frog, originating from all that devilment we have to deal with on this unholy server
I'm a princess
wat
i have utf set
oh thats nice
i have no intellisense
time to invalidate cahces
IntelliJ tax
how do i reduce a damage from an item?
@EventHandler
public void onCrafting(CraftItemEvent event) {
Recipe recipe = event.getRecipe();
ItemStack item = recipe.getResult();
double damageReduction = switch(item.getType()) {
case WOODEN_AXE -> 4;
case GOLDEN_AXE -> 4;
case STONE_AXE -> 5;
case IRON_AXE -> 4;
case DIAMOND_AXE -> 3;
case NETHERITE_AXE -> 3;
default -> 0;
};
// I don't know what to do now
}
ayy I fixed it
Get ItemMeta, cast to Damageable
Set the damage attribute to default - yourvalue
damage attack
how do i do that?
Find out the default values for damage and attackspeed (wiki)
Create AttributeModifiers for those.
Apply them to the ItemMeta.
How do you listen to EventEvent though
We need EventEventEvent
Don’t worry that it will cause recursion, it’s fine
Let me introduce to you: The spigot event system. (I think this guy might be new here)
@EventEventHandler maybe
Unless you wrap your events in your EventEvent class and manually fire them.
You just need to go through all places where events are fired and also fire an EventEvent with
the original Event as your property.
@lost matrix
@EventHandler
public void onCrafting(CraftItemEvent event) {
Recipe recipe = event.getRecipe();
ItemStack item = recipe.getResult();
double damageReduction = switch(item.getType()) {
case WOODEN_AXE -> 4;
case GOLDEN_AXE -> 4;
case STONE_AXE -> 5;
case IRON_AXE -> 4;
case DIAMOND_AXE -> 3;
case NETHERITE_AXE -> 3;
default -> 0;
};
ItemMeta meta = item.getItemMeta();
Collection<AttributeModifier> attrs = meta.getAttributeModifiers(Attribute.GENERIC_ATTACK_DAMAGE);
// now what? :s
}
simply add a new attributemodifier to the collection?
Now you are reading them from the meta.
Thats not what you want.
You need to write them to the ItemMeta.
Use this
Always assume that you are working with immutables or copies when the original class
has mutators already. So i would simply use the addModifer methods provided by ItemMeta (like addAttributeModifer())
@EventHandler
public void onCrafting(CraftItemEvent event) {
Recipe recipe = event.getRecipe();
ItemStack item = recipe.getResult();
double damageReduction = switch(item.getType()) {
case WOODEN_AXE -> 4;
case GOLDEN_AXE -> 4;
case STONE_AXE -> 5;
case IRON_AXE -> 4;
case DIAMOND_AXE -> 3;
case NETHERITE_AXE -> 3;
default -> 0;
};
ItemMeta meta = item.getItemMeta();
AttributeModifier attr = new AttributeModifier("GENERIC_ATTACK_DAMAGE", -damageReduction, Operation.ADD_NUMBER);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, attr);
item.setItemMeta(meta);
}
i don't know if i did it right now, but seems correct ._.
Adding mods will remove the default ones.
So you will have negative attack damage and no attack speed now.
.-.
well, i don't know, there are just that method and other one which is setAttributeModifiers, which requires a multimap, but i only want to change one of them, so if i use that other method i must do something to preserve other attributes? this is turning much complicated for a simple task
Again: As soon as you add any modifers, the original ones will vanish, no matter what.
So you need to replace them with your own.
Get the original attack speed and the original damage from the wiki and use them
as a baseline for your new values.
hmmm ok
@worldly ingot not sure if you are around, but what is the significance of this title field being final?
static class MinecraftInventory implements IInventory {
... Collapsed Above
private final String title;
... Collapsed Below
Because changing it doesn't do anything at all
I've been looking into the inventory setTitle PR rn and honestly the easiest way I found to do it without he packet hackery is removing this final field and adding a setTitle seems easiest
not immediately without an update
I mean, is the packet hackery not a valid solution
chatgpt at its finest
I guess it’s liable to break but so is most of minecraft
it is but its a client quirk
Someone go ask John Mojang if they intend to keep it
loll
if I were to do it with the client quirk instead of actually adding anything I was thinking I'd add like a sendTitlePacket or something instead of setTitle
because sendTitlePacket is more describing of whats actually being done
or sendTitle
whatever is usually done when sending packets I'd follow that naming
how about like sendTitleChange or something
should I just put it in inventory view you think or is that stuff organized somewhere else
Hmm
chat gpt is fuckin struggling with this rn
It’s per player right
It may actually belong in player then, or human entity
HumanEntity probably since that is where a lot of the inventory related things are
You could include a convenience method in inventory view that just calls the method for each viewer
@young knoll You know when you told me how to use the vanilla generator to make the generated sections and the rest void? I'm both pissed off and happy that it was that easy.
yeah good thought
:P
Those methods are new, so thank whoever added them
Does world generation automatically write to the file, or should I save the world?
Minecraft will handle saving
i want to add a folder to my jar file (with path), how can i do it using jar command? or any other way in cli?
for example i am going to add libraries folder to eg.jar, but i need to add them to eg.jar/META-INF
nvm, used zip cmd, works same as jar
Add load: STARTUP to the plugin.yml
@young knoll curious on your thoughts this is what i got
@Override
public void sendInventoryTitleChange(String title) {
if (!(getHandle() instanceof EntityPlayer)) return;
if (((EntityPlayer) getHandle()).connection == null) return;
if (getOpenInventory() == null) return; // Only send if the player is viewing the inventory
// No need to send InventoryCloseEvent, as the inventory won't be closed technically
EntityPlayer player = (EntityPlayer) getHandle();
Container currentContainer = player.containerMenu;
Containers<?> windowType = CraftContainer.getNotchInventoryType(view.getTopInventory());
// Opens window with new title and same id as current window
player.connection.send(new PacketPlayOutOpenWindow(currentContainer.containerId, windowType, CraftChatMessage.fromString(title)[0]));
}
I also added a method to InventoryView called sendTitleChange that just calls this method
This will delete all items inside the container (for the client)
I have tried this in the past
hm really
Instead of returning spigot normally uses exceptions
I forgot is the standard now is Preconditions or Validate
I'll tinker with it
This my friends, is a java app that takes a world file and finds every single instance of an item stored in a container (uncluding shulkers within containers).
900 regions scanned in 1 minute and 50 seconds.
The beginings of a bloody phenomenal anti duping app
guess I'll have to look into it more tomorrow iirc I had something working that didn't clear the inventory just forgot what it was
I had some on hand I just forgot where
?paste
Coll
fellow vscoder
I compiled my plugin with maven, still error saying that the plugin didn't load
What steps are you taking to make the plugin
I'll PR tomorrow lmao I'm going to bed
Is it just compile with maven, put on server
I used maven minecraft plugin sample.
I've compiled it 2 times now.
I have an events listener, main class and playermemory, playerutility that im going to send
I have it in my plugins folder.
I’m not sure why you’d have an invalid zip header
Unless you are manually messing with the jar or something
This method needs to be part of the inventory view not Player
Main (ForgingSystem.java)
package me.assailent.forgingsystem;
import me.assailent.forgingsystem.events.GeneralEvents;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import static org.bukkit.Bukkit.getLogger;
public final class ForgingSystem extends JavaPlugin implements Listener {
private Plugin plugin = this;
public File playersFolder = new File( plugin.getDataFolder().getAbsolutePath() + "/players/");
@Override
public void onEnable() {
// Plugin startup logic
Bukkit.getPluginManager().registerEvents(new GeneralEvents(), this);
getLogger().info("Plugin has now been enabled!");
if (!plugin.getDataFolder().exists()) {
getLogger().warning("No Plugin Folder (If this is the first time running you can ignore this, or if you wiped the plugin data.)");
plugin.getDataFolder().mkdir();
getLogger().info("Made a Plugin Data Folder!");
}
File playerFolder = new File(plugin.getDataFolder(), "players");
if (!playerFolder.exists()) {
playerFolder.mkdirs();
getLogger().info("Made a Player Data folder inside the Plugin Data Folder");
}
}
@Override
public void onDisable() {
// Plugin shutdown logic
getLogger().info("Plugin has now been disabled!");
}
}
Is there a way with CreatureSpawnEvent or another one that I can remove mob spawn conditions from spawners,
Event Listener (GeneralEvents.java)
package me.assailent.forgingsystem.events;
import me.assailent.forgingsystem.utility.PlayerUtility;
import me.assailent.forgingsystem.data.PlayerMemory;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.io.File;
import java.io.IOException;
public class GeneralEvents implements Listener {
private FileConfiguration cfg;
@EventHandler
private void onJoin(PlayerJoinEvent event) {
PlayerMemory memory = new PlayerMemory();
File f = new File(PlayerUtility.getFolderPath(event.getPlayer()) + "/general.yml");
if(f.exists()){
FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
memory.setForgeLEVEL(cfg.getInt("stats.forgeLEVEL"));
memory.setForgeXP(cfg.getInt("stats.forgeXP"));
} else {
memory.setForgeXP(0);
memory.setForgeLEVEL(1);
}
PlayerUtility.setPlayerMemory(event.getPlayer(), memory);
}
@EventHandler
private void onQuit(PlayerQuitEvent event){
PlayerMemory memory = PlayerUtility.getPlayerMemory(event.getPlayer());
File f = new File (PlayerUtility.getFolderPath(event.getPlayer()) + "/general.yml");
if(!f.exists()){
try { f.createNewFile(); } catch (IOException ex) { ex.printStackTrace();}
}
this.cfg = YamlConfiguration.loadConfiguration(f);
savePlayerData(f);
}
public void savePlayerData(File file) {
try { cfg.save(file); } catch (IOException ex) { ex.printStackTrace(); }
}
}
What conditions
In recent versions spawners have a setting for light level limits
I’m not sure we have an api for it though
How do i write non static variables to a yml when someone leaves
bet, I had it in both, but I'll just remove the one in HumanEntity
The MvP isnt public yet (we just got it working tonight and its held together with duct tape and dreams lmao)
moment it is a repo link will be yeeted
Could not load 'plugins/visc-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.visc.visc.Plugin'```
double check your JavaPlugin path
wdym?
The main entry in your plugin.yml does not match your code
Did you fix it to point to the right class?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
thats different. It is only for .config
sorry
config.yml*
when i want to save it per player
read it properly
A fuckin ball ache. Thats how. We spent a month on this xD
But scanning 900 regions in 1 minute and 30 seconds?
Yeah was worth every second lmao
Is it just me or the ocean ruins structures generated are offset from what the API tells you? I get the boundingBox lowest and highest corners and they're very very offset from where the structure actually is. Like ~50 blocks below it.
Might just be a quirk with how they are spawned
I think they snap to the ocean floor
I don't get it again.
sorry bout that, im new in plugin development. And I don't know much Java
name: visc
main: com.visc.main.Plugin
version: 1.0-SNAPSHOT
api-version: 1.15```
java/com/visc/main> Plugin.java
Could not load 'plugins/visc-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.visc.visc.Plugin'```
Even after compiling it..
you have no main class at visc.visc.Plugin
The error and this do not match
Is it com.visc or com.visc.visc
I tried verifying, compile, test-compile, and validate.
idk how but it loaded...
maybe cuz the .jar wasn't being updated..
You cut off the stack trace
- Not spigot
- @worldly ingot you broke it
Open a bug report (with Spigot)
Maybe?
Try with spigot and see
MD can someone smell when it’s not spigot
I haven’t spotted it yet
Ope I see it now
No. Its early
?
Yes
What's your point
It is a bug in the server
If it is a spigot bug (ie happens on spigot) then open a spigot bug report
You are not currently running Spigot
Hello There, i was investigating about obfuscation for protecting my plugins of being decompiled.
Does this work for the plugins?
Any type of effect appears on them?
Or they just keep equal.
Your stack traces will be horrible to read.
Also: If they want to decompile it then they will decompile it. Nothing you can really do about that.
Well ye, thats true
But ive seen examples
Literally impossible to read
Do you even have something thats worth obfuscating?
I dont think so, but you know
Better to just be safe
Its never impossible. There has been no instance of a java application that couldnt be deobfuscated.
Dont bother. Not worth the hustle.
Latest i suppose
Open Source your plugin it's better for everyone involved, you can't prevent piracy.
Don't worry about shitty code, everyone writes it.
