#help-development
1 messages · Page 653 of 1
I just figured it out 😅
It's really simple...
Just add a delay between closing the shulker and re-opening the chest.
Seems like 1 Tick is enough
Thanks for your help 😅
np, sorry I wasn't very useful lol
damn it involves NMS, I probably wanna learn the fundamentals of java first before tackling with NMS
You don't need nms to serialize an object
what but they used it in an example I found in the forums
Event is causing server to crash, seems to spam, listener registered only once, anyone?
@EventHandler
public void onPlayerSleep(PlayerBedLeaveEvent event) {
World world = Bukkit.getWorld("world");
if (world == null) return;
event.getPlayer().sendMessage("Time: " + world.getTime());
}
op nvm found a simpler way to do it
why are you fetching the world
this is a thing
Ik, this is not the problem tho
last time I used PlayerBedLeaveEvent it worked fine
Change it anyways, and check again. There is nothing else in this event that could cause a crash.
Wouldn't it just throw an npe tho?
Right, but that doesn't really explain the spam
It wouldnt cause an npe
Well yeah it this case it would just return
Im suspecting that there is a recursive trigger of this event somewhere else
Which means it can't be the problem because the code below it is running
Yeah the problem can't be with the code they showed
Hm weird, i've just restarted the server and now it's working as it should 🤔
Nevermind, thanks for help
Dont tell me you used /reload
Again, something else is causing it
Restart
you called player.toString() instead of getName()
Also cancel the chat event or other players can see that
okay
Okay I now see what's the issue here, how to teleport somewhere after they wake up?
Just teleport them after they leave bed
It's causing to loop
@EventHandler
public void onPlayerSleep(PlayerBedLeaveEvent event) {
Player player = event.getPlayer();
World world = player.getWorld();
player.sendMessage("Time: " + world.getTime());
player.teleport(new Location(world, 0.0, 87.0, 0.0));
}
}```
Why are you hard coding the location
I have the same question
Just for testing
Wdym
I can set it with injected config no difference with the functioning
I want to teleport player when he leaves the bed.
Why?
Delay the teleport by one tick
Some sort of minigame
Okay
why does delaying always sound so much of a band-aid solution?
fr
theres quite a bit of instances where you are forced to in the spigot api though haha
depression be like
I remember I had a plugin where for each certain action I would create a timer for x amount of time, which means there would be a shit ton of timers running each tick
yikes
i once spent 4 hours debugging why my plugin messaging was not working, to have my friend read me one line from the PlayerJoinEvent documentation: "you cannot send messages immediately upon join, wait a bit"
funny thing is that i've read the docs before but completely forgot about it
yeaa thats another one
Oh man that's the worst
at least its documented for that one
When the solution is right in front of your face but your just blind
I swear programmer blindness is a real thing
You might need to wait for a tick or so
Yeah just maybe
how do I hide yaml files from the server's files
Why?
Why would you want to do that
You mean that they aren't put in the config file?
There are certainly situations where you would want to "hide" those files.
I mean sure you can just put the file somewhere else
Yeah, for example in the .jar itself using the resource dir
I don't want the players to access the file where I store the serialized objects
Wait what players? how would they have access to the file
uhm not players
Well players wont be able too, cause it's all server side. Only server OPs could then go into the files.
I meant those who have access to the servers files
just name the file something scary like ".data" or "DONOTTOUCH"
a competent admin will be able to open the jar archive and edit the files if necessary
it takes 0 effort
There's no real reason to hide files from admins, the server data folder exists for a reason
No need to hide it from them. Just make a comment at the top of the file with smth like: "Do not change these values"
okay
Also yeah just serialize to a dat
i just store stuff like that in bytes xd
good luck deciphering
Why .dat? Just use yml or json
You literally just make the object serializable and write it directly to .dat
Without needing to write serializing logic for yml or json
Just store the raw data if it doesn't need to be edited outside of run time anyways
just implement Serializable and write the ObjectInputStream to a .dat file
probably ObjectOutputStream but sure
Yeah lol
any config apis
?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.
that's for me
Make urself
I'm sure apis exist for it just look on spigot mc, what are you using it for anyways
Ima take a wild guess, creating and managing configs
Fair enough
Any way to detect and setCancelled on a warden doing a sonic boom attack?>
First result on spigot mc https://www.spigotmc.org/resources/config-api.40985/
nms
Alr
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
Unless theres a sonic boom attack event
Just use the damage cause
Ok but it took me 3 seconds to search the docs
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
how can i ceate a TabCompletor. i know how to set it to a command but idk how to create it
SONIC_BOOM is right in the docs for EntityDamageEvent
no how to actually create the tabcompletor
and?
implements TabCompleter, register TabCompleter
you will have method onTabComplete()
in your command class
after you implement TabCompleter
and then in main you would need getCommand("cringe").setTabCompleter(yourCommandClass);
yes
Learn how to add tab completer to your commands! Super fast and easy :)
~ Sorry I missed last week, been super sick. More videos coming soon once I'm fully healed :D
CodedRed.setHealth(20.0);
------ Links ------
Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers
Download Spigot: htt...
implements CommandExecutor, TabCompleter
alr
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return HypixelCustomItems.getPlugin().getItems().keySet().stream().toList();
}
like this?
sure
.
also
alr thanks
Well that would return the same list for any arg
You might want to check which arg your tab completing unless it's irrelevant
Why stream().toList() lol
Yeah that's a bit wierd
its a 1 arg command
Just return new ArrayList<>(set)
Ok then it's fine
any better ways?
.
and what is the problem of using stream().toList()?
You are making new stream instance and then still iterating over it to accumulate it into list
It's simply unnecessary
When you can just directly make it
ok alr
return new ArrayList<>(HypixelCustomItems.getPlugin().getItems().keySet());
like this?
and another question:
if i setup interfaces in my plugin for each class and then provide the plugin in my other plugin, will i beable to use all the methods from the 1st plugin?
Yeah as long as the class and method is public you just need to get the plugin and add depends in your yml
you can’t really have two plugins depend on each other
since the other implements it
you can have plugins depend on each other given two caveats
for the functions to work, you need to instantiate it which according to your code is in the second plugin
- you don't define hard dependencies
- you don't use the other plugin's methods before load is complete
you then can use bukkit methods to obtain the plugin instances
not a good idea tho lol
Yeah unless you didn't make them it's kinda pointless
then why did spigot-api do that?
wym
its all interfaces
not spigot-api.jar and spigot-impl.jar
well yes
bukkit is interfaces
craftbukkit implements it
it tells your IDE 'this method exists'
and in spigot everything implements the things in spigot-api
so that you can compile
yes
if you run buildtools with --generate-source youll see what i mean
wait so bukkit has a class org.bukkit.CraftPlayer that Implements EntityPlayer(org.bukkit.EntityPlayer)
and in bukkit api theres an interface at org.bukkit.EntityPlayer just to make the ide think theres an actual meethod at that position?
you got it kinda wrong
but Player is a bukkit class
with your api methods
CraftPlayer implements it
bukkit is the api
so bukkit is just the api and craftbukkit is the actual code executor?
yes
craftbukkit mainly uses nms which is mojangs code to implement bukkit
oh jree fava lessons is back
and paper is kinda spigot but with some features
so therefore inside bukkit
you cannot access
craftbukkit
you cant just do new CraftPlayer inside bukkit
they can’t depend on each other
its a one way thing
and spigot IS bukkit but just has ~5 methods for timings
Spigot just bukkit but orange
And paper is just spigot but white
tf
com
Is it okay to store an arraylist inside an hashmap thats inside another hashmap
?xy
Asking about your attempted solution rather than your actual problem
what the heck
if you tell us the context of the situation we can advise you a better solution
List<HashMap<HashMap>>
no
JSON addicts:
wait actually nvm I'll just fuck around and find out
Great idea
but is this performant though
Fr tho what led you to that abomination
[[{[{}]]}]
Sure it is
I don't know, I don't have any other solutions in mind
Asking about your attempted solution rather than your actual problem
nah I'm scared to get humiliated, I'll just fuck around and find out
Mate if you want help you gotta give us something to work with
I will if this wont work lol
If your really that self conscious dm me lol
wait Im actually dumb
why am I even doing this
😭
You good man?
I dont know why I'm storing this in a hashmap
You probably want to explain what u want to do
Because you probably don't need that much nested collections
I know what to do now
I might need a database for this wait nvm
damn, I should have changed one more file
thats alot of files lol
the .gitignore one?
oh wow
main reason for all the file changes is that I changed the main class name lol
Ouch
how to make intellij stop claiming that "%%__USER__%%".startsWith("%") is always true
without the s I think?
Aww hmm well u can add the appropriate inspection exemption by alt + enter othewise (and then click one of the bottom thingies)
yeah
its only purpose is to print "AngelChest" or "AngelChest Plus" anyway
blossom?
blossom 
Yeaa blossom, epic stuff
A Gradle plugin to perform source code token replacements in Java-based projects
just don't name the org it is under in the spigot discord 
i wonder how spigotmc's .jar injection stuff works
it somehow "transforms" .jar files on the fly when you download any paid plugin
java assist maybe?
doesnt javaassist work at runtime
then i guess not
how do i rotate player in vehicle without dismounting?
I made a plugin to change the basic attributes of the player, but due to bugs they stacked and in the end I demolished this plugin from the server and the effects remained
setting a player's direction should work
what do
whats the method?
I don't think it will
Entity::setRotation
I think they are talking about the player head block?
nvm
pretty sure a head cant ride a vehicle
But it can be on an entity
good morning. In my command I find myself doing a lot of if eles to check the arguments (if there are 0 args, if there are 1, 2 etc...) it makes me recopy a lot of code and I was wondering if this was a bad thing?
if-else is done sequentially, so it's slower than switch for large amounts of if-elses. if you have the same code often you should probably put it in a function
but since it's in a command it should be fine
I would recommend using a command framework, such as ACF; Search "acf spigot" and you'll find it.
It makes creating and maintaining commands much simpler.
yes I see but in itself it's not so bad so?
I find switch are less readable than if-else in most cases. However they have their place, especially when you want smth different to happen with different enums or such.
It's not "bad"; However many if-else statements are unreadable aswell, especially when they are nested.
Try not to nest if statements if possible, but rather use "guard clauses" or create a function which contains the logic then
anyone know why the color shit isnt working
and also when i type a command and then a console message happens, it disregards the command
Also the other point Moterius made, with putting the logic in a completely, probably static, function is good; ASLONG as the code is exactly the same.
Too often have I tried aswell to make one function fit all my needs, don't do that, it'll get messy real quick
Maybe your console doesn't support it?
its windowspowershell
what console supports it?
because it supports colors here
I think there's a function to check that using sender#canSendColor or smth like that
weird, idk, sry
i dont have any plugins on the server
then probably go to #help-server
yes, it's not the same, but it looks the same.
then leave it
#help-server maybe someone knows the answer
patience
why line on the first screen can give null?
do you mean the line:
Particle.valueOf(...)?
yeah
exist an event when a block got breaked by explosion?
Cause if the name for that enum doesn't exist in the enum, it'll throw an exception and return null
But java can't garuantee that it is the same, if the name is not specified within the byte/src code
I need to know when a block is broken. No matter how. Excepted block break event. What other reasons/events could there be?
There might be smth like BlockChangeEvent and then check if the new state is of type Material.AIR?
How to create a shared inventory with multiple players, that can be updated in real time, like if I use the same instance of an Inventory for all players does it work, or I need to use events etc?
bassically I want a command /inv that opens that shared inventory
just create 1 inventory object and open it for the players
would it update each time someone changes an item?
yes
okie, thanks
BlockBurnEvent
BlockExplodeEvent (may be the tnt, may be the blown up block)
BlockFadeEvent
LeavesDecayEvent
SpongeAbsorbEvent
plus all player stuff @sterile breach
You sure?
the inventory should be a reference
this isnt feasilble for player inventories, but easily done with extra inventories
yes
Yeah, but I don't think it sends the updates to other players automagically
it does
neat
its same inventory object
so why wouldn't it?
just test it yourself if you dont believe
Cause I'm not sure if Inventory updates after changing stuff with it
it doesesses
Can affirm
Damn, that's cool. I didn't think it would send the updates.
That makes stuff like that very easy
hey, how i could make only 1 nether portal in world ? and disable ability for other players to create one?
you just make a nether portal, and listen for the events that would create or destroy one, and cancel all those events
could you make one for me? im not good at this 😅
I ran buildtools with --generate-docs
org.spigotmc:spigot-api:jar:javadoc:1.20.1-R0.1-SNAPSHOT was not found in https://jitpack.io
did something change?
How do i put knockback on a stick? java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
you should be able to tell the stick it has the knockback enchantment, maybe you're trying to apply it to the wrong thing
Add unsafe?
im doing it like this ```ItemStack stick = new ItemStack(Material.STICK);
stick.addEnchantment(Enchantment.KNOCKBACK, 2);
p.getInventory().addItem(stick);```
Does anyone know how to make a 1.19.4 plugin to the following versions 1.20 1.18 1.17
afdUnsafeEnchantment
can someone please post me a working project xml file with the javadoc and source code pulled from .m2? For some reason it's noto working for me
@Override
public void onBlockBreak(BlockBreakEvent e){
if(e.getBlock().getWorld() != HypixelCustomItems.getPlugin().getServer().getWorlds().get(0)){
for(int x = 0; x < 3; x++){
for(int y = 0; y < 3; y++){
for(int z = 0; z < 3; z++){
if(allowedBlocks.contains(e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x+1, y+1, z+1)).getType())) {
e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x + 1, y + 1, z + 1)).setType(Material.AIR);
}
}
}
}
}
}
will this replace the blocks in a 3x3x3 area if the world isnt the main world and the block type is in the list of allowed block types?
okay so if i want controle a spawner. i just need to use block break and BlockExplodeEvent (creeper, tnt etc..) ?
im not guaranteeing anything, but that's what i think is more or less everything that can remove a block
Does anyone know how to make a 1.19 plugin to the following versions 1.20 1.18 1.17
i havent done anything with nms so prob not
viaversion?
allows new clients onto old servers
isnt that player only
thers a reverse of that too
but it glitches if you go over that version that changed world height
ik but i want my plugin to be complatable with a few versions i dont want it to depend on viaversion
bump
stop comparing worlds with !=
you have .equals for that
or you can compare their names
with .equals also
Hm this is interesting. Seems like it isnt building the javadocs. Anyone know why?
java -jar BuildTools.jar --generate-source --generate-docs --rev 1.20.1 --remapped
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Spigot-API 1.20.1-R0.1-SNAPSHOT .................... SUCCESS [ 13.127 s]
[INFO] Spigot-Parent dev-SNAPSHOT ......................... SUCCESS [ 0.010 s]
[INFO] Spigot 1.20.1-R0.1-SNAPSHOT ........................ SUCCESS [ 37.505 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50.723 s
[INFO] Finished at: 2023-08-03T16:22:29+02:00
[INFO] ------------------------------------------------------------------------
Picked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.spigotmc:spigot-api >-----------------------
[INFO] Building Spigot-API 1.20.1-R0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------```
How can I find out if a player's inventory is open?
oh, getOpenInventory()
so what does that mean? with what i need to check player inventory if he has inventory closed?
null?
it writes me "always false"
Have you read that
what is "internal crafting view"?
2x2 crafting inventory I assume
The one in the player inventory
what is the name of the inventory in which there are 9 slots
hotbar, Dispenser, Dropper
class org.bukkit.craftbukkit.v1_20_R1.inventory.CraftInventoryCustom cannot be cast to class org.bukkit.inventory.AnvilInventory
with var inventory: Inventory = Bukkit.createInventory(null, InventoryType.ANVIL)
and val anvilInventory : AnvilInventory = inventory as AnvilInventory (here is where the error happens)
this is really weird, because its an anvilInventory...
createInventory always creates that "custom inventory", not the real type
O_O
you'll have to work with the indexes for inputs/result
not that the anvil is too complicated anyway, 3 slots
i mainly use the the anvil for its typing function, is there any selution for? otherwise i dont need it anyway
?

there's some anvil api's
i mean you can still use that
pretty sure you need NMS for the AnvilInventory to work properly
NMS? is that an api?
"work properly"?
well you can't get the text field from CraftCustomInventory unless I'm wrong
I mean that'd be the main reason to really use that inventory virtually I can think of
no its the internal server code
oh wait ,yea, netMinecraftServer
welp, i guess i am not implementing any text ediding then lol
https://github.com/WesJD/AnvilGUI this is the only api I can think of
I don't like its api that much, but idk what else exists
Efficiency in minecraft: regular enchant lores
MD_5 Efficiency: DIG SPEED
surewhynot
wdym
like this? /13
tbh idrk how to do that
oh ok thats fine
cause i use loop for stuff lol
ight
Hello, i can help you, what exactly are you trying to achieve?
here ill list my code.
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (sender instanceof Player){
Player p = (Player) sender;
if (p.hasPermission("be.flyspeed")){
if (args.length == 0){
p.sendMessage(ChatColor.RED + "Please provide the speed");
p.sendMessage(ChatColor.GREEN + "Example: /flyspeed 2");
}else {
p.setFlySpeed(flyint);
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Flying enabled");
}
}
}
return true;
}
im trying to make a ./flyspeed command
i need to get an interger arg insted of a string arg
org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin BoxEssentials v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
it gave me a null
you entered /flyspeed 1, right?
yeah
/flyspeed 2 to be specific
i mean it said flying enabled, which is after setting flyspeed
so
you should be faster?
Just parse the string
String flystring = flySpeed[0]
int flyint = Integer.parceInt(flystring) ;
Missing ; and a typo
but in your oncommand it says args
whats the typo i added the ;
is your flyspeed defined to be the args ?
i got this error
parceInt should be parseInt
ty ill try compiling it
ok
so
flyspeed 1 works flyspeed 2 doesnt
org.bukkit.command.CommandException: Unhandled exception executing command 'flyspeed' in plugin BoxEssentials v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (sender instanceof Player){
Player p = (Player) sender;
if (p.hasPermission("be.flyspeed")){
if (args.length == 0){
p.sendMessage(ChatColor.RED + "Please provide the speed");
p.sendMessage(ChatColor.GREEN + "Example: /flyspeed 2");
}else {
String flystring = args[0];
int flyint = Integer.parseInt(flystring);
p.setFlySpeed(flyint);
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Sucsesfully setted flyspeed.");
}
}
}
return true;
}
sure
here it is
theres no line 47
pardon?
this says the erro is in line 47
wait you somehow broke bukkit
LOL
i used your code and it works fine
what u mean?
like are u able todo ./flyspeed 2?
remember that flyspeed 1 is the maximumg and you need to differ with 0.1 0.2
setting it to 1 is the max
you cant set it to 2
so the line that causes the error is sender.sendMessage(line);
line here is something from config
ik thats why i got that error
well if you set a point before it it shouldnt be counted as a command
we fixed it, its alright
theres no reason for you to get an error
uhh
if you want to ahve it from 1-10, just do switch cases with all the number and set the speed on 1 to 0.1
@inner mulch try ./flyspeed 0.2
you need to set it to double
...
int wont work with 0.2
alright
yeah i wanna do 1-10 how tho?
i said it in the same exact message
switch is something like an if sentence but it switches corresponding to the value
ok
how would i make this like go on and on
?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.
yeah i am learning java
just repeating the same bevahiour
case 2:
blabla
break;
case 3:
blbl
break;
You should be doing that before starting with Spigot
i know
ahh ok
why mad?
dont forget to break;
ik
breaking the case is very important
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.
yes but its not spoonfeeding
i told him about switch cases
and the next time he has a problem he will hopefully use them
I guess you volunteer to be a Java teacher then
i already implemeted em in another command
because they will ask for help with other basic Java things
instead of following the Java tutorials first
I prefer to learn like this as well, I do something that I want and once I have a problem I google or if that doesnt help ask here
im not watching 10 hours of tuts
i will start and ask once a problem occurs
asking here doesnt guarantee answers
wacht ill demonstrate
is there a non-backtracking regex for 'only numbers' and is it faster than try/catch around the java number parser?
idk ask gpt
did you wait your lifetime for this?
not really no
you send these messages like you copied them
i feel like you waited for the perfect moment
i prewrote that one like ten minutes ago and didnt want to interrupt
no deeper reason lol
ok xd
this would work?
its not loading
case 10:
p.setFlySpeed(1F);
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Sucsesfully setted flyspeed.");
break;
this would work right?
try it :)
I would recommend that you use intelliJ, its the most newbie friendly program in my opinion
i am
hmm i guess yours looks different
a few minutes ago you had a problem with "parceInt" intelliJ wouldnt let that slide
i guess
but why wasnt there anything that told you its incorrect
why did it even compile?
Eclipse can compile invalid code
i dont know java well but i can read and this aint looking good
just throws an error when that code runs instead
he said he's using intelliJ
Olivo, do you know how I can get if a crop is fully grown?
Ty for helping
np
it works
have fun with lightspeed flying
- the message
is someone good in math here ?
inf money glitch
look for someone making plugins for money, then u list ur service for $2.50 more then the other guy then u hire him to make the idea ur customer wants u give the plugin to the customer boom free money
okay may you help me with some calculations
ehh decent (eu education)
well i need one picture which is 100x100 to be in center of my screen on x axis and slightly upwards then middle of screen on y axis .. so i need to calculate position of that image (x and y coordinates) to be exactly placed as mentioned before in middle of x axis and slightly upward on y axis like 200px higher than middle of y axis
im out gl
i barley know how fractions work so
lets say this circle is picture and where it has to be placed
and it has to be in that position all the time even if display size is changed
Isn't that like anchor points or some shit like that?
no idea just need to figure this out :/
i can for example get current display size and just divide by 2 and that is middle of x axis
but y axis is bit complicated
and im not sure how to fix that
@eternal oxide might know he is good at math but he is not online
any booster perks?
pink name
awesome
i'd say worth it. I just won't pay for nitro lol
i didnt pay for it
i tried to buy it and itt went thru
i looked at my bank account nothing got charged
next day still nothing charged
so i just got free nitro
sounds good
ikr
freejava
wdym by backtracking
regex backtracks to satisfy it's conditions
pretty sure you just need to multiply a double that gives percentual screen height (like 0.3, since screens usually start counting at the start) with the screen height for your y value
or well 0.7 if you start counting at the bottom
no?
all commands in my spigot plugin 🙂
so like "[-+]?\d+" is backtracking
It did when I last used it (which was years ago)
It replaced the entire invalid method with a throw statement
it just throws 99 errors
when you try to compile
try catch on parse is probably faster anyways
How do i get if a crop is fully grown?
Ageable
public void test (BlockBreakEvent event) {
Block block = event.getBlock();
Ageable ageable = (Ageable) block.getBlockData();
if (ageable.isAdult()) {
event.getPlayer().sendMessage("gfg");
}
}```
I did this, but it doesnt work
so I'm encountering a bit of a problem after coming back to plugin development
and I am unable to add my jars to the build path in my ide to make a plugin
is it a correct ageable
I did a bit of research and it seems like now the jars contain many other folders
idk, tell me?
you need maven
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
?jd-s
declaration: package: org.bukkit.block.data, interface: Ageable
"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.
if i get scaled height and i multiply with 0.1 when window is maximized it turns out to be exactly on spot correct with what i want but if resolution is smaller like 512 then it is not set properly
i dont have getmaxage
and???
can you write me down formula or example and just say what is what because it is hard for me to understand like this
Its not THERE
Ageable is part of bukkit api
well its screen height * percent value - 1/2 image height
not paper
its non existent
how can I get ping response of a server with bungeecord plugin?
I need to get this
for some reason it imported entity age
i didnt even know that was a thing
BRO you asked
so guys
if you didnt know
discord is currently shitting itself
and also
I actually managed to get the thing working
somehow
through just trying stuff in the ide
so thanks guys
?
none of that happened to me toeday
Hello, is there a way to get all the pieces of cugarcane if i break the bottom part?
Hi, someone know when i make color code on the display name the name of the player doesn't change on the top of his head ?
tab and player name are different things
i dont know the name of what you need to change tho
its probably referenced in the player class tho
how to send multiple clickable messages in a single message?
what do you set it to @last abyss
not the tab and the chat are already working but when i change the display name the player "name" doesn't change and i would know why this doesn't work ?
yea i think you need to show the relevant code her
the "relevant code" ?
yea how you're setting the name
but i can only set the display name and the playerlist name or i just don't see it
there might be some update weirdness
i remember that there was some changes with inventory where it only updated if you called a specific update method
does the name change if you relog?
with the account whose name was changed
I'm trying to have my plugin execute a /spreadplayers command with a specific set of players and if I have read the spigot source code of their extension of the vanilla command correctly then my implementation should work:
String command = String.format(
"spreadplayers %f %f %d %d %s",
map.getWorld().getSpawnLocation().getX(),
map.getWorld().getSpawnLocation().getZ(),
map.rtpDistanceFromPlayers,
map.rtpRadius,
respectTeams ? "true" : "false"
);
for (Player player : players) {
command += " " + player.getName();
}
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}```
It sadly does not work because I get the following error in the console when I try to run this with 2 (or more) players: `Incorrect argument for command ... player1 player2<--[HERE]` (where player1 and player2 are the names of whichever players I test it with), what am I doing wrong?
nop
hm maybe google can help you but im out of ideas
probs an issue of the command not accepting the arguments for whatever reason, the code you posted is fine as far as i can see
mitght be a config problem, might be a problem in your command code
am I maybe accessing the vanilla command? I'm trying to use bukkits implementation I saw here: https://hub.spigotmc.org/stash/users/minidigger/repos/bukkit/browse/src/main/java/org/bukkit/command/defaults/SpreadPlayersCommand.java#20,23,26,92-93,95-96,100,102,104
but I wouldnt know how to specify another version
whats the exact error
does anyone know how to use componentbuilder or textcomponents to send multiple clickable messages to a player?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
theres nothing more than the small snippet I sent above where it throws an error as soon as there is more than 1 player (like it would if it were the vanilla command)
heyyy soo i got an problem with my server world spawn when i use /setworldspawn it set my world spawn but if I spawn it on that pre-marked spot just back to the lobby
any ideas how to fix it?
Have patience and stay in #help-server
:?
tried this and it didnt seem to work
this is the snippet they provided
BaseComponent[] component =
new ComponentBuilder("Hello ").color(ChatColor.RED)
.append("world").color(ChatColor.DARK_RED).bold(true)
.append("!").color(ChatColor.RED).create();
what command code do you mean? Is there something else I would need to implement I forgot about?
no i thought it was an issue in the command code
?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.
but if its spigot commands youre using its probably not
right right
heres a really dumb idea that might work
call the SpreadPlayersCommand::execute method directly
I guess I'm just not doing it right bcs copying the snippet in works
oh I just saw that the code I was referring to and linked to above is @Deprecated 🤦♂️
Hi, how i can do a confirmation gui? I use a callback ?
Does async catcher catch player.inventory.addItem
really naive question but how do I do this I cant figure it out
SpreadPlayersCommand.execute(Bukkit.getConsoleSender(), "spreadplayers", array_of_arguments)
why is the armorstand not removed after the server is turned off? it's not null, it just stays on shutdown
It cannot resolve the symbol 'SpreadPlayersCommand' even when I have import org.bukkit.command.defaults.*;
yea im out of ideas
no worries, thanks for the help though at least I know I'm not missing something obvious
You should remove your entity in the chunk unload event
does this event only work on shutdown?
This is ancient
Doesn’t exist anymore
No. The vanilla command exists on the server. You can’t access it’s logic with the API
If you wanna make your own command, just make your own
Doesn’t matter what else is on the server
I can't run that command ingame either. Unless I only specify one player argument
hm okay I guess I'll do that then, thanks for the info
The spread players command? It accepts an entity selector
yes. He tried to do player1 player2 which is not an entity selector
creating a custom entity selector is not possible, right? Because if I had a way to pass my list of players as that to the execution of the vanilla command it would be perfect
I guess I could tp all the players to the world first and then could do all the players in the world
You could add the same scoreboard objective to all of them and then use that as a selector
oh good idea, they have a scoreboard set already anyway
what would be the best way to randomly select a block inside of a chunk that is surrounded by blocks?
Select a random block in the chunk, if it isn't surrounded, try again?
Or you could try to figure out a density distribution and then use some fancy probability math to select a block and then test if it's surrounded by blocks
mm true
but that won't work if the plugin can be used on maps with custom maps or such, cause you have to prepare the density map beforehand. or make one by selecting random chunks when the server loads
is there a way to add all block types in all variants easyer? so i dont have write like that
STONE: [PICKAXE]
DIRT: [SHOVEL]
LOG: [AXE]
GRASS_BLOCK: [SHOVEL]
Is there any way to cancel the advancement completed broadcast of a player?
sometihng something preferred tool
why are my effects not showing when I join the server? I have 3 infinite effects. Such as invisibility and saturation work, but jump boost does not. Removing those effects manually per /effect clear player effect removes them saying the effect is removed successfully. This is very confusing and breaks jump boost, why and how do I solve that?
even temporary effects don't appear
huh this is weird
this definitely shouldn't work like that
this seems to be due to some plugin I had in my plugins
and it is not the plugin I'm testing currently
no way
if that is it
okay it was not viaversion
and there are two plugins left that can just not possibly do it
bro what
how
skinsrestorer it was
this is what happens when your friends play cracked
theres a reason i be like 'no warranty except: this will work with my other plugins'
I have just one question
how
how could SKINSRESTORER break EFFECTS
and this is what was stopping me from developing my plugin
SKINSRESTORE
lmao what
cracked servers show aled/steve skins by default
afaik skinrestorer messes with packets
so thats probably the issue
how to make whit this ?isPreferredTool
i want make a plugin that allows to break blocks whit specific tools
stone whit pickaxe dirt whit showel
yes for u its simple :)
no literally
that event has the block broken and the player that did it and iirc the tool too
just check that and drop the block if applicable
Hi im using this for a kbffa plugin but if i hit someone off it works but if they then jump off after respawning it still counts as a kill, therfor an unlimited kill glitch
reset it then
How can i execute commands as the server?
Bukkit.dispatchCommand(Bukkit.getConsoleCommandSender() iirc
you beat me to it
How to set Command prefix? like:
/gm menu/gm create ...
for something like /menusetting okay I can understand.
Hello, how i can create a ShapedRecipe and set the Amount of the Ingredient Item?
google "spigot tabcomplete"
the amount is always one
if you wanna have recipes with different stack sizes, you have to listen to PrepareCraftItemEvent or however it's called, then set the result manually
but the recipe book will not properly work for that
okay and give it a other method to create a custom recipe
if(e.getBlock().getWorld() != HypixelCustomItems.getPlugin().getServer().getWorlds().get(0)){
for(int x = 0; x < 3; x++){
for(int y = 0; y < 3; y++){
for(int z = 0; z < 3; z++){
if(allowedBlocks.contains(e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x+1, y+1, z+1)).getType())) {
e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(x + 1, y, z + 1)).setType(Material.AIR);
}
}
}
}
}
this piece of code doesnt replace a 3x3x3 chunk of blocks. does anyone know the problem?
you are comparing worlds using ==
you should be using equals
also why are you using such a complicated way to get the relative block
and you shouldnt use variable names such as "e"
lemme do those things
what exactly is the point of this?
if(event.getBlock().getWorld().equals(Bukkit.getWorlds().get(0)) {
for(...) {
for(...) {
for(...) {
Block relative = event.getBlock().getRelative(x+1, y+1, z+1);
if(allowedBlocks.contains(relative.getType()) {
relative.setType(Material.AIR);
}
}
a 3x3 pickaxe or sth
but why add xyz +1
yeah the math is pretty bad
this seems completely unnecesary but who knows what he's trying to do
Shouldn't it go from - radius to radius?
usually you should also take the direction into account
For a true 3x3 pickaxe?
yea
ok wait
@Override
public void onBlockBreak(BlockBreakEvent e){
Block block = e.getBlock();
if(!block.getWorld().equals(HypixelCustomItems.getPlugin().getServer().getWorlds().get(0))){
for(int x = 0; x < 3; x++){
for(int y = 0; y < 3; y++){
for(int z = 0; z < 3; z++){
if(allowedBlocks.contains(block.getWorld().getBlockAt(block.getLocation().add(x+1, y+1, z+1)).getType())) {
block.getWorld().getBlockAt(block.getLocation().add(x - 1, y, z - 1)).setType(Material.AIR);
}
}
}
}
}
}
i believe this is better
usually you do something like
offsetX = 0;
offsetZ = 0;
if(player is looking north) offsetX = 1;
else if(player is looking south) offsetX = -1;
else if(west) offsetZ = 1;
else if(north) offsetZ = -1;
x = blockX + offsetX;
z = blockX + offsetZ;
for(int x = -radius; x <= radius; x++)
okay, i understand. then, are there any additional settings in plugin.yml?
im sure worldedit has a superpickaxe or something lemme check their source code
their superpick is just really fast
@spare hazel what is that code supposed to do?
3x3x3 Shovel
wtf
go look at slimefuns explosive pic and modify it
package com.amirparsa.hypixelcustomitems.Items;
import com.amirparsa.hypixelcustomitems.CustomItem;
import com.amirparsa.hypixelcustomitems.HypixelCustomItems;
import com.amirparsa.hypixelcustomitems.Rarity;
import com.amirparsa.hypixelcustomitems.Stat;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
import java.util.ArrayList;
public class ChunkMiner extends CustomItem {
private ArrayList<Material> allowedBlocks = new ArrayList<>();
{
setId("CHUNCK_MINER");
setMaterial(Material.GOLDEN_SHOVEL);
setName("Chunk Miner");
setRarity(Rarity.RARE);
setAdditionalLore("Breaks A 3x3 Area Of Blocks");
addStat(Stat.SPEED, 100);
allowedBlocks.add(Material.DIRT);
allowedBlocks.add(Material.DIRT_PATH);
allowedBlocks.add(Material.COARSE_DIRT);
allowedBlocks.add(Material.GRASS_BLOCK);
allowedBlocks.add(Material.PODZOL);
}
@Override
public void onBlockBreak(BlockBreakEvent e){
Block block = e.getBlock();
if(!block.getWorld().equals(HypixelCustomItems.getPlugin().getServer().getWorlds().get(0))){
for(int x = 0; x < 3; x++){
for(int y = 0; y < 3; y++){
for(int z = 0; z < 3; z++){
if(allowedBlocks.contains(block.getWorld().getBlockAt(block.getLocation().add(x+1, y+1, z+1)).getType())) {
block.getWorld().getBlockAt(block.getLocation().add(x - 1, y, z - 1)).setType(Material.AIR);
}
}
}
}
}
}
}
and get how they do it
why don't you just use a temp variable for the block in the loop
instead of doing this weird getBlockAt twice
there isnt even a need for a plugin instance either
you dont even need the getserver
that code also doesn't take the player's looking direction into account, as I already said
it doesn't need direction if it's just 3x3
ok
3x3x3
yeah
private List<Block> findBlocks(@Nonnull Block b) {
List<Block> blocks = new ArrayList<>(26);
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
// We can skip the center block since that will break as usual
if (x == 0 && y == 0 && z == 0) {
continue;
}
blocks.add(b.getRelative(x, y, z));
}
}
}
return blocks;
}
slimefuns code for this isnt too bad tbh
void onBlockBreak(BlockBreakEvent event) {
final Block block = event.getBlock();
final World world = block.getWorld();
if (world.getUID().equals(Bukkit.getWorlds().get(0).getUID())) {
return;
}
final BlockData blockData = Bukkit.createBlockData(Material.AIR);
for (int x = -1; x < 1; x++) {
for (int y = -1; y < 1; y++) {
for (int z = -1; z < 1; z++) {
Location offsetLocation = block.getLocation().add(x, y, z);
world.setBlockData(offsetLocation, blockData);
}
}
}
}``` here @spare hazel
lol
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Random;
public class SpawnBreak extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@SuppressWarnings("unlikely-arg-type")
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.SPAWNER) {
int GG = new Random().nextInt(100);
if (GG >= 90) {
block.breakNaturally();
} else {
event.setCancelled(true);
}
}
}
}
dont do that
why are you putting it in 1 class
that is just wrong
giving be huge chatgpt vibes tbh
use ThreadLocalRandom.current().nextInt(100) instead of new Random on every block break
no, you can't
because then the chance generated once will always be the same
huh?
what even is the problem you're having with that code?
did you register the event...?
how?
so man has a variable for plugin manager
you didnt even take the allowed blocks into account
imagine breaking bedrock using a shovel
debug ur code
so im gonna guess you dont know what it means, and dont want to ask. Add sysouts and see whats actually happening
private ArrayList<Material> allowedBlocks = List.of(Material.DIRT, Material.DIRT_PATH, etcetc);
{
setId("CHUNCK_MINER");
setMaterial(Material.GOLDEN_SHOVEL);
setName("Chunk Miner");
setRarity(Rarity.RARE);
setAdditionalLore("Breaks A 3x3 Area Of Blocks");
addStat(Stat.SPEED, 100);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
final Block block = event.getBlock();
final World world = block.getWorld();
if (world.getUID().equals(Bukkit.getWorlds().get(0).getUID())) {
return;
}
final BlockData blockData = Bukkit.createBlockData(Material.AIR);
for (int x = -1; x < 1; x++) {
for (int y = -1; y < 1; y++) {
for (int z = -1; z < 1; z++) {
Location offsetLocation = block.getLocation().add(x, y, z);
final Material material = offsetLocation.getBlock().getType();
if(!allowedMaterials.contains(material)) {
continue;
}
world.setBlockData(offsetLocation, blockData);
}
}
}
}
wtf is this code tho
setId("CHUNCK_MINER");
setMaterial(Material.GOLDEN_SHOVEL);
setName("Chunk Miner");
setRarity(Rarity.RARE);
setAdditionalLore("Breaks A 3x3 Area Of Blocks");
addStat(Stat.SPEED, 100);
}
``` why are u doing this
Its a custom items plugin
that is the wrong way to handle that
most of that should be a super call in the constructor
have an abstract item class and have a builder(toBuilder = true)
and just use the builder
cleaner
i mean, not really here
depends on his use and how "modular" this plugin is supposed to be
you should use builder if each item didnt get its own class
this works for me
and its readable
- lombok is cool
you should take java courses though
the code u initially sent is bad
lombok is cool, just depends how you use it
bro lombok is amazing
if you use it correctly yeah
ah i can't send pictures
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
!verify
Usage: !verify <forums username>
oh fuck off
SPOILER: Its Not
if(rightClickAbility != null && rightClickAbilityDesc != null){
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: " + rightClickAbility + ChatColor.YELLOW + "" + ChatColor.BOLD + " RIGHT CLICK");
lore.add(rightClickAbilityDesc);
}
if(blockBreakAbility != null && blockBreakAbilityDesc != null){
lore.add("");
lore.add(ChatColor.GOLD + "Item Ability: " + blockBreakAbility + ChatColor.YELLOW + "" + ChatColor.BOLD + " BREAK BLOCK");
lore.add(blockBreakAbilityDesc);
}
i got one but the username is from the 15 year old version of me
i am confused
what is this
😭
hard coded item ability lore for later use.
i wrote a multi mining thing in 3 minutes, all you need is some basic math
its 3x3x1 not 3x3x3
!verify noobdog2013
A private message has been sent to your SpigotMC.org account for verification!
and?
i sent you code that does it
it's not like making it 3 blocks wide would make any difference
you just change one line
its not that easy man
instead of doing * offset you do * offset * radius
lemme just add in the Heavy Diamond Hoe and then i will test my current code, and then if it didnt i will use your code
add the Heavy Diamond Hoe and let us know 🗣️ 🗣️
"I will steal your code!!!"
"it's not even my code lol"
literally
every based programmer
if you think about it