#help-development
1 messages · Page 1310 of 1
Not without making major changes to the jvm
nope its native
You're approaching the "rewrite the server" territory
Well, technically if you want more then 300 players while still maintaining performance you will indeed need to rewrite some or a good portion
and that has always been the case really
I said it was possible, just didn't caveat it yet with the probably going to take some work though part lol
As I have always said, you can't expect to get free enterprise software
although there is some exceptions like apache and mysql lmao
They wanted to get 300 players on a single server
and then a bit later they said they are doing skyblock
then from there, it was about folia and then sharding and then caveats of the two I guess
having a lobby and the dungeons on separate instances has many advantages, so that sounds about right
for the skyblock backend, i'd probably use folia for it
if worse comes to worst it won't be too late to switch it out for sharding if you eventually do need it
if you play your cards right, the dungeons instance not having the skyblock commands can be an advantage; most of those commands probably shouldn't be usable in a dungeon anyway
a lobby instance, especially for a cracked server, is useful as an auth sandbox
Folia or if u got competent devs maybe multipaper
and of course as a place to toss players when a backend is undergoing a restart
i work for a server with a few hundred ccu, we use folia and its going pretty great
we did have to make some changes to the original software
but it works
i wonder what hypixel uses
hygot
modified 1.7
they are on 1.7?
i thought they were on 1.8
they should really work on maybe updating
theres so much cool stuff in 1.21 and i wonder what those guys could do with that
We support the 1.8 protocol, but Hygot is based on the 1.7 codebase, yes
Everything in modern versions has to be implemented manually by us though. We're so far derived from vanilla or Spigot
So we implement what we need
interesting
"hygot" 💀
We've got a lot of fun names that I can't reveal cause they're not public lol
Some of them are pretty good
LOL
We have a housing furniture store in-game called Hykea
okay that one's pretty good
well thats one way to do it...
i dont even understand how hypixel is still alive
i get that it gets tens of thousands of players but aren't the costs like millions of dollars?
millions of dollars in what timespan?
every year
a night 
i have noticed that hypixel has a pretty high conversion rate
alao
i wouldnt say 80% tho
Skyblock makes a lot of money
i like it 🙁
i have like 1k hours in sb
but still like how much could it possibly be making
thats what confuses me
either the average hypixel player is a big spender
or their costs are way lower than i think
whales
i mean, it's not like they have thousands of developers
they have choco
and that's all
choco is all they need
yet he charges millions a year
I'm an expensive bitch
Hello,
I need help with NMS implementation. I dont know where I should start to get it implemented into my plugin. I know I need to get a Server JAR but idk how. I also dont know how to implement it then into my plugin.
Can someone help me?
?nms
Site not found...
Sorry.
This snapshot cannot be displayed due to an internal error.
🤣
Now, I downloaded the BuildTools and built the JAR with that command:
java -jar BuildTools.jar --rev 1.18 -remapped
What's next? How can I include the Server JAR into my plugin so I can use NMS?
?nms
Oh
repositories {
mavenCentral()
mavenLocal()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://oss.sonatype.org/content/repositories/central")
maven("https://repo.opencollab.dev/main/")
maven("https://repo.extendedclip.com/releases/")
maven("https://jitpack.io")
}
dependencies {
compileOnly("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT")
}
That one works but the NMS code is still obfuscated. What do I have to change? I provided the -remapped argument for the BuildTools
for gradle there is a gradle plugin you need to use
huh, it does not show the dep declaration
cool
anyway, i think you need to use the spigot-remapped artifact instead of just spigot
idk
Tbh, if it’s too much of a chore just use paper for it. They got plenty of documentation for gradle
Is this action correct?
RemapTask.Action.MOJANG_TO_SPIGOT
I dont want to get charged by Mojang haha
the readme says that's the default
Yeah but is this the good one I need?
Because I heard that Mojang also gives non obfuscated code but it's not allowed to publish work with that
that is not entirely correct, but that is the correct setting yes
change your dependency to org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang
just make sure you have ran buildtools for that version with the --remapped argument before
?whereami
someone had to do it
Ah great, ty
Haha yeah I also prefer Paper
Now I got NMS in my project. How can I now get the TranslatationKey?
You need the remapper plugin
getDescriptionId on the nms itemstack
:remapped-mojang is working perfectly
Until you run the plugin
Oh
You need to remap the plug-in afterwards otherwise it’ll be compiled with Mojang mappings
You get the nms itemstack by casting the bukkit one to CraftItemStack and then calling getHandle
Was getDescriptionId a method on the ItemStack or the Item instance tho
If it is on the item then you’ll have to do getItem on the nms stack and then getDescriptionId to that
I’m aware, why do you think i explicitly said paper
There is no getHandle method
public final class CraftItemStack extends org.bukkit.inventory.ItemStack {
net.minecraft.world.item.ItemStack handle;
}
But in the class there is a handle var. unfortunately the variable is private. Do I have to access it via reflection?
If they wanted to use paper they’d be in the paper discord
Ah there is an static asNMSCopy method
public static net.minecraft.world.item.ItemStack asNMSCopy(org.bukkit.inventory.ItemStack original)
Gradle fails to build my plugin:
plugins {
id("java")
id("com.gradleup.shadow") version "9.0.0-rc1"
id("io.github.patrick.remapper") version "1.4.2"
}
repositories {
mavenCentral()
mavenLocal()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://oss.sonatype.org/content/repositories/central")
}
dependencies {
compileOnly("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:remapped-mojang")
}
tasks {
build {
dependsOn(shadowJar)
dependsOn(remap)
}
remap {
version.set("1.18")
action.set(RemapTask.Action.MOJANG_TO_SPIGOT)
}
}
Error
Execution failed for task ':spigot:remap'.
> java.nio.file.NoSuchFileException: /home/tommy/Workspace/IdeaProjects/CaseOpening/spigot/build/libs/spigot-1.0.0.jar
can someone help me
because my luckperms wont show in chat i have every plugin required
instead of showing luckperms ranks it shows the world name
somebody help
ok
Is it possible to automatically upload plugins to spigot using some api?
Nope
Would it be worth considering doing this? It would make things a lot easier if my GitHub workflow uploaded the plugin.
not a chance
they dont allow bots for scraping or anything like that lol
There should be account requirements then
yeah but not for premium resources
you would have to figure out a way to convert github markdown to xenforo formatting, or keep your changelog as plain text so that it doesn't break in-between platforms
anyhow, it has been discussed many times on the forums and the conclusion was always that it wasn't worth the effort given md is the one having to do all that
IIRC biggest hurdle was the fact that the xenforo plugin that spigot uses for the resource manager wasn't made by spigot so adding an API would require mantaining their own custom version (created from scratch, since the xenforo addon isn't open-source), which would have its own share of troubles
how to execute a command without this wierd message to operators?
[Console : ... ]
isn't that a property in server.properties?
broadcast-commands-to-ops or something like that
looking free api for transport player datas to other servers
like inventory, food level, xp
if the servers are connected through bungee proxy you could use the server messaging protocol i think that's what its called
i will do with db but i don't have time for code this
im looking free api for this
the bukkit api is pretty free
if you are gonna do it then thats a good way to do it
also some external api would also just use it anyway under the hood
what exactly are you trying to do? whats the use case?
i want to transfer a player's inventory to another server
yes
oh hi lol
i did it like this https://paste.md-5.net/rayomemewu.cs
Hello,
I have an issue with ItemStack serialization.
The issue is when I'm trying to serialize an item, the serialization force the Components (displayName and lore) colors value...
This is my code (very simple):
public String itemToBase64(ItemStack item) {
if (item == null) {
return Base64.getEncoder().encodeToString(new byte[0]);
}
return Base64.getEncoder().encodeToString(item.serializeAsBytes());
}
public ItemStack itemFromBase64(String data) {
if (data == null) return null;
final byte[] bytes = Base64.getDecoder().decode(data);
if (bytes.length == 0) return null;
return ItemStack.deserializeBytes(bytes);
}
And with the screenshot you can see the difference between the 2 items. The left item is the serialized and stored item, the right item is the original item on my inventory.
Thank you very much !
Screenshot:
https://prnt.sc/JU1tER5mRRop
How can i force remove player's FishHook from the world?
I did it with Draws two vertical lines of red particles (top and bottom points) beside an armor stand, rotated based on the stand’s yaw.
then rotates those points around the stand’s facing direction (its yaw), so the line is always aligned with the armor stand’s rotation.
and i think it was best apporch for my use case
how to execute a command without this wierd message to operators?
[Console : ... ]
weren't you already answered
without transferring the player..?
you were already answered, scroll up
sooo? ive been trying for past 2h and couldnt do anything with it
someone will help you if they know the answer
meanwhile it can help to also look at other sources
Hello!
Is it possible to load a player as a "new" player on login? Then do login, then load his actual data. Well it is possible through nms... but in from the API standpoint...
If not, is it possible in ||paper||?
for what purpose
Something tells me offline mode
im pretty sure you are right, to hide player inventory before login
I am against offline mode, but I am trying to create some sort of system, yes.
then what would be the point of login system when only online players can join?
well what if I want my own auth system, or just something to have as a test plugin?
I don't think it's possible anyway through the api.
Hey i have the economy++ plugin everything works fine but i cant figure out the / sell hand command, can someone help me out
from API standpoint no. You will have to alter the protocol in regards to the login process and just send back data that it was successful to the client
and then you can do whatever you want after that
also, you will want to alter their UUID as well and not accept whatever the client sent
this way you don't re-introduce UUID spoofing lmao
OH
TY VERY MUCH
oh no its the bot, thank goodness they finally read the part where they were responded to
True. Exactly what I was thinking. Basically I just change the uuid, then when I want to, actually load the player with their real sent UUID. The re-loading data part is the problem...
its not a problem
you just remove them from the tab list and re-send packets to everyone and re-add to tab list
and everyone should get the updated data
I must somehow change the uuid of a player internally for the server to recognize the data.
its not hard
but all of this simply can not be done from the API though
not even with paper
@wet breach thank you for help
np
Use a transfer packet to reconnect the player to the server and swap their fake uuid for their actual uuid in the prelogin event
Should be completely doable with the paper api, both transfers and swapping out the uuid
but you can't halt the login process for later with the api though
basically they are just wanting to move the verification portion to be done later, but still allow them to join
This should be doable, did they mention needing something else?
Roll a random uuid on join, set it in the prelogin event, set auth to offline in the same event, then do your verification once the player joins in
Transfer the player back to the server, this time let them use their actual uuid
I guess paper allows setting auth on a per event basis, but with spigot you can not do that
Just make sure all plugins are set to actually use uuids and not names
I don't know if spigot let's you set the uuid either
it doesn't, which is why I said you can't do what they are wanting with the API
also not seeing where paper allows per event auth either
Yeah I doubt they would add that
paper allows setting uuid in the profile, but not entirely sure if this applies to the player object though
yes
I recently downloaded a vehicles plugin by pollitoyeye and it seems theres a permission issue as normal players cannot use /[vehicle]shop. Anyone else experiencing this or have an answer?
Tried luckperms verbose mode?
Looking for Dev
-# I need a dev for my mc server I need a custom plugin ny budget is 5 dollars dm if you can help
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
you can get the profile in the prelogin event modify it, or create a new one, and set it in the event with https://jd.papermc.io/paper/1.21.1/org/bukkit/event/player/AsyncPlayerPreLoginEvent.html#setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile)
for forcing offline mode auth, it looks like that's on velocity and not paper https://jd.papermc.io/velocity/3.3.0/com/velocitypowered/api/event/connection/PreLoginEvent.PreLoginComponentResult.html#forceOfflineMode()
no with player
then just transfer the player and then on the other server grab their inventory?
yes
i don't know off the top of my head any plugin that does this out of the box
you might have better luck in #help-server
anyone happen to know if set view distance for text display is broken for 1.21.8 or something, it doesn't seem to be working for me
I swear it was working before
in what way
the property you set on the entity is applied clientside during rendering; ramping it up super high won't make the server send it from any farther away
yeah, 1.0 is the default and means use the default entity draw distance on the client
so i have made a placeholder and it seems to work fine, but not sure how to make it work with essentialsx chat's chat formatting beacause it doesnt allow external placeholders maybe, any other idea so that even if a server has essentialsx chat , then also the placeholder would return the expected output?
if you are using papi, you could use a chat injector to make it work with essentials
or you could check the source and hook it into essx's api by yourself
that plugin worked thanks
Hi, I have a problem with the ChatComponent API. I want to send a message to the player where {name} gets replaced with the won item name. Is there a better way than this?
private BaseComponent[] buildMessageWithItemName(String rawMessage, String prefix, BaseComponent wonItemNameComponent) {
String[] parts = rawMessage.split("\\{name}", -1);
ComponentBuilder builder = new ComponentBuilder();
if (prefix != null && !prefix.isEmpty()) {
builder.appendLegacy(prefix);
}
if (parts.length != 0 && !parts[0].isEmpty()) {
builder.append(parts[0]);
}
builder.append(wonItemNameComponent);
if (parts.length > 1 && !parts[1].isEmpty()) {
builder.append(parts[1]);
}
return builder.create();
}
It also doesn't work like it should ...
If you're on paper or can use adventure, they have replaceAll and similar functions on their components that allow you to search for string matches and substitute them with components
And on spigot?
Glhf
So that's the best way?
for text components, yeah probably
Yeah the problem is the prefix and the parts have legacy color codes
Run it through the LegacyComponentSerializer to parse them into proper components
So how can I fix this?
If I make builder.appendLegacy(parts[0]), the color codes of this part are formatted but the wonItemnameComponent, which is a TranslatableComponent, is not translated (then there just stands item.minecraft.blabla). But If I make builder.append(parts[0]) the TranslatableComponent is translated but the color codes are not formatted
Ah that's a great idea Ill do try that out later ty
witht the §? or the regular ampersand?
The value that the method gets goes through ChatColor.translateAlternateColorCodes(string, '&')
So it's with §
should work with what vcs2 suggested
Perfect :)
There is no LegacyComponentSerializer
He is talking about the adventure api
the only proper way to deal with text components as now on spigot without touching internals
Ah nvm, this code works pretty good if I only use append and no appendLegacy
anyone know how this works? im assuming something with resource packs bur confused with the rainbow and the enchanted back box
The text is made with color gradient and the fancy rank icons are made with texture packs
probably itemadder
Oh the imagine isnt animated that was what was confusing me the SYBAU tag was a animated rainbow gradient and the ENCHANYED had a moving background
Would that be the same?
is that chat ?
idk how to do animated chat messages
yeah once the chat is sent and received it stays as is with one set of colors, the only way to animate it should be by removing and resending it every tick with diff colors
That sounds awful
you could technically add animated textures to that, i dont know how you would do that for the text part tho
im sure the rainbow part is with shaders but can textures in chat be a gif / animated?
if so then i could just do that right?
thise would be dynamic and the rainbow would be static because the shader does all the work
not a gif but a longer texture like this, saved like somename.png
and a set of instructions like this named somename.png.mcmeta
its a diff font from normal
so its likely a pack yes
the server i work for uses resource packs like this too
Or they're re-sending chat every tick 
If that's actual in-lined chat colour animations, I would also be willing to bet it's a shader. Set it to be a really obscure colour that you probably won't use, then override the text shader to replace that colour with a rainbow effect
It actually would be a relatively simple shader to make too
wouldnt that require the end user to use optifine that way tho?
text shaders are a vanilla thing
you can make one with a resource pack
interesting
how do i set nbt data like VaultServerData.stateUpdatingResumesAt on a vault?
can you explain how I would do that
What part do you need help with?
Change the scale in the transformation
i get this error while using buildtools when building 1.21.8
i have maven installed
Yeah that's known issue I'm suprised it still hasn't been fixed
Setup your local maven install properly so BuildTools can detect and use it
instead of trying to download its own
Do so by setting the MAVEN_HOME environmental variable and point it to you maven install directory
problem is that im pretty sure i have it setup correctly
does it specifically need be v3.9.6?
No
if you run echo %MAVEN_HOME% what does it say
C:\Program Files\Maven\apache-maven-3.9.11
How are you running BuildTools?
As in, through command prompt or?
oh okay
Run it using the jar and through the command prompt
Looks like BuildTools still checks for M2_HOME even though MAVEN_HOME replaced that one in Maven 3
So se that as well and see if it helps
didnt work thru cli, so i tried to install latest build tools and ran it, and now after 3mins of building it did this...
That's odd could you run it again in an empty folder
i mean i ran it in empty folder
ima try one more time
the rage bait 🥹
and it worked SOMEHOW
It has compiled
Gremlins in the machine
Must've been the wind
Is there any info on how interaction entities can lag the client?
We have about ~2.7k item displays in use right now and about half of them have an interaction entity as a hitbox
we're already looking into merging a lot of these models and implementing culling but there's room for improvement
mfw someone replaces outdated code with modern standins 🤯
huh interesting it seems like protocollib is still the most unreliable POS library I've ever used
hm? What's wrong
I'm trying to prevent interaction entities from being sent to the player
And it's detecting every single item display being sent but not any interaction entities
can you not use the api to hide them?
I see, was just asking while browsing through some code
yeah you'll probably have a better time with that
ProtocolLib is pretty painful to work with tbh
and if that doesn't work then I'll be lost
because I disabled hitboxes on nexo as well
and /kill @e[type=interaction] does nothing
i mean, that just straight up indicates they are not real server entities
which like, who/how is sending them then
If they're getting sent deep in the network pipeline (e.g. wire packets), PL won't see then
Dump your netty pipeline and see who's where
I probably missed the reply
Class<?> relEnum = Class.forName("net.minecraft.world.entity.RelativeMovement");
enumPlayerTeleportFlags.addAll(Arrays.asList(relEnum.getEnumConstants()));
float diffPitch = targetDirection.getPitch() - currentDirection.getPitch();
float diffYaw = targetDirection.getYaw() - currentDirection.getYaw();
//Normalize to (-360..360)
diffYaw %= 360;
//If greater than 180 in either direction, mod 180 and flip the sign; 270 % 180 = 90, 90 * -1 = -90
if (Math.abs(diffYaw) > 180) diffYaw = (diffYaw % 180) * -1;
if (Math.abs(diffYaw) < 15 && Math.abs(diffPitch) < 10) continue;
diffYaw *= 0.05;
diffPitch *= 0.05;
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.POSITION);
packet.getDoubles().writeSafely(0, 0.0D); //x
packet.getDoubles().writeSafely(1, 0.0D); //y
packet.getDoubles().writeSafely(2, 0.0D); //z
packet.getFloat().writeSafely(0, diffYaw); //yaw
packet.getFloat().writeSafely(1, diffPitch); //pitch
@SuppressWarnings("unchecked")
Set<Object> relativitySet = (Set<Object>) packet.getModifier().read(RELATIVITY_BIT_FIELD_ORDINAL); //relativity bit field
relativitySet.addAll(enumPlayerTeleportFlags);
packet.getIntegers().writeSafely(0, ThreadLocalRandom.current().nextInt()); //teleport id
packet.getBooleans().writeSafely(0, false); //dismount
try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); }
catch (Exception ex) {
ex.printStackTrace();
}
this was in 1.20; i've since removed the logic since players found it disorienting, and i'm fairly sure the relativity set has been changed since
does java have a lazy String.replace where I can toss a supplier or something
I might've gone a bit crazy with my placeholder system and it's wasting a lot of time rendering strings that will never be matched
wdym by this
Use Apache's StringSubstitutor @echo basalt
ah, I get what you mean now. Only replace if it finds the placeholder
Something like
"Really really big string".replace("really", () -> Whatever)
declaration: package: org.apache.commons.text, class: StringSubstitutor
Otherwise, what stops you from making your own:
public static String lazyReplace(String source, String target, Supplier<String> replacementSupplier) {
if (!source.contains(target)) {
return source;
}
return source.replace(target, replacementSupplier.get());
}
that defeats the whole purpose of being "lazy" since we're always calling replacementSupplier.get() regardless of whether a replacement is needed??
Well it could in theory find the target and its start and end positions before having to call the supplier
I'm just not sure if apache figured that out or if it's just a utility for replacement
I think its more extensive
I'll need to investigate
I see what you mean, so maybe:
private static List<Integer> findAllOccurences(String source, String target) {
List<Integer> positions = new ArrayList<>();
int index = 0;
while ((index = source.indexOf(target, index)) != -1) {
positions.add(index);
index += target.length();
}
return positions;
}
public static String lazyReplace(String source, String target, Supplier<String> replacementSupplier) {
List<Integer> positions = findAllOccurrences(source, target);
if (positions.isEmpty()) {
return source;
}
String replacement = replacementSupplier.get();
return replaceAtPositions(source, target, replacement, positions);
}
or you could use boxed with streams
I'd just make a proper tokenizer at that point
Yeah lol
ok what the fuck
this guy's either running this a trillion times or hosts his minecraft server on a smart toaster
lmfao what
hasMetadata is essentially just a Map#containsKey so I wonder if it is just sampling bias
was checking if they're npcs
as for MSPT it's sticking at around 80
2% of that going to metadata checks is still more than it should be
Hi 👋 I’m looking for some help to build my Paper 1.21.8 plugin with Gradle.
If anyone is available, could you please contact me in DM? 🙏
Thank you very much!
Sir, This is spigotmc discord server.
Hi, does anyone here know the Essentials plugin well? I'm having some problems blocking certain commands. Can anyone help me?
Are you asking to block commands like Essentials?
This is #help-development
Yes. Is there any chat where I can ask questions about plugins?
sorry
the server channel
thanks
Why when I change remove the same letter or ' and after dm reload this menu doesn't work
I have 193 menus but i removed ' and dm reload - 192 menus and again i put this ' and dm reload- 192 menus
I've seen this problem in other menus from buil.b_b*t ( where there are ready-made menus ), but these menus are from my developer from 7 months ago and if I change a letter, the menu doesn't work.
' is a quote, why are you removing it?
chat why is it that when I remove a \n the line doesn't break anymore
if I change a letter or word in this menu after dm reload this menu does not work
I removed it for testing but as I said I put it back on afterwards
does anyone know what sound this is?
one of the nether waste's ambience sound
Ohh i see, is there a way to get one sound specifically from the list of available sounds?
well there is probably a way, but yeah
maybe using the playsound with seed option
void playSound(Entity entity, Sound sound, SoundCategory category, float volume, float pitch, long seed)
you are particularly interesting in this https://youtu.be/-C-zQLd03Ic
Plays when the player is inside a nether wastes or basalt deltas biome.
Java Information
File name: mood3.ogg
File path: sounds/ambient/nether/nether_wastes/mood3.ogg
Sound event: ambient.nether_wastes.mood / ambient.basalt_deltas.mood
Subtitle: None
Category: Ambient/Environment
Added in: 1.16 (20w15a)
Bedrock Information
File name: mood3...
ah look, someone already provided a list of seeds that can be useful
Thanks!
TIL about StringSubstitutor
that you knew this out of the blue is impressive
i knew it was an ambience sound from the reverb but the mc wiki helped
Ur late to the party smh
frankly using a Pattern with a literal string is very fine too, probably not as "elegant" but you don't need a whole stinking apache library for it
static final Pattern P = Pattern.compile("foobar", Pattern.LITERAL)
P.matcher(input).replaceAll(match -> ???)
and because it's a simple string literal it's dirt cheap
(a) single-letter constants 😔
(b) Isn't Apache text already shaded into Bukkit?
Hey, I made a move-able building and I just added a function to move all entities inside of its bounding box, however when I try to teleport the player, I feel like it resets its camera to previous tick or smth, so I was wondering if there's a way to teleport the player without resetting its pitch & yaw? I'm not entirely sure of the source of this issue, so here's a video and my code:
public void moveEntities(World world, Location posA, Location posB, int dx, int dz) {
BoundingBox area = new BoundingBox(posA.getX(), posA.getY(), posA.getZ(), posB.getX(), posB.getY(), posB.getZ());
Collection<Entity> entities = world.getNearbyEntities(area);
for(Entity entity : entities) {
Location loc = entity.getLocation().add(dx, 0, dz);
entity.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
}```
a) typing code on discord, be grateful i added static final
b) yes, however: apache
Ye, you need to teleport the player relatively instead of this way
But I don't think spigot has a way of doing it
Try to TP by dispatching a command instead teleport <player> ~dx ~ ~dz
EyeLocation has pitch and yaw, not sure entity location has teh correct value
I mean, I do teleport the player relatively with entity.getLocation().add(dx, 0, dz);,
I can try to do via command but I have some doubts, still doesn't hurt to try it ig
but spigot teleport does support pitch/yaw
no I mean that the TP packet literally has "relative flags" which I doubt are added by the teleport function in API in any way
If you TP with yaw/pitch then you would take the servers latest value which will not be up to date 'cause ping exists
indeed, since yaw and pitch are stored in the Location class variable. And it seems there is no other teleport functions, when looking at the interface, that only handles position and not pitch/yaw.
Oh wait so you meant like to use the tp command to only use relative pos and ignore pitch yaw right
I think that way the clients yaw and pitch will be taken instead, I do not know tho
I know there was a guy who was trying to do recoil and that involved TP as well
something similar
Sound logical, I will try that
Last time I tried to dispatch commands, it was burrying the console so I'll see if there's a "cleaner" way to do it with flooding 😅
Well you can always just teleport directly with NMS :D
Oh yeah, I'll check that out (haven't used much NMS, been dark sorcery for me ngl xD)
Is there any way to test my newer version of my plugin without restarting server with something like reload?
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")
}```
Hey, i get this error, when i try to compile the gradle project
```Configuration cache state could not be cached: field `provider` of `org.gradle.internal.serialize.codecs.core.ProviderBackedFileCollectionSpec` bean found in field `element` of `java.util.Collections$SingletonList` bean found in field `elements` of `org.gradle.internal.serialize.codecs.core.ResolutionBackedFileCollectionSpec` bean found in field `__classpathSnapshot__` of `org.jetbrains.kotlin.gradle.tasks.KotlinCompile$ClasspathSnapshotProperties_Decorated` bean found in field `__classpathSnapshotProperties__` of task `:compileKotlin` of type `org.jetbrains.kotlin.gradle.tasks.KotlinCompile`: error writing value of type 'org.gradle.api.internal.provider.DefaultProvider'
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find net.md-5:bungeecord-chat:1.12-SNAPSHOT.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/net/md-5/bungeecord-chat/1.12-SNAPSHOT/maven-metadata.xml
- https://repo.maven.apache.org/maven2/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.pom
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/net/md-5/bungeecord-chat/1.12-SNAPSHOT/maven-metadata.xml
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.pom
- https://oss.sonatype.org/content/repositories/snapshots/net/md-5/bungeecord-chat/1.12-SNAPSHOT/maven-metadata.xml
- https://oss.sonatype.org/content/repositories/snapshots/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.pom
why does it work when i do this:```
maven("https://repo.md-5.net/content/repositories/snapshots/") // required for bungeecord-chat
i do not use bungeecord chat
its not mentioned in the docs
The Spigot API uses it
i dont need to add it in my other projects
You do if you want to use the Spigot API
The home of Spigot a high performance, no lag customized Bukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Yeah, and BungeeChat for version 1.12 (which you are depending on) exists on the md-5 repo, not the Sonatype repo
That wiki page is for 1.20
Hey, i m new to plugin developement and i was wondering how can i make my minecraft plugin work in different versions? without the use of NMS.
The api does it by default
The spigot api?
yes
alright thanks for the informtion
Just make sure to depend on the oldest version you want to support
What do u mean?
means that if you want to support something from 1.X to 1.Y, you need to use the 1.X dependency
ok
i.e. if you want to make a 1.21 plugin work on 1.18, you have to code it for 1.18
Use the functional replace methods on Matcher
If you're matching for literals, wrap your pattern in Pattern.quote
This also allows you to parse through the string in one go resolving all placeholders at once, rather than searching for them individually
i am making custom recipes ofr cookies but htye are not registering
only the honey cookie works and all of the funcitnos are claled in on enbable and cookite items. then ame is using the item fomr anypother class which works with t the shop
Hi there! i just published my first plugin and it says i need to enable 2FA to push an update, i did enable 2fa, tried relogging and clearing cache but no luck sadly
update for the plugin is to connect to spigot api for plugin updates and really dont want people downloading without that but needed to upload plugin to create the plugin resource
probably best to contact the support email
?support
Use the bukkit api
and what version do i need to build?
do you konw why they dont work
Can you share code?
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
I am new to minecrft plugin developement, while i was tying to code my plugin i am not getting any code suggestions can any one help me?
Which IDE are you using
Does your plugin compile?
ye
My IDE can see normal Java classes (like onEnable()), but it doesn’t recognize Spigot classes like Player, Bukkit, or CommandSender. I think the Spigot API jar isn’t properly linked or downloaded. Could you help me ensure the API is correctly set up so imports and suggestions work?
How did you set up ur project?
by using micraft generator vilble in the ide
what build tool are you using? or are you using the ide's built-in dependency manager?
i think he is talking about minecraft dev plugin in intellij
the default build tool for that is maven iirc
do you have pom.xml or build.gradle files?
if yes - show contents of it
Hey guys, do commands have to have their own class?
not really, people do that to keep their code tidy
Is there any set collection that's made for bulk adds / removes? HashSet's collection constructor manually adds each entry one by one
and that's hogging 6% of the server performance at ~2500 entries a tick
i mean, hashset kinda has to do that, as it needs to hash each item to know in what bucket to put it
any other set is not going to have the properties of a hash set
why are you copying a collection with 2.5k items into a hash set every tick?
It won't let me be sure it's to long
it's a bulk update task kind of thing
could you use a tree set? the NavigableSet interface has some really neat methods that might be useful, but it heavily depends on the use case
obviously that implies ordering
goes a bit like this
public void bulkUpdate(Collection<Entry> entries) {
this.existingEntries.computeIfAbsent(entry, EntryWrapper::wrap).update();
Set<Entry> expired = new HashSet<>(existingEntries.keySet());
expired.removeAll(entries);
bulkRemove(expired);
}
the whole method pulls 6% cpu time, evenly divided between computeIfAbsent and the set add / removeAll methods
hm, is the use of a hash set there strictly necessary?
you could use an array list with the capacity ctor and manually add the entries that aren't to be removed instead of add all + remove all
or if you can somehow determine an immutable ordering for the entries, using a tree set/map and getting all the keys before/after some min/max entry
use fastutil collections
and instead of the constructor that takes a collection, use .clone()
this'll just clone the underlying structure rather than initializing an empty collection and adding things one by one
Hi, is it allowed to upload a jar on Spigot that's not a plugin but helps for servers?
So the JAR doesn't implement any Minecraft API
eh, fastutils is kind of whatever in my experience if you aren't working with primitive types
you'd need to clone the whole map since you can't clone just the key set but i guess that would work too
i changed the link
it's still unreadable
you copy pasted from your pastebin so zero formatting remained
nope
try this link
better
do you discover recipe for the player?
when i put them in a crafting table only honey cookie works
the other ones dont work
grandmacookierecipe.addIngredient(10,Material.COCOA_BEANS);
i'm not sure if this is something you can do
have you checked the console for errors?
yes
and nothing
but the other ones dont work either and beofre i had muilitolpe amoutns they still didint owrk
so how can i
you maybe can but 10 isn't going to fit in the crafting grid
um yeah
2 should
ah I see
your second recipe errors out at startup so only the first recipe is registered
you are erroring out of yoru onenable
that's why i asked for errors, but supposedly there aren't any
not to say we don't trust you but uh maybe send your server startup log in another paste
yeah, he'd miss it as its during startup and he's likely not looked there
also NameSpacedKey shoudl all be lowercase
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>HellFire</groupId>
<artifactId>ReportDesk</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>ReportDesk</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
i use featther launcher servers
but some of them are lower case
also as vcs said, change the value down from 10 so all components fit in a crafting grid
ALL have to be lower case
and your error is your quantity of ingredients
yes, that's not how shapeless recipes with amounts work
having an amount of n means the ingredient needs to appear n times in the recipe
think fireworks gunpowder
or honestly god only knows if amounts work in shapeless recipes at all, iirc fireworks are a special case of a complexrecipe
get rid of the amount numbers in your code and send the server startup log in a paste
amounts work, but I don't remember how you do them in the api also you have to know which ingredients can be stacked and which can't lol
public void ProtienCookieRecipe(){
ShapelessRecipe protiencookierecipe = new ShapelessRecipe(new NamespacedKey(this,"protien_cookie"), CookieItems.Proiten_COOKIE);
protiencookierecipe.addIngredient(Material.COOKIE);
protiencookierecipe.addIngredient(Material.COOKED_BEEF);
protiencookierecipe.addIngredient(Material.COOKED_BEEF);
Bukkit.addRecipe(protiencookierecipe);
}
would this wokr
?tryandsee
My IDE can see normal Java classes (like onEnable()), but it doesn’t recognize Spigot classes like Player, Bukkit, or CommandSender. I think the Spigot API jar isn’t properly linked or downloaded. Could you help me ensure the API is correctly set up so imports and suggestions work?
Is there any1 here who knows how to fix ghost blocks on bridging server?
Pls i really need help
Pretty sure 1.20 requires a higher java version. But I couldn't tell you which
onEnable is not a class and it is indeed from the spigot api
can you maybe send a screenshot of what you're seeing, or specific linkage errors if you are getting any
?paste
Looking to paste something? Try a code block or one of the following websites:
- https://pastes.dev/
- https://sourceb.in/
- https://mclo.gs/ (best for server logs)
Nope, seems 17+ is ok
My best guess is you have a fubar cache
clear cache and restart, under the file menu of IJ
I think
either "repair ide" or "invalidate caches and restart" under that menu yeah
in the meantime also consider switching to gradle
oh ok
thanks it worked
how i can update a gui (without the cursor of the player moving) or move my cursor in a specific position when opening a guy?
don't close the old one
and how i can update the amount of an item?
call set amount on the itemstack
ok ty
the problem is that the gui is already opened i'm doing something like a shop with a limited amount of items so i want that the number decrees for the player that just bought it too
have an inventory per player
then you can reorder and change the inventory as much as you like without having to close it and open a new one, except for changing the dimensions of the inventory, and maybe i think the inventory title
and how i should do something like that sorry?
do what you're doing now but instead of just having one inventory, have one inventory for each player
yeah just get the item in the gui and set the amount
i'm creating a inventory in a class for all my inventories and then opening it with the p.openInventory(shop(p)) then if i try to do the item.setamount in the function when i buy the item nothing change
someone throw that bot command with the inventory framework guide at him
?gui
thanks and sorry 🙁
@torn shuttle Hi, does your model thingie support Inverse Kinematics ?
My renderer... doesn't :D
LGTM
IK? not yet
ah sad
I've seen it being implemented elsewhere, didn't seem that hard
there's definitely a wealth of guides on how to do it out there
Hello everyone, who wants to help me with plugin creation? I dont know anything about spigot coding, but i have great idea
Ye I got the Fabrik thing there, but I just can't properly rotate the elements
there's a billion guides on ik out there
maybe take a look at them
pretty sure it's soemthing ai can do too since it's been done to death
you know what it can't do though
wfc
ask me how I know
I'll ask better, what is wfc :D
wave function collapse
Pls, can somebody help me? I want to create a great plugin, but i don't know how
we're clearly not interested
Aaah that thing
I tried once and failed horribly haha
?services if you want to hire someone
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
simple wfc is trivial but making it perform well enough to be feasible is difficult
mine performs real well actually
the thing killing me though is the antipattern bs I've been doing with it
like the concept of nothing spaces or world borders
tag-based generation and meta tags like no-mirror
also honorable mention to worldedit for being generally unpleasant to interface with
it's working though
she's a beaut
my wfc approach basically blocks-as-voxels; pixel art in 3d
I mean blocks are voxels but sure
since every block was its own point in the solution space with its own wave function to collapse, it was pretty difficult to get it to perform reasonably
this one generates that in about 10 seconds tops I think
including paste time
well within reason
in the end i had to make it approximate and just regenerate portions if it ran into a contradiction
also without causing lag because I put that sucker on its own workload task
wasted 2 hours at work trying to force an empty chunk into paper's chunk system
wsup nerds
why not just make a chunk with a pixel art display of your bank account status instead
Oh ye ok, that was stupidly easy
Just one ask to ChatGPT :D
Ty MagmaGuy hahaha
np
I think I only ever did it once for unity ages ago, I have no memory how now
very basic game dev stuff
or robotics
same thing powers articulated bots
?xy
What's not working and what are you trying to do
Thank you ❤️
alright cheers for that not patronising at all
VehicleBlockCollisionEvent never fires
when I google this it seems to be common knowledge
maybe it's just an issue with paper, but I'm wondering if there's a commonly known way around it
Well if you're using Paper, there's always the possibility it behaves differently
Known? Not here because this isn’t paper. People who use spigot use the event no problem so there wouldn’t be a need for a workaround
?whereami
the event is firing up correctly
I like your water slide. Can I use it as a schematic in my world? I will pay you in robux
i am currently in prison, i only accept packages of noodles as payment
oof, hope you havet been bummed too much there.
anyone know the event for feeding an animal?
Did you look at the javadoc?
I found one result for “animal feeding events” British Columbia:
Don-O-Ray Farm Adventure
Located in Kelowna, this family-friendly farm offers a petting zoo where visitors can feed goats, ponies, ducks, and bunnies. The farm is open on weekends and during school holidays. They also offer season passes for unlimited visits between May 16 and September 30.
https://donorayfarmadventure.com
-# This response was performed automatically. If this response was not accurate, type /help.
yeah couldnt find any
ooga booga
i guess PlayerInteractAtEntity
Probably entity interact? Not sure specific one for feeding
bro wrote spigot and doesn’t know 😭😭😭
F
||its the guy in his basement writing it||
jk
How do you know about me?
guy
its in the copyright info, chapter 8 page 8892 line 9003789
oh yeah i said guy not gal haha
cant be you jokes on you
Had no idea Mr Md iteration 5 discriminated.
i dont think there is one
the EntityBreedEvent has a getBreeder but thats already uhh... postpartum
In other words, after they make sweet love.
wait
you can probably make use of the Animal#isLoveMode() to cancel the event earlier if an animal is already fed
isLoveMode is a weird way to say isArroused.
do md's not start at index 0
oof good point
this md5 was written in lua
Look for at the javadoc
not there
i need the VaultServerData.stateUpdatingResumesAt
Hi, I don't know if this is the place to ask, but I have tried using BuildTools to build spigot-1.8.8.jar. I am running into issues while building though:
https://pastebin.com/QtjuKqHz
Depend on nms, cast world to craft world, get it's handle, optionally get the chunk, then get the tile entity from the chunk
I don't remember all of the method names off the top of my head but if you build against mojang mapped nms they will be fairly self-evident
yeah i ended up doing whatever this is
That also works
How I can make on screen animations like for example egg Hatching or just like a block that moves
Can you provide an example ?
Just for make you make the idea https://youtube.com/shorts/fcBwc1xECZk?si=15KU5D5BlOYsL3Td
Something on the screen that moves
This is not fucking roblox
Hahahaha ik I haven't found someone showing it on Minecraft that was the first idea that game to my mind
I remember someone did it on Minecraft but I don't remember where I saw it
Can definitely do it with display entities
yes but it would not be "tied" to the screen.
Spectate armorstand ez
and also, an egg isnt a model, so all you can pobably do is have a 2d egg sprite that rolls back and forth
Okay thanks
100% doable with a resource pack
you could send a title with a font and replace that font with the tiny animation u want
So if I want to make a farming plugin where you can select different crops and it only needs to be showed to the player that select it, I need to use Protocollib for fake block spawning right? So it will plant a specific area with that crop you select for the player.
the api has supported sending block change packets for a while
when empty hand right click fires? (i tried in PlayerInteractEvent)
if you're right clicking air with no item no event will be fired
The client never sends a packet to the server
When you make a plugin does the maven create a normal jar or a fat jar ???
Depends on your setup
why is there so little documentation on nms
Hopefully this is the correct place to ask; I was installing spigot via BuildTools and got this error:
[ERROR] Failed to execute goal on project spigot-api: Could not resolve dependencies for project org.spigotmc:spigot-api:jar:1.8.8-R0.1-SNAPSHOT: The following artifacts could not be resolved: net.md-5:bungeecord-chat:jar:1.8-SNAPSHOT (absent): net.md-5:bungeecord-chat:jar:1.8-SNAPSHOT was not found in https://oss.sonatype.org/content/repositories/snapshots during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of sonatype-nexus-snapshots has elapsed or updates are forced -> [Help 1]
The command I ran was:
java -jar BuildTools.jar --rev 1.8.8 --remapped
because it's Mojangs code
and it keeps changing
I really hate it
but the first thing is I need to get access to NMS 😭
can't even build NMS for some stupid reason, and im not sure why I CANT ACCESS spigot-api via the repository
You using buildtools?
Minecraft has updates?
yes on linux (if it helps, with java 8)
delete the cached failure from your m2
and let it fetch again
deleted everything literally in that folder
Could you send the full log of the first run with an empty m2
Do you mind if I ask what changes?
With packets
I dont want my code to be meaningless if I update my version
depends on what's changed about them
for example, in one update mojang arbitrarily made the delete entity packet hold a list of entity id's rather than a single entity id, to delete entities in bulk
why? i'm not sure
will something like it happen again? for certain
not to mention nms is massive
in what way specifically? god only knows
It would take a crazy effort to document it all
lol
not to mention it really isn't needed that much
you can usually just read through the decompiled code and figure out what things do
is that good ^ or should I manually copy from terminal?
?paste
Looking to paste something? Try a code block or one of the following websites:
- https://pastes.dev/
- https://sourceb.in/
- https://mclo.gs/ (best for server logs)
^^
update on this: i invalidated IntelIJ Idea cache and it somehow seemed to fix itself
code rating plz (you can ping me) https://github.com/jpwcguy/Fakeop
my fault
Could I pay someone to update a plugin for me?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Uses gradle, 0 out of 10
Bruh
does anyone know how to get the resulting item entity from a block break event?
You can't really
The event is fired before the drop is fully calculated
There a separate event you can use, let me check
declaration: package: org.bukkit.event.block, class: BlockDropItemEvent
I forgot dropItemNaturally existed
under the world class
that solves it thanks alot tho
I wanted to drop tnt randomly along with the result. I thought I could add it in the drop table but I can just spawn a tnt and drop it naturally
anyone know where i can still find net.md-5:bungeecord-chat:jar:1.8-SNAPSHOT? maven central only has 1.16+ and buildtools can't build 1.8.8 without it.
Thanks. Any clue why this is suddenly missing?
1.8 is not supported
sure but this was fine a couple weeks ago
my buildtools runs in a github workflow, they start with a fresh repo every time
then I guess it was removed
must be related to that sonatype sunsetting thing
probably
Hello, I'm making a Spigot plugin. Is it possible to lower the horizontal velocity of a player's jump?
jump length? or just the speed?
Jump length
put some weights in the player's pockets
GENERIC_MOVEMENT_SPEED?
1.20.1
ah thats unfortunate
because now we are obligated to say that its not supported
or smth like that
i think you can find old javadocs somewhere tho
helpchat has them
yes that
yeah no movement efficiency in 1.20.1
even more unfortunate
imagine having no support AND no feature
make a fork of 1.20.1 and add it yourself instead of updating to a newer version which has the feature to show dominance
make a custom client to go along with it to show double dominance
i think the slowness effect/movement speed attribute still applies midair
there'll be some latency related inconsistency, but if you apply an attribute modifier or the effect on the jump event you can probably reduce the jump length, or at least midair movement control
Yeah but it changes the FOV
it does but you should be able to use the movement efficiency attribute to counter that
🎮 Hey! I’m hugozz26, a developer focused on Minecraft.
✅ I create custom plugins, configure servers and also build Discord bots.
🔧 Affordable prices for server owners who want to level up their projects.
📩 DM me and let’s talk about your idea!
Nah
Invite me for gta6 beta bro
Does anyone know where I can find a list of all clientbound nms packets?
Why?
No but if you say what your goal is, people might be able to give a more helpful answer
Im trying to make player npc's
also nice to meet you 🙂
?protocol
and mappings.dev
but also just use Citizens, this isn't something that needs to be reinvented for the 1000th time
wait for 1.21.9 and use mannequins
or that if you only want to support newer versions
this
u dont want ur fake players to be ticking the world due to a bad implementation
citizens is goated
thats like everything else then basically
that is every single line of code ive ever written
ive never used the citizens api but the citizens2 plugin itself is goated
well as long as you don't question it then its fine >>
me omw to make citizens3 with a strong focus on writing the most infuriating code
My personal favourite approach is still to use libsdisguises and just disguise a mob type of my choice as a player, and then control it's ai through the api
Doesn't come with nearly as much baggage as citizens
BuildTools <1.12 are failing for me. The sonatype repo it references appears to be online... https://i.imgur.com/N9ORf24.png
shant be using versions that old anyway.. smh
BuildTools is supposed to support 1.8+
I discovered a temporary fix for buildtools. Third party repos, use with caution.
Declare ~/.m2/settings.xml with the following contents:
<profiles>
<profile>
<id>legacy-bungee-mirrors</id>
<repositories>
<repository>
<id>elmakers</id>
<url>https://maven.elmakers.com/repository/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>stellardrift-snapshots</id>
<url>https://repo.stellardrift.ca/maven/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>legacy-bungee-mirrors</activeProfile>
</activeProfiles>
</settings>```
manually installing the bungeecord chat jar will also work
it chokes on bungeecord parent when you do that
is the repo ok?
got status code 502: bad gateway
papers repo is odwn
mfw asking if Spigot's repo is down when it very clearly says it can't reach the Paper one

i cant read red text mb
i can only read errors when its a stacktrace
i also do not speak Could not HEAD
Could not HEAD is a pretty awesome error message
also i did just realise that this is the spigot server and i asked about paper
i swear to god if anyone whereami's me
?whereami
time to boycott hypixel
so no head?
I have a question when it comes to Runnables. I’m new with using runnables and the api altogether. So would having many runnables cause my plugin to lag the server?
It depends
hmm
A runnable is basically just an interface that defines a method named run exists, takes no arguments and returns nothing
And whatever you define its implementation as, is what is run
If you're running heavy code, then yeah it might lag
in the code block of the runnable?
It's like asking "if I give my employee a task will they take long?"
Yup
Whatever that runnable's implementation is
it's obviously a lot more complicated than this but at a lower level a scheduler is just
public class Scheduler {
public void addTask(Runnable task) {
...
}
public void tickTasks() {
for (Runnable task : getTasksForCurrentTick()) {
task.run();
}
}
public Collection<Runnable> getTasksForCurrentTick() {
...
}
}
tickTasks is then aligned to the game's tick loop
Which is basically something like
public class TickLoop {
private static final int TICKS_PER_SECOND = 20;
private static final long TICK_TIME = 1000 / TICKS_PER_SECOND;
private long startMs;
public void tick() {
this.startMs = System.currentTimeMillis();
doTick();
long elapsed = System.currentTimeMillis() - startMs;
long timeLeft = TICK_TIME - elapsed;
if (timeLeft > 0) {
sleep(timeLeft);
}
tick();
}
public void doTick() {
// tick scheduler and world and whatever
}
}
would this cause lag
What would?
calling the run method on each task
It depends on what the task is
An empty task will basically do nothing when run
something heavy will do a lot when it's run
What do you mean when you say “define its implementation”, are you trying to say there is different implementations of Runnable?
Yup
The idea of an interface is that you're defining how you want to trigger behavior without knowing what that behavior is
Or in other words, a contract for a class
That defines what methods it'll have
Yes as every method in an interface is abstract
Each class that implements that interface, in turn, implements those methods
and defines their behavior
Here's an implementation
public class TextPrinter implements Runnable {
private final String text;
public TextPrinter(String text) {
this.text = text;
}
@Override
public void run() {
System.out.println(text);
}
}
It would run the block of code every time run is called
But why would that be useful
This is just a silly example
I often implement runnables to define specific tasks as its own class
For example
Ahh ok
public class DebugClaimOutlinesTask implements Runnable {
@Override
public void run() {
if (!PluginLogger.isDebugging()) {
return;
}
for (GuildData guild : CorePlugin.getInstance().guildManager().getLoadedGuilds()) {
for (GuildClaim claim : guild.getClaims()) {
Color color = pickColor(claim.getClaimId());
Cuboid bounds = claim.getBounds();
World world = claim.getCenter().getWorld();
for (Point3D point : bounds.renderOutline(0.2)) {
world.spawnParticle(Particle.DUST, new DirectLocation(world, point.getX(), point.getY(), point.getZ()), 1, 0, 0, 0, 0, new DustOptions(color, 1f));
}
}
}
}
private Color pickColor(UUID claimId) {
Random random = new Random(claimId.getMostSignificantBits());
return Color.fromRGB(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
}
Ok so if you implement the runnable interface you have to have the run method in your class correct?
Yup, the Runnable interface forces me to
And that's by design
Whatever method takes a runnable doesn't need to care about what code is running
It just needs to know how to call it
You can also make your own methods that take runnables
For example
public void doSomethingWithACallback(String input, Runnable callback) {
process(input);
callback.run();
}
Runnables are basically just a way to represent a function call as a variable
And other functional interfaces to the same, but for different parameters and types
For this block of code, why are you implementing the Runnable, I am curious about its purpose for this specific block of code
Read and figure it out, the code's pretty clean
I mean it’s just that I don’t really understand why you’re using the run method for it
What else would I be using?
For me I thought Runnables were meant to be used when it comes to Timers/delay and whatnot
So would you be able to have the same sort of outcome without the use of the Runnable implementation in this block of code
I wrote the runnable implementation
I think we need to backtrack
Let's say you have a plugin that gives players rewards when they vote
Yes
And you have different kinds of rewards, such as running a command, giving an item, adding currency through Vault
mhm
The beginner approach would be something like this
public class CommandReward {
private String command;
public CommandReward(String command) {
this.command = command;
}
public String getCommand() {
return this.command;
}
}
public class ItemReward {
private ItemStack item;
public ItemReward(ItemStack item) {
this.item = item;
}
public ItemStack getCommand() {
return this.item;
}
}
...
private List<CommandReward> commands;
private List<ItemReward> items;
public void award(Player player) {
for (CommandReward command : commands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.getCommand().replace("%player%", player.getName()));
}
for (ItemReward item : items) {
player.getInventory().addItem(item.getItem());
}
}
Now this works and might be okay for some people
But we can do better
Hmm
For example, we could define a common interface among all rewards and pass the actual logic from the "award" logic to each implementation
So that the CommandReward class handles running the command
the ItemReward class handles giving the item
etc
But for that we need to say that "no matter the reward, it'll have a award(player) method"
in other words, we need to specify common behavior across every reward
Do you mean part where you’re giving the item or running the command on the specific player
Yup
Awesome
So it'd look a bit like this
public interface Reward {
void award(Player player);
}
public class CommandReward implements Reward {
private String command;
public CommandReward(String command) {
this.command = command;
}
/* We don't need this anymore
public String getCommand() {
return this.command;
}
*/
@Override
public void award(Player player) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", player.getName()));
}
}
public class ItemReward implements Reward {
private ItemStack item;
public ItemReward(ItemStack item) {
this.item = item;
}
/*
public ItemStack getCommand() {
return this.item;
}
*/
@Override
public void award(Player player) {
player.getInventory().addItem(item);
}
}
We can also merge our handler class
private List<Reward> rewards;
public void award(Player player) {
for (Reward reward : this.rewards) {
reward.award(player);
}
}
Got it
A single interface not only defines common behavior among classes but also results in cleaner, more organized code
Our handler class does not need to care about the different types of rewards that exist and this even opens the possibility of having plugins add their own kinds
like pet exp, rankup levels etc as rewards
It's up for each implementation to decide what it does
Yes 👍
Now, Runnables are an interface like any other
And if you boil it down it looks like this
public interface Runnable {
void run();
}
Okay
I can make a class that implements it and sends a message to everyone
Or spawns some particles
Or updates a boss bar
Or runs some code
Whoever I'm passing that runnable to, doesn't care about what it does
It just knows when to call it
I just don’t see how that’s better than making your own method to for example update a boss bar
You can definitely make a runnable that just calls your method
