#help-development
1 messages Β· Page 1936 of 1
Spawner isn't considered a CreatureSpawner?
it is
class org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock cannot be cast to class org.bukkit.block.CreatureSpawner
you sure creature spawner is a block?
oh, hey md 5
Only block states can be cast like that, not blocks
It's not. It's a state
Call .getState
md_5, do you like redlib?
"What's that"
The 51st state, CreatureSpawner
he's heard of it before I think
whatβs the most efficient way of detecting when one entity gets close to another?
I want to code a plugin with my friend so is there is any IDE which allows that?
like in VS code there is a option through which i can liveshare and both me and my friend can type in same time but i dont see any features to code java spigot thats why i am asking is there is anything similar to that on which we can code together
If you are talking about both viewing the same code at the same time, "Code Together" plugin for Eclipse. Its probably available for InteliJ too
ok i use intelligi let me search
oh yea its there
thx π
String name = chunk.getX() + "," + chunk.getZ();
file = new File(Minewindpvp.getPlugin().getDataFolder() + File.separator + "chunks" + File.separator, name + ".yml");
chunkFile = YamlConfiguration.loadConfiguration(file);
boolean dirCreated = file.getParentFile().mkdirs();
boolean fileCreated = file.getParentFile().createNewFile();
if (override || !(dirCreated || fileCreated)) {return;}
chunkFile.createSection("blocks");
chunkFile.createSection("palette");
}``` is creating the 'chunks' directory but not the actual yaml file, any insight?
why this can't resolve constructor?
ItemStack head = new ItemStack(Material.LEATHER_HELMET, 1);
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(spirit.getId(), 5, CraftItemStack.asNMSCopy(head));
control click the class and see what the constructor should be
whatβs the most efficient way of detecting when one entity gets close to another?
Is there a way to get a base64 skull heads without using nms?
you dont need packets for this
in 1.18.1, yes
declaration: package: org.bukkit.entity, interface: Player
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
I tried this code
if(player.getActivePotionEffects().equals(PotionEffectType.LEVITATION)){
player.spawnParticle(Particle.FLAME,player_under,5);
}
```but it does not summons the particles
but i want to spawn an packet armor stand with item equipped
Wait, for how long this existed?
nah i meant profiles
Yeah, profile API was added 3 days ago
Can you get/set a profile of player?
My plugin is giving this error...... I don't even know https://pastebin.com/atDcDGVc
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
And we don't even know because without code this error is useless
I tried this code
if(player.getActivePotionEffects().equals(PotionEffectType.LEVITATION)){
player.spawnParticle(Particle.FLAME,player_under,5);
}```
it was supposed to summon particles when a player has levitation but it does no that
it does not summon any particles at all
youre trying to see if an entire collection is equal to a single object
Ahhhh
you need to do player.hasPotionEffect not player.getActivePotionEffects().equals
someone had already told them to use hasPotionEffect anyway
.

normally id be a little more ass and just ?jd, or even a ?learnjava
but imo they had the spirit, just missed the mark a bit
I imagine that at least intellij would give a type warn
it should
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Only happens when the player is offline
I am aware getOfflinePlayer() is bad
what is the event for right-clicking villager?
Get offline player is only bad if you use name
I couldn't find any way to get UUID
The only way I found was literally just doing getOfflinePlayer(name).getUniqueId() lol
I'm not doing anything critical that will matter if it gets the wrong player which is unlikely to happen anyway
Thst can cause a blocking web request
Idk how else to get the UUID................... so I just get the thing with the name
Ik it causes a blocking request but I also don't know how to stop that either
Hello, I'm getting this error installing BuildTools.jar
Enter the version: 1.18.1 Error: Invalid or corrupt jarfile BuildTools.jar
you dont have BuildTools.jar downloaded to your current directory

I have it, I try two ways, auto install by .bat and manually, either worked
Then redownload the jar file if it's corrupted?
Make sure it's fully downloaded then run it in cmd
I did it manually two times :(
And I tested with a past version when I used it to install 1.16 and 1.17 spigot version
screenshot what youre doing
I can do it by MD? Here i can't send images
Imgbb or something
Yup, al ready!
Directoy, .bat code, cmd
is something wrong?
What's in the buildtools folder?
Btw I'm doing this to use NMS on my plugin
This
And I restarted my pc and update java, but nothing
Why not just run it via cmd? What version is this for
the fact that its 1kb
something is probably blocking the download
just download it yourself
Ah shoot didn't see that
if you use curl
It's truee, ok I will download it again
curl -L before the download link
i think your download link redirected to somewhere else
so use -L it will support the redirect thing
thx it worked
Ohh, ok thanks!
This .jar I must to execute via cmd or via git?
Or both are fine?
It's a local jar run it via cmd
either is fine, git is recommended
wait ur supposed to run it through git bash?
yeah if you use bat thing from windows it will just gonna download git
so use it through git
it will not download anything
other than cloning things
always wondered why it downloaded PortableGit even when i had git for windows installed
Is there something about doing this to an OfflinePlayer that causes ticking entity error and freezes the whole server?
cant really help you without the error
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
purpur
so do paper
sir this is spigot
he copied that again
the error could be specific to purpur
I'll be back if error is still there
purpur is paper fork btw
Isn't paper spigot though? Or am I wrong abt that
?paper
could still be an issue in purpur rather than spigot
Boutta find out
No, its patrick
It works!!
Really thanks @sullen marlin @vocal cloud β€οΈ
im sad that i did not get any ping, but then i realized im not really like pings
On spigot the exact same thing happens but it doesn't post anything in the console
π π π
Oh hey it finally crashed
https://pastebin.com/tR6CBqGm that's true, it is
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its an inherent problem with the OfflinePlayer API in that it has to save after each method call
so your bulk method is resulting in hundreds/thousands of saves
just delete their stats file tbh
Lets go I didn't think of that and instead jumped to the most complicated answer
Thanks for your help
I don't think I woulda figured it out otherwise
Is there a way to check if a player who sits on armorstand pressed W or A Or Spacebar?
Doubt it
on LivingEntities, with some nms hacks, that's possible
but i doubt it is on armorstands
Which nms hacks?
Is SpongeAbsorbEvent#blocks mutable?
Maybe, check
Thanks
is it possible to change slimeblock restutiono?
Does the block metadata change when the block is removed or replaced?
What metadata
Block implements Metadatable, I'm talking about the methods that it implements
Actually, it is a bit irrelevant in my case. Thankfully
Wha-
I only upload the best quality stuff on my account
whats the difference between getName and getDisplayName?
I meant if anyone has ability to upload his own plugins on spigotmc
on a player object, getName returns your minecraft name and nothing more, where getDisplayName returns the name with optional prefix and suffix etc
getServer().getPluginManager().registerEvents(listener:this, plugin:this); Anyone know why both of the : are showing up on a red underline?
ok
ok
yeah it is
looks weird i dont understand the context
idk im following a tutorial and for some reason its not working
can just remove the this bit
i hope its not codedred ._.
idk i just clicked on the first one that showed up
kay
Are you sure that this is java and not scala or something
yes
because that is no java syntax
so like this getServer().getPluginManager().registerEvents(listener::, plugin::);
hmm
no colons
ok
no. this.plugin and this.listener
x::y marks a method reference. Mostly used with functional interfaces, but that is something for later
ok now were down to only 2 errors
It is very unlikely that you will need it
cant resolve symbol plugin and listener
would be unecessary
they are not defined
have you set the plugin and listener variables?
or fields
getSerer().getPluginManager().registerEvents(new MyListener(), this); // in your main class```
Could you link us that tutorial? I'm interested why it is suggesting you to do what you are doing
or replace this by your plugin's instance if not main class
hes using getServer so its in the main class
cool
the listener: and plugin: parts do not actually exist and are just inserted by intelliJ to aid the developer. They are the names of the parameters
if you look what he typed, you would have seen that he only typed "this" twice
Hello, to use import net.minecraft.server. * I must to add this right?
nope
its 2 lines above
if you use "spigot" you also have access to nms
if you use "spigot-api" you only have access to the spigot api and no nms
remapped-mojang is just for having nice named nms-methods / classes
but with "remapped-mojang" you will need an extra thing in the pom
Yep, I'm using both, it's fine?
just use "spigot" as artifact id
you dont need to add spigot-api if you have spigot
Ok it's fine, and the 'extra thing' where can I put it? above of version?
With what tool? Maven? Gradle? No tool?
you have to set the output path
If you're using Gradle, by default it will be <projectDir>/build/libs/
Guys! how can i use grandle with eclipse in an already created project? @quiet ice i used your method but i can't find the terminal
rephrasing my question, how can I remapp NMS?
there is a way with BuildTools?
I was confusing two things yesterday
In an existing Gradle project? Or you want to convert a no build system project into Gradle? Or Maven -> Gradle?
You need to do it via the "gradle tasks" view
now i get this logo on the project
?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
Can i use java 11 with spigot 1.8?
its this the right page?
You need to double click the "init", then go to the console view/window and complete the setup
Don't manually install the jar. Run BuildTools and it will install things for you
?bt
i don't get that page here
Oh first you need to go to the gradle tasks view. That would be
Window (on the top bar) > Show view > other > gradle > gradle tasks
Also never download the spigot jar. There is no official download page. The only way you should get it is from BuildTools
?bt
?buildtool
okay nice
Well yeah since you shouldn't use it
what should i use?
basic
oh god this is getting harder
Groovy, eclipse does not support kotlin well
eclipse doesnt support anything well
ok i did it, now i can see the grandle page
(Also this is how you should always create gradle projects in eclipse. Otherwise eclipse will go with the application template and let me tell you - in 80% of cases it sucks)
Eclipse is just sucking at everything
Eh, I'd say that this is a gradle issue
so now to import some api i can just use grandle right?
Yep.
Noice
It is best to get fully rid of whatever system you have in place right now, but you can always delay this task to later
?
Well your old eclipse build path is still present (I. e. when you told eclipse to use spigot). This may interfere with gradle
It isn't really important until you want to actually build via gradle (e.g. to shade stuff like bstats into your plugin) or until you switch your PC
so? i'm a little scared that this is actually going to damage my plugin
i spent like 2 months on that so...
Hi, I remapped the NMS, but now I don't access to the imports, is something wrong?
Not really. It's just right clicking on your project > build path > configure build path > libraries
Then you can remove any external jar you set up previously (though you need to readd them in your build.gradle file later on).
Without the remapp I have the imports
so i need to remove the spigot api from there and get the grandle one?
Yes
with the remapped-mojang the names have changed for the nms classes
also you need to run buildtolls with the remapped mojang flag once
how do i import it with grandle? π
https://www.spigotmc.org/wiki/build-you-spigot-plugin-with-gradle-groovy/ should be applicable there
yep, I already have it remapped, but but I still don't have acces to the imports :(
yeah because the name changed probably
EntityCreature will be Creature (same name like spigot, but different class)
also EntityZombie and all the other entities will now have the name without the Entity prefix probably
xd omg, is there a site or documentation to check the name changes?
contains a lot of data and thats why its soo big xD but you can search at top left for class names if the page loaded completly
? would be useless to search things on a 10% loaded page and then write " i cant find anything i search"
thankssssss
hmm im looking for a method to colorize hex colors and normal chat colors on the same string
and i want to use the normal hex format, not the one with a & infront
How do I stop scoreboard flickering
use scoreboard packets instead i guess
oh no you summon md5 with that
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
CompoundTag maybe
Likely by obtaining the locale of the player, then matching the timezone of the locale.
It isn't error free however, but it is the best thing you can do
Unless you are willing to do an IP lookup
Okay, i've made a command working, but whenever i send the command it outputs what i've set to, and the command too
if ((label.equalsIgnoreCase("ban"))) {
player.sendMessage(ChatColor.GREEN + "Hello " + player.getDisplayName());
player.getServer().broadcastMessage("hello");
}```
nvm
i was missing a return statement
return
wow
i just realised how inefficient bukkit itemstacks in inventory are
whenever you call getItem() inside Bukkit Inventory class
it would create new CraftItemStack object
also whenever you set ItemStack inside the slot
it would make a NMS copy inside method and store it
i know π³
how do i compare char? neither equals nor == is working
then why does it give an error
char x = 'x';
if (x == 'a') {
System.out.println("I destroyed the world!");
}
That is a string, not a char
...
chars use '
its the quotation marks aint it
you're using " which is a string, a char is '
Also, you should be using .codepointAt if there is only the slight doubt that you will encounter non-ascii characters
Plus it confuses decompilers :)
does this looks good?
When I do player.getHealth() it shows like 14.4999999046325684 on the health, anyone know how to fix this?
String#format
if(plugin.getConfig().getBoolean("enable")){
if(args.length==1&&args[0].equalsIgnoreCase("set")){
Location homeLocation = player.getLocation();
plugin.getConfig().createSection("savedLocations."+player.getName());
plugin.getConfig().set("savedLocations." + player.getName() + ".x" + homeLocation.getX());
}
}```
it was suppose to add the player x on config but instead it says 'set(java.lang.String, java.lang.Object)' in 'org.bukkit.configuration.MemorySection' cannot be applied to '(java.lang.String)'
this is not an real issue ^^ the player can also have 0.01 health and still alive
Well it is a bit difficult to display it
But using String.format("%.02f", player.getHealth()) should suffice here
or just multiply by 2, cast to int and handle it manually
you'dont need to set the new matcher every time
I just want it to be a whole number :/
then cast to int
yea i have it as a field but it was to show the pattern
Good idea π
just know that 14.49... will be 14 after getting casted
nah i dont mean this
ah that
matcher =... in while loop is unecessary
i saw it in the video lol
Matcher's similar to iterator
A lot of stuff on the interwebz is bad
dont know how to do it myself lol
hi
hi
?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.
?paste it
Could not find artifact org.bstats:bstats-bukkit:pom:1.8 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
is the error message
And pom.xml is
yes
Plugin version: 1.12.2
Need to import luckperms and essentials
Is there further informations needed?
Try using bstats 3 instead
bstats 3?
Nvm
How do I use it?
Just exclude every dependency
okay.
I. e. something like
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.6-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Yeah, give your ItemStack a UUID inside its PersistentDataContainer
setMaximulStackSize or something?
would that really work?
A UUID in the PDC will work
Yeah
And it's the more traditional approach
never heard of that
As you can only stack two items if almost all the metadata is identical
do I put this exclusion in every <dependency>
why an uuid tho?
Yes, though with different groupIds, artifactids and versions
or a random string
Or more simply a long obtained from an AtomicLong
cooldownTime.put(p, plugin.getConfig().getInt("cooldownTime"));
cooldownTask.put(p, new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownTime.get(p) - 1;
cooldownTime.put(p, timeLeft);
if(timeLeft == 0){
cooldownTime.remove(p);
cooldownTask.remove(p);
cancel();
}
}
});
cooldownTask.get(p).runTaskTimer(plugin, 20, 20);```
does anyone know why this is not working?
random values are inherently expensive to produce
oh no runnables for cooldown
just hashmaps?
and dont read config every time; read it onEnable and store it somewhere
with a runnable
okay
It worked ig
No bugs but is it ok with no dependency?
Most of the time you do not need transitive dependencies
And when you need them you can simply re-add them
Invalid maximum heap size: -Xmx4G
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Use 64 bit java
Right now you are using 32 bit java, which only allows up to 2G of memory
download it
Uh, where did you encounter this error?
saw that
hello, wanted to ask, why brigardier isn't really implemented in spigot, and only in library plugins? does nobody had time or brigadier that went to MIT licence isn't enough to make a proper support in spigot api?
Bro how can i fix that. It is bungee server
this is good?
if (!player.get(0).equals("ERROR")) {
ResultSet playerRS = (ResultSet) player.get(0);
if (!playerRS.next()) {
String encodedPassword = Base64.getEncoder().encodeToString(password.getBytes());
ArrayList id = mysql.select("SELECT max(id) FROM authentication");
String insertQ;
if (!id.get(0).equals("ERROR")) {
ResultSet idRS = (ResultSet) id.get(0);
if (idRS.next()) {
insertQ = String.format(
"INSERT INTO authentication (id, username, password) VALUES (%d, '%s', '%s')",
idRS.getInt(1)+1,
username,
encodedPassword
);
} else {
insertQ = String.format(
"INSERT INTO authentication (id, username, password) VALUES (0, '%s', '%s')",
username,
encodedPassword
);
}
mysql.insert(insertQ);
return 1000;
} else {
return (Integer) id.get(1);
}
} else {
return 1001;
}
} else {
return (Integer) player.get(1);
}
that looks like bedrock edition
Backends need to be in offline mode
- Please paste it in https://paste.md-5.net/
- Why don't you just try it?
Bro how can i fix that. It is bungee server
Bukkit comes from pre-brigardier times. Noone ended up changing it and so we are here
this is spigotMC discord I think
nice, password encoded in base64
work, but the code is like a giant waterfall and i don't know if is the recommendable
spigotMC and bungee come from the same house though
I know but geyserMC
Use generics
They are the best invention since cut bread
so if someone crazy like me will have nothing to do and give a try to implement it, there won't be problems, right?
org.bukkit.plugin.InvalidPluginException:
that mysql library goes brr tho
This happened when I put the plugin in the folder
do you have a plugin.yml file?
yes
Well it would be difficult to get it PR'd into spigot because it is stagnant, but there is probably nothing that is really blocking it
at least in source code
sec
paste your plugin.yml in this and it'll say if its valid
http://www.yamllint.com
Validate and Verify your YAML documents, optimized for Ruby on Rails
Bro i need help
question, do plugins get loaded into RAM or are they executed from the drive? Or is it a mix of both considering events get registered?
Ok
After classloading, RAM, before classloading disk
So if you delete a class from the jar before that class is loaded, it will throw an exception when it attempts to load that class
oh, good then, because this will be really interesting to do in my free time, even if it won't come even to a pull request
At least that is the case in my setups. Windows will have it's differences
its valid
?paste it real quick lol
is it even in the reources folder?
yes
You could try decompiling your plugin
Using JD-gui
And see what sort of plugin.yml you have there
I'm actually asking because i have 4GB ram and 200GB drive space
Then just use swap
I'm deciding if i want to optimize for speed or for size
but don't
name: RankUI
version: '1.0-SNAPSHOT'
main: com.mcpkdot.rankui.RankUI
authors: [ mcpkdot ]
description: rank UI
is in decompiled
Screenshot?
Recaf > JD-gui
whats the path of it?
Do you have the "com.mcpkdot.rankui.RankUI" class?
?stash
Bruh probably some very little error
With the right package?
package com.mcpkdot.rankui;
hehe i love optionals
hehe
what is teh exact error?
full?
?paste it, yes
the stacktrace
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java#179 one day I really need to rewrite spigot to use saner IO
Lmao
You do not have ess installed
bruh
Or ess loads after your plugin
It might be but how to change sequence?
set essentials as a dependency
Don't reference foreign plugins in your constructor or fields
Theres EssentialsX-2.19.2 in plugin files
in your plugin.yml depend: [Essentials]
or soft-depend if you want to use essentials' things but dont want to stop the plugin if essentials isnt installed, you would have to check manually tho
You can only safely use foreign plugins in non-JavaPlugin classses, provided they are not used in the constructor of the JavaPlugin
Well soft-depend wouldn't work here
i dont understand what you're saying lol
yay it worked thank you!
Well it would still attempt to load the class and would still throw an exception if ess is not loaded
i would do PersistentDataType.STRING and UUID#toString but idk if that will work
That is even worse
yea thats why i said "you still have to check if the plugin is present"
Use AtomicLong instead of anything random
You can assign the AtomicLong to a random value at startup if that is the issue
why atomic?
but afterwards it is just an increment + 1 which is a lot faster than a random number generator
For which UUID.randomUuid.toString should be fine
AtomicLong is faster!
Should be said, any of the atomic classes do not guarantee synchronization (necessarily not talking about lock mechanisms)
But AtomicLong has compareAndSet which can be a lifesaver to guard against race conditions
The goal here, is to have unique data in each ItemStack that would prohibit them from stacking.
That will not always guarantee atomicity
however you can use sth like getAndUpdate
Which ensures a synchronized βget value, change it, set it back based on previous valueβ
Hm, I thought weakCompareAndSet would be the one that doesn't guarantee atomicity
Well, they guarantee atomicity, provided that you know how to use them correctly
Idk the exact difference between weakCAS and just normal CAS after they changed to VarHandle as opposed to Unsafe
But hopefully they havenβt changed in spite of the internal change
getAndUpdate internally uses weakCompareAndSetVolatile
I got
Could not pass event PlayerCommandPreprocessEvent to RankUI v1.0-SNAPSHOT
Can you help?
That's not the actual error
full stacktrace please
?paste
are you importing the wrong Utils class?
Yes which is just a weakCompareAndSet to any variable which is volatile
I think, or perhaps if VarHandle was the class that could override that
But ye
RankUI.onCommand(RankUI.java:72)
I think compareAndSet is the same as weakCompareAndSetVolatile, though latter is HotspotIntrinsic so eh
what's more efficient and/or faster? Storing a group name per player then check in a FileConfiguration if that group has an attribute, or storing a EnumSet per player, then calling set.contains(enum) ?
?
Ah right, but ye you could stick with weakCAS. Probably worded it wrongly, those methods are atomically safe, but they may not end up guarantee synchronization of actions and updates you perform.
oh
public void onCommand(PlayerCommandPreprocessEvent e){
String[] str = e.getMessage().split(" ");
str[0] = toLowerCase(str[0]); <---------line 72
if(str[0].equals("/rankshop")){
openInv(e.getPlayer());
cool. So I did not misunderstand the atomic objects
why are you listening for a cmd preprocess event tho?
because Idk how to use normal way to do commands
you have to implement CommandExecutor and set an executor for a command
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Uh, complicated. Basically it is a wrapper around the primtive long (just like Long) but is mutable
^ if you wanna know you ought to look up the semantics of what volatile guarantees
It's main plus is that is provides many methods that allow multiple threads to operate on the object at the same time. Though you also need to use these methods correct
How do i access the black glass stained pane via code?
The entire motive behind atomicity is to avoid rigorous lock implementations π₯²
nawh
I do not have an example that uses atomic longs at hand, but there is something similar to it with a ConcurrentHashMap:
do {
PlayerRecord oldSuccessor = successors.get(worldPos);
if (oldSuccessor == null) { // There is no successor, so we can easily change it now
oldSuccessor = successors.putIfAbsent(worldPos, tickedRecord);
}
if (oldSuccessor != null && tickedRecord != oldSuccessor
&& oldSuccessor.score().get() < tickedRecord.score().get()
&& !successors.replace(worldPos, oldSuccessor, tickedRecord)) {
continue; // The old value changed in the meantime: let's have another poke at it
}
} while(false);
As you see, it is complicated
the itemstack is new ItemStack(Material.BLACK_STAINED_GLASS_PANE)
do while false huuh
forgot to mention, spigot 1.8
I think that was supposed to be true
Unfortunately you cannot do something like
loop: {
if (cond) continue loop;
}
But ye
Nah, while(false) was intended
Was it?
isnt it the same?
Isn't
for the continue i guess
Yep, I could've also used while(true) but I would have to invert all the conditions in the if statement and replace the continue with a break
which 'overrides' the false?
Usually when we change something atomically we have a boolean flag which is set to true and then dependent on some comparisons we set it to false thus terminating the atomic update
Ah right
Fair
Hi, how can i check when an armor is equipped and disequipped?
π₯²
Armor equip and disequip event
would only be something like
loop:
iload cond
jump_ifeq loop
How do you even remember those devilish instructions lol
I got error with inventory click event
?paste it ._.
just send the whold thing
also good
xd
omg
When did you define premiumPrice?
Okay, wrong wording
did you give it a value?
That is better
Pre-flattening black stained glass pane was STAINED_GLASS_PANE with meta something
13? idk
Does anyone know whether eclipse has a plugin that implements basic support for jetbrain's Contract annotation?
I'm having trouble with the playerItemDamageEvent event, it doesn't seem to cancel durability change at all when I cancel the event, I have a 1.8.9 server, any reason for this?
did you register the event? did you cancel it?
I'm impressed by the fact that even though 1.8 has a userbase of under 10% there are still quite a lot of devs for it
Yes
public void noDurability(PlayerItemDamageEvent event){
if (event.getPlayer().getWorld().getName().equals("spawn")){
event.setCancelled(true);
}
}```
uhm probably the world checking
Hm, and the condition can indeed evaluate to true?
Add a sysout or something
I can't exactly make it a global thing
Well then debug it
print all bukkit worlds and you'll see if it contains "spawn"
It's probably because people still play on servers that are 1.8 compatible
isnt hypixel still 1.8?
Hypixel is different
Ok so I'm using the ArmorEquipEvent and it works perfectly, but now how do i check if i disequip an armor piece? will it work with dragevent? if yes, how can i check the old item position?
or just a plugin that allows 1.8 like pvp
Nah, it's still on an ancient version, it really does not like 1.13 movement
The event from this https://www.spigotmc.org/resources/lib-armorequipevent.5478/?
i found that the inventorydragevent has an option to get the cursor position, but it is a set of integer, how can i get the first one?
Ah thatβs forked from the original
See the resource page I linked to check for unequipping
ty
.stream().findFirst() lol
Basically old item != null and new item == null or air
oh
nobody saw that
You donβt need the drag event
And?
Sadly not afaik
will it work? or will it throw some weird errors?
oh wait
it is the same as the one i was using
Should work fine
lol
I told you that you are just using a fork
The documentation for the original still applies
what its wrong with this? it doesn't do anything
Quite a lot
?
i want to make like an attribute to the item with stats
variable naming is unconventional
Use pdc for storing attributes
how should i store the data? in the item name?
.
You are invoking getLore#indexOf while iterating over it to obtain the index of the current value
i understand it is not good code
what is that?
?pdc
You then proceed to get the item at the index of the current value, which is completely useless
You use #replace() when #substring() is more performant
And that is about it
Pdc is so much nicer
well
No weird string faffing
cast?
nevermind
Do you get a ClassCastException or something else entirely?
if(plugin.getConfig().getBoolean("enable")){
if(args.length==1&&args[0].equalsIgnoreCase("set")){
Location homeLocation = player.getLocation();
plugin.getConfig().createSection("savedLocations."+player.getName());
plugin.getConfig().set("savedLocations." + player.getName() + ".x" + homeLocation.getX());
}
}
it was suppose to add the player x on config but instead it says 'set(java.lang.String, java.lang.Object)' in 'org.bukkit.configuration.MemorySection' cannot be applied to '(java.lang.String)'
At compile time or at runtime?
You need a key and a value
You are just passing a single argument
compile time
how do i import this?
Type it and the ide will handle that
You should have already done this if you are using 1.14+
If you are using 1.13- you are out of luck
i'm always in 1.17
Then you have it as part of the API
Sorry for asking again, now it is working fine when i disequip the armor but not when i do equip it, can you help me?
What's the best way to find a player that has a colored name?
@lost matrix
I read your guide on tracking player's block changes, and i am trying to store world,x,z of a chunk in a single key. i got something like this:
private long getaLong(UUID world, int x, int z) {
return x & 0xFFFF | (z & 0xFF) << 16 | (world.getMostSignificantBits() & 0xFF) << 24;
}
but im not too sure about how unique it would be, wondered if you had a better way
sorry to bother you π
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getDisplayName().indexOf('Β§') != -1) {
// Colored name
}
}
probably this
Ok i found the solution
what about to get player's name from a gui like
there's a inventory named <playername>'s info
If you created that inv, just keep a concurrent hash map
!
It's a ban GUI, you click on a player and it opens info inventory
Yeah, then HashMap
still better than the title ._.
Well yes
Map<UUID, UUID>
UUID is the viewer, the other UUID is the viewed player
Saves you a Bukkit#getOfflinePlayer lookup
thanks
I have a feature in my plug-in that changes a players skin when they join the server to a specified skin. It works well for the most part but an issue that it seems to have is, if the player is in the nether when they join the server the world will not load for them until they are teleported to the overworld. Does anyone know how I can fix this issue?
i doubt that's a good idea
Its been fairly reliable so far
Maybe use the new PlayerProfile api
Lets you set the skin from a mojang texture server texture
It's only in the like very latest builds tho
A UUID is 128 bits in length. A long has 64 bits. An int is 32 bits long.
This means that you can not reliably store a UUID inside of a long. 2 ints are however fine. 2x 32 = 64 π
Wish I could but the server Iβm developing for is still in 1.16,
Best you can do is
int x = ...;
int y = ...;
long key = (long) x & 0xFFFFFFFFL | ((long) z & 0xFFFFFFFFL) << 32;
When do we get 128 bit numbers
Uhm. Why? You dont need to persist the UUID because its always available on runtime.
long long ^^
int int int int
The idea was that i had like a Map<long, ChunkSnapshot>, where the key is the world,x,z of the chunk
BigInteger
Best you can do is a Map<UUID, Map<Long, ChunkSnapshot>>
Because String based arithmetic is so fast
Aren't big integers theoretically limitless in size
Yes
Pretty much
Are they string based?
Mhm
Lame
Let me double check
I believe to some extent they are?
Why can't java just support arbitrary bit length integers
It's what happens when you want beeeeg numbers
Table<UUID, Long, ChunkSnapshot>
π tables are underrated
I want 72 bit integers
Long2ObjMap (:
Long2whatnow
if you are still running on a 7MHz potato...
if you're not, I would not worry
Because nested maps smell. I would use a Map<UUID, WorldDomain> with WorldDomain managing a Map<Long, ChunkSnapshot>
also BigIntegers aren't exactly String based, are they?
I've never looked at their source
Yeah but tables already abstract the nested maps for you
HashBasedTable is quite slower than just nested map since it has to update an additional backing map most of the time
thats a point actually. Yeah ill do this
Tooble
It may be slower but ahh ugly
Yeah true
I guess this is nicer
i tried to use one of these then i found out old spigot versions dont shade it and for the negligible perf gain against not supporting legacy i just chucked it in the bin
π₯²
I thought only paper shades fastutil
oh wait really
that might be it lol
cause i run paper 
I believe there is some other primitive collection library that was used during some interval
banned
Trove or sth iirc
Trove
Yaa

GoldmanSachsCollections
They used that one also?
Oh nope. I just listed all the primitive collection frameworks i know XD
Ah, didnβt know that one so very pog
wtf is a trove
treasure trove
bootleg fastutils
SCHNELL
A better version of trove
Immutable primitive collections when βΉοΈ
π
Technically you could wrap around and provide an immutable view
But thatβs not as nice
I've heard of java plans of making primitives actually objects
It is going to happen anytime soon?
FastUtil is a high performance collection library for java.
Primitive collections prevent the overhead of wrapping
primitives into they Object counterpart. So long -> Long, int -> Integer etc.
Map<int, Object> is not possible in Java. This results in Map<Integer, Object> being used instead.
FastUtil provides collections like
Int2ObjectMap<Object>
or
Int2IntMap
To save some cpu time and memory.
Hmm, I mean there is project valhalla
how come like if a method returns void, you cant return the result of another method that returns void
wha
public void foo() {
return anotherVoidMethod();
}
eg
Interestingly my benchmarking of those collections showed that the initialisation of FastUtils collections
is quite expensive. So if you have long lived collections like a
private final Int2ObjectMap<>
then FastUtil is better. But if you have a spot where a lot of collections
are being created then Javas Collections are better suited.
thsts.. Pointless?
not completely, if it was in an if statement it will save a line ig
right, but void = void
how? if(smth) doSmthIdk()
thx!
void marks the absence of a pointer. So there is nothing to pass down then call chain.
returning from a void?
right that makes more sense
you can. and you don't even need to use "return" for that
Btw this problem was also encountered by oracle when working on Java 8. They just made a Void Object for this XD
Haha
Wait its been there since 1.1?
wasn't Void included since java 1?
oh or this
I thought it was JDK 1
like, "always been there"
Weird i swear ive seen this in 8 for the first time
well tbh I've seen many things for the first time like 10 years after they were added
normalise Void > void
for example being able to throw RuntimeExceptions without throws
int x = 1 / 0; XD
But elaborate. I dont know how to do this.
you can simply do
public static void doStuff() /* throws IllegalStateException // not needed */ {
throw new IllegalStateException();
}
without declaring throws IllegalStateException
because IllegalStateException is a RuntimeException. You can throw them always without having to declare it
that's e.g. why you don't have to wrap Integer.parseInt into a try/catch
Oh i thought you meant throwing an exception without the throw keyword...
oh no
throw and throws are both keywords π
well you still can: Integer.parseInt("GET REKD")
lol
Can I detect if a mob spawned naturally or by /summon?
in the CreatureSpawnEvent, yes
after that, no
but
you could listen to CreatureSpawnEvent and simply add the SpawnReason as PDC tag to the mob
ok ill try that
Btw you dont have to declare throws ever. Thats completely optional and you can compile
code opting out of catching uncaught exceptions.
uhm noooo
in bytecode it works, but javac doesn't like it
that's why Lombok invented @ SneakyThrows
Thats where i got it from ^^
Sure but you can kinda trick it into thinking you caught the exception even when you did not. Moderately usefull.
yep. I use it for stuff like FileNotFoundException when I already checked whether the file existed etc
I dont use it anymore because i had a really bad experience where it hid a thrown exception within a CompletableFuture<>. Took me a while to find.
whoops lol
yeah I only use it in API methods that aren't longer than 5-10 lines. Noone wants to e.g. have to wrap this into a try/catch:
List<String> lines = FileUtils.getResourceAsStringList("disabled-blocks.txt");
if the developer really forgot to include that file, tbh it's their fault. If this ever fails, things are seriously fucked up anyway
This makes sense
I need to take a look at those sween annotations a bit more often.
@Cleanup InputStream in = new FileInputStream(args[0]);
@Cleanup OutputStream out = new FileOutputStream(args[1]);
byte[] b = new byte[10000];
while (true) {
int r = in.read(b);
if (r == -1) break;
out.write(b, 0, r);
}
Auto cleanup of open resources looks kinda neat.
Cleanup? Never heard of that one
Same
is that Lombok too?
Yes
huehuehue
I really dont like lombok but i have been somewhat forced to use it
I don't understand why people don't like it
you can always decide if you want to use it or not
mfnalex when you sleep or rest
like wtf is this 
and @ Getter @ Setter @ RequiredArgsConstructor (or, in short: @ Data) for sure is better than having to write it yourself
but intellij does it for you
Hi guys how can I get the index of a specific itemstack in an inventory?
this creates a getter, equals method, hashcode method, to string method
u just have to start writing get... and can tab it in with autocomplete
the ToString.Include annotations are useless here
I think it can be a bit obfuscating if you dont fully understand the implications of each annotation and that
they are present at compile time but not runtime.
yeah and the file gets 300% bigger
useless boilerplate code
sure you can, but a simple @ Data at the top of the class adds as many getters and setters and equals and hashcode as you need
what's your question? π
meh whatever
when I'm so drunk that I pass out. Like this morning at about 3 am
its on #help-server
getContents and then find the index of that item
Depends on how specific you want it. But here:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Inventory.html#first(org.bukkit.inventory.ItemStack)
declaration: package: org.bukkit.inventory, interface: Inventory
why duplicated?
Return the contents from the section of the inventory where items can reasonably be expected to be stored. 
Those return two different arrays. The first also includes armor content etc
oh huh
this
is it possible to make this stuff or is it only for jdk shit
well what's easier?
writing
@Getter boolean someBool;
or doing this:
boolean someBool;
// Now click on Code -> Generate -> Choose "Getter" -> Choose "someBool" -> Click on Code -> Generate again -> update equals method -> Click on Code -> Generate again -> update hashCode method
oh and toString, too
The javadocs?
yes
what about javadocs?
but the getcontents does not have a method to get indexes
ah, intelliJ issues
you can do that easily
are you using maven?
yes
okay one sec
check out my pom
it's the "attach-sources" and "attach-javadocs" plugin or however it's called
HOWEVER - those javadocs will be a separate .jar
in the repo it'll look like this:
I think the IDE also is able to create the Javadocs if only the sources are available, but do not quote me on that
might be true but - why not just provide the javadocs if you provide the sources anyway
laziness
it's just one additional maven plugin π
Is it even a maven plugin?
the sources do NOT include the javadocs
my javadocs .jar is 150kb, the sources jar is only 26kb
which plugin is that
Because the sources are raw sources, and do not contain the additional markup
I know with eclipse however when it sees the javadocs it automatically "compiles" (if you can call it that) into HTML
The HTML form however will be a lot bigger than the raw form
What is a quick and dirty way to get the UUID of a player if Player#getUniqueId returns null?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
actually I am kindof dumb
how did you manage it to return null lol
tldr lombok messes up the javadocs plugin
how? i never had any problems
i think its the builder
except that of course lombok generated methods don't have javadocs
I saw that either the key or the value was null, the key was the player UUID but I didn't look at the value which was obviously null
meh ill look at javadocs another time
Wrong channel
anvilInventory.setRepairCost(0);
That doesn't work, right?
It works, to some degree
The method call is valid, however if I am right paper does not like this (no idea about spigot)
Welp π¬
Trying to not steal experience when using an anvil as a text gui
Whats the EntityType for WitherSkeleton?
You probably can achieve this via packets as I am fairly certain that the server is the issue here
bc EntityType.WITHER_SKELETON doesnt exist
?jd
is recipe book clientside or serverside
not in 1.8.8RO
then why there's separate ID's for furnace, blast furnace, and smoker in protocol
Basically:
1.8: EOL
1.9: EOL
1.10: EOL
1.11: EOL
1.12: EOL
1.13: EOL
1.14: EOL
1.15: EOL
1.16: EOL
1.17: EOL
they all share the same UI
What is a EOL?
End of life
End Of Life
and how does that help me set a entitytype to wither skeleton?
Skeleton skeleton = (Skeleton) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON);
skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER);``` big brain,
could be done a bit smarter I believe
spawnLocation.getWorld().spawnEntity(spawnLocation, Skeleton.class).setSkeletonType(Skeleton.SkeletonType.WITHER);
ok bro
only if the returned object is not used
Nope, seems to just be clientside and is easily fixed by just adding 0 levels to the player's exp
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT/.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT/.pom
Required by:
project :
whats the issue here?
im really confused- ive tried changing stuff and it just doesnt work
hi, i want tipped arrows to disappear when they hit anywhere but the players. so the players wont be able to pick them up. which event should i look into?
ProjectileHitEvent ?
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
thanks! i think getEntity will return the arrow, right?
Even smarter would be using a method with consumer
Did you forget to add the spigot repo?


