#help-development
1 messages · Page 1879 of 1
Sure. Go ahead and try to explain to him how to setup debugging for spigot.
I'm confused. You're saying that like it is a very complicated task
He's making a plugin, right? lmao
getConfig().options().copyDefaults();
saveDefaultConfig();
How can I get online player list?
Should that generate a config file as long as i have stuff in the config
it doesnt but i want it too
This is not Array
Collection<T> collection = /* ... */;
T[] array = collection.toArray(T[]::new);
You dont need it as an array
He might, let him do what he likes
I cant think of a single thing that you can do with an array of players that you couldnt do with a Collection
Random select an element
Sure, you could do it with a stream, but it is nicer with an array
Collection<? extends Player> playerCollection = Bukkit.getOnlinePlayers();
Optional<? extends Player> randomPlayer = playerCollection.stream()
.skip(ThreadLocalRandom.current().nextInt(playerCollection.size()))
.findFirst();
Slow
Has anyone encountered an error loading values from bukkit enums, 'Cannot be resolved or is not a field", This code was working but suddenly stopped, seems to only be newish blocks, lectern doesnt work either. Any help appreciated
Pom:
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Yes it does.
Sounds like a dependency is pulling in outdated spigot API
Micro optimization is pretty irrelevant. Using a plain array instead of an array list wrapper is also pretty irrelevant
Micro optimization?
Surely you didn't just say micro optimization
ahh yep, looks like it weird
Overall most certainly lol
Absolutely not!
Unless that code is hot as fuck it doesn't matter
copying a collection to an array is an O(n) operation + it uses extra memory.
Skipping n elements in a Stream is really not a big deal.
I would argue that the difference is negligible in this case
yeah im not sure what the deal is, the spigot api (1.18) is there, but there is also Bukkit 1.13.1
You'll have to figure out what dependency pulls that in
And manually exclude it
Use Mavens dependency tree
Maybe you added a spigot jar besides your maven dependency
mvn dependency:tree presumably
nah, vault is pulling it in
Contextually, yes, copying takes time. But in terms of the broader picture, accessing an array is substantially faster than using a stream lmao
Let me write a jmh benchmark just to be sure...
If you're trying to tell me that an aaload would even be comparable to spawning god only knows how many objects xd
Did you also add other spigot dependencies manually with eclipse?
You dont. If they have the chunk then they can see the block.
Fixed it, thanks guys
raytracing
or easier, if a block is surrounded from all sides with solid blocks, noone can see it anyway
Oh you mean direct vision.
Ray tracing. But thats really expensive.
What anti xray engines normally do is check all 6 directions around a block and make it visible if one side is not obstructed (air)
Hi guys quick question. I need to retrieve the total slots of a server (linked through bungee) when there is no one online (Start-up process). Does anyone know how to do this using CustomPluginMessages?
I don't think the messages work without players
Don't bother with plugin messages. Use Redis.
You cant send custom messages without a player
I'd use redis too
Topics 😄
Quickly, take this! https://github.com/redis/jedis
SQL, but without everything that makes SQL worth using lmfao
Its not even comparable to mysql... And it can do SO much more than just key value storage
Yeah redis is damn powerful
mmm pub/sub go brrrrrrr
it was just the easiest explanation I could find for someone who never heard of it
Except when you start measuring persistency ):
Well then you didn’t need redis in the first place
So I would need to create a bungee plugin that put the total slot of a server inside a redis db and then from my plugin retrieve that value?
Yup
Hopefully you got sth like postgre in that case
ACID go brrrrr
mh, ty
# Run complete. Total time: 00:08:02
Benchmark (elements) Mode Cnt Score Error Units
RandomElementBenchmark.randomFromArray 10 avgt 5 0,029 ± 0,001 us/op
RandomElementBenchmark.randomFromArray 100 avgt 5 0,095 ± 0,001 us/op
RandomElementBenchmark.randomFromArray 1000 avgt 5 0,858 ± 0,056 us/op
RandomElementBenchmark.randomFromStream 10 avgt 5 0,047 ± 0,001 us/op
RandomElementBenchmark.randomFromStream 100 avgt 5 0,139 ± 0,001 us/op
RandomElementBenchmark.randomFromStream 1000 avgt 5 1,418 ± 0,033 us/op
If it would be x10 (1000%) slower then i would consider it an optimization.
Its not even 50%
I mean the BlockFaces
JVM caching go brr
up, down, west etc
There is nothing cached. Jmh disables the JIT
:thonk: I really thought JIT was stepping in here
I'll take the dub on "still faster" though :,)
Sure... i wouldnt use a stream like that either
Let's see that benchmark code, though
?paste
I believe postgre does in fact have those props, no?
Yeah, that's why ACID is going brrr
Hell no! Boy you better cache that array
Let's also ditch the rng
No you dont. Thats cheating.
No it isn't?
Making a field just for a tiny bit of performance improvement smells like micro optimization
We're not measuring copying speed of an arraylist, we're measuring access speed of an array vs a generic collection
convenience > performance
Me when I can't real time program because of Java streams 😢
There is nothing to measure there. Arrays have the fastest access time possible
Exactly, an aaload is incomparable to a stream skip lmao
In fact, I said that earlier, too! #help-development message
Dont use raytracing. You will tank every servers performance into oblivion.
how does that help?
He doesn't want raytracing. As previously mentioned: #help-development message
Please enlighten me on how Block.getRelative can be used to see whether Player X can see Block Y though
Let's get rid of jump instructions as a whole, while we're at it
Anti x-ray usually is done like this:
- Monitor outgoing chunk packets
- Parse them and replace every invisible block with stone.
- Invisibility is determined like this: If the block has any relative block (regarding the 6 faces) of type air it is visible.
- If a player comes near an obstructed block or a player frees an obstructed block you send a block update packet with the real data
@quaint mantle
You cannot detect if the player is in F5. At this point, you're looking for a mod.
Since the application you want to use it for is anti-xray, you'd be better going off with 7's recommendation instead of trying to do the math here
A cube has six sides. Blocks are cubes, so blocks have six sides. A player would not be able to see a block if all six sides of the block are obscured by another block
It would be best to cache the block visibility status somewhere and then only update adjacent blocks on block updates
That will grant you the best performance at the sacrifice of some memory
Is there practical application for this xray plugin or are you making it for learning purposes?
Why not?
Hypixel is not 100% custom
Block visibility status is just if the player can see it or not
They use WorldEdit
Block updates is just talking about breaks, places, stuff like that
Then be prepared for years of development. And at your stage you can add another year for learning stuff and then scrapping your whole code
a year later because you then cringe at your old code. Been there.
Just hide your plugins from public lol
Hiding plugins is the virgin solution ;)
Real chads make all their plugins custom, like this guy ^^^^ (toto)
Good luck.
it's cringe to make a server that uses ONLY plugins made by you if you want to make something complex
The more time that passes, the worse it will get lol
Factually incorrect
Real chads do not spend time for nothing and reinventing the where, but actually doing unique stuff
for example, would you want to pretty much remake worldedit?
A simple task to complete.
or make your own placeholderapi?
A very simple task to complete.
No not really
Depending on what features the task can be colossal
Simply because you make all of your plugins doesn't mean you're re-inventing anything. All comes down to what you're making
🍔
burghir
Depends on how much time you can dedicate to it and which parts of it you'll make. The concepts behind WorldEdit are straight forward, there are just a lot of them lmao
Nothing is hard, you just have to be willing to spend time on it
Yeah, and the bigger the project potentially becomes, the more design problems you’ll have to face and address, which can be hard
Contextually, I disagree with this. WorldEdit doesn't have many design problems to speak of, just algorithms
That very much depends on what features you add as said before
We also need to concretize the definition of simple
Sounds about right. Good luck
Whether something is simple is purely subjective. A beginner might believe that looping through a polygon's region isn't simple, while a geometry-focused computer science major may disagree
That’s besides the point, what I mean is how do you define simple as a measurement, since you did use the adjective.
The features of WorldEdit are simple. You have two points and you manipulate the space between them.
Yes in abstract terms
If everything you mean by worldedit is simply that, without any concerns of anything else, then creating your worldedit might be a simple task in terms of both difficulty and time.
More of a discussion
Tho when I refer to worldedit I don’t mean just two points, I mean the entire project.
I'll disregard their cross-platform compat and focus solely on implementing a version of WorldEdit for Spigot only.
You disregarded a lot of other things as well, but sure
For the coming assertions ^^
Sure go on (:
Mirroring the entire project, WorldEdit is extremely easy in terms of difficultly, but very time consuming. It would be a lot of easy work, essentially
I would love for you to name a feature of WorldEdit that I'm forgetting that is ridiculously difficult to implement ;)
bUt WhAT aBoUT ThE PaTtErNs, bK?!//?!1
😂
Yes I remember that command you did lol
Ah yes, the gamer command
Actually depends on requirements a bit, but let’s say we have the non functional requirement of speed and performance in terms of space. That can be an easy task if we make it a functional requirement but if not, it can be a bit difficult arguably.
10 minutes of setup for ~10 seconds of code writing
🌞
Yes
In main class
getServer().getPluginManager().registerEvents(this, this);
this, this
you just registered your main class
you need to register an instance of your listener class
getServer().getPluginManager().registerEvents(new eventlistener(), this);
Name a WorldEdit algorithm that you think would be hard to match in terms of actual performance
Thanks
please give your classes proper names
and your methods too
you literally use ClassNames for methodNames and methodNames for ClassNames
They'll be fine, they're a beginner
I know but it's just confusing
it's very bad because it makes them not understand the difference between classes and methods etc
Factually incorrect
ThisIsAClass.andThisIsItsField
Sure, it is convention, but if he wants to define his own local convention as having things named in lower camel case for classes and upper camel case for methods than that's his business
It is along the same line as operator overloading in C++
of course but obviously he has no idea what he's doing so better to stick to the "rules" and learn it the proper way from the beginning
Eh, they'll learn later. No reason to criticize them on it
I didnt critize, I just said "please give your classes proper names"
Why not help him along while he's figuring things out.
isnt it helping if someone will never make an mistake with classnames/methodnames because he fears mfnalex ?
Most operation when given a humongous volume of blocks. You could make it so the operation is done over several game ticks, but that’s not perfect. Doing this asynchronous would probably require locking which is also not always trivial, in fact concurrency can be ass to test sometimes. As said if this is a non functional requirement it most likely wont be categorized as simple.
"operation is done over several game ticks"
why is that so bad ? if you do it the right way it should work flawelessly
Can I trun Bukkit.getOnlinePlayers() to Array<String> list?
limit the time per tick where it places stuff for example ^^
can I get the NMS Item from a Bukkit Material?
Yeah
if so, how? 😄
Believe there’s a craft class
its magic
CraftItemStack.toNMS(org.bukkit.ItemStack) i believe
Thanks ill check it out lol
Over head!!!
hm so it requires me to create an itemstack
Ah wait
CraftMagicNumbers
Can I trun Bukkit.getOnlinePlayers() to Array<String> list?😣
why not
Yes but you shouldnt
Why do you want to do that?
What is an Array<String> list
I want to use indexOf
Too bad
yes ... but why ?
ugh
ah nvmd ^^
Why? The list will always have a different ordering.
The players that are online have no notion of order, especially by index
If you want to refer to a player, do it by their UUID
I want to http post online player list to server
And why do you need an indexOf method for that?
you shouldnt need an index of a player then
In javascript API server
Thonk
Im confused...
So is there any way to get players as list?
CraftMagicNumbers.getItem
yes ^^
new ArrayList<>(Bukkit.getOnlinePlayers());
but its bad ^^
Just
public List<String> getOnlinePlayerNames() {
List<String> names = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
names.add(player.getName());
}
return names;
}
or simply
public List<String> getOnlinePlayerNames() {
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
}
Not setting the initial capacity! Cringe!
@ivory sleet How to make a non-moving visual effect? Because if I do this world.playEffect(point, effect, data); the particles are moving up
I believe that’s out of control?
thanks
Set the speed to 0
Unsure tho
thanks
there are more data you can set
Where to set the speed?
There’s an overloaded method with a speed parameter
check the other methods with more arguments
Ok thanks
Actually it may be called int extra, idk
playEffect() is client-driven, you have no control over how that looks. spawnParticle() may or may not respect the extra/speed data
Again, client-driven
If it doesn't respect speed, you can't make it sit still
if you want to control movement for spawnParticle you want to set the amount to 0
How did Hypixel do that then?
What particle is it?
For example, DRAGON_BREATH
Yeah the client could just decide to make the particles on your screen go nuts
Some particles don't even support speed 0, so you may have to set it to speed 0.0001
Good idea
The particle arguments are so dependent on the particle it's insane
Like this one. Mob spell is RGB, but it's only RGB if count is set to 0
Then the RGB is the offset params
Hey there. I'm trying to get BuildTools to build me a JAR that contains the CraftBukkit stuff and the NMS stuff, but I can't get it to work. I've had successful builds using the following commands: java -jar BuildTools.jar --rev 1.18.1 and java -jar BuildTools.jar --rev 1.18.1 --compile craftbukkit. I added both to my Gradle build file, but haven't had any success on either. The normal bukkit things work, but I don't have any of the CraftBukkit stuff (CraftArmorStand for example) and NMS classes for things like packets I also cannot find. Can anyone help me?
It doesn't use DustOptions like redstone does
Thanks!
Ok will set count to 0
Solve P = NP lmao

A simple task, if you asked me personally
Another question: in Remapped 1.18, the maxStackSize of an NMS Material ("Item") is Item.maxStackSize. It's private though so I need Reflection. However, special sauce plugin doesn't translate it so I still have to find out the obfuscated name "c" in this case. Is there ANY WAY I can set the private field WITHOUT reflection, or make the special sauce plugin translate it for me anyway?
(Because right now I will have to update my setMaxStackSize method for every new NMS version)
Still moving
heh, special sauce
So then tell me how is it simple? Out of curiosity
that's what it's called 😄
The requirement as said is non functional so you won’t be able to match your implementation against anything bk
Check out remapped-reflection maybe?
so my question in short: can remapped work with reflection or do I ALWAYS have to use obfuscated mappings for reflection?
what's that?
A library by jpenilla; allows you to work with reflection on mappings
couldnt find it, you got a link? 🙂
I actually always thought its called special sauce and I wondered why lol
Thats a reflection-remapper actually
thx, will check out!
It also has very cool reflection proxies
oh well that doesn't look too easy
I found out that some particle types are indeed not supported
Ye
is there any other way of generating blocks in a 10 by 10 besides looping through the x and looping through each z?
how would you get the blocks else when not looping ?
I dont know, thats Why i was asking.
the api dont provides something like that.
Where is the problem with looping ?
Well of course because I am the smartest man alive and solving P = NP is a trivial task
you only need to do it once... as a little help you can create a BoundinxBox to get the lowest Position and highest Position... but thats something you can calculate faster too
xd
its only for a flat plain
then just calculate minX, maxX and minZ and maxZ ... 4 lines for all^^
ok ok
Without trolling, as you called it simple, so I am curious how you would address this requirement
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.724 s
[INFO] Finished at: 2022-01-11T16:58:06+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project LostKingdomDSRV: Could not resolve dependencies for project me.Branchyz:LostKingdomDSRV:jar:1.0: The following artifacts could not be resolved: net.kyori:adventure-platform-api:jar:4.0.0-SNAPSHOT, net.kyori:adventure-text-serializer-bungeecord:jar:4.0.0-SNAPSHOT, net.kyori:adventure-platform-facet:jar:4.0.0-SNAPSHOT, net.kyori:adventure-platform-viaversion:jar:4.0.0-SNAPSHOT: net.kyori:adventure-platform-api:jar:4.0.0-20210914.041527-74 was not found in https://hub.spigotmc.org/nexus/content/groups/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced -> [Help 1]
<!-- Spigot -->
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
I'm getting a error when i'm trying to build, does any1 know what the problem is?
Give a better read to the description
Metadata
Show full pom.xml
?paste ofc
change spigot repository to this and try again
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
Thx, that worked!
Without trolling, the whole topic would be null and void
and nil
Yeah I have been serious, as just trolling around doesn’t help anyone here really
Since .getDurability is now depricated, what am I supposed to use to fix my items?
Is there a plugin for developers to more easily test their plugins? Things like commands to listen to events and loggin em, changing player's uuid to test shop plugins etc.
Cast meta to Damageable
✨ Unit tests ✨
If you can somehow simulate an entire server sure
Hi
Hi
Somebody can help me?
I don't know what is the problem with my plugin:c
Do state the problem
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Why would you want to? Just test stuff separatly?
This event is not working
@EventHandler
public void JugadorEntraACama(PlayerBedEnterEvent e) {
Location playerbed = e.getPlayer().getBedSpawnLocation();
Boolean weather = this.OverWorld.hasStorm();
Long time = this.OverWorld.getTime();
if (weather || this.Dias >= 20L || time < 13000L) {
e.getPlayer().setStatistic(Statistic.TIME_SINCE_REST, 0);
e.getPlayer().sendMessage(Main.PluginName + " Se ha reseteado tu sueño");
e.getPlayer().getWorld().createExplosion(playerbed, 0.0F);
e.setCancelled(true);
}
}```
any error on console?
I assume plugin developers often do system testing on test servers and sometimes want to listen into block events for debug purposes, right?
MockBukkit
check if the if statement is true
show "Dias" field
MockBukkit would allow you to essentially to do unit tests with mocks
Noice, thanks
why does it get Cancelled
Can you send us your main class?
?paste
if(this.getConfig().getString("Fecha").isEmpty()) { int Dia; int Mes; int Año; Dia = this.Actual.getDayOfMonth(); Mes = this.Actual.getMonthValue(); Año = this.Actual.getYear(); String fecha = ""; if (Mes > 10) { fecha= Año + "-" + Mes; }else{ fecha= Año + "-0" + Mes; }; if (Dia > 10) { fecha= fecha + "-" + Dia; }else { fecha = fecha + "-0" + Dia; }; this.getConfig().set("Fecha",fecha); this.saveConfig(); this.reloadConfig(); System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+" &fSe ha cambiado la fecha de inicio a &c" +fecha)); }else{ System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+" &fFecha de inicio: &c" +fecha)); }; this.Inicio = LocalDate.parse(this.getConfig().getString("Fecha")); this.getDays = this.Inicio.until(this.Actual, ChronoUnit.DAYS); if(this.getDays == 0) { this.getDays = 1; System.out.println(ChatColor.translateAlternateColorCodes('&', PluginName+ " &fDía de inicio detectado")); }`;```
with the Paste System
register events?
I have to make it cancel when there is rain, because I want to keep the rain when a player dies
Ok
instance = this;
pm.registerEvents(new JugadorEventos(instance), instance);
pm.registerEvents(new Cambios(instance),instance);
registrarComandos();```
ok maybe im blind then
I have seen example codes.
And some have an "final" before the "PlayerBedEnterEvent"
What's that?
the value can not be changed anymore
Because it's... yes
Uh?
Putting final before the event ensures it can’t be reassigned
if you have:
final Player player = ....
you cant modify the player-variable later
Just to make sure that it doesn't get Touched by some other Thing
Would you say final is more of a "making sure I don't do something stupid" than it is valuable for Java itself
Pretty much
Ok.
My server is a HardCore Server .
When someone dies, hours of rain are set relative to the number of days that have passed.
But, when some player sleep, the rain goes away.
Likes ElRichMc Permadeath Proyect.
So?
so, you don't want People to Remove the Rain by Sleeping?
Yes
Disable the Beds when it Starts Raining
so it does not have to be Cancelling the Event Every time
Or you can restore the rain after they sleep
Exactly
How can I do that?
This sounds better
PlayerBedLeaveEvent
Ok
Yes
do you want disable the beds when the world is storming?
You'd want to cancel PlayerBedEnterEvent to disable beds
If you cancel PlayerBedLeaveEvent they'll just be stuck in the bed 
Something like that
The idea was not That
Save the rain time when a player sleeps and set it using the TimeSkipEvent
it was to Remove the Rain
Either way Pbt, Coll's idea is better.
@EventHandler
private void onPlayerBedEnter(PlayerBedEnterEvent event) {
event.setCancelled(event.getPlayer().getWorld().hasStorm());
}
[00:39:09] [Timer-15/WARN]: Exception in thread "Timer-15" java.lang.IllegalStateException: Asynchronous player kick!
[00:39:09] [Timer-15/WARN]: at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14)
[00:39:09] [Timer-15/WARN]: at org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer.kickPlayer(CraftPlayer.java:346)
[00:39:09] [Timer-15/WARN]: at handler.player.kickplayer(player.java:52)
[00:39:09] [Timer-15/WARN]: at handler.player.check(player.java:42)
[00:39:09] [Timer-15/WARN]: at handler.timer.run(timer.java:9)
[00:39:09] [Timer-15/WARN]: at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
[00:39:09] [Timer-15/WARN]: at java.base/java.util.TimerThread.run(Timer.java:516)
you can't kick player in async
What's wrong?
Don’t kick async
I Agree
Okey,
So, I just save te rain time
And after a player sleeps, do I put it back?
Bukkit.getScheduler().runTask(plugin, () -> player.kickPlayer("reason"));
public static Runnable kickplayer(String player,String msg) {
Objects.requireNonNull(Bukkit.getPlayer(player)).kickPlayer(msg);
return null;
}
This is async?
If you're calling it async it will be
Thanks for the help 
method with just 2 lines and it will always return null but you want an Runnable ???
thats so useful wdym
yeah
so the folders are
com.forbiddenbox.me.swsutils
>Commands (folder)
NPC
SwSUtils (Main)
this is package name
look example
name: Test
version: 1.0.0
main: com.viiictorxd.test.TestPlugin
package com.viiictorxd.test;
import org.bukkit.plugin.java.JavaPlugin;
public class TestPlugin extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("Plugin successfully enabled");
}
}
main class package name (com.viiictorxd.test) + main class name (TestPlugin)
result: com.viiictorxd.test.TestPlugin (main class)
🥳
let's try again kkkk
now it's will work
send me last recent error, plugin.yml and main class
InteliJ
show me where is the plugin.yml
let me check
kk
the folder
yeah let me go to imgur
yeah nothing
did you have sth selected that could be refactored into a method?
what it do?
here works
weird
i have used hotkey
try the hotkey
Having the same issue...
@EventHandler
public void EntitySpawnEvent(org.bukkit.event.entity.EntitySpawnEvent e)
{
Entity mob = e.getEntity();
if(mob instanceof Zombie)
{
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta meta = chestplate.getItemMeta();
meta.addEnchant(Enchantment.DURABILITY , 5 , true);
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL , 5 , true);
meta.setDisplayName(ChatColor.AQUA + "Zombified chestplate");
chestplate.setItemMeta(meta);
((Zombie) mob).getEquipment().setChestplate(chestplate);
((Zombie) mob).setHealth(10000);
mob.setCustomName("Zombie Minibos");
mob.setCustomNameVisible(true);
}
}
I don't know why when i'm spawning zombie he doesn't have custom name and he has basic hp?
how do you spawn it ?
it's all in SpawnEvent
try change verification by type
if (mob.getType() == EntityType.ZOMBIE) { }
rip doesnt work for me 😦
lul 😭
but he has diamond chestplate
so it's not this
try look the all hotkeys if ctrl+alt+m is there
hmm
internet sucks rn wth
lol
uploaded
same code @daring lark
my game is glitched
ok, let me see
it's correct, lul
what's wrong with your code 😂
yeah, it says that its ctrl alt m in the menu
which spigot version are u suing?
1.12
I own a premium plugin, but decided to make it free from now on. How would I do that? Website wont allow me to set price to 0 😄
re-post xd
lul kkkkkkk
lol it's not working now
kkkkkkkkkkkkkkkkkkkkk
it's happening when i'm adding line which is setinghealth
i know what is wrong
ohh tjanks
Is that the only way? I don't really want to lose 8 years of ratings and discussion 😅
i'm setting it to 1000
to change to 10000 life, you need use pathfinder (or something like this)
ok, try and say me if it's works
what plugin is it? 👀
try to talk with an mod
Java math..... Kept adding 0.1
why resource is paid and it's open source? 🤔
Well I added the github link today, but being paid and open source is not mutually exclusive.
many premium resources do that ^
most people take it like, you're paying for support etc
Yea anybody could build the plugin themselves, but by buying it you support the development and support etc.
plus, 9/10 times the people who self-compile probably wouldn't actually buy the plugin anyways kek
i can't set hp of zombie by calling function
void processZombie (Zombie zombie) {
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta meta = chestplate.getItemMeta();
meta.addEnchant(Enchantment.DURABILITY , 5 , true);
meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL , 5 , true);
meta.setDisplayName(ChatColor.AQUA + "Zombified chestplate");
chestplate.setItemMeta(meta);
zombie.getEquipment().setChestplate(chestplate);
zombie.setCustomName("Zombie Minibos");
zombie.setCustomNameVisible(true);
zombie.setHealth(1000);
}
https://pastebin.pl/view/36639057 why is this not working
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
i dont get any error in console but i can still spawn with egg
The string list from the config contains a string I presume right?
check what e.getEntity().getWorld() returns
it returns world aight but how do i get a world from config then
you need get the world name
bruh let them figure it out
lol
i am sorry
getWorld.getName?
try it
What's the problem
I have a problem with selling I can't sell
You don't have any steak to sell
close inventory one tick later
item wont be air
What does "I can't" mean please be descriptive?
I mean, if I have 32 pieces and I want to sell one piece, I can't even though I have 32 pieces!?
isnt it possible to set a block to chest
and set something in the pdc of it in the same tick ?
prob possible why
because i cant even with a delay:
it is never set with this code
Are there any good API's for custom config? I want to be able to get all yml files in a folder with it, a bit like how DeluxeMenus gets their config.
Make one
is there a need to setstate for the block after editing the state?
I have a config library
only blockdata has to be set again
yea that, did you forget that
i dont use blockdata to get pdc ?... its directly in state
oh
state ... update() ... -.-
https://paste.md-5.net/kivolacoho.java i wrote this once
public class ExamplePluginClass extends JavaPlugin {
final ConfigurationWrapper myCustomConfig = new ConfigurationWrapper(this, new File("myCustomConfig.yml"));
@Override
public void onEnable() {
// load config
myCustomConfig.trySaveDefault(/* overwrite */ false);
myCustomConfig.reload();
}
}
Check out DazzleConf
Or sponge configurate
Thanks, i'll give them a look
my gosh
lmfao
What's the event for a grass block changing to dirt when a block is above it? I've asked before but all those events didn't do the trick for me
Any way to check when a method was implemented?
I only have to worry about the libraries that are actually in my jar, not all that i have downloaded, right?
Using abstraction, want to know when the Player#sendTitle method was implemented
what do you mean by implemented
because if its abstract or in an interface then it has to be
so theres no point in checking because you cant instantiate an abstract class or interface
In which version the sendTitle method was implemented?
try BlockFadeEvent
version?
imma try that again
Yes which spigot version?
ohh
i guess you could use
try {
player.sendTitle(...);
} catch (UnsupportedOperationException e) { }
and wrap that in a method
i dont think theres a way to only check it
except through bytecode analysis
@main matrix
try {
Player.class.getMethod("sendTitle");
} catch (Exception ex) {
// Server too old to support command.
}```
wait does he mean like it throwing an UnsupportedOperationException
or it actually not existing
it wont throw that
oh
a noclassdeffound or something
yeah i know
but some spigot methods threw that right
because they werent implemented yet
yeah the Player#spigot ones
yeah so i thought maybe it does it there too
I wonder why Spigot cant just be an interface
why would it be
you would need more api-implementation complexity
we would get like CraftSpigot or something
or just implement it in the player class
Found another way by just changing the version in the docs link and using ctrl f to find the method.
Seems like sendTitle(title, subtitle, fade, stay, fade) was implemented in 1.11 :)
well, whats the problem? Even now you need this
or, yes
yes but we would need either a seperate CraftSpigot from CraftBukkit or a fork of CraftBukkit
this would make more sense
Why so
are these all the methods?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.Spigot.html
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
because the interface needs an implementation right
and you would have to put that somewhere
its like only send messages
yeah
ive never understood Collection, Set and List and what they promise
actually only what they promise
i know that List promises some degree of ordering or something
but thats it
yeah that would be possible
Like, to make Spigot work you eill have to extend it as well
but whatever i just see no point in the extra effort
you also have Iteratable but that makes sense
yeah
LoL you only get extra effort by throwing excwptions in every unimplemeneted method
I dont see any reason of why Player.Spigot cant be just an interface
ok
Very readable thanks
._.
thst was my question
yeah i know
ah yes BeanContextServicesSupport is my favorite collection
oh ok so a Set promises no duplicates
a collection is ambigous and doesnt promise shit
only that it exists and has stuff
and promises that its implementing classes support basic operations like adding and removing elements from the collection
oh it has add
but that still falls under the catagory "i have stuff which may or may not be mutable"
Why do you want it to be an interface? I think Spigot is an ugly inner class sitting there and for practical convenience without having a point to further abstract
CraftBlock{pos=BlockPosition{x=127, y=62, z=108},type=GRASS_BLOCK,data=Block{minecraft:grass_block}[snowy=false],fluid=net.minecraft.server.v1_16_R3.FluidTypeEmpty@48284d0e}
where did you get it from
this
because there's no reason to be a class
BlockFadeEvent.getNewState().getBlock()
But okay lets forget this fucking design nightmare
that returns the current block
in the current state
just log getNewState
why does it say getNewState
because the state is just a collection of data
its not something in a world
and it links back to the block
so just log getNewState
is sign a block or an entity?
the state is Dirt's default Block State, if you don't cancel the event that state will be updated
block
ty
Tile entity to be exact
which events do you need to cancel in order to prevent movement of an certain item? There is so many different events with moving items (hotkey swap, clicking and dropping item or swapping an item, throwing the item out etc). Is there any examples of people doing this?
it has a tile entity
Did you answer yourself for the first question? As of second i guess you can look at any gui plugins
Yeah and there are more but I am also getting a problem with my current ways. Canceling the event but if you kept spamming it would still go in...
also is anyone here using intellij minecraft plugin to make plugins?
InventoryMoveItemEvent and PlayerDropItemEvent
and InventoryClickEvent
i could find those
may be more
because I want to know how I can set the output directory in maven
InventoryMoveItemEvent is for hoppers
oh shit
InventoryDragEvent maybe but i dont know if this accounts for hotkeys
or shift click
yea that is what i mean so many different ways and if you cancel the wrong event you might cancel two times and it will clip in the inv
give a search online, I personally use resource plugin to duplicate the jar over
then how do I get the block it changed to?
just
that is the block
getNewState().getBlock() is this block
the block is just a position
it will be changed after the event
so check the block at the location for a dirt block?
no because the event happens before it is applied
what are you trying to achieve lol @modern vigil
if you want to set what it changes to, i think you can modify getNewState() directly
don't have to check, if it isn't cancelled, it will change
getNewState().getType() == Material.DIRT
tried that
and it was false
yes
then it might be the wrong event
it is the correct event
exactly
seems weird to me
yeah
wait
did you check getNewState().getType() or getNewState().getBlock().getType()
just getBlock().getType()
or equivalent
so if I understand it right, I have to check the block after the event triggers?
no check the new state
yes but if you look into the method BlockState#getType(), it gets the block first before getting its material too
lemme try getting the block in the world
trust the event with this, it will update unless the event is cancelled
so is there a way to get the block that the block faded into?
and the type?
then try getNewState().getBlockData().getMaterial()
but yeah as solar said just trust it it doesnt matter
if you still want the new material for some reason just use event.getNewState().getBlockData().getMaterial()
i checked the craftbukkit source
wait lmao i just checked how the event is fired
it seems like you won't be able to tell from the new state
not even using this
wait nvm you can
ohk
that seems to have worked
wait is that nms class
yep
the getNewState().getBlockData().getType()?
yes
BlockState stores the location
yea...
w h a t
oh wells
@Override
public Material getType() {
return CraftMagicNumbers.getMaterial(data.getBlock());
}
bruhhh
where is it
what package
net.minecraft.world.level.block
ah thx
ah shit i dont have mojang mappings
CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.j.getBlockData()
is that what fires it
oh lmfao
obfuscating block names
public static final Block a;
``` my favorite block
make a wild guess
oh lol
kinda cool to see the internals of the server
when looking at for example the block dispenser you can see the code behind something youve seen in action and taken for granted thousands of times
Mojmapped makes things much better
buildtools
banners maker
._.
oh yeah
lmao
how would you use mojang mappings for different versions in maven ?
make a guess
nvm you can't
unless you set up a multi-module project
do you think i can use loom for paper
where each separate module imports a certain version of the artifact
or actually spigot
hmmm i think i will stick to the newest version only xD
yes force users to update
Take a look at this: https://github.com/PaperMC/paperweight-test-plugin
ty
Hello, does someone have a working code to check if a player is in a specific area please? It's been few days i'm looking for something like this, and i coded a thing that worked a bit but i think my code isn't good
?paste your code
okay
god no
here is my code: https://paste.md-5.net/toveyuhiso.java
p.getLocation() is the current player location and the getX1, getY1 etc are the 2 xyz coordinates of the area
yeah thanks for the tip 😄
it works for tiny areas but it doesn't with very big area so i thought my code is wrong 🤷
are you calculating what getX1 is ?
probably X1 and X2 are not min and max and cause some errors when not min/max declared
i can give you the whole class
you can also create a boundinx box with 2 locations and check if the player boundinxbox hits this
idk what is boundinxbox, i'll search it
its like the class you just created ... but with more functionality xD
and safer code then yours is since it calculates min/max from your input
Okay thanks
e.getCursor is the most useless thing ever
ok dont use it then
https://paste.md-5.net/evocegavav.cpp
Is this notice.txt fine? I add the Copyright Motive tomorrow
So i just checked and you'll say i'm coding on a very old version but this class doesn't exists for 1.12.2
so the only solution i have is coding something myself to know if the player is in the area
or just copy BoundingBox class ^^
probably online
and even after copying it i wouldn't know how to use it for what i want
if you want to code it yourself you should think about how to get the min Location and max Location and check if the player is between them
?
Copyright 2016 inventivetalent. All rights reserved.
But why? What reason do you need to do this?
I would bei hundret percent Safe with my plugin-release
What license are you using?
Gplv3
If you're creating an open-source Gplv3 plugin why would you need this? You only need to do this if their license requires it
Because spigot is under gplv3, and gplv3 says that i have to use the Same license
I didn't completly understand the licenses so i die thus
the only thing you should rly need is this part and a check whether the playerLocation x is between min/max and y between min/max and z between min/max ... should be simple af
Unless required you really don't need to. So if they want you to include the GNU license you can but you don't need to have a notice letting people know you use said code.
OK thanks man you are one of the First persons that explained IT that i can understand. Thanks
With Apache 2 license when it says "requires a notice" it means that if the original project has one A copy of the NOTICE file with attribution notes (if the original library has one).
It's basically if the library or whatever has an attribution notice you must copy that over
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
OK i Just inlcude the notice from the library and the all licenses If needed
Yeah. I mean personally I wouldn't worry about it. It's not like you'll ever see legal action on it especially if you're making yours under a public license
It works now, thank you very much!
I added this to my class and execute setMinMax method when a coordinate is added:
public boolean isPlayerInRegion(Player p) {
Location pLoc = p.getLocation();
double x = pLoc.getX();
double y = pLoc.getY();
double z = pLoc.getZ();
return x >= this.minX && x < this.maxX
&& y >= this.minY && y < this.maxY
&& z >= this.minZ && z < this.maxZ;
}
public void setMinMax() {
this.minX = Math.min(this.x1, this.x2);
this.minY = Math.min(this.y1, this.y2);
this.minZ = Math.min(this.z1, this.z2);
this.maxX = Math.max(this.x1, this.x2);
this.maxY = Math.max(this.y1, this.y2);
this.maxZ = Math.max(this.z1, this.z2);
}
When I am calling my custom BagInventoryClickEvent whenever I pass through all variables and the events get called the e.getWhoClicked().getHolder() chances
hi do you know open source project use ASM?
?
ASM
do you know ASM?
no
what do you prefer?
ChatColor.RED + "" + ChatColor.BOLD
// or
ChatColor.RED.toString() + ChatColor.BOLD
The above performs an unnecessary stack push and method call
I'd probably create a function like format
which would be format(ChatColor..., String)
oh wait varargs are at the end
uhh
format(String, ChatColor...)
if i have a java 16, 1.17 server, would a plugin made with java 17, 1.17 spigot api work on the java 16 spigot 1.17 server?
all in all, it's a complicated matter
you can give me example? to apply change to exists class?
Is the class loaded?
If you can't answer that question, you shouldn't be doing ASM.
yea
Then you can't apply changes to it.
JVM implementations typically disallow the modification of an already loaded class.
You have to apply transformations before the class is loaded, e.g. within a custom ClassLoader implementation or via instrumentation (java.lang.instrument)
I would like to override the already existing spigot classes
You require instrumentation then (as you can't change how Spigot loads via a Spigot plugin)
But there's a problem with that:
It's harder to set up for the end-user, AKA server owners, as it requires adding an additional startup flag.
I would like to do without javaagent
Well, you can't.
;/
If you're going in through a Spigot plugin, Bukkit/Spigot is already loaded and even then you can't change the classloader they use.
Instrumentation is run before every class is loaded, no matter how it's loaded, and is therefore the only option.
Your other option would be modifying Bukkit itself via a fork, but obviously that's not viable.
engine modification is annoying
When you have access to the bytecode of a class (represented as a byte[], like in ClassFileTransformer), you can pass it to an ASM ClassReader.
With the ClassReader, you can work with the class via ASM using a ClassVisitor (which you will implement yourself)
I don't quite know what you mean
I'll give some code give me a second.
you could attach a dynamic agent at runtime and retransform loaded classes, few limitations but they aren't too bad
var cr = new ClassReader(bytes);
var cv = new MyClassVisitor(Opcodes.ASM9); // Create MyClassVisitor yourself.
cr.accept(cv, /* flags here */);
I believe that should be correct ^
The problem with dynamic agents is that server owners require a JDK installation for them to work.
They're also incredibly hacky.
wdym?
that depends. if you compile it for java 16, it will work
if you compile it for java 17, it won't
you can set the desired target version e.g. in your pom.xml
I always use java 17 to compile (so I can also access 1.18 NMS) but set my target to java 8 so it also works in 1.16 on java 8
@main dew You need a basic understanding of JVM bytecode if you want to work with ASM, at least for method instructions.
and how can i use cw or cv latter?
Oh right sorry I also forgot to mention ClassWriter
I know I can save to disk or create my own class
so i have a light which is on top of a mountain (part of a plugin im making) and it spins slowly but i want to make an invisble light source wherever it is facing so when the light spins the light source moves with it making it look like there is a beam of light coming from it, is there an api to help with this or an easy way to do this?
If I wanted to display currency on screen from a hotbar message how could I reposition it on the screen for example in the top right or is it not possible?
If not then is there another way?
Well, no.
ClassWriter is used for saving an ASM class to bytes.
Not just for writing to a file.
It is essential for classfile transformation.
File file = new File("Example.class");
if (file.exists())
file.delete();
file.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(classWriter.toByteArray());
fileOutputStream.close();```
Notice the toByteArray()
That returns a byte[], and is not exclusive to file IO.
I believe ClassFileTransformer requires you to return a byte[] on transform?
Yes
The return value is the transformed bytecode while classfileBuffer is the original class.
but how can i use it later?
One second.
https://docs.oracle.com/javase/8/docs/jdk/api/attach/spec/index.html
Notice that the API is under com.sun, it's JDK exclusive.
Just wanted to add clarification.
the best option for me would be to overwrite
but you tell this is imposible 😅
sorry for my English
var cw = new ClassWriter(/* flags */);
cv.accept(cw);
byte[] bytes = cw.toByteArray();
Note: You have to utilize the return value of the visitor's methods to actually transform things.
ASM also uses nested visitors, so you have a MethodVisitor created by your ClassVisitor.
yea I have byte code with edits what next?
Well
You find some way to pass that byte array to transform the class ig
You have 2 possible options:
what's an ig?
it stands for "I guess"
- Static instrumentation (
jvmagent) - Dynamic instrumentation (Attach API)
So either way, there's going to be some pain for server owners.
what does it do?
What does what do
this is the first time I hear these terms
what am I doing these things and why are they problematic?