#help-development
1 messages · Page 819 of 1
do they not? I thought they did well not the blocks themselves but their states
Well that's just it. Bukkit's Block is essentially a wrapper around a position that fetches from the world
but like you can have more than one instance of Block whereas that's not the case in server internals
The server stores everything about a block just as a single integer 👀
how is that possible? I didn't think their were enough bits for that
that's not included block entities
well cramming everything into 32 bits seems
Bukkit's BlockData is analogous to NMS's block states
oh okay
Yeah I'm excluding tile entities
Those are stored separately lol
I was about to be like wtf
It’s just a big map of states iirc
If a player smacks an armor stand with a knockback weapon, is there a way to detect when the stand stops moving? Off the top of my head, I could theoretically use a BukkitTask and check every tick if the armor stand moved, and when it goes 2 ticks without moving, it's stopped? There's not an event for armor stand movement?
no event
Well it is an entity. So should be able to use entitymove event
If not, just use a task to check its position. Should be able to utilize pdc to store position for this. Then its a matter of checking its recorded position with current position
There’s no entity move event
how do i see if a shield has a banner on it
Hmm. Then maybe we can create one lol
Frost prs spigot??
Frost have you ever contributed to CB? Weren't you a forums mod or something back in the day
I was a bukkit dev staff member not a forums mod
Basically i got to approve or reject project pages and check jars that were submitted lol
Ahhh
I did try to contribute to CB but evilseph and wolve both rejected my ideas before i could submit them as prs and so i never bothered to try and contribute after that.
Ahhh
Tbh I'd say go for an EntityMoveEvent tbh doesn't seem like it'd be a ton of work.
Tho it'd be a very hot event
I dont think it would be as i think there is a packet for when entities move
And if so, havent checked, then its just utilizing what is already there
Yk that'd make sense lmao
Tbh if you'd be interested in pr'ing it'd be a good first I can't really see it being rejected as it's got obvious use as API
I could try. I hate messing with patches though
In fact might need to restructure api though
Pr to CraftBukkit you don't have to mess with patches just run applyPatches and makePatches
Make a generic move event that player and entity extends from.
Spigot is where it gets weird imho
Lol
Or should there just be entity move event and player extends from that?
I guess it dont matter and someone else can fix it lol
Well you don't really need to do that as PlayerMoveEvwnt makes the most sense as a PlayerEvent
Well typically when we have two events like this they either extend a generic event or player extends from the entity
feel like this is a get it down figure it out later type of thing xD ¯_(ツ)_/¯
Lol that is why i said i guess someone else can fix it later
I'd say if you don't plan in doing it make a jira issue and someone will prob get to it
I think the better approach is the generic event since neither of the events come from the same place
Yeah probs
Why ConfigurationSection.getValues instead of getMap
Hello, BukkitScheduler#runTaskTimer will run in the main thread right? So if i have a queue of tasks to be executed in a specific interval, there should not be any problems if I add or remove Elements to/from that queue, as Long as its always done in the main thread as well, right?
Well if you iterate upon that list and remove elements you'll have ConcurrentModificationException. As long as you don't do that it should be fine
But either the task Timer accesses the queue to get the next Element or in some other Part of the Code an Element ist added or removed. So there cant be parallel access since there cant be queue access while the task Timer polls. (As Long everything is in main thread)
Like i just wanna know if my theory is correct that there cant be parallel Access to the queue when adding, removing and polling is all done in the Same thread which would mean that the normal task Timer is always being executed in the main Thread as well
runTaskTimer is ticked on the server thread and the callback is also invoked on the server thread
Meaning its all single threaded
So yes its fine w whatever unthread safe data structure u may have
completely different if you start using runTaskTimerAsync
Yeah okay. To ensure that my methods are only called on the Main thread, can i cache it on startup with Thread#currentThread and then compare it on each method call or is there a better way achieving this? @ivory sleet
Does anybody know, i need add which librarys for proguard? I think spigotmc and spigot api 1.18.2 but i dont know i can download they in where
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Server.html#isPrimaryThread() @old cloud btw, tho I highly doubt you need it
To ensure that tasks cant be added/removed by another thread because my design is Not thread safe since it really doesnt Need to be imo
Ah thanks 👍
no dont do that
all methods can be invoked async by default
Does that mean we should take precautions as a means of reassurance?
No
Just write big ass bold letters in the documentation that it is a nono
if something by nature becomes exposed to concurrent modifications, then by all means add necessary thread safety
Otherwise just let it be
.
I have done that load distribution thing in one static class. My queue there is not Thread safe. So if someone (for whatever reason) schedules a (load distribution)-task from another thread, then dumb shit might Happen. Thats just what i try to prevent
Ok
Well yeah because its a public method that adds a task to a queue
I know
No, I mean, do you explicitly modify the queue on more than one thread?
Nope
Then don’t take any thread safety precautions
I mean sure if you write an api for the entire world to consume, and the api becomes very large, having small checks here and there can be reasonable
But in your case, dont do that
Ok so you mean its not my problem if someone might use it wrongly in the future?
You know exactly which parts if your program that will be interacted by multiple threads
definitely not your problem
Yeah, maybe im thinking too much like „what could happen if someone will use that Class in the future“
i mean you can state something like in the javadocs of that class that the underlying queue is not by default thread safe
Yes, I will do that. Thankyou for the help and the advice 👍
Awesome :)
Yeah well when it comes to concurrency its hard
Usually we try to identify early on what resources will be exposed to a concurrent environment, such that we can properly plan our design around that
Yeah I mean I knew that i would Never Need to access the thing async, but i was really Like thinking of other ppl
But I think a Note in my docs is a good compromise
Yea good enough :)
prob not
anyone knows here how I can remove this?
some ItemFlag right?
nah
probably potion effects
u reckon
imma give it a try sec
didn't work
this.itemBuilder = ItemBuilder
.builder(Material.LEATHER_BOOTS)
.modify((meta) -> ((LeatherArmorMeta) meta).setColor(team.getTeamEnum().getColor()))
.name(team.getTeamEnum().getChatColor().toString() + ChatColor.BOLD
+ Language.getInstance().getTeamName(team.getTeamEnum()))
.flags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
I tried these flags
Try all of them
shouldnt be
oh yeah its not in 1.14
yeah i should've mentioned that I am using 1.14
it was added earlier this year
probably nms
mhn okay
i made a json file using blockbench with custom model data but its not my model when i give it to myself on game
@remote swallow i remember u know about textures
no clue
have u used blockbench
i made a block model there then i put custom model data on andesite's json file with model of the block i made on blockbench but somehow model is not chaning
hi! i need help, is there a way to check if player can break? using worlguard api
Check if block break is canceled
and set prior to lowest
So it runs first??
Wdym
Lowest priority runs first
Cause it’s lowest priority
It makes no sense to me
only the last change to the event actually changes it so it is
i need to check in a diffrent way, cause i want to cancel armorstand damage if player can't break in that region
Ask on worldguard discord
okay ty
Heya, I could need some help :)
I want to get the next X amount of chunks in the direction the player is facing. For this, I've implemented Bresenham's line drawing algorithm. However, I get a, somewhat, incorrect result.
The first image depicts a line being drawn from the centre of the chunk, this normally works fairly well.
The second image depicts a line being drawn from the edge of the chunk, this is pretty much always incorrect.
In both instances, the yellow square depicts a chunk which is not considered by the algorithm. This is very annoying since it is paramount that all chunks are considered when the line passes.
For reference: The blue squares are the chunks correctly calculated by the algo and the black squares are just radii around the centre chunk.
Here's the code which I now have:
final List<int[]> result = new LinkedList<>(); final Location clone = loc.clone().multiply(1 / 16f); clone.add(clone.getDirection().multiply(distance)); double x0 = (loc.getX() / 16), z0 = (loc.getZ() / 16); double x1 = clone.getX(), z1 = clone.getZ(); double dx = x1 - x0; double dz = z1 - z0; int steps; if (Math.abs(dx) >= Math.abs(dz)) steps = (int) Math.abs(dx); else steps = (int) Math.abs(dz); double xIncrement = dx / steps; double yIncrement = dz / steps; double x = x0; double z = z0; for (int i = 0; i <= steps; i++) { result.add(new int[] {((int) Math.round(x)), ((int) Math.round(z)) }); x += xIncrement; z += yIncrement; } return result; } ```
The part: final Location clone = loc.clone().multiply(1 / 16f); just ensures that the chunks are viewed as a 1x1 pixel, instead of 16x16.
Because the higher the later, thus you can override earlier changes such as result and cancellation state
Well it's called lowest priority because it runs first and can be overridden by higher priorities
Thanks for sniping my answer xD
soz lol
😛
I have installed BuildTools, but how do you now change so that you can see the code as not obfuscated? So you kind of have to change
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
Or something to make it work
?nms
that was the website I started from but didn't quite understand what to do after installing the build tools
modify ur pom
Yes, I have done that as well, but is there a connection needed between builds tools and pom.xml?
add everything it shows updating any 1.18.2 to whatever version your on eg 1.20.2
thats done automatically as buildtools installs to your maven local
I think the calculation of the step might be incorrect. As in, the for-loop just steps over the chunk?
But it's still obfuscated code :/
?paste ur pom
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/
The only thing I had "forgotten" was "<classifier>remapped-mojang</classifier>" but when I add it net.minecraft disappears
did you run buildtools with --remapped
Yes, I had it in another folder on my computer called type server 1.20.2
Yes that was what command i run
did it complete fully and create spigot-1.20.2.jar in the same folder as the buildtools.jar
if anything you ran buildtools for 1.20.2 instead of buildtools for 1.19.4
when you need remapped for 1.19.4
or they used the incorrect jar
IE, ran for the correct version but wrong jar used lol
well if net.minecraft stops existing when adding the classifier and they say called type server 1.20.2 im gonna guess it was ran for 1.20.2 accidentally
If I download builds tools for 1.19.4 and my plugin should support 1.20.2 - 1.19.4 how can I do?
Also if I use nms and basically my plugin is a "Spigot plugin" does it also work for paper servers?
if you need to support multiple versions with nms you either have to use reflection or you need mutlimodule
and it should work with paper untill they stop relocating craftbukkit and you then need spigot nms modules and a paper nms module which doesnt really work on maven
Yo guys, I've seen that you can generate three different kind of jars, jars with your program, plugin, whatever, jar with javadoc and a jar with sources. What are these sources?
The source code
Oh
And you can make your own package qualifiers
Javadoc and sources are required for maven central, and are used by your ide for example when looking through a dependency's code
Interesting
the cool part is instead of providing a separate source jar, you can just combine the compiled and source together into a single one. Think you can technically do this with the javadoc as well but I never tried it
Bro
Do you know i can found bukkit lib 1.18.2 for proguard in where
proguard is just for generic java apps not specifically spigot
proguard or any other obfuscator is mostly useless to use for java anyways. Exception is if you need some weird hack optimizations that some obfuscators can provide but like its neglibile that I doubt any plugin would ever come to a point in requiring such things
Compiled code is already obfuscated asf
takes like 2 seconds for me to open recaf
Can I somehow listen to region creation with Worldguard API?
I also asked on the EngineHub server but perhaps somebody here knows the answer as well
Its can decompile in 5 second.
I know. But this is better than other free obfuscators. (I think)
so add the required maven plugins to obsfucate
Do you can say it if you know?
what would be better for saving lets say for example: player sethomes
Json or yml?
json i think
It depends on your personal preference tbh. I prefer JSON
Would it not be extremely laggy if I have hundreds of player sethomes?
You can have more than one file to avoid loading it all at once
Like when a player joins
how do i get the block a player is looking at
Ray trace
shudders
I assume I have to load the file async or something
i dont know how to use raytracing
to not cause lag
One sec I'll get a snippet
Right now I'm thinking of the best way to migrate my playerdata from skript to java - and the best solution that I came up with so far is to load it all into a json file, and then put it in my java plugin
final RayTraceResult result = player.rayTraceBlocks(5);
if (result == null) return;
final Block block = result.getHitBlock();
if (block == null) return;
That's basically it
Can I listen to region creation with Worldguard API?
this works, 5is the range right?
BlockData
Specifically ageable
ohh
It creates shaded jar?
i was doing block instanceof Ageable
instead of blockdata
yay it worked
thank u all
It dont worked. it gaves error
Warning: there were 268682 unresolved references to classes or interfaces. [proguard] You may need to add missing library jars or update their versions. [proguard] If your code works fine without the missing classes, you can suppress [proguard] the warnings with '-dontwarn' options. [proguard] (https://www.guardsquare.com/proguard/manual/troubleshooting#unresolvedclass) [proguard] Warning: there were 422 unresolved references to program class members. [proguard] Your input classes appear to be inconsistent. [proguard] You may need to recompile the code. [proguard] (https://www.guardsquare.com/proguard/manual/troubleshooting#unresolvedprogramclassmember) [proguard] Unexpected error [proguard] java.io.IOException: Please correct the above warnings first.```
I would honestly not bother with obfuscating your code. 99.9% of the code for spigot plugins is not worth obfuscating. And
it just makes your life harder when it comes to supporting your plugin.
np for me
What exactly are you trying to obfuscate?
Discord plugin. But very advanced. It doesnt finished yet but im trying obfuscate for future
I want to obf my code. Do you know anything?
Im trying maven proguard but ir gaves error
Proguard is the most common one i know.
But i would recommend to not obfuscate your code.
How do you expect people getting access to your code in the first place?
Depending on how you deploy your bot, the user never sees a jar.
Idk. I said. Im planning do it pl advanced. Thats why i want obf it
the error gives advice for fixing it
proguard is not something you can just plug in and go, you actually have to configure it beforehand
I'm sorry, but is obfuscation just an extra layer of ✨ complexity ✨ you want to have?
As smile mentioned, the user might not even have access to your jar
So you're obfuscating just to make a point
There is nothing advanced about obfuscating... But your go ahead and do you.
Disable minimizing from proguard and try again.
sad
worldguard only has one event
however there is only one way to create a region and that is with a command
well aside from a plugin using the api to do it
but there is no event for that
Yeah I've done a bit of investigation and looked into the source code
The only way I can do it is by listening to the command preprocess event which I'd rather die
So I'm contacting the dude who's commissioning me to see if an alternate solution is possible
Idk. Im only want to obf my code for people dont copy it etc.
If I really want to copy your code I'll spend a bit of time deobfing it.
obfuscation isn't going to stop that
You don;t have code which anyone will want to copy.
All the code in the existence of coding is copied from somebody lol
You're implying that you're going to be writing the most unique project ever
however copying isn't really the issue, second it isn't necessary to deobfuscate to copy code either
obfuscation only changes the method, variable and class names
not how the actuall code works
No
Theres only one reason to obfuscate and thats to maintain a copyright.
Im not a best
So why would anyone want to copy your code then lol
anyone who has code worth copying that they don't want copied typically don't release such code to the public to begin with
To prevent idiots who have no knowledge of coding etc. from just doing copy paste.
they could still copy and paste as I explained above
obfuscation doesn't change how the code works
if they have no knowledge of coding then copying and pasting a couple snippets will do nothing lol
Because they have no idea how to chain those snippets into a functioning program
And the only way that they can copy your code into a working program is, well
By copying your jar
Which you cannot prevent if you're distributing it
They are can learn easily
you are really overthinking this
And thus
and worrying about nothing
They don't need to copy your code
Because they will, allegedly, learn easily
And thus be able to code by themselves
Question to you: if you have a problem while coding that you can't resolve, do you go and ask somebody for help, or do you decompile jars and take code from there to solve your problem?
Im trying to mean pom, file ways and plugin.yml.
Why would literally anybody copy your pom or plugin.yml
That's literally the dumbest thing to copy and the easiest thing to understand
no no.
And this does not answer my question
im trying it on this message
Please use a translating service I do not understand what you're trying to say
First me can try write to anybody but me search jars in the any time
That mean both
Well that is highly weird
If I would assume that like 0.5% of the people here decompile jars to solve their problem I'd probably be overexaggerating accidentally
You need to get familiar with the codebase, find the snippet that you need, and understand how to integrate it into your code
Why would ANYONE go through that instead of looking up their problem or asking on the forums
Think of it. I'm out of this discussion. Obfuscate your code if you want, it will do absolutely nothing but waste your time
My message "Im trying to mean pom, file ways and plugin.yml." was meant for replyed message. Personally, file ways, pom.xml and plugin.yml are easy to learn
^ nonsense. English but not.
Yea. Some.
I think i need learn english 💀
the part I know doesn't seem to be enough lol
only people I know who do this are the ones who made the jar to begin with and just happened to lose the source for it XD
Yep lol
your sentence is confusing TheRoborkedi
lol
yea. some ☠️
yamlconfiguration isn't too hard to learn
Yea im using yamlconfiguration
probably "already"
Yep
😵💫
i have seen people use alr for alright
._.
it can probably be both in context
Yes
if its just alr its prob alright if ifts got stuff before its probably already
possible
Yeah but usually it's "alright" in my experience
makes sense
I'm injecting the player's channel handler using raw nms. But in 1.20.2 my NetworkManager field search in the PlayerConnection class returned that there is no field like that. Help
anyone know why the fuck it says its always 1 or higher
oh nvm
div has priority
ofc
sht
Oh, wow, that's niche. I was wondering what operator precedence had to do with anything but I guess if it was zero you'd get an arithmetic exception lol
What is that syntax at the end here?
yup Intelli recognizes that the number most be positive in order for the code to not malfunction
lambda
Lambda
Desperate for _ being officially supported as an unnamed param
yeah
Ahh, I overlooked Predicate<T> at the start.
Thaught it was some cool highlighting for returning true
It's on its way
uSe AlL tHe PaRemEtErS 😠
Mhn
ima still be stuck on java 8 tho
at least for this library
lol sucks2suck
Honestly just upgrade anyways best practice even for libraries
nah i want to support 1.8
Unless your target audience only can use java 8 then you're screwed
i made it for my own 1.8 server
pretty sure orby supports legacy
@glossy venture any reason you aren't forking spigot?
ah
for
your server
java 8+ support?
Yeah @worldly ingot until clients adapt it we already have AI coding for us
why would i fork spigot
because 1,8 is mad outdated if you're going to be on it you might as well fork it
whats better: multiple hashmaps, or one hashmap with an object of multiple values?
gives you better control for bug fixes etc and exploit patching
also i have no idea how forking works especially with patches n shit
its jsut a server i made bc i was bored no reason to put so much effort into it for me
Depends on your use case but if you find yourself mapping two different values to the same key, you should probably make an object and use one map
Honestly the cost of hashing, hash collision and tables greatly outweighs a simple data wrapper, so go with the object imo
@proud badge
In my case its a sethome
Isn't sethome just a one to one relationship
Player (ID) to location
X, Y, Z, World
well if you ever release to the public its something to think about. Seeing as 1,8 is vulnerable
Yeah maybe
just use Location
thats already an object which represents that
Yea that or block lol
Create one map that stores another object as a value, which in itself is representing a map I would say. Alternatively you could use a SetMultimap with values each being a data object, that contains the location and home ID whereas the hashcode returns the hash of the ID so you can retrieve and test against the ID at O(1)
That might lead to a.equals(b) evaluated true even if A's location differs from B so be careful
where can i find the 1.19.4 documentation
You can usually just take a look at the latest Javadoc
wouldn't that be innacurate tho
Not much
not super innacurate
okk
if you really want the 1.19.4 Javadoc you'll need to make it yourself with BuildTools
spigot API does not change much between versions
well are the old documentations lost tho
HelpChat might host them
No you just need to generate it
yh i heard from u using BuildTools
anyways thanks
btw do i need nms to make custom mobs
ye
You don't need nms to give custom names to mobs
should accessing something from a json be async?
but what if i want to spawn them with items
without modifying the normal mobs
still not needed
how which one do i have to access
when you spawn mobs you can set their name, equipment and even adjust their health/stats
just with the API
i can't find it
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/RegionAccessor.html#spawn(org.bukkit.Location,java.lang.Class,java.util.function.Consumer)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/LivingEntity.html#getEquipment()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Nameable.html#setCustomName(java.lang.String)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.html
When people say World#spawn do they mean World.spawn()?
can somebody help me with my code?
package me.uwunugget.morph;
import org.bukkit.plugin.java.JavaPlugin;
public class Morph extends JavaPlugin {
@Override
public void onEnable() {
getCommand("morph").setExecutor(new ());
}
}
because # is used in Javadoc links
the
getCommand("morph").setExecutor(new ());
``` part isnt working
You can also do what Conclure does; use :: instead
Wth is that
new ()
???
yeah what do i need in that part?
This looks like a learnjava moment to me ig
Yeah
i basically never made a plugin wich uses commands
That should be super basic stuff
Just pass it an instance of your command class
Why
because nobody is helping me?
Olivo literally told you the answer
he did tell you. Its just your knowledge of Java is too low to understand the answer.
Which translates to LEARN JAVA
E
You shoudl at the minimum start with a first plugin tutorial.
i did with the kody simp tutorial but its basic af
like
then follow a more advanced one
"hOw To sTarT IntelliJ IDEA"
How is this relevant to what I've said
i know the java basics
I see
i can't seem to find World#spawn
get teh World object you want to spawn the mob in
i mean the docs for it
they were linked above
declaration: package: org.bukkit, interface: RegionAccessor
^
Oh yeah with the consumer is better
i get this error if i start my server with the plugin i fixed every issue:
18:01:56 ERROR]: Error occurred while enabling morph v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:255) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at me.uwunugget.morph.MorphCommand.<init>(MorphCommand.java:5) ~[morph-1.0-SNAPSHOT Kopie 2.jar:?]
at me.uwunugget.morph.MorphCommand.onEnable(MorphCommand.java:9) ~[morph-1.0-SNAPSHOT Kopie 2.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:422) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Don’g create a new version of javaplugin
how can i fix this 😭
you can't create a new instance of your main class.
i have 2 classes
only your main class extends JavaPlugin
Remove “new MorphCommand”
Or whatever extends JavaPlugin there is present on the second class
remove extends JavaPlugin from your MorphCommand class
and pass an instance from your main when you create it
in the main i have:
package me.uwunugget.morph;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class Morphing implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be run by a player.");
return true;
}
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("morph")) {
if (args.length == 1) {
try {
EntityType entityType = EntityType.valueOf(args[0].toUpperCase());
player.getWorld().spawnEntity(player.getLocation(), entityType);
player.sendMessage("You have morphed into a " + entityType.toString());
} catch (IllegalArgumentException e) {
player.sendMessage("Invalid entity type.");
}
} else {
player.sendMessage("Usage: /morph <entityType>");
}
return true;
}
return false;
}
}
```in the second class i have:
```js
package me.uwunugget.morph;
import org.bukkit.plugin.java.JavaPlugin;
public class MorphCommand extends JavaPlugin {
@Override
public void onEnable() {
getCommand("morph").setExecutor(new MorphCommand ());
}
}
new MorphCommand(this)
bro i meesed up with the `s
What are you reading
wdym by that?
um
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
yeah you shoudl be calling new Morphing(this) not new MorphCommand
ur naming is certainly weird
Morph
so like this? getCommand("morph").setExecutor(new Morphing(this) ());?
no
remove ()
tf
?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.
https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
so like this? getCommand("morph").setExecutor(new Morphing(this)); if this is wrong ill eat a broom
then in a constructor in Morphing you need to set a field to the plugin instance
yes this is correct
kk ill try it now
getCommand("morph").setExecutor(new Morphing(this));
^
required: no arguments
found: MorphCommand
reason: actual and formal argument lists differ in length
```i get this as error-
then in the class constructor you add this.plugin = plugin;
.
IntelliJ recommends putting this in Morph:
public Morphing(MorphCommand morphCommand) {
}
idk if i should do it tho
JavaPlugin plugin;
public Morphing (JavaPlugin plugin) {
this.plugin = plugin;
}```
You REALLY should go take some Java course
oh
We shouldn't have to spoonfeed you basic Java code
you then have access to plugin in your Morphing class
wait imma try it now
again-
an error from the server log
[18:14:35 INFO]: Enabling morph v1.0-SNAPSHOT
[18:14:35 ERROR]: Error occurred while enabling morph v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.uwunugget.morph.MorphCommand.getCommand(String)" is null
at me.uwunugget.morph.MorphCommand.onEnable(MorphCommand.java:9) ~[morph-1.0-SNAPSHOT Kopie 4.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-307]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:422) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1100) ~[paper-1.19.2.jar:git-Paper-307]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-307]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[18:14:35 INFO]: Disabling morph v1.0-SNAPSHOT
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.uwunugget.morph.MorphCommand.getCommand(String)" is null
commands: /morph so this in plugin.yml to my knowledge
wrong syntax
?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.
commands:
morph:
description: "morph command"```
._.
check it but that should be correct
org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here
in 'reader', line 10, column 14:
description: "morph command"
^
i dont see anything which is wrong
as yall know entities ai gets taken over by the one riding it, so what happens if i take a chicken jonkey and put an armor stand on top? will the zombie still be in controll?
?paste your plugin.yml
give us your whole yml
yh its wrong
_ _
let me give you a correct version
yep
i wonder why
because thats how yamal works
you have sections
that have sub sections
that can have subsections
...
i just did /reload confirm im too lazy to shut down my server restart my server, force java to start the process
i hope it wont destroy my server
the only thing that can happen is that plugins dont load propperly
sometimes it will work. Others the server blows up
99% of the time its fine if your plugins dont do certain stuff
still wouldnt recommend it
Does anyone know if there is a way to start the return of a trident to it's owner?
E
"start the return"`?
bro /morph PIGjust summons an fucking pig
wtf is this
its suposed to replace it with the player
tf
that does not work lmfao
u cant just replace the player
um you asked about doing custom mobs, like name, items and attributes
like if it is enchanted with loyality the trident will return to it's owner as soon as it collides with a block or an entity but I want it to return after a specific time
no shit sherlock
ahh
are you trying to make the player LOOK like a mob?
nuh uh im switching back to datapacks
yeah?
wtf you thing is a "morph"
good luck with that
find the reason it returns normally and artificially recreate it
like if its velocity set the velocity to 0
NMS
most basic way would be to spawn the mob and make the player ride it
and also
making the player invisible
if you keep being so toxic no one here will help youi anymore
i would think the best way is to use datapacks tbh
i wanted to make an command for it but
if you can do it in datapacks go for it
i have like 2 years experience for it
I've not messed with datapacks
then why go to spigot
not many here have as we all write plugins
doing something like morphing propperly requires NMS which is like
the most complicated stuff around here
NMS = a pain and version specific
i fr tought you just said MSG
net.minecraft.source = nms
yeah ill go for datapacks then
maybe later i might need help for UI like some sort of chest UI with clickable stuff
Isn't it more like net.minecraft.server
y
not yet
thx
I tried to give the armor stand an AI now, but it's still not working. It is only working as long it has Gravity and is not marker. Is there any way to set a Velocity for an armor stand that is marker and has no gravity?
no
bruh
0 to 53
why's that
size is 54 or 53
because Mojang
Teleport it using a scheduler
What the event is to get if player started breaking block?
.
none
packet listening only
oh...
i need to break block if player is breaking it a lot of time..
it's only packets and nms?
Lmao
declaration: package: org.bukkit.event.block, class: BlockDamageEvent
Should be what you're looking for my friend
when was this added
We also have if you need
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockDamageAbortEvent.html
declaration: package: org.bukkit.event.block, class: BlockDamageAbortEvent
then help me with this
Can't look on my phone
Ty
for some reason there's no field like that in 1.20.2
if(e.getClickedBlock() != null) {
if(CustomConfigSetup.getFileConfig().getList("locs").contains(e.getClickedBlock().getLocation())) {
Bukkit.getPlayer("limpeex").sendMessage("WORKS2");
player.openInventory(InventorySetups.MARKET);
}
}``` This turns false
While i set it up on onEnable here
public void addLocs(Location loc) {
ArrayList<Location> set = new ArrayList<>();
set.add(loc);
CustomConfigSetup.getFileConfig().set("locs", set);
CustomConfigSetup.save();
}```
You don’t set anything there
wym
You only add one location and no more
why
Any way to obtain logout location from the player.dat?
Sure
{
super(((CraftWorld)world).getHandle());
List goalB = (List)getPrivateField("b", PathfinderGoalSelector.class, goalSelector); goalB.clear();
List goalC = (List)getPrivateField("c", PathfinderGoalSelector.class, goalSelector); goalC.clear();
List targetB = (List)getPrivateField("b", PathfinderGoalSelector.class, targetSelector); targetB.clear();
List targetC = (List)getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityIronGolem.class, 1.0D, false));
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntitySpider.class, 1.0D, true));
this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false));
this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
}``` Does anyone know anything about Pathfinding? My entity has these goals but just walks around like a regular Zombie, doesn't attack players
whats the exact method to add a value to an array, idk why but I cant seem to find this anywhere on the internet
array_name[index] = value
Use a List
or resize it and set the last index
ok thx
if u want a mutable array
do I use StringBuilder or something if I want it all in one message?
StringBuilder can be more performant from what i’ve heard (specifically in for loops / many concatenations)
big disagree on it being more convenient
String#concat 
Yep
I mean JIT and even the jvm does a lot of things to optimize strings in particular
but the big point is to avoid throw away object creation when using use string builder in iteration flow since it uses system copyarray under the hood which is fast and neat
Just a quick question - I got a ton of coexisting projectiles on my server and all of their movements are individually controlled by a Bukkit Runnable. Would it be more efficient if I controlled all of their movements by only one Bukkit Runnable for all of them?
it gives this locs on debus
How many runnable instances darth mango?
and im clicking the same location
depends on how many projectiles are there at the same time, sometimes over a 100
Go with a single runnable
alright thanks
I think its fair to compromise on that
How to make velocity of spawned item like from drop of the block?
But the single runnable would run permanently while the individual runnables would only run for the view seconds the projectil is living. Still a single runnable?
You can benchmark it maybe?
Having one runnable is always a good idea ig
java.lang.IllegalArgumentException: Cannot spawn an entity for org.bukkit.entity.Item
World world = block.getWorld();
Location blockLoc = block.getLocation();
Item item = (Item) world.spawnEntity(blockLoc, EntityType.DROPPED_ITEM);
item.setItemStack(new ItemStack(Material.BARRIER));
Use consumers for spawning entities to spawn already modified entities. Listeners that listen to CreatereSpawnEvent will receive the spawned entity before you call any other methods
https://blog.jeff-media.com/use-consumers-when-spawning-custom-entities/
When you want to spawn a custom entity, e.g. with a custom name or certain items equipped, you must use the method World#spawn(Location, Class, Consumer) unless you give a shit about compatibility with other plugins. I’ll explain why. The shitty way Usually, you can easily spawn entities like this: That is fine, as...
how do we increase attack damage of itemsta
Ty
Attributes
It shows every states of the damaga how do i make it only attack damage
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("generic.attackDamage", 7, AttributeModifier.Operation.ADD_NUMBER));
When on Head, When on Body
java.lang.IllegalArgumentException: Cannot spawn an entity for org.bukkit.entity.Item
World world = block.getWorld();
Location blockLoc = block.getLocation();
world.spawn(blockLoc, Item.class, (item) -> {
item.setItemStack(new ItemStack(Material.BARRIER));
});
There's a special method for items, World#dropItem()
Oh really? Thanks
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onArmorEquip(ArmorEquipEvent e) {
if(e.getNewArmorPiece() != null && e.getNewArmorPiece().getType().toString().contains("NETHERITE_")){
e.setCancelled(true);
}
}```This code cancels armor worn by right-clicking, but does not affect armor that has been dragged. How can I fix this?
Yo
What is the package of ArmorEquipEvent?
thats an api
Okay, how can I cancel dragging into armor slots?
We’ll help if you show us sure
Just check with InvClickEvt if inv is CRAFTING
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
if (event.getWhoClicked() == null || event.getInventory() == null || event.getInventory().getType() != InventoryType.CRAFTING) {
return;
} for (int slot : event.getRawSlots()) {
if (slot >= 5 && slot <= 8) {
ItemStack draggedItem = event.getOldCursor();
if (draggedItem != null && (draggedItem.getType() == Material.DIAMOND_HELMET || draggedItem.getType() == Material.DIAMOND_CHESTPLATE
|| draggedItem.getType() == Material.DIAMOND_LEGGINGS || draggedItem.getType() == Material.DIAMOND_BOOTS
|| draggedItem.getType() == Material.NETHERITE_HELMET || draggedItem.getType() == Material.NETHERITE_CHESTPLATE
|| draggedItem.getType() == Material.NETHERITE_LEGGINGS || draggedItem.getType() == Material.NETHERITE_BOOTS)) {
event.setCancelled(true);
return;
}
}
}
}```
Try inventoryclickevent too
you will need 1 tick delay
in this code?
Hi , hh am i doing something wrong here?
https://paste.md-5.net/acezodewod.coffeescript
when i click on game-leave-item , it show the spectator gui .. ?
What
Api version?
1.13.2
Pdc?
no ?
No, just check in a inv click event with one tick delay, because the armor is registered in the inv after the event, thus 1 tick delay.
Cancelling it works
Do some debugging
do you happen to know anything about redis?
Nothing major
iam making a gui system for avillable servers for a game type it , but not sure if iam doing it correctly
lets say :
/play SOLO ,it will show only SOLO GameModes , and i already did that
my problem is something with the inside code itself .. so it should say :
- if 2 servers have the same arena map , it should show 1 itemstack , and it would say that : amount of servers : 2 for example
and in the default case , just add new item for new srevers arenas names that runs
Basically you need to keep track of your open GUIs
assign some metadata to them or something
make a notification system
At work, in the past, I just had a registry that allowed me to associate menu IDs with packet ids
So that when I received a "update member" packet it'd update all menus in the list
i do have a random uuid for each server is running
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.getWhoClicked() == null || event.getClickedInventory() == null || event.getSlotType() != InventoryType.SlotType.ARMOR) {
return;
}
ItemStack clickedItem = event.getCurrentItem();
if (clickedItem != null && (clickedItem.getType() == Material.DIAMOND_HELMET || clickedItem.getType() == Material.DIAMOND_CHESTPLATE
|| clickedItem.getType() == Material.DIAMOND_LEGGINGS || clickedItem.getType() == Material.DIAMOND_BOOTS
|| clickedItem.getType() == Material.NETHERITE_HELMET || clickedItem.getType() == Material.NETHERITE_CHESTPLATE
|| clickedItem.getType() == Material.NETHERITE_LEGGINGS || clickedItem.getType() == Material.NETHERITE_BOOTS)) {
new BukkitRunnable(){
@Override
public void run() {
event.setCancelled(true);
}
}.runTaskLater(plugin, 1)
event.setResult(Event.Result.DENY);
}
}``` Is that enough?
so each game server runs , it will have random uuid
This is more of a code architecture thing rather than networking
But to be honest if you have no clue about this you shouldn't be making a sharded system in the first place
what's the alternative?
using arena per world ..
take some time to learn
that's bad for perofrmance ..
that's why iam asking to learn ..
what is better for my use case?
should i do this or publish?
Well, do you think the version without delay will work?
Yes maybe?
im trying right now
If i want to save itemstack to persistant data container, how could i do it?
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
Thanks
I think I didn't explain it well. The way I usually do stuff like this is by checking if the player clicked a armor slot and then after one tick, checking if the armor of the player contains disallowed items. If this is the case, I remove that armor and drop it to the floor. I guess you can do something similar with the ArmorEquipEvent of Paper, but i think it dosn't work in this case. My solution should work tho.
I mean sure, cancelling the inventory event works fine too though i think?
but maybe I can do something like converting itemstack to byterray?
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
oh ok i'm sorry
In most cases, yes. But somethimes it seems to be buggy in the player inventory. (Especially in creative mode.)
Yknow i thought there was an itemstack in there buut
Creative mode is always buggy
yeah
It doesn't track type of action in InventoryClickEvent 💀💀💀
in creative mode
@kindred sentinel I think in those morepdc by alex itemstack can be used as ConfigurationSerializable
Yeah creative mode sucks ass
I spent so much time figuring out how could I completely hide a player without making him unhittable (hypixel bedwars invisibility), I tought about making an invisible armour stand and hiding the player (idk if I can apply invis on armour stand)
You can
this code should hide an armor stand but it does not:
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
if(as.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 620/*31s. 1s additional for player to not see armor stand in case of lag!*/, 1, false, false), true))
Additionally, does anyone have an alternative method for accomplishing this?
I don't think you need to compensate for lag, since if you send the players the data that the stand will be invisible for X seconds, the client will also keep track of that.
Isn’t there a setInvisible or smth on armorstand
it is but it will make the armor stand unhittable (iirc)
yo i got a weird error on 1.20.1
error: https://paste.md-5.net/aduyekazap.sql
code: https://paste.md-5.net/wogidibira.cs
can someone check it?
You can't listen to BlockEvent
i just started creating my firt plugin but i cant load it
load harder!?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
this comes up
command not in plugin.yml
see that squiggly line? It says you need an element under the key
so description: "test command"
what?
look at the example I linked
Can u send a pic of ur project structure for me. Unrelated
No
okay i ask some1 in this chat
Just change the block to the one you want
Use Location.getBlock().setType()
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Block.html#setType(org.bukkit.Material)
declaration: package: org.bukkit.block, interface: Block
Hi, I am making a plugin with intellij, and I cant ctrl-click to find references. It says 'No usages found in All Places' when I see it has a usage right below it. I am using spigot and not spigot-api, and when i try to download sources it says it cant find them. When I tried ctrl-clicking in a workspace which uses spigot-api it worked. If anyone has information to fix this I would greatly appreciate it.
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
if ur using spigot instead of spigot-api its probably locally decompiled without source jars
so how would I go about fixing this (I assume i need to download the source jars)? are there any guides on this matter
I've never gotten that to work
hm
why isn't this working?
public static String colorizeHex(String message) {
Matcher matcher = HEX_PATTERN.matcher(message);
while (matcher.find()) {
String hex = matcher.group(1);
Bukkit.broadcastMessage(hex);
message = message.replaceAll("&#" + hex, ChatColor.of(hex).toString());
}
return colorize(message);
}
it should be formatting it
Aren’t you trying to replace &##ff99cc
You just need to remove the # in “&#”
can anyone remind me what's used for optional vs required (<> / [])
?paste
im no expert but
Cannot register AttributeModifier. Modifier is already applied
MARKET.setItem(20, newIs(Material.DIAMOND_SWORD, 10, "Uzak Dövüşlerde Başarılı", "Kral Edward Tarafından İlk Kez Kullanıldı",
ChatColor.DARK_RED, "Spiritual Sword",ChatColor.RED, 90, 13, 2));```
seems whatever you're trying to do is redundant
anyone know the conversion factor for bukkit/spigot velocities to vec3 for ClientboundSetEntityMotionPacket?
Was looking for if I should create a new connection everytime and I am using SQLite. What does this mean? Why do you not have to do it with SQLite?
Nvm found a video on youtube on sqlite in java
In what instance should onCommand return true/false? I understand that it returns true if it's a "valid command", though I'm not sure what constitutes "valid" vs "invalid". Should the command return false if it's a permission error? Syntax error? Fails to find the specified player? etc etc
False sends the usage message from the plugin.yml
Is there a reason why this is not creating a scoreboard when the server starts? The function is being ran all log messages are going through and no errors?
plugin.getLogger().info("Initializing scoreboard...");
// Try to initialize the scoreboard
this.scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getNewScoreboard();
// Log statement for successful initialization
plugin.getLogger().info("Scoreboard initialized successfully!");
// Register the objective
this.objective = scoreboard.registerNewObjective("Levels", Criteria.DUMMY, "Player Levels");
this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
is InventoryClickEvent also used for survival inventories, including the 2x2 crafting grid and the output?
If you're doing this onEnable() it won't work and is probably throwing an NPE somewhere
Objects#requireNonNull() will throw an NPE if the value passed to it is null, which Bukkit's ScoreboardManager will always be before a world has been loaded
You're assuming their plugin is load: startup
Why this exist
Like it gonna call npe anyway
It's so the IDE stops complaining
it explicitly asserts that you don't want it null and you can attach a custom exception message if it is
There is a problem with the Bukkit plugin. When the player uses the "/name" command, the display name changes correctly, but the custom name overhead is not updated; Spigot 1.20.1 is used and the relevant part of the code is:
package chihipiro.nickname.Commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Name implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)){
sender.sendMessage(ChatColor.RED + "Please execute this command in-game.");
return true;
}
if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Please provide the correct number of arguments.");
return true;
}
if (args[0].length() > 16){
sender.sendMessage(ChatColor.RED + "The length of the name should not exceed 16 characters.");
return true;
}
final Player p = (Player) sender;
final String name = ChatColor.translateAlternateColorCodes('&', args[0]);
p.setDisplayName(name);
p.setPlayerListName(name);
p.setCustomName(name); // Set the custom name above the player's head
p.setCustomNameVisible(true); // Make the custom name visible
sender.sendMessage(ChatColor.WHITE + "Your nickname has been set to " + ChatColor.RESET + name);
return true;
}
}
. I have restarted the server and checked the console for errors, but the problem persists. Any assistance in resolving this issue would be greatly appreciated.
Is there a way to make the charge time of a bow longer or shorter?
hi , uhh second time i click on the item [it will send a messge using redis to the proxy server , it will send me to the required server] , first time it works just fine but second time , it just stop executing
with this little code provided i don't think anyone can help
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
how would yall increase hitboxes for entities ( where you can punch em an shi)
interact entity as passenger
nms hackery
you're telling me I can't override the nms entity's boundingbox?
do your own raycasting or sumn
Probably for collsions too since player movement is
Why is ItemStack.setDurability() deprecated? Java docs says "durability is now part of ItemMeta" but I can't do ItemMeta.setDurability()... What should I use instead?
Use javadocs and google for more info
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
sendCompass(player);
MongoWrapper mwi = helper.getMongoWrapperInstance();
FindIterable<Document> queryResults = mwi.findDocuments("players", player.getUniqueId().toString(), "type", "skin");
if (queryResults.iterator().hasNext()) {
// Player has a skin document, morph their skin
Document skinDocument = queryResults.first();
Document skinData = skinDocument.get("skinData", Document.class);
Document texture = skinData.get("texture", Document.class);
String textureValue = texture.getString("value");
String textureSignature = texture.getString("signature");
helper.getSkinUtils().setCustomSkinAsync(player, textureValue, textureSignature).thenRun(() -> {
msg.send(player, "Morphing you into your avatar..");
});
}```
my onPlayerJoin listener runs twice when a player joins, does anybody know what could be causing this behaviour ?
as you can see it is running twice
its been doing this even before having the iterator
also its simply checking if the iterator hasNext lol
What does deprecated mean?
it works but its old
Did you register the event twice?
Add a debug statement to check if the event is really fired twice
already done that it is indeed running twice
I have a lot of "old" things in my code then that I should convert; thanks
and i checked if i registered it twice but i dont think so ?
Deprecated methods should not be used. Spigot always has an alternative impl for deprecations
im registering within the constructor of the class
It's deprecated because you're using paper
maybe thats the issue ?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/ChatColor.html Spigot does not deprecate it
it can tell i am using paper? neat.
Depends. Show your constructor call.
PS: This is dirty
why is it dirty ?
Because you are moving the responsibility from your JavaPlugin to your Listener.
Constructors should also contain as little logic as possible. And they 100% shouldnt have any side effects.
They are initializers and shouldnt be used for anything else than initializing.
also is that sync database usage I see 👀
i didnt implement the code for that listener im just debugging it, also i think i found where it could be causing the issue
oh right i made the project with paper i remember now; its been almost a year now since i started this project
You are registering it twice? 🙂
So yes you are registering it twice
i dont really think thats how its done lol
^
got it
You can register your listeners like that. Just remove the registration out of your constrcutor.
Well... nvm. You are abusing your constructor again...
@young knoll @river oracle https://hub.spigotmc.org/stash/users/lynxplay/repos/bukkit/browse?at=refs%2Fheads%2Fitem-block-type and https://hub.spigotmc.org/stash/users/lynxplay/repos/craftbukkit/browse?at=refs%2Fheads%2Fitem-block-type are up respectively
i didnt make this class lmao
also its only initializing once
The only downside to the removal of generic params is that you loose the ability to define a creation method on the non-generic type as a parameter of Consumer<ItemMeta> cannot be overwritten by the same method but with param Consumer<M> where M extends ItemMeta.
The current solution to this is a small shortcut back to a typed instance. E.g. if you have a plain ItemType in the API and need a consumer method, you call itemType.typed().createItemStack(meta -> meta....)
You should sue the person who wrote this for abusive behavior. Because thats what the author is doing. Abusing the constructor.
I dont get a quick fix for ChatColor, but since it is fine with default bukkit does it need to be fixed?
im just here to debug, ill let the devs know lol
You need to decide for which platform you want to deploy. The answer depends on this.
paper
Then fix it
You can keep using the legacy text format
you just have to be fine with the deprecation
also, why would it cause lag ?
// Named color
Component message = Component.text("Some cool message").color(NamedTextColor.RED);
// RGB color
Component message = Component.text("Some cool message").color(TextColor.color(40, 30, 150));
Because you are using IO on the main thread
or use MiniMessage 
or, even more speed Component.text("Some cool message", NamedTextColor.RED)
or, even MORE.speed via static imports text("Some cool message", RED)

No. Bad Lynx.
IO ? like input/output ?
if you mean the database calls, i can make them async
Yes, the DB calls. A single DB call in your JoinEvent can completely cripple a server by itself.
whyyy
ill just go for completable future then
thank you
I find static imports to be generally ugly 🤷
I mean, sure for most calls
this is so much more work; isnt a fork of something supposed to make it simplier. I found the paper api dev docs so looking through that
builder calls like this, I generally don't mind
look at mini message then
its a more complete format than legacy