#help-development
1 messages · Page 1782 of 1
i've had this issue before
What are you trying to do
Ah
Technically don’t need PluginCommand at all
it breaks things if you don't use it
Incendo/Cloud 👉 👉
for example getCommand() doesnt work anymore
since it checks instanceof PluginCommand
or something like that
afaik
yeah sure but you could just create a new derived system based of Command ?
Yuh
Which class
PluginCommand
PluginCommand
wouldn't it be useless
not like i can override its methods
You can inject a custom command executor
And what not
Because most of its properties are mutable
hm i don't know, that sounds worse than just extending Command
it’s a bit limiting sure
Dam just use a command framework
Bukkit’s command api 
Bukkit's command api's kinda doo doo
I wish we will get a better command api someday
new CommandBuilder("addenchant")
.setAliases("addcustomenchant", "customenchant")
.appendArgument(new StringArgument()
.setArgName("enchant id"))
.setTabCompleter(enchants::getRegisteredEnchantsIds)
.appendArgument(new IntegerArgument(1)
.setArgName("level")
.setTabCompleter(1, 2, 3, 4, 5)
)
.appendArgument(new PlayerArgument(true)
.setTabCompleter(Utils::getOnlinePlayersList)
)
.executesPlayer((player, args) -> {
String ench = args[0];
int level = Integer.parseInt(args[1]);
Player playerArg = Bukkit.getPlayer(args[2]);
//code
}
});
i like this more
by command framework i meant proper command framework
@ivory sleet @sullen marlin Thanks for your help. (Also anyone else I didn't mention but that had helped.)
https://github.com/TheCrappiest/TaskManagement
Output: ```
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] ForkJoinPool-1-worker-13
[2021-11-22 10:20:50] ForkJoinPool-1-worker-4
[2021-11-22 10:20:50] ForkJoinPool-1-worker-9
[2021-11-22 10:20:50] ForkJoinPool-1-worker-11
[2021-11-22 10:20:50] ForkJoinPool-1-worker-2
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:20:50] main
[2021-11-22 10:21:01] main was delayed.
[2021-11-22 10:21:01] ForkJoinPool-1-worker-2 was delayed.
yeah anyways i guess i'll stick with restarts
Singletones ☹️
-1000000 social credit
☹️
i use singletones sometimes, they're useful
especially to store player data or such
What stops you from not using singletones to store player data or such
Oo pog
Singleton and unit tests 
Oh god... I just looked through the github... why does github add 8 spaces instead of 4 for spacing?
Idk might be cause you use tabs
nothing but i see a lot of different opinions about them
That's really not unique to singletons at all
I don't. I add 4 spaces xD
Uh Idk then 
(RedLib adverstiment starts here)
so i really don't know if i should use them or not lol
I wish you could edit a class without needing to commit
What
wait redempt you used to be a developer on orbitmc or something similar
didn't you
All I'm sayin is that builder looks real ugly
Yes, I was the only developer lol
Wait I remember you from there
What is your preferred style
I knew I remembered you from somewhere!
annots?
Those are just as space inefficient
you were talking about it in server chat too lmao
Yeah Idk what’s better either
Annotations -> organized

Want to try an alternative
tbf i'm surprised it got it to work
Proves you’re smarter than what you think (:
i took a look at it before deciding to develop my own
No abstraction at all, primitive types only and no possibilities to get annotation paramaters from non static context ☹️
accidental reactions
just wanted to challenge myself so i made my own
i had found a similar one but it was for 1.13+
and i'm on 1.8
insults incoming
Primitives only?
Really?
Tbh builders with generic types would be nice once we get project valhallas primitive generic thingy jep
Well that changes my tune
cringe
Builder ftw. Annotations use reflections to process things
:d
Well , enums, classes, and arrays
Reflection is fine lol
i like builders, they are very sexy
I love reflection
You could probably abuse enum mutability but eh
i have a gui builder, item builder, command builder...
Reflection is fine until you don't use it as your main source of doing all the things
And honestly I would be really surprised if the reflection overhead is higher than time it takes to process commands anyways
Considering how complicated that code is
reflection based code is a nightmare smh
afaik reflection abuse not gud
Yeah conflating all reflection with abuse is also not good though
You can make a lot of really nice abstractions with reflection
Obviously you shouldn't use it for everything
But it's not nearly as slow as most people will lead you to believe
And it's getting much faster in java 18
its not slow af as it used to be
As in, java 18 will have nearly no reflection overhead
Oo, what is getting improved more specifically?
i love patterns in jdk14+
Reflection is going to use method handles under the hood instead of its own pathways
Ah
i've heard it's going to use methodhandles internally
That’s awesome
please help me
https://paste.md-5.net/exaliwosab.sql
error
if iam using any command regarding plugins it is showing a internal error occured while attempting this command how to fiix it
imaginedev bro please help me
I know that if you use smtng like a method handle lookup where you unreflect a reflective object it’s going to be slow in invocation. But else yeah if you use lambda meta factory it’s darn fast.
so basically under the hood it would utilise some kind of address pointer under the hood
to find the method quickly
?
Method handles are just a direct reference to a method basically
honeslty, reflection code always looks like a mess
https://github.com/KyoriPowered/adventure-platform/blob/master/platform-bukkit/src/main/java/net/kyori/adventure/platform/bukkit/MinecraftComponentSerializer.java
as example
Really?
Yuh indeed
I thought unreflect made it faster
I haven't used it though so I don't know for sure
oh also a thing about reflection
this is more stream API mess than Reflection API mess for me
should you use it for NMS access?
Yeah redempt, think matt switched over to method handles in triumph cmds where he basically just unreflect’d turned out to be slower than normal reflection iirc
Stream API... Mess?
Weird
isnt unreflect is just a convenience method to get a method handle from reflection method?
Idk actually
for sure you can do a lookup by yourself
The overhead is really not a big deal for commands anyways though
Indeed
Commands aren't that performance critical
LoL no stream api is used here
Stream api tends to make code cleaner, and not messier 
oh wait nvm
Yeah
i prefer old C way
Stream API is a fucking godsend
its a choice
You shouldn't do everything with them
Not really
It's about 15-20% slower from benchmarks Matt ran
I don't use them on performance critical stuff
But for everything else they're cheff's kiss
well but parallel streams are really godsend
Ok I gotta go, toodles
Exactly
Can we choose the executor of a parallel stream? Haven’t used them so just out of curiosity
@mortal hare
Ah actually doesn’t look like its possible which might be a downside
yea it uses ForkJoinPool.commonPool()
just like CompletableFuture
but at least you can pass your own executor in completablefuture afaik
CompletableFuture doesn’t necessarily use fjp cp
Yeah
But if the parallelism of cp is 1 then iirc it just has an executor which starts a thread for every supplied function
how do you change the max hearts a player has
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
pass your plugin instance
Or config instance
^
or string 😳

CharSequence
stfu real bros use a char[]
const char*
dont break my brain again
how do I make an indefinite potion effect
by using Integer.MAX_VALUE as your duration
or 99999
How would you call an implementation of a Clan that also applies changes to the database? ClanImpl is already taken
AutoSavingClan maybe
yesh 
FinalDatabaseManagableClanImpl 🥴
just a quick question, the runTaskTimerAsynchronously function runs the runnable on its own new thread right?
It runs on one of the bukkit worker threads
Conclure, just want to thank you second time. I spent a lots of time solving that design issue, and now i finally feel free!
how do i set max health of a player
getAttribute(whatever the health one is).setBaseValue
will that change the ui for how many hearts you have
Yes
if i wanna run a task async, should i use CompletableFutures? Or BukkitScheduler is preffered?
What are you doing in the task? 😮
hahahahahaha... executing sql queries
Ah oui, hmm maybe a CompletableFuture with a custom executor.
i made a tricky editor system to apply multiple changes at once
I mean the Bukkit scheduler is fine, just that having your very own stuff gives you more power.
Oo
Like a bulk operator?
Yeah, kinda
public static void editor(Clan clan, Component displayName, ClanMember member) {
clan.edit(editor -> editor.setDisplayName(displayName).addMember(member));
}
Using jdbc transactions
Oo that looks neat
🧐
How may I convert player to string? so I can get the player name instead of the whole player thing
Question, how could I get the nearest player object from an entity?
player.getName...
getNearbyEntites i guess?
mmm how would does that work?
so i'm using the steer packet to help the player control an entity, but i believe i did it a little janky
i have a player riding an arrow riding the entity
because i needed to position the player
so i had them ride an arrow
Arrow arrow = (Arrow) entity.getWorld().spawnEntity(entity.getLocation().clone().add(0, 0, 1.5), org.bukkit.entity.EntityType.ARROW);
arrow.setGravity(false);
entity.addPassenger(arrow);
System.out.println(arrow.isInsideVehicle());
arrow.addPassenger(event.getPlayer());
event.getPlayer().setCollidable(false);```
that's the player getting on, entity being the vehicle / entity to ride
I tried that but I got this public HashMap<Zombie, Player> ZombieToName = new HashMap(); and im getting it by doing ZombieToName.get(zombie)) but when I do player.getname, it still doesnt actually just show the name but the whole player thing
@EventHandler
public void onSteer(InputEvent event) {
if (event.getPlayer().getVehicle().getType() != org.bukkit.entity.EntityType.ARROW) return;
if (event.getPlayer().getVehicle().getVehicle() == null) return;
if (!matches(event.getPlayer().getVehicle().getVehicle(), "helicopter")) return;
float angle = new Vector(event.getPacket().getZza(), 0, event.getPacket().getXxa()).normalize().angle(new Vector(1, 0, 0));
Vector vechileVelocity = event.getPlayer().getEyeLocation().getDirection().rotateAroundY(angle);
event.getPlayer().getVehicle().getVehicle().setVelocity(vechileVelocity);
event.getPlayer().getVehicle().setVelocity(vechileVelocity);
event.getPlayer().setVelocity(vechileVelocity);
}```
this is me listening to the steer packet event
the entity itself moves, but the player and the arrow remain still
Show the code
why dont function?
that is the code, what I showed
thats how I store and how I use it
what happens if you set the damage to negative in an entitydamageevent?
does the victim heal?
if i had to guess he'll die
Nothing
Maybe a illegal argument exception
bruh
try it on yourself?
thanks
What's the alternative to the depricated World#regenerateChunk ?
From the JavaDocs
"Deprecated.
regenerating a single chunk is not likely to produce the same chunk as before as terrain decoration may be spread across chunks. Use of this method should be avoided as it is known to produce buggy results."
If you don't mind that, you can keep on using the regenerateChunk method.
If you do, you'd need to pretty much rewrite all world generation in order to support it. (Also, look below for another possible solution)
can you send me the docs?
because here it doesnt say that https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#regenerateChunk(int,int)
declaration: package: org.bukkit, interface: World
uhh i found it on github
But doesn't deprecated mean its gonna be removed in the next versions
uhh i dunno how that works with the spigot api
Or do deprecated methods stay forever
idk either
wouldnt wanna use something thats about to be removed in 1.18/1.19
No
then whats the point of deprecated
to stop people from using it when theres something better
Deprecated is used to striketrough questioniable methods
To get developer attention LoL
Then whats the better alternative to regenerateChunk ??
not only
There's no, just read deprecation note
just cause it's deprecated doesnt mean there's an alternative
it's just often the case
there is no better alternative, you could store the chunks so you get the exact state
You just said that tho ... "to stop people from using it when theres something better"
"usually"
i wanna change a specific part of the seed and then regenerate them.
just gonna use it then and hope it doesnt get removed xD
Good afternoon! I'm trying to add a mechanic to my plugin where a crossbow is automatically reloaded (in certain cases). I'm attempting to do this via CrossbowMeta, setting charged projectiles and then setting the item meta. Currently, my POC code and testing it, I'm firing a health 2 tipped arrow and am trying to reload the crossbow with a regular arrow.
What I'm expecting to happen: After firing the health 2 tipped arrow, the crossbow is loaded with a regular arrow after firing.
What is happening: after firing the health 2 tipped arrow, nothing more is happening. I can't fire the arrow that should supposedly be loaded.
What I have tried: My suspicion was that I was trying to set a charged projectile too early and then tried setting the charged project in a sync delayed task.
Here is my relevant code:
@EventHandler
public void onArrowFire(EntityShootBowEvent event)
{
// If the entity is a player
if (MUtil.isntPlayer(event.getEntity())) return;
Player player = (Player) event.getEntity();
UPlayer uPlayer = UPlayer.get(player);
// and the player is a level 1 Qadir
if (!abilityCheck(uPlayer, 1)) return;
// and the thing that the Qadir is shooting from is not null
if (event.getBow() == null) return;
// and the thing that the Qadir is shooting from is not a cross bow
if (event.getBow().getType() != Material.CROSSBOW) return;
ItemStack crossbow = event.getBow();
System.out.println(crossbow);
// and the projectile shot is an arrow
if (!(event.getProjectile() instanceof Arrow)) return;
Arrow arrow = (Arrow) event.getProjectile();
// Prevent the arrow from being able to be picked up (don't allow people to dupe lol)
arrow.setPickupStatus(PickupStatus.DISALLOWED);
CrossbowMeta crossbowMeta = (CrossbowMeta) crossbow.getItemMeta();
assert crossbowMeta != null;
crossbowMeta.setChargedProjectiles(MUtil.list(new ItemStack(Material.ARROW, 1)));
crossbow.setItemMeta(crossbowMeta);
System.out.println(crossbow);
}```
In my debugs, I can see that the first System.out.println() is outputting the crossbow with the tipped arrow and the second one is outputting the crossbow with the regular arrow. I could also observe this behavior with the IntelliJ debug evaluator.
Please forgive me for any hilarious mistake I have made, I started working on this at roughly 2a today rip. A second pair of eyes would be appreciated though 😄
Here's a picture of the console debug output for good measure:
https://i.imgur.com/tKCtP9o.png
OH, I also tried just adding a new crossbow to my inventory, that works, I get a loaded crossbow.
What about player.updateInventory(); after the crossbow.setItemMeta(crossbowMeta);?
but just replacing the item entirely, like you're doing now, should also do the trick, yeah
Heya, thanks for your reply. Now I'm trying to just even remove the bow from the inventory after firing and I think I'm going nuts. I noticed that I was missing the updateInventory call a little bit ago. The following won't work:
public void onArrowFire(EntityShootBowEvent event)
{
// If the entity is a player
if (MUtil.isntPlayer(event.getEntity())) return;
Player player = (Player) event.getEntity();
UPlayer uPlayer = UPlayer.get(player);
// and the player is a level 1 Qadir
if (!abilityCheck(uPlayer, 1)) return;
// and the thing that the Qadir is shooting from is not null
if (event.getBow() == null) return;
// and the thing that the Qadir is shooting from is not a cross bow
if (event.getBow().getType() != Material.CROSSBOW) return;
ItemStack crossbow = event.getBow();
// and the projectile shot is an arrow
if (!(event.getProjectile() instanceof Arrow)) return;
Arrow arrow = (Arrow) event.getProjectile();
// Prevent the arrow from being able to be picked up (don't allow people to dupe lol)
arrow.setPickupStatus(PickupStatus.DISALLOWED);
CrossbowMeta crossbowMeta = (CrossbowMeta) crossbow.getItemMeta();
assert crossbowMeta != null;
crossbowMeta.setChargedProjectiles(MUtil.list(new ItemStack(Material.ARROW, 1)));
player.getInventory().removeItem(crossbow);
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR, 1));
player.updateInventory();
}```
I can remove other stuff though with success. I was doing `.removeItem(new ItemStack(Material.CHEST, 1))` with success. I think that if I get the above working, I can identify the root of the problem.
I noticed that when calling removeItem(), there's a hashmap that it returns with the items that could not be removed and the hashmap is empty. So, I believe that Spigot *thinks* that the item is being removed. But it persists in my inventory after relogging and disconnect, so I don't think it is a client side issue.
I also looped through the player's entire inventory and noted the crossbow was not there after the method completed.
How do i disable taking off armor with spigot?
Also I'm in survival
does player.updateInv() even does anything?
I thought it was necessary if certain things were updated. But I think that opening and closing an inventory will accomplish the same functionality.
i update things and i dont need it
You could find the associated event and cancel it if it's armor, maybe InventoryClickEvent https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html could help. Alternatively, you could just apply like curse of binding or something.
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
sometimes i'm getting NaN when dividing the event damage squared over the final damage. what might cause it?
NaN in java 🤔
0.0 / 0.0 gives NaN
that gives a ..
it gives NaN
dividebyzeroexception or something?
rawr
https://www.jdoodle.com/online-java-compiler/
Input System.out.println(0.0/0.0);, will give you NaN
Are you taking a square root of anything? NaN could result from the production of an imaginary number i. Otherwise, I think a floating point zero divided by 0 will output a NaN.
nope, i'm just dividing the square of the damage by the final damage
it's basically to set the final damage
WHAT THE HECK
and if both is 0 your doing 0.0/0.0 = NaN. just check if its not 0
xD
what if it is 1.0/0.0
think so
hey java.lang.ArithmeticException: / by zero
at Main.main(Main.java:3)
like 0.00000001
then it will just get close to infinity
does it approx to 0.0
java cringe
gives 1.0E10
noone ever told me nan exists in java
u know double can do really high and low right
yea
xD
because sometimes i've noticed my damage gets very close to 0
or sometimes doubles randomly gains 10 nines after the dot
that should be a worry tho
and i still don't understand why
wont give NaN
aight
i heard that too much this evening bye
aight thanks
no problem
night 
night
You can just do
if (Double.isNaN(result)) System.out.println(theOneDamageValue +" "+ theOtherDamageValue);
to see what the values are in case you get NaN
but yeah i assume they're 0.0
no problem ^^
yeah, better than println xD
:p
that doesnt exist in 1.8.8 XD
I have never touched 1.8.8, sorry
how do I get unicode characters to show in chat? I want a star
dont worry, i just checked with that event if it was armor you were right.
all it shows is the decompressed version
no recommened 1.8.8 unless pvp
thats probably why he uses it
with the \u.... code
whats the character you want
fuck 1.8 pvp tho
what character do you want
what star
yeah, I just did that, testing now
alright
I appreciate it
glad i could help
The InventoryClickEvent does exist in 1.8.8
https://helpch.at/docs/1.8.8/org/bukkit/event/inventory/InventoryClickEvent.html
im talking about curse of binding..
ahhh sorry
no worries
So 1.16 to 1.17 --- NMS changed a ton... any write up on those changes?
See 1.17 developer notes on spigotmc.org
static String formatterPatternSwitch(Object o) {
return switch (o) {
case Integer i -> String.format("int %d", i);
case Long l -> String.format("long %d", l);
case Double d -> String.format("double %f", d);
case String s -> String.format("String %s", s);
default -> o.toString();
};
}
``` duuuude
this is new in jdk 17
type checking switch statements
it is still in preview isn't it
That’s an expression I think but yeah pretty pog
no i think it got released
minecraft 1.18 is in jdk 17
I see the enumerable of all the particles that can be used in spigot here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
Is anyone aware of any like... pictures?
declaration: package: org.bukkit, enum: Particle
the full jdk 17 launched in september this year
i think
at least it was scheduled to
can't recall this being in first preview in java 15 tho
maybe theres a minecraft wiki about it
hm
idk
Yea, this is still in preview. E.g. the move of pattern matching in instance of: https://openjdk.java.net/jeps/305 in java 14 to https://openjdk.java.net/jeps/375 in java 15 and https://openjdk.java.net/jeps/394 in java 16
Yeah foreign memory api is all good to go
Foreign who what
I'm pretty excited about it ngl
Would anyone know how to fix this? https://www.spigotmc.org/threads/specialsourcemp-error.534817/ Or what could be causing this?
Speaking of development anyone have experience migrating nexus servers?
Got a lot of plugins depending on my nexus and i gotta move it off my box
which nexus version
I'd stick with 2.x if you can
I upgraded one to 3.x and kind of regret it
but it should be as simple as just copying the directories
its all self contained
I re-ran java -jar BuildTools.jar --rev 1.17.1 --remapped and tried to compile again and still the same error
thats really weird
oh hm could be your plugin jar is corrupt
youre not coding in a onedrive folder or anything are you?
No, but the project is on a different drive
hmmm I'll try building your plugin
compiled for me
lol
it'd be interesting to find the issue
antivirus maybe?
something is corrupting the jar
gottem
Thank you! anyways I should've tried that before asking for help; my bad
no worries, it's not always obvious
antivirus does seem to cause a lot of issues though
Anyone know how I'd add enchanted books to a merchant using MerchantRecipe, I tried but it doesn't show the recipe in the trading UI
however when I print the recipes the merchant has, it does show it has that recipe
ItemStack{ENCHANTED_BOOK x 1, ENCHANTED_META:{meta-type=ENCHANTED, enchants={MENDING=1}}}
doesnt show it how?
like at all? or do you need an enchanted book in your inventory
Ye
do merchants have enchanted items in vanilla?
Ye, f.e. librarian villagers I think hold enchanted books
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) enchanted.getItemMeta();
meta.addStoredEnchant( Enchantment.LURE, 3, true );
enchanted.setItemMeta( meta );
WanderingTrader trader = l.getWorld().spawn( l, WanderingTrader.class );
trader.setRecipes( Arrays.asList( new MerchantRecipe( new ItemStack( Material.ENCHANTED_BOOK ), 10 ), new MerchantRecipe( enchanted, 5 ) ) );```
does this look kind of similar
ye
oop ye :3
works for me
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) enchanted.getItemMeta();
meta.addStoredEnchant( Enchantment.LURE, 3, true );
enchanted.setItemMeta( meta );
MerchantRecipe first = new MerchantRecipe( new ItemStack( Material.ENCHANTED_BOOK ), 10 );
first.addIngredient( new ItemStack( Material.STONE ) );
MerchantRecipe second = new MerchantRecipe( enchanted, 5 );
second.addIngredient( new ItemStack( Material.COBBLESTONE ) );
WanderingTrader trader = l.getWorld().spawn( l, WanderingTrader.class );
trader.setRecipes( Arrays.asList( first, second ) );```
note: 1.18-pre5, but I doubt its different in 1.17.1
could you print the .getResult() from the second one?
like second.getResult() ?
[09:10:19] [Server thread/INFO]: ItemStack{ENCHANTED_BOOK x 1, ENCHANTED_META:{meta-type=ENCHANTED, stored-enchants={LURE=3}}}
oooh
I think the issue is you enchanted the book
not added a stored enchant to the book
use addStoredEnchant not addEnchant
they look similar aside from the text colour, but the result is different
Hey md_5 ive been having trouble with my plugins perms. any ideas? ive been getting ignored a bit and I dont know if its because the question is too dumb
too dumb
maybe :p
your code: "p.hasPermission("permissions.VB.SummonBosses")"
your permission: "VB.SummonBosses"
remove the permissions. part
(from your code, not yaml)
oh the path i copied from the yaml had that in there. thanks 🙂
now I agree. brainfart.
still doesn't work
Hello, is there ProtocolLib fan? Can you explain me how set structure for this nms packet: (pls ping me 😉 )
class PacketPlayOutEntityEquipment {
private final int b;
private final List<Pair<EnumItemSlot, ItemStack>> c;
}
only on 1.18 but yes
Thanks md_5, but I'm writing npcs :<
Woo new features
Do we have 1.18? XD
We have 1.18-pre5
why do you even need packets for npcs
cant you just like y'know spawn them in the world
I feel like the leap to entirely API npcs is not very far
interesting
what is the error
description 100
I'm assuming it's a null pointer
Does anyone know if it is possible to add potion effects if you walk on certain blocks…?
Sure
anyone know how to use custom heads in a gui?
Just add the itemstack
idk how to make custom heads in java tho
is there a way to just set / add the nbt to the itemstack?
It's a bit finicky
what's "finicky"
i can't use gameprofile, i've tried it before
Why can’t you?
its cause you didnt import authlib as a dependency
It's part of NMS, but you can also import it separately
not part of nms in 1.18
To add it:
repo: https://libraries.minecraft.net/
group id: com.mojang
artifact: authlib
version: 1.5.26
Is there a way to change the y level of where the player enters a different dimension?
am not sure how to use this
it'll be in your local repo if you've run buildtools
can anyone help
Trying to start a server on the 1.18-pre5 jar but every time it loads the end it gets stuck at a random percentage. Is this an issue for it right now?
no
Hmm weird then
try and isolate it without plugins / a specific subsection of your world, then open a bug report
seems surprising
how could i do a crafter system without needing to check every single item of the inventory?
i have the recipe stored in my object
you could try creating a hash based on the 9 slots of your inventory
and have a hashmap
that way you have O(1) efficiency
forgot to metion, it is in a chest inventory
i mean that doesnt matter
and the items arent ordered
Anyone know if protocolLib has a way to check if they are near a vehicle and if they are flying? Can't seem to find anything
cant u do nearby entities, if instanceof vehicle and if flying
something like getNearbyEntities(params).stream().filter(entity -> entity.isFlying() && entity instanceof Vehicle)
There is no reason to stream it
¯_(ツ)_/¯
i got this error after trying to load the 1.17 bungee proxy
oh i cant send images
Verify or use something like imgur
any help pls
How would one calculate airticks?
Hello. Is it planned to use kyori adventure in spigot? https://github.com/KyoriPowered/adventure
I read it is to replace "bungee chat" api and is new improvement.
probably not
it is however used in paper
ok I will keep using paper api
is it allowed paper plugins on spigotmc.org/resources? I think not
can anyone help with this? (look above for more info)
can plugins not edit text documetns?
File dataFile = new File(fileName);
FileWriter fileWriter = new FileWriter(dataFile, false);
String condensedData = "";
for (String s : text) {
condensedData += s;
condensedData += "\n";
}
fileWriter.write(condensedData);
fileWriter.close();```
sorry
forgot
lol
assume fileName and text are all defined
text is an arraylsit
help :/
hello
do yourself a favor and use a StringBuilder
i need help with replacing water with fire when the bucket empty event happens
i converted it baack from that
🤦♂️
There is nothing wrong with my plugin.yml. I dont know why im getting this error: ```[03:02:32 ERROR]: Could not load 'plugins/Tazpvp-6.9.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:160) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:136) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:293) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:202) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_292]
at java.util.zip.ZipFile.<init>(ZipFile.java:225) ~[?:1.8.0_292]
at java.util.zip.ZipFile.<init>(ZipFile.java:155) ~[?:1.8.0_292]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_292]
at java.util.jar.JarFile.<init>(JarFile.java:130) ~[?:1.8.0_292]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:148) ~[patched.jar:git-PaperSpigot-"4c7641d"]
... 5 more```
my plugin yml: https://www.toptal.com/developers/hastebin/ezonaxagem.yaml
zip file is empty?
what zip file?
its just an exception usually from some sorta corrupted jar or something
cause you know, jars are still archives
``java
oops
File dataFile = new File(fileName);
FileWriter fileWriter = new FileWriter(dataFile, false);
StringBuilder condensedData = new StringBuilder();
for (String s : text) {
condensedData.append(s).append("\n");
}
fileWriter.write(condensedData.toString());
fileWriter.close();``` you know whats wrong?
well, that seems right. But you called the method right? (brain fart check)
yes
public static Hashtable<String, Integer> getData(Player player) throws IOException {
String playerId = player.getUniqueId().toString();
List<String> readData = readFile("playerData.txt");
Hashtable<String, Integer> data = new Hashtable<>();
boolean found = false;
if (readData != null) {
for (String read : readData) {
String[] dataLine = read.split(" ");
if (playerId.equals(dataLine[0])) {
found = true;
Bukkit.broadcastMessage("Data Found");
String[] playerData = read.split(";");
data.put("Strength", Integer.parseInt(playerData[1]));
data.put("MaxHealth", Integer.parseInt(playerData[2]));
}
}
}
if (!found && readData != null) {
readData.add(playerId + " ;0;20");
writeFile(readData, "playerData");
} else if (!found) {
List<String> newData = new ArrayList<>();
newData.add(playerId + " ;0;20");
writeFile(newData, "playerData");
data.put("Strength", 0);
data.put("MaxHealth", 20);
Bukkit.broadcastMessage("Created new profile for " + player.getName());
}
return data;
}``` is this correct?
gosh you want HashMap not hashtable
also you store your data in a list not a map wish is very inefficient
turns out part of the event is not triggering and i have 0 idea on why it isnt
perhaps just use the YamlConfiguration API and store in yaml rather than you rown config format
but i suck
:/
but i just wantt o know why it isnt working
oh wait it does work
just its not writing in the correct file
oh bruh im dumb
i forgot to put txt after the file name
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
if(meta != null && meta.getLore() != null) {
if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
PlayerData.changeData(player, 1, "Strength");
Bukkit.broadcastMessage("Strength");
PlayerData.updateData(player);
} else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
PlayerData.changeData(player, 1, "Health");
Bukkit.broadcastMessage("Health");
PlayerData.updateData(player);
} else {
meta.getDisplayName();
}
if (item.getAmount() == 1) {
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount()-1);
}
}
}
}``` anyone know why this event keeps getting registered twice?
any one please help me i downloaded a plugin but it is not working properly but iam using via version still it is not working how to fix it
check event.getHand or whatever
String.join???
wdym
Hello, It's been quite a while since I've coded anything and I've recently been getting back into plugin development. I'm trying to make a very simple faction core.
Here is my code:
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
Player player = (Player) sender;
if (args[1] == null) {
player.sendMessage(Utils.chat("&cYou must provide a argument. Usage: /f create <name>."));
return false;
}
Configuration config1 = (Configuration) plugin.getConfig();
config1.createSection(args[1] + ": []");
return false;
}
Upon running it generates this error:
org.bukkit.command.CommandException: Unhandled exception executing command 'fcreate' in plugin funnyplugin v1.0
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
only left in the main parts ^
unsure exactly what the issue is, i suspect i may just be using the createSection method incorrectly
any one please help me i downloaded a plugin but it is not working properly but iam using via version still it is not working how to fix it
String result = String.join("\n", text);
?????
Read the docs
Check if args.length < 2
@quaint mantle
oh yeah i forgot u gotta check the args length 🤦
damn its been a while
i literally tried doing !args[1] at first
@young knoll -Pdevelopment to check for missing annotations (@NotNull)
also mention ticket in commit message if you can please
retyrbs wutg tge san errot
oml wtf did i just type
returns with the same error
Check before
if (args[1].length() < 2) {
?
No wtf
Legit my message
How are you going to obtain the second object on an array of size 1
does anyone know how to add a smithing recipe, but instead of the netherite ingot, it's a custom item in the same class? i cant seem to get smithing recipes working without custom items (normally) :(
Either events or nms
that doesnt help much, im a beginner
idk what u mean lol
well now despite there being a argument provided, it returns with the error i provided if a argument isnt inputted
Invert the check
?
i dont see where to add the ingredients
nvm that
how do i add AttributeModifiers to items
-Pdevelopment?
so does config.addSection() actually save a new entry to the config.yml or..
it seems to not be doing so for me
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
if(meta != null && meta.getLore() != null) {
if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
PlayerData.changeData(player, 1, "Strength");
Bukkit.broadcastMessage("Strength");
PlayerData.updateData(player);
} else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
PlayerData.changeData(player, 1, "Health");
Bukkit.broadcastMessage("Health");
PlayerData.updateData(player);
} else {
meta.getDisplayName();
}
if (item.getAmount() == 1) {
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount()-1);
}
}
}
}``` anyone know why its doing this twice?
defvelopment maven profile
can someone helpe me
The event fires once for main hand, once for off hand when they interact
Easiest way is to add this line at the start:
if (e.getHand() != EquipmentSlot.HAND) return;```
like before if(meta != null ....
that line?
Yeah just return if the interact was fired from the offhand
AKA not from the main hand
Speaking of which
You should use early return to clean up that code
Also 8 spaces for indentation?
🌚
public static void onPlayerUse(PlayerInteractEvent event) throws IOException {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
if (meta == null || meta.getLore() == null) {
return;
}
if (!event.getAction().toString().startsWith("RIGHT")) {
return;
}
if (meta.getDisplayName().equals(ChatColor.AQUA+"Strength Adder")) {
PlayerData.changeData(player, 1, "Strength");
Bukkit.broadcastMessage("Strength");
PlayerData.updateData(player);
} else if (meta.getDisplayName().equals(ChatColor.RED+"Health Adder")) {
PlayerData.changeData(player, 1, "Health");
Bukkit.broadcastMessage("Health");
PlayerData.updateData(player);
} else {
meta.getDisplayName();
}
if (item.getAmount() == 1) {
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount()-1);
}
}```
Here, see how I flattened it by taking some of the conditions out, checking them first and returning if they are not met?
It works the exact same way but it's a lot less indented now, much easier to read
?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.
is there a good implementation somewhere about how to setup a tabcompleter in each command class?
using command framework
hey
i cant figure out what i did wrong on this one
public String getPrefix(plugin prefix){
plugin.getConfig().getString("prefix");
}```
well tell me one
incendo/Cloud is cool
it gives me error here
i want to be able to just call this on other classes and get the prefix from config.yml
Plugin has to be uppercase
(Plugin prefix)
yes bro
still error
everywhere
what is the code around it
public void onEnable() {
Plugin plugin = this;
public String getPrefix(Plugin prefix){
plugin.getConfig().getString("prefix");
}
saveDefaultConfig();
getCommand("info").setExecutor(new info());
getCommand("Fly").setExecutor(new Fly());
getCommand("enchant").setExecutor(new enchant());
getCommand("Bangui").setExecutor(new Bangui());
getCommand("Heal").setExecutor(new Heal());
getCommand("Feed").setExecutor(new Feed());
getCommand("Gmc").setExecutor(new gmc());
getCommand("Gms").setExecutor(new gms());
getCommand("Gmsp").setExecutor(new gmsp());
getServer().getPluginManager().registerEvents(new JoinMessages(),this);
getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "BasicEssentials is now working !");
}```
do you know basic java
it gives me other error now smh
am learning it
ok
hyped
?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.
some good resources
k
anyways instead of in onEnable { instance = this; } and static Plugin getInstance { return instance; } cant u just return this?
owh yea i forgot
java doesnt know that its a singleton
welp
if you implement tabcompleter at the same class that implemented commandexecutor
then when you register the command
yea i know i have it in that way rn
it will automatically register tab completer for you
normally my onCommand method shared a private field with the onTabComplete by calling a method which initiliazes it but now i'm getting some nprs
so directly overriding onTabComplete doesnt really work as i should call super.onTabCOmplete every time to get the player object etc
rn i fixed it like this
but therefore i has no executor field in the method and it took the one from the parent class
which is null rn
so i have to cast it every time and thats stupid as i just want to share objects
Guys does 1.12.2 support getConfig().getLocation() ?
go find it yourself? idk
Idk how
lol.... 1.16 already support getlocation
i dunno it never worked with me
oh yeah
i used 1.16.5
or an alternative
getConfig.get(location here, Location.class)
hey i have question about java , so basically i did this and if i understood well , if am inside the same class i can just do getPrefix(); and it will do the action on the method ?
Plugin plugin = this;
public void getPrefix(Plugin prefix){
plugin.getConfig().getString("prefix");
}
Go learn java
Your code makes literally no sence
i wonder if he is trolling
or that is actually his code...
pov you are this bad ...that ppl think you are trolling
lol
yeah
I bump my problem, because i still don't understand why my event is not fire
i register it, and even remove all my code expect the System.out and he still print nothing when i'm in my area
I'm not too hooked into things but wasn't 1.18 meant to do some changes to chunk loading with visual only and mob chunk loading?
wait the scoreboard api changed to a max of 32767 characters?
what is this dark magic
does it autoscroll now?
what is the generic U?
totally depends on what the author wants them to mean
oki
honestly I prefer glitching out to erroring at 16, that thing made me want to pull the few hairs I have left out
so is there going to be an event for simulation chunks loading separate from the "visual" chunks now?
There's no real difference
Spigot has had essentially the same feature at various times
Notably entity activation range in 1.17
The block version was removed forever ago because everyone hated that it stopped their crops growing
Simulation range is really just that, entity and block activation range
well the real question is it detectable because if it is not this will effectively kill any plugins that scan entities on chunk load
I've come across with some issues, I can't tell exactly why, with persistent entities not being loaded on chunk load
That's a 1.17 thing and has been fixed months ago
has it?
I ended up taking the long way around that one lol
so it was a bug and not me going insane after all
though if entities don't load when non-sim blocks load and non-sim blocks "always*" load first, wouldn't that result in being unable to scan persistent entities in those chunks 100% of the time?
You're overthinking what simulation distance is
just activation?
Yes, as I said
I guess I assumed they went a step further and were sending players the chunk info without "really" loading it
so if one of those crash-happy entities resides in a chunk and it gets loaded into visual it will still crash a server just fine, right
Depends why it crashes?
excessive nbt data or whatever that exploit was
it's been a while
man just activation is pretty lame, for some reason I expected way more
huh barrier not a particle anymore in 1.18, interesting
that's a shame, it was super useful
does that mean barriers have a completely different display behavior then?
ah block_marker
If they're actually identical we can add a remap
they act the same
as it stands, just updated my 50k line codebase with only having to change 2 lines of code for the barrier particles, thanks for all the hard work with keeping things consistent throughout versions md_5 💯
Thanks, I'll look if we should add a remap and make it 0 tomorrow
that'd be awesome, I can verify in .5 seconds if they're the same behavior
actually it will take about as long as it takes to dl mc 1.18 snapshot 5, I was on 6
now that's interesting, the barrier particles did change
they used to take up the whole block
they are still as wide as a block on the barrier but via the API they are now noticeably smaller, maybe 50% of the original size
I don't have a banana for scale but I think you can sort of see it
private void doParticleTrail(Particle particle) {
bukkitTasks.add(new BukkitRunnable() {
@Override
public void run() {
//In case of boss death or chunk unload, stop the effect
if (!livingEntity.isValid()) {
cancel();
return;
}
//All conditions cleared, do the boss flair effect
Location entityCenter = livingEntity.getLocation().clone().add(0, livingEntity.getHeight() / 2, 0);
livingEntity.getWorld().spawnParticle(particle, entityCenter, 1, 0.1, 0.1, 0.1, 0.05);
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 1));
}
that is the code I am using to spawn particles, I am decently sure none of the settings should affect scale and they certainly didn't in the previous version
it would be cool if there is a way to fix this as I was personally using barrier block's ability to fully take up a block in width to preview block locations / visualizing specific locations in air without actually putting anything on there
should I report this as an issue or is it possibly intended 1.18 behavior
If you explicitly pass the BlockData to the particle it may expand outwards
Block markers accept BlockData as a data argument (because you can show literally any block), I'd just imagine that barrier is the default one
hm
livingEntity.getWorld().spawnParticle(particle, entityCenter, 1, 0.1, 0.1, 0.1, 0.05, Material.BARRIER.createBlockData());
(and tbh, ideally that BlockData would be a constant you can refer to instead)
can anyone help me to setup the worldedit API for my plugin - I have no idea how
no dice
Worth a shot I suppose
They might increase the size for blocks
Not much to do there
could be
why minify it at all, I will be among the few who will ever even see that they are tiny when spawned manually
oh well
so out of curiosity is the non-sim distance as simple as setting mobs to have a noAI tag?
I'm having a hard time manipulating BookMeta right now. Does anyone have a good resource on it so I can fully understand how it works?
Is it possible to make silent lava?
maybe theres a sound event which you can cancel?
so theres Player#stopSound, but i think it only stops already playing sounds. running it every tick doesnt seem like a good option. lemme search for something better
probably gotta use a packet listener, i dont think spigot has any SoundEvent implemented
but would be a great addition @admins
Question:
Do maps support RGB values?
I could only find MapCanvas#setPixel(int x, int y, byte color), but what the heck is the byte for? what combination of 1s and 0s is what color?
oof yikes this 1.18-pre-5 fps isn't feeling so hot
20 view distance tanks my fps down to 20 even when not moving and I have a beast of a pc
an i7 9700k and a rtx 3090
this is the one thing that minecraft has consistently failed to do and it breaks my heart every single time, I don't think we'll ever actually be able to see really far into the distance in this game
Is it bad or good practise to make your plugins main class a singleton?
public class MyPlugin extends JavaPlugin {
public static MyPlugin instance;
@Override
public void onEnable() {
instance = this;
}
}
That’s not a singleton
A singleton design pattern where you have a function which returns one instance
well then add a .getInstance()
Your static field is public and non final thus its mutable
ah you know what, I figured it out; it used to show the particle effect for the barrier block, but now it's showing the particle effect for the dropped item instead
So it breaks the pattern since you allow it to be mutated
these are likely two different particles
but i wont, so effectively its a singleton
No its not lol
its just that i didnt implement it right
whats the difference if mutable or not, if im not gonna mutate it
the ability to mutate it
but that doesnt change anything if i dont use that ability
i dont really see a point in making it unmutable, if i know its supposed to be unmutable
It’s not a singleton then
Yeah you are right but they are too, just create a static get-method to be safe
alright, will do that then, even tho i dont get the point
just good practise i guess
it's not a crime to make it unmutable, you were the one showing up here saying you made it unmutable in the first place
or a singleton to be more exact
Think about it this way: If you do not develop the project for 2 years and come back to it you might not remeber that part. Thats why you want to keep yourself from using it wrong
Anyways Bukkit actually provides a way to retrieve the plugin instance JavaPlugin::getPlugin
Also it’s called immutable not unmutable lol
sorry, im not english xD
yeah that didn't sound right, it's time for me to go to bed
No worries was just picking on your words
:D
Oof
sad xD
I can't even tell what's capping
46% cpu use, 35% gpu
but it is going between 8-20 fps on idle
Wait, so i dont have to make a singleton, so instead of
MyPlugin.getInstance()
I can just use
MyPlugin.getPlugin()
?
I wonder if it's single-threaded performance
In principle MyPlugin.getPlugin(MyPlugin.class) iirc

With 20 vd and 20 simdist i have 60 fps when its loaded on 3080 & 5950x
Anyways I avoid singletons since it makes unit tests a pain
I'm at current cap 32 vd and 10 sim
funny thing is
I get the same framerate at 20 that I get on 32
you unit test your plugins? :o
Sounds like a good idea, but a lot of work
check core cpu usage then?
Resolution?
4k
LUL
Yeah it is a bit of work in the start, but very addicting nonetheless lol
but you cant really test ingame stuff, can u?
with vd 32, sm 10, 4k i have 30 fps
with a website you can test if it looks how it should - but with minecraft you probably cant
Yes you can
You can use MockBukkit and emulate certain events and actions
Yes it’s a bit inconvenient but it works
Oops sorry vsync was on by default, 57
Oh wow, very useful, thank you
Yeah no worries 🍉
this sucks
If you dont use Singleton, which is like the only way i've seen plugins made, how does your main class usually look like?
well it's always good to get a little disappointment before going to bed
@ember estuary Just make sure you dont expose a map from a singleton or something similar. That typically ends in bad design
wym with map
Maybe, it will work better with something like optifine or sodium once those are out
you mean Objects in general? pass by reference n stuff?
For example Map<UUID, UserSettings> do not give out a reference to something like that
ok yeah
It’s probably smart to use proper encapsulation and abstraction
A lot of devs start with stuff like Map<UUID,Player> resulting in a clusterfuck of a plugin
Yeah makes the plugin very implementation dependent
oh wow I'm getting huge fps dips even at 10 view distance
even at 8 I get big spikes, is this even playable for other people?
I will give it a try once I get home
I am running it through spigot on localhost
Must be the cpu i think
I do get cpu spikes when just walking around
but they're insanely high
oh actually could be the server messing up
I can send a link
Maybe check CPU-Temps, might not be correctly setup?
Altho this never got finished
ok yeah the dips was the server loading enough blocks for my 32 view distance
though I still don't hit fps cap on idle at 15 vd which is not a good sign for performance
I feel like this update is going to leave a lot of people in the dust
Compare with SP. On VD 15 i get 250 fps... With 9700k you should get at least like 150 @ idle
but it makes sense, yeah
I'll compare with SP but I feel like SP performance tends to not match server client performance
wym with builder
Google builder design pattern (:
ah, i think i had that in university
also had factory and stuff like that
but i dont remember a single thing haha
Yeah
bdp is fine but it gets to be a massive chore a lot of the time
singleplayer idling at max view range I actually get exactly the same fps, 20
In MapCanvas#setPixel(int x, int y, byte color), what is the byte for? what combination of 1s and 0s is what color?
Actually no clue, but did you check out MapPalette
MapPalette.matchColor is probably what you want to use
deprecated :c
i wonder whats the alternative
ill just use that for now tho
why would they deprecate useful methods like that, there has to be an alternative
When you try to make a Github Account, use your super strong password that you use everywhere else too, and github just says "Password is in a list of passwords commonly used on other websites"
Bruh :c xD


lol, thats cool
Your GitHub account is a link?
xD
Hmm, I’d rather not
I bought the domain, just for that purpose
its not a ip grabber
ye I do
you can see which ips connected to your server, so technically it could be