#help-development
1 messages · Page 1929 of 1
has some code example?
declaration: package: org.bukkit.util, class: Vector
What version of java would I compile with if I want to support earlier version as well as 1.18
1.14-1.18
how can i check if in a radius of 5 blocks ( 5x5 ) there is a stone block?
i have a position and i don't know how to do it
You’d have to do 3 nested loops
If you just use the API you can technically still use 8
But like, use 17
You get so many nice features
example? I'm not intelligent 😂
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
you dont have to be intelligent
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
Can I get a list of this ones from my plugin?
declaration: package: org.bukkit, enum: Sound
Learn java
didn't asked for that
You have been asking related to basic java on slimefun dc and here
And while people offered you help there, no one will spoonfeed u
I aint saying about spoonfeeding
maybe a link to docs
Google.com exist
And https://discord.gg/spigotmc also
Do your own research and learn java first
I didn't asked for that x2
You expect someone to spoonfeed u everywhere?
I expect someone actually helping
you are repeating the same exact thing even when I try to learn by myself xd
because of your ability to read mentality?
you don't know what I've done by myself
you aren't a mind reader
Why are u asking the same shit over and over?
You are repeating the same over and over and yourself make this conversation lead to the same point eveytime
:c
If I ask in here you hate because I am a noob if I ask in slimefun you hate because of the same
I finally made the slimefun thing by myself
If I ask a thing I don't want to read you complains about I am a noob bruh
Nobody said ur a noob
Your trying to do things out of your power despite trying learn the basics first
But what does it matter to you to send me to a docs or smt to take a list of that
I mean after all I am learning in another way but learning
Goodluck
thx man
Bud, the point if this community is to help with minecraft related development, if you dont know how to get a list from something, then you should probably try learning a bit more about java
ha noob /s
😦
how can i cancel certain packet? Have I to cancel it for all players (add all players to the channel) or is there any other way
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class DisableDefaultMessage extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
e.setJoinMessage("");
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
e.setQuitMessage("");
}
}
Hi, when I put the plugin on the server it does not load but I have no error
I'd like to check if a player is currently pressing shift on a entity click event, how can I do this?
does the plugin come up if you type /pl ?
No
Then there is an error when the server starts
No error
no error in console log?
This is a binary outcome:
If the jar is in the plugins folder then either of those two events occur:
- An exception is thrown when the server starts
- The plugin comes up when you type /pl
Nothing else is possible.
[01:44:14 ERROR]: Could not load 'plugins\DisableDefaultMessage.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[Spigot-1.12.2.jar:git-Spigot-79a30d7-f4830a1]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [Spigot-1.12.2.jar:git-Spigot-79a30d7-f4830a1]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:305) [Spigot-1.12.2.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) [Spigot-1.12.2.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [Spigot-1.12.2.jar:git-Spigot-79a30d7-f4830a1]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml`
Two ways:
InventoryClickEvent#getAction()
InventoryClickEvent#getClick()
no inv
"Jar does not contain plugin.yml"
I think you can figure out what that means
main ?
not in an inventory
i meant as in right clicking anentityt
Thats not possible. You can only check if the player is sprinting or sneaking. No way to check for certain buttons being pressed.
It literally means that there is no plugin.yml in your compiled jar
Bruh thats what im talking about. on the PlayerInteractEntityEvent i want to check if the player that is interacting is currently in shift mode (Sneak)
lol
No idea what "shift mode" is but you can just check
Player#isSneaking()
check if event#action is left click or right click then then if(player#isSneaking) do your statement
oh its answered mb
Update to 1.18 :)
Gosh I wish we could check for arbitrary keys
Would be cool. But also a lot of unused packets that would have to be sent.
Yeah
Maybe if the server had to specifically register keybinds, that would reduce the packet count a bit
true. For example when the player joins you ask them for A, C and K
But then security is a big concern
How so
Asking the player to send all keys pressed is just a remote key logger
You would register a namespaced key and a default button (the client could then change that button in their options menu), when they press it a packet with they namespaced key would be sent
That would be a solution. Still doubt something like this would be added.
Not a big security risk if it only works while the window is focused
But I agree that it doesn't seem like something they would ever add
What I did to solve this was write a mod the user could bind keybinds to. When pressed they execute a Command the server picks up as a skill
Or just make a proper system with packets and a client mod
Yeah but it's a temporary solution atm
how would you go about getting a custom skull texture 1.17+
from minecraft-heads site
much appreciated
Looking for a dev that can code for free until our release, we are working on a big project I will give you all the info. but you have to work for free until our server release
Thanks!
Work... For... Free? How much you expecting to have done and I don't think this channel is for that...
But devs don't work for free...
We will continue the chat in DMs
Devs would need payment for their work
But you'd be paying the devs right?
Not until realease
But devs don't work for free, they'll need payment
Imagine working for free and getting paid when they release
What if they never release?

lol
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
I was doing a 50/50 deal with someone on paying a dev now they shown their true colors and dropped this is gonna be expensive for me...
... who would fall for this lmao. I guarantee you nobody is going to do this and if they do they are probably dumb and not a good programmer.
That's why I made a client-sided mod for VeinMiner 
ur choice
xD
Well atleast ask in the right channel
sure
Man there is no such thing as free
well, we will see
You do realize your basically attempting to scam people into free work right?
Nobody is that gullible and if they are they shouldn't be programming
a dumbass would do it for free
Right, and a dumbass would do a terrible job
And it'll end up being a shitty plugin lol
Then why are you asking for free ones???
Suuuuure
I hope you spell your words right
I hope u do too
Expecting somebody to do your work for free? you must be high
well
Sus
not in 2-3 months
i wish i could show proof here
but can't
u get
xD
Bee anger == 0 means normal bee?
very good lols
lol yes
I guess its free to dream
i guess it's okay
goodluck with your offer
some people are fools
Good luck finding someone who is willing to do work for a future paycheck
well we already have some
thanks
then why ask lmao
i really apologize for that
can we move on
we need mor to make there future paychecks fast
i guess
How much r u eventually paying ur devs?
Time is a valuable resource, if people aren't compensated for the time they will lose by committing to your project, they will likely quit after the first day or not even join in the first place. You will be hard pressed to find anyone here who will work under the guise of "payment after server release". I've met several people who said the same thing and based on my experience, it's almost never ended well.
The people who you will get from your request are either
- Beginner level programmers who are looking for opportunities to grow in plugin development. (Meaning they are still learning and won't be making proper systems)
- People who are work on their time because they have things that take higher priority than volunteering.
- Newbies who only copy and paste code or edit configuration files.
I've been down that path before and 9 times out of 10, the projects never get off the ground. The ones that did never made it past two months. Now, I have no clue whether or not your intention is pure, but if somehow get off the ground and you don't pay your developers, you are in for a rude awakening.
This isn't meant to be condescending or an attack towards you, but a reality check. You need to compensate people for their time.
i am not the owner
Amen
prayers to anyone who has to work with you then
i am one of the small devs
you got no time to fix your problems?
Feels like a pyramid scheme to me
feels like a scam link
maybe not xD
same2u
"you wanna work until youre eventually paid?"
"When will I get paid and how much"
"You will eventually get paid"
Well, it's u choice if you wanna trust us
you're a small dev working for free?
yes i am working on minor plugins
I mean no shit. But you give no one any reason to trust you
may god bless you
i dont even need money
I work for fun
xD
sure
Good for you means literally nothing when 99% of the people who code do it as a career
Ive done free work for people too, doesnt mean I should expect anyone to do the same
Fun is all i want :D
Thats great! Coding is fun, expecting people to code for free with zero info on payment is not
bro like people play game for fun and i code for fun
i understand
i just really want fun
That's fine, but the situation changes when you are asking people to work for you for free.
Then why bring up personal opinion when ur a minority on the subject?
maybe idk
cuz he doesn't know how to deal with it
Bro bcz some other people
also code for only FUN
not just for money..
and i am here to look
Just stop
and i aplogize for writing here
Enough
this may shall end ig
Kids these days
All your comebacks are lameass
ha ha jk
But youre offering to pay people. Then give no info on payment
ur opninoin
I am not the owner
bruh
this kid is on fire
so then dont go around asking people to work for an eventual payday when ur not qualified to do so
I have a question boi
why do I even need a proof for it
You dont have to be a kid to act like one
okay ig end this some peole have opnions
maybe
The way you type.
The way you respond.
The Dream SMP pfp.
The way you don't listen to people.
also over use of "xD"
You are a small dev but want to teach others how to program? Makes sense
does that make a differnce
When i did i?
It does cause im not gonna trust someone who acts like a child to pay me for work I do. Or be in charge of recruitment
bruh
that's okay
when we will realease you all will understand..
Untill then Good Luck 🙂
No because nobody care :(
okay free kid

I guess I should also mention that you may actually be older than you let off. You could actually be 26 and it wouldn't matter because what really matters is emotional maturity.
we'll see
true but, different people have different opinions
mostly people work for money
Well to this people true
Why do people argue about anything? lol
he showed his character thats all I want
alteast i am not toxic like u all guys xD
There's no point in bickering with this kid
I want to know what its like to work for free for this kid
recieved happiness ig
Seems to me like he can't handle criticism or he can't handle it when no one is representing his point of view.
join and see
well only some people are
Copege
No thanks
@surreal valve You should check out r/ChoosingBeggars
Who cares about a minecraft server in 2022 ;(
u should too!
You dont understand what Im refering to do you
no thanks kid
u don't understand too!
Especially one that plans to "eventually pay their devs"
sure
Wishing u a goodluck, end it here
POG
okay cool
I'll prove u all wrong 🙂
prove*
Cope
oops
sorry
Gn8 all its 5 in the morning rip
How much time is it by u m8
10?
Why are you up that late geez
Because I have late shift
Ah
Im from Germany I live in the Future kappa
I didn't get an answer last time on how to download a plugin from the website through a script, so.
In inspect element I copied the download request as a curl request and pasted it in a terminal and outputted it to a file.
but.. my problem is the ?version=434732 If I put this curl request in a bash script, will it download the newest version, or will it download the specific version im messing with right now?
I could always just curl the website html and parse out the url and just replace it in the curl request every time I want to update the plugin.
Does anyone have a less hacky method?
you wanne just start the server with code or create an server ?
well... thats not that easy ... but copy&paste an dictionary to a specific location, edit the server.properties for the right port and register it somehow to bungee and then start it ...
I imagine hypixels system is far removed from spigot
In other words what they do is no simple feat that anybody would be able to replicate easily.
Actually i think that they don’t remove the lobbies
Because then when it is needed you’d must wait until the lobby starts up
They do stop them
There just are so many that you don't notice when a new one is started
Ok, i didn’t knew this
i think they have a buffer for those servers and the wait time could be the time for copy&paste your world or just loading it
I am working on a plugin and I have made 2 crafting recipes and i have made a one final crafting recipe which requires other 2 recipes which i made earlier so how can i use the earlier crafting recipe item in this recipe(All the recipies are in different classes)??
Use RecipeChoice.ExactChoice with your item
i can but i have made it on diffrent class
oh yea
Tysm it worked 🙂
How would I check if object is instance of “Optional<ItemStack>”
Or I guess if an object is an instance of a list of a certain type
Because (obj instance of List<Integer>) doesn’t work
I have created a custom stick for my plugin
so how can i make it so that if i click it it should do a set of actions
Listen to the event and then check item in hand
Pretty sure only List?
I assume you want thr PlayerInteractEvent
ok
public void onWandUse(PlayerInteractEvent event){
Player player = event.getPlayer();
if(event.getMaterial()==Material.STICK){
player.sendMessage(ChatColor.RED+"Yo");
}
}
```I tried this code but its not working
if(player.getInventory().getItemInMainHand() != null && player.getInventory().getItemInMainHand().getType() == Material.STICK){
Try that instead
Also make sure to have @ EventHandler before the method if you don't have
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
sorry
tysm it worked 🙂
Basically
Check if the object is an instance of Optional
Then do sth like
Optional filter(ItemStack.class::isInstance)
map(ItemStack.class::cast)
orElse(null)
also how to get chat clicable chat buttons
i meant is there any special class for that?
Yuh check out bungeecord chat api
fade in?
probably do some wunky things with lighting
i dont know any other possible way than doing it with lighting
I'm trying to include a uuid in an item lore, and have it invisible. I'm trying to hide it this way
` public static String invisibleString(String str) {
String invisibleStr = "";
for(char ch : str.toCharArray()) {
invisibleStr += "§" + ch;
}
return invisibleStr;
}`
When retrieving the string (and replacing all § with nothing) I get "a-c-c-f-1" back instead of "375be66a-566c-4ddc-ad3f-a3e594f87931" that I included in the lore. Any idea why that happens?
I have used that method in previous versions of Minecraft and it used to work iirc
Why not use pdc
I'll look into that, thanks
Just use pdc, profit
Ok so I'm trying to make a /duel accept command which accepts a duel req but the player who was sent a req can /accept anybody without sending a request
because you need to store each duel invite in a map
use their UUID
zombieVillager.getVillagerProfession() == Villager.Profession.ARMORER
always false?
and do what mike said
In Bungie Cord Chat API when i use text component it says Out side package can't be access
?paste
when write this, IDE give me that warning
Your code
Have you checked the docs as to why that is
?jd
Or to why your IDE is giving you that error in the first place?
I didn't test that. got error so asking if that code is ok or not
Seems ok
In Bungie Cord Chat API when i use text component it says Out side package can't be access
?paste
What exactly does it say
@warm light is variable type ZombieVillager or Zombie
If Zombie, cast to make error go away
ZombieVillager
If ZombieVillager then its intellij weirdness with inheritance
The method in Zombie is always false, but not ZombieVillager
ok
the remapped jar from buildtools works only for post 1.17 right?
happy to be wrong, would appreciate answers
Yes

how do i set a premain class and other related manifest attributes like Can-Redefine-Classes with gradle
not related to spigot, just general java/gradle
will scheduler work when i returned from the method which calls it?
Context?
what pattern should i use for balance?
you mean... like this?
void something() { return; // scheduler code }?
if thats what you talking about then it wont work
Bukkit.getScheduler().runTaskTimer(Main.getInstance(), () -> {
entityEnderDragon.setHealth(entityEnderDragon.getHealth() - 1.0f);
if (entityEnderDragon.getHealth() <= 0) {
sendPacket(new PacketPlayOutEntityDestroy(entityEnderDragon.getId()), p);
return;
}
updateEntity(entityEnderDragon, p);
}, 20, 1);```
by 'return' i want to just cancel this task
i think return will get out of run task timer
use the consumer then
rrc
me too but i want to be sure
maybe use task cancel
And btw
yeah use task cancel for safeness
You still have to return to stop code execution in current method
But cancel will stop future conceivable iterations
can u explain this
yeah
In this case being BukkitTask
Ofc you can make it to a lambda body expression
Such as
task -> {
task.cancel();
}
And also should mention, the name "task" does not matter (could be sth else) just like every other function parameter name
one querstion
u used ....task.cancel();
as an example or i should use it
as u wrote it
Bukkit.getScheduler().runTask(Main.getInstance(), task -> task.cancel()); like this?
Well no
Obv you need to use runTaskTimer if you need that instead
And include the code you want to run
I just provided pseudo code
^ (or maybe both, entirely depending on what you want)
it's boss bar method so i want to stop running it when hp/progress is < 0
also there's a one problem
because when player recived packet which removes the dragon
bossbar stays for ~10s
is there a packet/method to remove it right away?
anyone?
what design pattern should i use for economy
economy is about transaction, so..
so what
transaction pattern
This is a very ambiguous question
first and foremost design patterns are implementation details
So you there’s no correct answer really
you can only find yourself less “right” answers
So I got map with players which I am looping every 5 ticks because of rotation of armor stand on there head it run on main thread
Now I am adding people to map by listening to packets on entity spawn and destroy
As I read protocollib does that async
So what are my options because I know it could be problematic if different threads read and write/remove data should I make new BukkitRunnable in protocollib litenere and just put add method in it and run it sync
i thought about a singleton
For what o.O
Static singleton or just singleton?
multiple currency’s
Is this an api or just structure?
structure
Or are you trying to create behavior here?
wdym
Behavior and structure are not the same
Hence why there are structural design patterns and behavioral design patterns
which are fundamentally separate
use a condition if it becomes true cancel the task
Anyhow regardless on what you want you most likely are going to use the behavioral ones so look at those
then, some of the structural ones can be good to keep in mind
Would also like to mention you most likely want to make it work
im new to java sorry my friends insulted me because i didnt use a pattern
Then you refactor the code
dont listen to your friend
The first thing you learn about hopefully isn’t design patterns
i know all basics ig
Principles before patterns
i read books too
Fundamental object orientation knowledge and java semantics come before principles
Well do you remember what you read?
what is principles
Else the books are useless
yes
no learned much out of it
Principles are ideas that try to address a generic problem
i know principles

i didnt knew the english word
Ah fair
sorry
'
Don’t think those definitions help him further
I mean google is nice
for that kind of question
🥲
🤮

Ye

https://pastebin.com/bL2tt3BL
Hi, so I wrote this function for an axe throw, which is called when the item is right clicked.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
However, the axe doesn't seem to be returning to me... what am I doing wrong?
what happens instead ? i think you just cancel the task so it cant return before
So the axe throw works
And like it despawns at the right times
But I don't get the item back
did you debug it ? i guess armorstand cant be dead or alive ... it has always the same state
Lemme try debugging by sending a message
Hey, I tried using
loc.getBlock().setType(Material.DIRT);
mineWorld.getBlockAt(loc).setType(Material.DIRT);```
For setting a block but it doesn't work
https://pastebin.com/wU5AKSEv
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
also this is not the good way to do it: runTaskTimer(SleepyEnchants.getPlugin(SleepyEnchants.class), 0L, 1L);
see dependency injection to use you main class in the right way
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
I tried to use
loc.getBlock().setType(Material.DIRT);
mineWorld.getBlockAt(loc).setType(Material.DIRT);```
And it isn't setting the block
Code -> https://pastebin.com/wU5AKSEv
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i would check the name of the world from the blockbreakevent and not searching for another world and check if its the same worlds
and still
?notworking .... what error ? did you debug it ? did you register it ? did you install your plugni ? did you reloaded the server or started it with the new plugin ?
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
No error yes I debuged it I registered it I installed it
?paste
debuged if the event gets called ? debugged the world objections if they are not null ? debugged if the world names are equal ?
if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(thrownItem.get(player.getUniqueId()));
thrownItem.remove(player.getUniqueId());
sendMsg(player, "&aReturning Axe!");
So I added the "returning ask" to send the message, and the message sends so like
It gets called yes they aren't null both worlds are the same
The problem lies where the item isn't added to the inventory
I can't use textComponent even i have imported the bungecord chat api and when i use text component it shows this error
https://paste.md-5.net/evalofizow.coffeescript
so is there any solutions for it?
so you get the "asd" msg ?
whats your code ?
oh
you importet the wrongthing -.-
yes
?
TextComponent message = new TextComponent("sad");
i dont think so
your in block break event ... if you set a block but not cancel event it will get destroyd in the process of the blockbreakevent by the server
you need to cancel the event
oh now it does not show the eroor
still same issue
Delay a tick
sure ? then it might not work setting the block of blockbreakevent ... if you tested it correctly
Imma bump
well.. did you test the object you get from the thrownItem map ? if the item != null or Air and still not working even if the inventory of the player is empty, then idk
Ah lemme check that, thanks
ouch
ahhh
you want to do something based on a number between 0 and 24 ?
You can switch on a number fine
It's not equal to null, just tested
no like
switch(int) {
case 0=>int<=25
case 25>int<=50
}
I have created a text component for a clickable chat message and i have create a function to do a specific task so is it possible to run that function when clicked?
case 0
case 1
case 2
case 3 { number between 0 and 3 included}
so I need to manually enter every number?
Yes
for that its better
Or use an if
I have created a text component for a clickable chat message and i have create a function to do a specific task so is it possible to run that function when clicked?
if you let the textcomponent run a cmd and the cmd is linked to your function yes
Without code we can only just respond with yes.
public void onWandUse(PlayerInteractEvent event){
Player player = event.getPlayer();
if(player.getInventory().getItemInMainHand() != null && player.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD+"The Magical Wand")){
TextComponent spell = new TextComponent("sad");
spell.setBold(true);
spell.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new Text("The magical spell to fill your hunger")));
spell.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/summon zombie"));
player.spigot().sendMessage(spell);
}
}
public void onSpellUse(Player player){
player.setFoodLevel(20);
}
And does it work?
I made a system for this. With a Map<UUID, Consumer<Player>> and a hidden command which uses those UUIDs as a argument.
yah but instead run command how can i make it so that it would run onSpellUse function
@spiral light how do I check what the itemstack looks like?
getType ?
i did not get it
This is what i use:
https://gist.github.com/Flo0/ed2a740e6c9f3e0bd7d790a5a810205d
is it useless to use a PreparedStatement instead of a Statement if you're jsut creating tables?
You will probably not be able to copy that but you might get the idea.
You use some sort of Map<String, Consumer<Player>> or Map<String, Runnable> where you add a generated key with
a specific functionality when creating the click event. Then when the command is run you retrieve that function and call it.
i saw it on stackoverflow but on baeldung they say that a preparedstatement is optimized
I mean if you send just a Statement then you are sending a String that has to be compiled. Preparedstatements get precompiled and can be used to reduce execution time a bit.
ah thanks
I think the changes wont get reflected but take that as a guess
I have an idea instead of that function i can make a really complex command which cannot be cracked then it should do that spell
This approach generates really complex commands because it uses a UUID that is only retained for 15minutes. Not crackable.
ohh
But whats the purpose of the click event if u can do it directly saving u some string serialization
it will save u alot of time when expending it
Are u invoking ur #onSpellUse?
iirc you can use a command that isn't even registered using the PlayerCommandPreProcessEvent
Hello is it possible to remove a specific amount od an item from an inventory so like if you have a stack of bones it removes only 10 not the whole stack
The command itself can be as easy as /spell
But then you can have a Map<UUID, Something>
Where you generate a UUID when the server starts and add it in that map.
Then a spell would look like this:
/spell 8fa62bb4-84ef-11ec-a8a3-0242ac120002
The problem here is that this is not safe as some players can read out the text packets they send to figure
out what argument they have to use. So to be completely safe you should generate a new UUID for
each clickable component and remove it again after the component was clicked.
i saw someone handling it commands through listeners
Like remove an odd amount from an itemstack inside an inventory?
removeItem respects count iirc
Sure. inventory.removeItem(new ItemStack(Material.BONE, 10)); for example
I tried that but that didnt work
item#getAmount - 10
Its like a gui and when you click an item it checks if you have 10 bones and then it removes 10 bones
Thats it
Hm. Maybe its inventory.remove(new ItemStack(Material.BONE, 10));. Try that one isntead.
Il try
(short) 10 iirc
Wait this respects amount
You can loop the contents of the inventory if u want
Check if the amount is enough, just do checks
Then decrement
No this should def work:
inventory.removeItem(new ItemStack(Material.BONE, 10));
It removes 10 ItemStacks of every itemstack where isSimilar returns true.
Make sure they have the items first
Yeah just do checks
ItemStack in the sense of an Object with that material and a single amount. 10x ItemStack{material: BONE, amount: 1}
Use this first
Traverse the inventory, just skip null
Oh use the one from mike
Hi um I'm going to ask this again since I debugged and it should work
can you have a JDA discord bot in the same file as your spigot plugin to connect the two?
The first thing you should do is add a ton of new methods so your code is half readable/debuggable
I made an enchantment for throwing an axe, and it's called upon if the player right clicks an item with the enchantment. Everything is working as expected, and the debug messages appear as well. However, the axe isn't being returned, so what am I doing wrong?
Sure
cool, thanks
Just like a trident?
Oh it returns the item afterwards without the need to picking it up
But the problem is the item isn't being returned
But yeah kinda similar to a trident
Show code
It's right here
This works THX for the help man
Just make sure to check if they have it first 👍
Oh jeez I'm on a phone rn
oye i have another question. When you remove those bones its meant to give you a speed potion that works fine but i dont know how to make the potion length 8 min and not 3.
Can u show a video of it behavior, I'm keen to see it
Custom potion effect
I cant read the code rn, using phone
Why dont you just use a snowball and set its texture to an axe?
Not a effect but a actual potion.
Potion speed = new Potion(PotionType.SPEED);
this is what i do rn
Oh because I made it spin while it's being thrown, similar to an actual axe
Add potion effect to the one who clicked it. Check the docs :)
i have that already but the duration.
This is what i have right now
f (player.getInventory().contains(Material.BONE, 10)){
Potion speed = new Potion(PotionType.SPEED);
player.getInventory().removeItem(new ItemStack(Material.BONE, 10));
player.getInventory().addItem(speed.toItemStack(1));
Pretty sure your using inventory click event for it
yes
#getWhoClicked cast to a player interface if u want
ItemStack potion = new ItemStack(Material.POTION);
PotionMeta meta = (PotionMeta) potion.getItemMeta();
PotionEffect customEffect = new PotionEffect(...); // Create custom effect
boolean overwriteOld = true;
meta.addCustomEffect(customEffect, overwriteOld);
meta.setColor(Color.PURPLE);
potion.setItemMeta(meta);
Why u adding the potion as an item
Use the method from the player entity on adding potion effects
Potion class is really old and outdated. Are you using an ancient version?
Wait let me show u a snippet
Because its for a uhcf gamemode and its meant so you can trade bones for a a speed potion
No just 1.8.8
Oh ita not meant to be added directly to the player as an effect but an item stack?
That IS and ancient, outdated and unsupported version that nobody should use.
yes
@sharp flare https://streamable.com/3vbrkz
Use this then
well allot of people use 1.8.8
Honestly... this can be done in like 10 lines of code if you just use a snowball and the ProjectileHitEvent
But will the snowball spin?
I see. No it will not.
yeah that's the main reason why I didn't make it a normal projectile
Btw for(Entity entity : as.getLocation().getChunk().getEntities()){
wtf
Pretty sure the item is removed when the armorstand is despanwed
Crap this autocorrect
I'm not calling on the armor stand's item, but rather the item that's kept in the hashmap
You should def ray cast your projectile path. What you are doing is a potential performance killer.
Yeah thats a lot of things to process
Clone it before adding it to the HashMap
how do I clone it?
.clone
ItemStack#clone()
oh aight
Then retrieve the item from the map, or u want it to spin back to u?
just retrieving it from the map
Change the thrownItem#get == null to thrownItem#containsKey(), for readability
Just to make sure
Clone is red fsr
Clone the itemstack that will be added
thrownItem.get(uuid)== null why is that == instead of !=
I put the ! at the beginning
The very first thing you should do is structure your code with more classes and methods.
Take a look at this template:
https://gist.github.com/Flo0/2acfd5e01afe27a8ba2f782a9d09f510
This way you can focus on exactly the parts that dont work instead of having this big chunk
that handles everything and everyone has side effects on the other methods.
Alright, but what do I do with the clone?
And i mean this. It will speed up your development big time. And if you encounter a bug you can fix it in 10% of the time.
"The only way to go fast is to go well" - Robert C. Martin
Got it, thanks
Tho uh this
Add it to the HashMap instead of the original. This was just a guess from us btw. There could be other things that
prevent the item from returning. But nobody wants to properly disect that code.
The very first thing you should do is structure your code with more classes and methods.
Is there a tool to make plugins with Lua?
lukkit plugin, LuaJ plugin, or https://github.com/EngiN33R/LuaSpigot
But those are for 1.8
figuring out java for this'd probably be your best bet
I'm terrible at java
I went from roblox to java, took me about a year but now im really good at java in a spigot related context (shut up you lot I know java and spigot are different)
just focus on trying to so something, and you'll learn it on the way
okay then ¯_(ツ)_/¯
what is java? i code in spigot
pathetic, learn to code in nms
giga chad
oh wait I forgot I came here with a question too
I might be on something here, I might've just dreamt this or some shit, but in java, I'm pretty sure ive seen enums like this below. I wanted to know if anyone has a name for it or any documentation I can read on it
public enum Enumerator {
ENUM_ONE {
//some functional code here
}
}
does anyone have any clue if this actually exists?
enum code blocks
That is a pretty disabled move
sorry, can't see your message, burnt out my retinas
nah
Nah
Did u used any extra libraries for it?
how i Export File in Build tool
?bt
ACF for commands. Thats all.
Ah and Lombok
what does Player.getInventory().getArmorContents() return?
declaration: package: org.bukkit.inventory, interface: PlayerInventory
Your IDE also tells you exactly the return type of a method.
But when in doubt: javadocs
?scheduling
?thx
ty
okay
oh item stack
but what if its different armor
ItemStack[]
is there an event for advancements
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
specifically the diamond one
thanks
Btw your class should be called DamageOP not damageOP
why?
its not a class its the project
Java style convention
is there anyway I can make the plauyer place a block on playerinteract event
Oh i see
i cant find it is it posible to provide the links?
if i dont cancel the event, if th player clicks on a chest or a noteblock it interacts with the said block
D:\games\Minecraft\lib\BuildTool\Spigot\Spigot-API
What are you trying to do?
thx
What do you mean by "export file form this path"
Do you want to run BuildTools to get a server jar?
im using noteblocks for custom blocks
yrp
I need it so when the player right clicks to a noteblcok
it places the block
instead of interacting with it
Check if Action is RIGHT_CLICK_BLOCK and the Material of the players main hand ItemStack returns true for .isBlock()
Dont cancel it in this case
yeah but when you click on a noteblock with a block it just interacts with the block
?bt
This explains everything
All good
im bad for English
what type is an advancement?
I see...
Advancement
but like
how would i use it in an if(event.getAdvancement() == WHAT)
i want it to be diamond event
mhm
Advancement.DIAMOND ?
ok is that how it work
First of all: == is only used for identity checks. (If two variables point at the exact same memory location)
Only use it for primitives (int, long, double etc). For Objects you should use .equals()
Advancement is an instance of Keyed. This means it has a method getKey() which returns a NamespacedKey
A NamespacedKey consists of a namespace and a key in this configuration: namespace:key
For minecraft keys its always minecraft:key
To find out what that key is you can look at websites like this one:
https://minecraft.fandom.com/wiki/Advancement
For "Diamonds!" its story/mine_diamond which means the NamespacedKey is probably one of minecraft:story/mine_diamond or minecraft:mine_diamond
Either way you could just for contains. Example:
public boolean isDiamondsAdvancement(Advancement advancement) {
NamespacedKey namespacedKey = advancement.getKey();
String key = namespacedKey.getKey();
return key.contains("mine_diamond");
}
And this wont work as Advancement has no constants and is not a enum
Thank you! This clears a lot of blocks in my brain!
Hi, the plugin.yml file can be read in a folder?
yes
im guessing there is no way?
I try to put it in the "resources" folder but it is not detected
now i can't convert src to jar file
Im only coming up with NMS methods in my head. There is a player interaction manager that can make a player place blocks which will also respect fired events.
By what?
is there a way to edit bossbars
Yes
how?
By the server, I have an error message
https://www.youtube.com/watch?v=RgLdRS4Cc04&t=611s look like this
what's the function
declaration: package: org.bukkit.boss, interface: BossBar
Open your jar with a compression application (7zip, winrar etc) and see if the plugin.yml is in there
1L is one tick
oki
If you dont have quite a bit of development experience then you should not attempt to create custom spigot jars.
Thanks, I'll take a look at the docs from now on.
The L just makes it a long value
Open your jar with a compression application (7zip, winrar etc) and see if the plugin.yml is in there
i has litile quite
what difference is between 1 and 1L?
okkk
How do you compile the jar?
Would this work?
public void AdvancementEvent(PlayerAdvancementDoneEvent event) {
NamespacedKey namespacedKey = event.getAdvancement().getKey();
String key = namespacedKey.getKey();
if(key.contains("mine_diamond")) {
}
}```
manifest
But in this case it doesnt matter as an int 50 would be implicitly cast to a long 50L when compiling.
Probably. But add a debug log that prints the namespacedKey and tell me what it was. Not sure how exactly the resource locations are translated to namespaces.
?
so for me to understanding
BukkitRunnable runnable = (BukkitRunnable) new BukkitRunnable() {
@Override
public void run() {
block.setType(Material.DIRT);
}
}.runTaskLater(Ores.getInstance(), 1L);```
Okay
this will set the block type after 1L right
Can't test the plugin atm, but I will get it to work
with manifest
After one tick which is 1/20th of a second (about 50ms when you have 20.00TPS (Ticks Per Second))
how can i make a hashmap for the whole class (including event handler)
A field will be for the whole class
no idea what "i compile by using the manifest" means... Do you just build artifacts?
Or do you use maven/gradle
but i have to use hashmap in constructor
will it be available anywhere within a constructor?
Thats something you should discover when learning the java basics to be honest.
ok
public class DropListener implements Listener {
private final Map<String, UUID> someMap; // This map will be accessible in the whole class
public DropListener(Map<String, UUID> someMap) {
this.someMap = someMap;
}
@EventHandler
public void onEntityDrop(EntityDropItemEvent event) {
}
...
}
I am getting this error
oh ok
BukkitTask task = new BukkitRunnable{}.runTaskLater();
The method runTaskLater() returns the started BukkitTask
BukkitRunnable runnable = new BukkitRunnable(){...}; // Creates an anonymous class
BukkitTask task = runnable.runTaskLater(...); // Runs the task containing the BukkitRunnable
Just artifacts
So I need both?
I am not understanding what you last said
Show your project setup pls
I was just disecting that blob into smaller pieces. Because in those lines there is a lot of stuff happening.
Put your plugin.yml in the src folder
Remove the resources folder
Remove the META-INF folder. You dont need it.
thanks, i stupidly spent ages trying to do it, and i literally came out with the exact same answer :(
yep
When it is compiled it will generate a resources folder?
And when the server stops then all the ores that are not respawned by that point are just gone for good? 😄
this morning I was told to wait 1 tick before changing the blocktype
in onload i'll make oll the ores to spawn
that's not the problem
Yes. Map can contain a HashMap or a LinkedHashMap or any other Object which implements Map.
Same goes for List which can contain an ArrayList or a LinkedList or an ImmutableList or Set which contains a HashSet or a TreeSet etc.
For example if you have an Object field then everything can be put in there as every class extends Object in java.
private final Object someMap = new HashMap<String, String>();
But then you lose functionality.
okay
Ah you mean in the BlockBreakEvent. Yes you should wait one tick or else the Block will be changed and the server will think the player broke bedrock or whatever your replacement block was.
but how do I wait that freaking tick
The Bukkit runnable task will always be at least 1 tick later
Just like you did it. A more compact version using a lambda:
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
JavaPlugin plugin = Ores.getInstance();
Bukkit.getScheduler().runTaskLater(plugin, () -> block.setType(Material.BEDROCK), 1);
}
Variable someMap might not have been initialized
Show your code
Did you forget the constructor?
basically i don't understand how to use the thing
ok it works nwo
yes
@lost matrix this code isn't working
it’s pseudo code
oh wait
ignore me i thought you were taking about something earlier 
@EventHandler
public void onBreak(BlockBreakEvent event) throws InterruptedException {
Player player = event.getPlayer();
World playerWorld = player.getWorld();
World mineWorld = Bukkit.getWorld("mine");
Block block = event.getBlock();
if (playerWorld.equals(mineWorld)) {
player.sendMessage("sad");
JavaPlugin plugin = Ores.getInstance();
Bukkit.getScheduler().runTaskLater(plugin, () -> player.sendMessage("asd"), 1);
}
}```
So it prints sad but not asd
are there any errors
oh lol
how tf I haven't thought of seeing console -_-
public static Ores getInstance() {
return instance;
}```
getInstance from main
is something wrong with it?
(Just pass the plugin in constructor)
have you initiated instance
wdym by that
public static Ores instance;
public static Ores getInstance() {
return instance;
}```
yes ig
like in your main class you need an Ores field and then onEnable you need an ores = this at the start
im not smart enough to do this someone please help
I don't have anything at onenable
oh ok
im trying to make it so whenever a player right clicks to a noteblock it places the block
so you need an
instance = this at the start
instead of interacting with the block
PlayerInteractEvent - you can cancel it
you can set the blocks in the event listener
ItemMeta meta = border.getItemMeta();
meta.setDisplayName("");
border.setItemMeta(meta);
I want the text to not be there but it does:
Still plugin cannot be null
you try with " "?
Nah will do
Break.java
@EventHandler
public void onBreak(BlockBreakEvent event) throws InterruptedException {
Player player = event.getPlayer();
World playerWorld = player.getWorld();
World mineWorld = Bukkit.getWorld("mine");
Block block = event.getBlock();
if (playerWorld.equals(mineWorld)) {
player.sendMessage("sad");
JavaPlugin plugin = Ores.getInstance();
Bukkit.getScheduler().runTaskLater(plugin, () -> player.sendMessage("asd"), 1);
}
}```
Ores.java (Main)
```java
public static Ores instance;
public static Ores getInstance() {
return instance;
}
@Override
public void onEnable() {
instance = this;
System.out.println(Color.translate("&aOres para la mina listos <3"));
loadEvents();
}```
And it says plugin cannot be null
@terse oreYou have the error log?
runTaskLater(plugin, () -> player.sendMessage("asd"), 1);
in break.java
worked thanks
put Ores.getInstance()
no problem this remind me for the error try to send a title empty... empty its like null internally for a few things.. then a space can fix many things xd
?paste
^^^^^
no
is there a lombok annotation to select many fields
i dont wanna write @Getter @Setter for every field
thats the 100th question of him and it still seems like he dont know java O.o
annotate class with @Getter
but bruh lombok


