#development
1 messages · Page 124 of 1
let me introduce you to ✨ adventure ✨ https://docs.adventure.kyori.net/bossbar.html
no its not

Wait.
and depending on a whole ass other plugin that may be incompatible with existing plugins other people may be using.. isn't?
I know that adventure its probably better, but you will add a lot of weight to your plugin
probably, yes
it's like 500kB
everything
lmao
@neat pebble What's TabPlayer?
TabAPI.getInstance().getBossBarManager().createBossBar("TEST", 0.1f, BarColor.PURPLE, BarStyle.NOTCHED_20);
TabAPI.getInstance().getBossBarManager().toggleBossBar(TabAPI.getInstance().getPlayer(player.getName()), true);
.
.
it does have a bit of a learning curve if you aren't familiar with the concept of components (though they have existing for almost a decade.... funny)
Installing it now.
but once you get a few concepts down which can be easily solved by reading the docs and asking away, it's pretty nice to use
ngl adventure is 🔥
I dislike that they don't want to add support for other formats for MM placeholders :((
well the format has to follow the rest of the MM format
Is there any plugin that I would need to install or nah?
it's a library you shade into your plugin, no
Ah, perfect.
The BossBar doesn't seem to show up...
can't help with what I can't see
Sending it.
what did you even do until now?
BossBar bossBar = BossBar.bossBar(Component.text("Cat counter"), 0, BossBar.Color.RED, BossBar.Overlay.PROGRESS);
Just copied it from the docs to test.
No errors.
Did I forget to add a player...
What about that exactly isn't working? It's not finding the BossBar class? A method isn't working?
It just doesn't show the BossBar.
Like, there aren't any errors.
ok but I don't want to 👊
I don't know how adventure handles bossbar, but probably you have to add a player
or audience
I don't see a method for it.
You need to send it to a player, you'll definitely want to go over these tho
Please please please please DO read the docs to get a grasp of how the whole thing operates https://docs.adventure.kyori.net/getting-started.html
This is the bit of library you use to bridge adventure with Bukkit https://docs.adventure.kyori.net/platform/bukkit.html
^
Audience#showBossBar
player.showBossBar(bossBar);
It just doesn't show up as a valid method.
Because it's not
^
.
Wait, I'm stupid.
Omfg, that's embarrassing.
lol
don't be, happens more than it should
yep XD
Uh, what's a pointer in the audience() object?
Think of an audience as a "viewer", in the case of sending messages the "viewer" could be a player or could be console
Pointers are an abstract way to get data from an audience they may or may not have, e.g. a UUID, console does not have a UUID, but players do
How do I get the classes from the package with the path "path" that extends Component? ```java
public static Set<Class<? extends Component>> getComponentClassesFromPackage(String path) {
Set<Class<? extends Component>> set = new HashSet<Class<? extends Component>>();
try {
Reflections reflections = new Reflections(path);
for (final Class<? extends Object> clazz : reflections.getSubTypesOf(Object.class)) {
/* Add the class "clazz" to the set if it extends Component */
}
} catch (Exception e) {
}
return set;
}```
Wat :V
So like, player.getUniqueID()?
Yeah
Audience target = Audience.audience().get(player.getUniqueId());
It's says that it's an invalid pointer hmm.
uhm yeah that's not how you get an audience tho
Pointers are irrelevant to your situation right now just to be clear
I mean, I need to set an audience right?
Or can I just do Audience.audience().showBossBar(bossBar);?
No, you need to use the BukkitAudiences to get an Audience from a player, BukkitAudiences is what provides you audiences from players, command senders etc
Like these (ignore the filter one)
Wait, I'm a bit confused. So audience has it's own player variable or do I define a player as an audience method?
Let me start from scratch
You have a Player
Yes.
But you need an Audience to send the boss bar
Yup.
BukkitAudiences (https://docs.adventure.kyori.net/platform/bukkit.html) is an audience provider, it has methods that you provide a player or a UUID or a command sender and it will give you an Audience you can send stuff to
BukkitAudiences is that bridge between Bukkit and.. Audiences
lol
Uh, BukkitAudiences always seems to be undefined...
what do you mean?
Cannot resolve symbol 'BukkitAudiences'.
I tried to follow the initialization process on the docs.
Did you add the -platform-bukkit dependency?
That would explain things...
I get this java.lang.NoClassDefFoundError: org/reflections/Reflections error when I run this code in my program. java try { System.out.println("Test"); Reflections reflections = new Reflections(path); set.addAll(reflections.getSubTypesOf(Component.class)); } catch (Exception e) { e.printStackTrace(); } I read I have to shade it, how do I do that? Google isn't very helpful rn...
just rename 5555 to 0
ez @burnt turret
what
is all you have to do rename them?
because you could just rename 5555 to 0....
as I said
I am genius
no, but for real you need to use the #937946722028617759 channel
nope
I am trying to use ParticleLib to spawn a custom particle in my plugin (1.7.10)
But I am not sure how to get the net.minecraft.world.World parameter needed.
The error i get currently is:
org.bukkit.craftbukkit.v1_7_R4.CraftWorld cannot be cast to net.minecraft.world.World
and my function for particle lib is:
ParticleLib.proxy.spawnParticle((net.minecraft.world.World)player.getWorld(), ... other args
I've tried this method: ( (CraftWorld) player.getWorld()).getHandle() but it doesn't return the right type.
particle lib function takes these args:
public void spawnParticle(World world, double x, double y, double z, ResourceLocation texture, int age, float gravity, float scale) {}
How do I get the world if I'm using org.craftbukkit?
@burnt turret Does that thing needed to be shell script itself?
Also I'm not strictly looking for an answer to that question, I'm just looking for a way to spawn an effect with a custom texture in 1.7.10
who?
the guy that was asking for a script
dumb question alert 
How do I tell intelliJ that this is not null if isOnTeam returns true
Don't have a separate field for isOnTeam, just have getTeam return null if no, and a team if yes
then you have one check for if getTeam == null and otherwise you got the team
isOnTeam returns this.team != null should I avoid using functions like this and just get whatever object and check it where I want to use it?
Yes
Null check at the point of usage, less chance for a race condition or whatever
And then IJ can see what you're doing and guarantee that it's not null
Alright, thanks 👍
plugin noflyzone doesnt work please help me!!!!
?
So with deluxe tag this is the right format right? "{prefix}{name}&8: &e{message}" '%deluxetags_tag%'
What doesn't work
noflyzone obviously
Does anybody know the equivalent for curl --form on java HttpRequest?
I need to send a file and a string to an api https://github.com/oraxen/oraxen/blob/master/src/main/java/io/th0rgal/oraxen/pack/upload/hosts/Polymath.java#L25-L27
Hi how to add js packages in js expansion scripts
Does anyone know why the font priorities get messed up? https://gyazo.com/1180cf942c01d72422fdfce11db901e8
https://gyazo.com/35f61654eda65dfbb5714f56745502cb optifine fixed it
Collections.unmodifiableMap retuns a normal map you can just do entrySet on it, I don't think I understand the issue
How do I fix Exception in thread "main" java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile? My plugin worked, then I exported it again and it stopped working. I change some souts, that was all.
I'm assuming you reloaded the server, restart it instead and try again
That wasn't my issue. I was getting the wrong method 🤦 its IBlockDataHolder.u() instead of IBlockDataHolder.t()
Thank you though.
I used buildtools and got the unobfuscated version of 1.18.1 nms, and added it to my project libraries through my Intellij project structure. How do I let gradle know that I did that, and allow me to compile the plugin?
To make your life easier use the paperweight gradle plugin
if you're using gradle and you want to use internals
trust me
paperweight is the easiest way to go
if you don't want to target paper specifically.. just don't use paper specific methods
You can use spigot for the plugin and paperweight to add nms
what difference does it make?
It fixes this issue
You won't be able to compile to obfuscated while using deobfuscated without it
This is a great repo to see how it's setup https://github.com/PaperMC/paperweight-test-plugin
I added the entry to plugins {} and not it says it that it is not in the org.gradle namespace and it cannot resolve plugin artifact
is there a repo or something I am missing?
Yeah, check the settings.gradle.kts file, you need the plugin repository
would that translate over to a non Kotlin setting.gradle file?
Idk if it works on groovy, I remember seeing a message about it on paper saying it only worked on kts but I am not sure
Use kts though, it's not that different
so just change the ending to .kts?
Yeah
k
It says that compileOnly is invalid, would I use implementation instead? I am using a gradle shadowing plugin that uses implementation
all of them
For nms it'd be paperDevBundle for spigot api it'd be compileOnly anything you want to shade is implementation
Intellij says compileOnly doesnt exist
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
It's not letting you do that because you still need to change a few things to refresh it for the first time
Also don't use paperweightDevelopmentBundle
ok
what are those?
Here I commented some stuff out and added a few needed things, https://paste.helpch.at/bewexiduho.cs
Once you refresh gradle and it loads everything you can uncomment the rest
ok, now my gradle looks fine
but it still wont compile
says that it cant find symbol
Can you send the logs?
import net.minecraft.world.entity.EntityTypes;
^
symbol: class EntityTypes
location: package net.minecraft.world.entity
import net.minecraft.world.entity.EntityTypes;
it says that msg for each reference
of net.minecraft
Hey
Anyone got an idea on checking the amount of players in a world?
List<Player> players = world.getPlayers();
Integer size = players.size();
And then just do if(size == 2) {
Run code
But it only runs when 3 players join
run a for loop and have it run over every player and print their displayname to console, it will then tell you who is in that world, its possible that a player is duplicate or a npc is being counted for whatever reason.
because it should show just the players
Well I wanna get an integer not player names
i know that
actually thinking about it, why are you using Integer and not int?
i said that so you could figure out why and who was actually in the world
so you could figure out why its not working with the correct amount
you said it ran only if 3 players were in the world even tho you want it to only run if there are 2 players
luna is asking you to add some debug print statements to better understand exactly why you're not getting the results you expected; a sanity check to help make sure you didn't make a silly oversight
or better share the class? 
the thing that makes no sense is that the code should only function if the size of the list comes back as 2
unless list.size starts at 0
How can I make a while loop with spigot? When I use normal while it freezes the server.
what are you trying to do?
Im trying to repeat a set of code when something is true, if thats not possible I want to repeat something for 15 seconds when I say so.
then you should use the bukkitrunnable
then use that
you shouldnt have a while loop that goes on for so long
you can schedule a repeating sync task
ye im trying that
what he/she was asking (i think) was what are you trying to achieve
yes
not how
what you wanna do exactly
example:
if you say: i want to repeat a task every 10 seconds
you should say: i want to spawn particles in players location
we wanna know what you wanna do
when they hit the ground could they take damage?
No
cus if they took damage you couldve just listen to entitydamageevent and checked for the damagecause fall
just tell us!!
Ok
So
I have something that launches a player up
And I want to detect when they hit the ground again
jsut say it
what would you do when this check is successful?
Aight so I want it to summon an explosion particle and deal area damage
i think he's adding the player to some kind of list
and he wants to remove the player on ground
ahh lol
golem skill
if (p.isOnGround()){
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 100));
// p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 0));
Location location = p.getLocation();
World world = p.getWorld();
List<Entity> nearby = p.getNearbyEntities(4, 4, 4);
for (Entity tmp: nearby)
if (tmp instanceof Damageable)
((Damageable) tmp).damage(15);
world.spawnParticle(Particle.EXPLOSION_LARGE, location, 10, 1, 1, 1, 1);
hitground.remove(p.getUniqueId().toString());
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
whats that?
is that supposed to be a skill?
No its an item
mmmm
Here is the whole code
easy then
right click, run runnable every 10 ticks or something
max time = 15 seconds
check every 10 ticks if player is on ground
if so, spawn explosion
cancel task, remove from map
damn, that indentation
:D
wait, the spaces
it was a tesT
thats run in less than a second
I know
yes YES
run task timer
int time = 0
time++ inside the run
if time >= 30
that means 15 seconds passed and player is still flying
we dont care about that, cancel task
xd
and thats it
if they didnt hit the ground they are hacking
easy
oki
il try that
or
imagine dying
aight fine
or they are in the corner of a block
or a shulker hit them

:p
there are alot of reason that a player might not have hit the floor
tho you could force the position
i get it
in theory
dont need to rub it in

Final goal: When 2 players join the world, code is run. And anyone that joins when there is already 2 players will not be able to join.
w h y
alonso, i wanna make a speedrun
i wanna make a manhunt
i wanna make a skywars of 2 players
making a bedwars 1v1, everything is working apart from this.
When 2 players join I want it to run specific code (Starting countdown and tping), I want so that when there are already 2 and other people join it doesn’t let them
you need to start with that
if you have a bedwars system
then you are using arena manager
that means you have a method to
joinArena(Player player
or something like that
make the check there
Okay look
"i wanna make it when 2 players join the same world"
that's totally useless since you already handle
games in a way
How do I get the amount of players in a world, and if there is 2 players run certain code
why world?
why?
if you have an arena system
you must have a way to check
how many players
are in that arena
why not simply check that
bruh
But not that
if (hitground.containsKey(p.getUniqueId().toString())) {
why
cant you simply check uuid
you should Hashmap<UUID>
instead of Hashmap<String>
why the hashmap for that?
this.counter--;
Its so multiple people can do it at once
suggestions:
- use UUID, not toString()
- the hashmap should be usingSkillsMap where player is added on right click and removed when (1. hits the ground 2.time expires)
- dont use unnecessary line breaks (enter), it makes the code unreadable


How can I import javascript packages in javascript expansion's scripts
depends on what you mean by a javascript package
I want to use string-similarity
I use this for getting data in SQLite but how would i for example get the player from the kills? (the other way arround)
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = getSQLConnection();
ps = conn.prepareStatement("SELECT * FROM " + table + " WHERE player = '"+string+"';");
rs = ps.executeQuery();
while(rs.next()){
if(rs.getString("player").equalsIgnoreCase(string.toLowerCase())){ // Tell database to search for the player you sent into the method. e.g getTokens(sam) It will look for sam.
return rs.getInt("kills"); // Return the players ammount of kills. If you wanted to get total (just a random number for an example for you guys) You would change this to total!
}
}
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
} finally {
try {
if (ps != null)
ps.close();
if (conn != null)
conn.close();
} catch (SQLException ex) {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex);
}
}
return 0;
}```
wtf?
and please use UUIDs
you can do SELECT * FROM table WHERE player = ? and use prepared statement to fill the blanks
wait can you do SELECT * FROM ? WHERE player = ?
nm i am just being dumb
What is a prepared statement?
SOLID
and is it possible to loop through a column?
i want to get the player with the most kills for example
to loop a column
if you mean loop all entries
i guess a while loop
question is why
SELECT * FROM table_name ORDER BY kills DESC LIMIT X
Where X is then number of players you want to fetch
to get the top kills
then do what Yugi suggested
i am gonna try 🙂
Is it also possible to get the number of rows for the X value? (so i can get the number of players in the column to use as the X value)
I think you should learn more about SQL and programming in general, not being aggressive here.
X is the amount of entries (rows) your query will return. If your X is 100 and your table has 10 rows, it will only return 10.
If you want to get ALL of them, don't do limit.
what?
Ty
uhm how can I change the effect, more specifically the color of a potion itemstack?
d;spigot PotionMeta#setColor
void setColor(@Nullable Color color)```
Sets the potion color. A custom potion color will alter the display of the potion in an inventory slot.
color - the color to set
that's since 1.14?
Imagine documenting the api with @Since smh
Probably 1.13? But not sure
uh I will only support 1.17+ I think
with full respect and no offense to anyone.
Officially. Fuck legacy versions.
(and thanks matt)
||I felt offended, reported to discord||
Also, that allows for custom colors, what if I want colors from actual different potions that already exist?
sus
Try and see it
I hate that there are like 2 or 3 different ways of making potions and defining their color
And depending on which method you use you can't do some other stuff
how can I try it lol, potion colors from existing potions don't follow a pattern
(or do they? fuck)
I am basically trying to loop all potion effects and give them their respective pot
I mean would it make sense for it to not work if the color is the one another potion uses?
uh I just looped PotionEffectType.values()
and then used the #getColor() of it to get the color
so suppose we gud
I cant seem to get buildtools working is there any other way to get the Spigot 1.17.1-R0.1 sources etc.
How do I get the NMS Level object from a bukkit world?
I try the whole getHandle() thing but that returns WorldServer
Vector dir = p.getLocation().getDirection();
p.setVelocity(dir.multiply(2.5));
```Anyone know why when I launch myself upwards its so much more dramatic than when I go forward on an angle?
normalize your vectors
da fwak
.normalize()
although getDirection() may already be normalized, I forgot
yeah, it's normalized. Nevermind, it wouldn't do anything
Direction is a vector between -1 and 1 on each axis
public Vector getDirection()
Gets a unit-vector pointing in the direction that this Location is facing.
anyways, you might be talking about how when the player is on the ground, their velocity gets reduced by 0.6 * 0.91 every tick. While if the player is in the air, it is reduced by * 0.91 every tick
-- bump --
java -Dpaperclip.install=true -jar paperclip.jar
for the paper sources at least. anyways, I'd just get buildtools to work instead.
I have been trying but I don't really use git so idk what it means by invalid remote
https://paste.helpch.at/atozituwem.pl
Did you try deleting everything in that folder except BuildTools.jar?
lol
perl filetype
i believe I have I have also tried it in something like E:\folder (just incase it was some windows nonsense) also It hink that is the wrong error lol this is the one I cannot solve
Anyone know if there's a way to disable this?
What is this called?
list:
'nested1':
- 'String'
- 'String2'
'nested2':
- 'String'
- 'String2'
#...
A nested string list?
I believe?
Anyways, I can't figure out how to get the amount of nested lists there
Like I want to add nested1 and nested2 together
Get lists, combine both
for (String key : config.getConfig().getConfigurationSection("list").getKeys(false)) {
I've tried creating an ArrayList to add the keys right?
But it doesn't return right
Hold on, let me try to recreate it
So yes, "list." + key
What do I add to the ArrayList?
key, or "list." + key?
And if I add "list." + key I need to do config.getConfig().getString("list." + key)?
list is a configurationsection
list.blah is a list of strings
Right, and I want to get the amount of list.blah
Are you trying to get the list from config?
Yes
You can use getList()
I want to get the amount of lists
oh
In the configurationSection
how many lists are under list
In the example, 2
yeah
I think he wants the size of keys under that list
Yes
config.getConfigSection("list").getKeys(false).size() should work ?
I will try that
anyone have experience with the 
Thank you
And thank you Failures and thank you AlonsoAliaga
Did you follow the buildtools guide exactly?
You built Spigot and have the spigot jar? If you do and it's not working for the API in your plugin, try to navigate from the folder where the Spigot jar was built, to Spigot > Spigot-API > target then use the shaded jar
If that's what you're asking
I know that worked for 1.18 for me, before I switched to gradle
Seems like he wants the source code
if you really give up, codemc has a NMS repo
wait what-
true
Who cares about that dkim
Pretty much nobody unless they are trying to go open source
Even then mojang won’t care for half a second
I have Spigot-API in maven. But the plugin I am trying to build required access to Spigot-1.17.1-R0.1 and from what I saw I need to use buildtools to generate the sources in my maven directory but builttools won't finish
--
Also yes I followed the guide exactly
artifactid spigot-api doesn't include nms btw
Why does BuildTools fail?
Are you using java 16?
hello guys! Maybe who knows how to correctly cancel WindowClick packet on 1.17+ versions?
i am tried method from PlayerConnection
// Clear carried item
connection.sendPacket(
new WrappedOutWindowSetSlotPacket(
-1,
-1,
player.playerInventory().incrementStateId(),
player.playerInventory().carriedItem())
);
// Reset in menu
connection.sendPacket(
new WrappedOutWindowSetSlotPacket(
packet.windowId(),
packet.clickedSlot(),
player.incrementStateId(),
packet.clickedItem())
);
// Update current container
player.updateContainer();
but when user is spamming with click it removes item from menu
i am not sure is the best solution hold previously clicked item as far as i have animated buttons
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent event) {
event.setCancelled(true);
}
i want use bukkit event system
i just trying to found another way to handle inventory click and implement it in my gui system
?mf
Looking for useful libraries/frameworks?
Here are some which have been deemed useful by the community and are used daily.
-> Menus: https://mf.mattstudios.me/mf-gui/gui
-> Commands: https://mf.mattstudios.me/mf/mf-1/getting-started
-> Messages: https://mf.mattstudios.me/message/mf-msg
-> Config: COMING SOON™️
i guess, that someone also tried to do smth like that
i just moving my own menus from bukkit to packets
Nvm, founded solution
simply caching in updatable buttons current stack (if someone will need)
anyone know how to use TimeAPI with maven?
what TimeAPI
jsut like you do with any other dependency
maven 🤡
^ that too
we do
well on its github repo page
becuase
exactly the same
hey piggy
oh hey PiggyPiglet
apparently maven users are not treated equally here on this discord server
I think you can just paste the gradle code into your pom and ij will translate it to xml
Have you ever felt like a piggy bank?
they are not treated equally by me 
also feel free to give this a read - https://wiki.helpch.at/piggys-barn/java/gradle/argument
okie I will try that
ok that didnt work
I use IntelliJ
the url is the maven repository url, I'm sure you can convert that to maven format on your own
the dependency is groupid:artifactid:version
the version being + is equivalent to maven's LATEST
"implementation" is equivalent to the COMPILE scope for maven, however that's default, so no need to explicitly declare it
you should add a comparison between shading with Maven and Gradle
shading isn't a vanilla feature of gradle, you have to use a third party plugin
because thats a big point for me, at least in Minecraft terms
(mind you, you have to use a plugin in maven too, but that's official)
you have to do that with maven too
that argument is only really based on vanilla features
its just so much bigger with maven, and i think that's important to note
but in saying that
to shade with maven you've got what, like 30 lines of plugin configuration
it's legit just 1 line in gradle
yep
id 'com.github.johnrengelman.shadow' version '6.0.0'
*7.1.0
idk what the latest version is
yea
and the configuration
with relocations and exclude stuff
goals n stuff
many less lines, so i think it should be there
relocations are just one line in gradle aswell, excluding the 2 lines for block opening & closing on the shadowjar configuration
yep
I guess the non third party way for gradle would be the distribution task from the application plugin
But it doesn't shade exactly, it creates a jar with lib jars inside
its works on 1.18.2 ?
what is "it"
Placeholder api
Should, some people have issues with connection time out or something
Finally, I have something to battle maven users against 😳, thanks piggy I've never seen in my life
You win by saying mavens 200 years outdated

btw, is it weird that I do not see any improvements with build cache? Can I check that it is really turned on?
I have a pretty small codebase tho (about 8k lines)
Well gradle already caches and watches input and output files pretty aggressively but you can generate a build scan with ./gradlew build --scan and check in the switches tab if the "Build Cache" is on or off
Build scans are godly 
So are you ems
pft if only
😘
it's on
I mean it still builds very fast
I mean as far as I know it's working so 
it just doesn't really change whether I turn it on or off, I guess I have too small codebase
it still builds under 2 seconds, so I am very happy with it
You can also check what's taking the most time in the performance tab
I stg whoever invented build scans is the greatest person ever
yuh
it's like timings, but for building
lol I'm an idiot
the difference is 4s -> 1s with build cache
so worth it
Since modifiers does not exist in the Field class in java16. How can I edit a final field?
Google didnt help?
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
Unsafe unsafe = (Unsafe) unsafeField.get(null);
unsafe.putObject(connection, unsafe.objectFieldOffset(connectionsList), wrapper);
"Unsafe.class.getDeclaredField("theUnsafe");" I think this won't work on all JVM's
Please take a look at this method from Google's GSON
Guys how do I make a loop of all json object of json array in js ?
I mean i do myJsonArray#forEach but it returns undefined and when I print my json array everything is fine
also I can do myJsonArray[0].id
without problem
it's different on android jvm
How do I change the player skin using this? Not sure which property to use, cannot find it in the docs or any tutorial
protocolManager.addPacketListener(new PacketAdapter(infection, ListenerPriority.HIGH, PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketReceiving(PacketEvent event) {
super.onPacketReceiving(event);
for (PlayerInfoData playerInfo : event.getPacket().getPlayerInfoDataLists().read(0)) {
playerInfo.getProfile().getProperties().put();
}
}
});
Using Protocollib
It is
you never know what people are going to attempt to do with your stuff
I recommend just sending a new packet if you want to change there skin
changing player's skins is very difficult after 1.7.2 i believe
visually atleast
i remember watching a videa that said that cause people were changing skins too easily
Does someone know if its possible to serialize a TextComponent from adventure to String and deserilize it later without losing click events, hovers, etc?
I need it to send a redis message
👍
pretty sure it works similar still
i thought that it was clamped down on pretty hard by mojang, could be wrong tho
nah i think its just value sig with playerinfo packet
wouldnt make much sense for that to change
maybe tho
it's possible
ok thankyou 
Found out that it's not very difficult with Paper, you just need a signature for the skins now and the base64 ofc.
Anyone know the base float for player speed?
0.1
When I deserialize the component, it doens't appear formatted in chat, I mean, it broadcasts the component style. How can I give the format that needs?
wdym "it broadcasts the component style"?
what does it broadcast exactly? how are you deserializing and how are you broadcasting?
I tried that but it seemed too slow
It’s not as simple as a number
.5
that also seemed too quick
It also depends on current friction
Lmao idk go look at source
getFrictionInfluencedSpeed
TextComponent finalMessage = chatFormatSerializer.format(chatFormat, player).append(Component.text(message));
return GsonComponentSerializer.gson().serialize(finalMessage);
thats how I serialize @lyric gyro
how are you deserializing and how are you broadcasting?
Bukkit.getServer().broadcast()
Bukkit.getServer().broadcast(GsonComponentSerializer.gson().deserialize(chatMessage.getMessage()));
what's chatMessage?
public record ChatMessageBroadcaster(String message) {
@ConstructorProperties({
"message"
})
public ChatMessageBroadcaster {
}
public String getMessage() {
return message;
}
}
redis message
message is the serialized string
.
are you calling toString on a component anywhere?
that would be it
ill try
Oh, I'm using Player's default setSpeed function
I assume attributes and setSpeed() is a bit different
It just sets a value. I don't know if it does what you want it to
It does the exact same as the attribute in my experience
Well speed gets overwritten by the attribute, so setting it directly doesn't seem wise
I'm currently trying it live and it seems to be working as much as i can expect, though attributes is safer i assume?
Another reason I get annoyed by java...
ConsoleOutput.debug("Location: "+(minion.getLinkedChest("Link_Chest") != null ? minion.getLinkedChest("Link_Chest").toString() : "null")+
" Current: "+b.getLocation().toString()+" Match: "+
Boolean.valueOf(minion.getLinkedChest("Link_Chest") != null && minion.getLinkedChest("Link_Chest") == b.getLocation()));
Location: Location{world=CraftWorld{name=world},x=8.0,y=99.0,z=71.0,pitch=0.0,yaw=0.0}
Current: Location{world=CraftWorld{name=world},x=8.0,y=99.0,z=71.0,pitch=0.0,yaw=0.0}
Match: false
(Forgot I need to use .equals() But still annoys me lol)
That's a lot of method calls for something that should really just be called once and cached
eh, it probably gets inlined
Its also just debug lol
yeah just to help Yapper remember that Java has referential equality lol
Yeah. I forget that not only String can be compared with .equals() alot
every object 😌
How do I get the direction a player is facing? North, East, South or West
if player.getYaw() > -45 && player.getYaw < 45 return WHATEVER DIRECTION THIS IS
right
don't forget you also might have to add or remove multiple increments of 360 degrees
player Yaw is not bound between 0 and 360 lol
technically, the server does bind it between -360 and 360
as it crashes if you get the yaw too high
i thought its between -180 and 180
nope lol
apparently it's -360 and 360 lol
public static String getCardinalDirection(Player player) {
double rotation = (player.getLocation().getYaw() - 180) % 360;
if (rotation < 0) {
rotation += 360.0;
}
if (0 <= rotation && rotation < 22.5) {
return "N";
} else if (22.5 <= rotation && rotation < 67.5) {
return "NE";
} else if (67.5 <= rotation && rotation < 112.5) {
return "E";
} else if (112.5 <= rotation && rotation < 157.5) {
return "SE";
} else if (157.5 <= rotation && rotation < 202.5) {
return "S";
} else if (202.5 <= rotation && rotation < 247.5) {
return "SW";
} else if (247.5 <= rotation && rotation < 292.5) {
return "W";
} else if (292.5 <= rotation && rotation < 337.5) {
return "NW";
} else if (337.5 <= rotation && rotation < 360.0) {
return "N";
} else {
return null;
}
}```
oh no it's actually just not bounded
plugins can set the yaw to anything
Spigot api 😌
lmao I just tested and it's -180 to 180 in 1.18.1 at least
so weird I came over here and the same thing is going on
actually trippy
It's normally between -180 and 180 but it can be more cuz bukkit
more like buzzit
If you want a simpler version
private static final List<BlockFace> DIRECTIONS = Arrays.asList(
BlockFace.NORTH,
BlockFace.NORTH_EAST,
BlockFace.EAST,
BlockFace.SOUTH_EAST,
BlockFace.SOUTH,
BlockFace.SOUTH_WEST,
BlockFace.WEST,
BlockFace.NORTH_WEST
);
public static BlockFace getCardinalDirection(final Location location) {
return DIRECTIONS.get(Math.round(location.getYaw() / 45f) & 0x7);
}
since 1.13 yes
Ugh, is there a way to "round" it? Like that there are only 4 directions instead of many more
huh?
Yeah this is all the method returns
Dafoq is up down
Looking up or looking down
This still better 
Though getFacing will never return UP/DOWN/SELF tho but yeah they exist
you want my code?
i just did it
I just did this
Currently messing around eith that
if (yaw > -45 && yaw <= 45) {
//positive z
} else if (yaw > 45 && yaw <= 135) {
//negative x
} else if (yaw > 135 || yaw <= -135) {
//negative z
} else if (yaw > -135 && yaw <= -45) {
//positive x
}
But ^ 
weird stuff
i like
This is literally the thing i have
Almost
The 3rd if is the else
Im stuck trying to figure out why when a player who tries to appoint another player to someone they have permission to it is sending them the error that they cant appoint any ranks, but their appoint list shows all of those ranks that they should be able to appoint others to
but it only does it for all of the groups besides the first one defined in the config
If I am op, it obviously works. But when I'm not op and I have the permission for cityrp.appoint.secofstate, it tells me there are no ranks I can appoint.
Config
Groups: # // DON'T CHANGE THIS! \\
President:
permission: "cityrp.appoint.president"
track: "executive"
groupNames:
- 'speakerofthehouse'
- 'secofstate'
- 'secofdefense'
- 'secofjustice'
SecOfState:
permission: "cityrp.appoint.secofstate"
track: ""
groupNames:
- 'firechief'
- 'fireasstchief'
- 'firecaptain'
it's doing that on the president permission
if you sent the message of what the permission was, you'd see
instead of return and send error message, try continue
continue will skip the rest of the code in the for loop, right to the next item in the iterator (if any)
Will try this tomorrow I’m in bed 😂
continue pog
To connect a plugin with another one do I just need to add the jar of that plugin to the libraries?
hi people, i need help with PacketEvents Metadata:
https://upload.skyslycer.de/idea64_GHNN7y1x3R.png
The only thing that works is 5 (no-gravity), everything else just doesn't apply
Wiki:
https://wiki.vg/Entity_metadata#Armor_Stand
Armor Stand metadata
https://wiki.vg/Entity_metadata#Entity
Entity metadata
You probably need to do the shifting
Idk what EntityData is tho
Or if it does it for you
i already tried 0x00 | 0x20 or is that wrong?
0 is the identity element for bitwise or
what
0 | n = n
That's one too many smart words in one sentence
I need to pretend to be intelligent!
i should try to do that too, but i failed already
I mean (0.toByte or 0x20) should work
Don’t armour stands already have methods to handle meta for you?
meaning that the integers form a monoid under the bitwise or operation!
😌
client side entities probably
Ah I see
no one responding in their discord so i thought id ask there
Wont the servers Meta data just overwrite what you’re sending to the client anyways?
why would the server overwrite anything that doesnt exist on the servers end?
i jsut need to know how to do that bitmask shit lol
what is a datawatcher?
anyone? please?
So I should try
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + " &7There are no ranks you can appoint!"));
continue;
}
if (!(target == null)) {...
but would that not spam the error message for every group they dont have perms for?
does Bukkit.getOfflinePlayers() also return online players? I would think not, but I need to get all players, including online and offline. Would I have to add them together with the Bukkit.getOnlinePlayers() and Bukkit.getOfflinePlayers()?
yes
yes to which one
yes to the first question
there's no point in answering the other one
What does Bukkit.getOnlinePlayer() return when it cant find anything? It has the annotation @NotNull
..
it will create an "empty" OfflinePlayer object for that UUID with no name
you could check for a null name yeah, I'm not sure if there are any "saner" options tbh
i think u can also check if it's online, and if it isn't, check if it played before
although getName check is simpler
although iirc it returns false if it's the player's first time
if offlineplayer is null then it will give you a npe i believe
unless it returns an empty player
getOfflinePlayer will never return null
yeah ive just seen, it returns an object even if it doesnt exist
I was gonna say "it's annotated with notnull" but then I remembered spigot annotates a lot of shit with notnull yet it can return null
getName() can return null though
:OMEGAWHEELCHAIR:
bruh
lol



🍞
if (args[0].equalsIgnoreCase("request")) {
if (args.length >= 3) {
for (String key : CityRpAppoint.aPlugin().getConfig().getConfigurationSection("Groups").getKeys(false)) {
ConfigurationSection configSection = CityRpAppoint.aPlugin().getConfig().getConfigurationSection("Groups." + key);
String permission = CityRpAppoint.aPlugin().getConfig().getConfigurationSection("Groups." + key).getString(".permission");
List<String> list = CityRpAppoint.aPlugin().getConfig().getConfigurationSection("Groups." + key).getStringList(".groupNames");
Player target = (Player) Bukkit.getPlayer(args[1]);
String targetRank = args[2];
if (!sender.hasPermission(permission)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + " &7There are no ranks you can appoint!"));
continue;
}
CJ told me to make use of continue. This does work, however it sends the error message even though it is still requesting to appoint a player
where does it send the second message?
Here I will get a paste of the entire command code
thanks
well, it gets sent for every single value in groups
so if there are 2 groups
and the player has the permission for one of them
but not the other
So should I just simply remove the error message
since players shouldn't have the permission to use /appoint anyways if there are no ranks they can appoint
probably
👍
I am designing a plugin that involves mongodb, and I am expecting large quantities of players. What is the most efficient way of making DB calls? I am caching everything, and should I make it all at once every 5-10 minutes update everything using async. Or do I make it more spread out?
Just send off async db updates whenever they happen
The cache is the source of truth while the server is running, so just have it update the DB as it needs, doesn't matter if it takes a few seconds or whatever
I feel like I said instead of error message AND return
idk if you fixed it yet, just saw the ping 🤷♂️
How would i get the port of a domain in php?
rn i have gethostbyname('play.hypixel.net'); but that only returns the ip adress without the port but i need the port aswel
I have no idea about PHP, but that works with an SRV record in DNS, so maybe you can query the DNS?
any idea why the text looks like shit? 😅
Why is this Deprecated cannot be resolved to a type? I'm trying to deprecate a function. I get no suggestion to import it or anything, it works nowhere in my project? I guess I'm just dumb, but I can't get it to work lmao
it is @Deprecated
/**
*@deprecated Use {@code #newTestMethod)}
*/
@Deprecated
public void test() { }```
Have you ever used it without being like that before?
nah I just installed the scene builder kit
What's your screen resolution?
1920x1080
Odd. I've used scene builder before but never had that problem
hi, what is first event you can cancel to close player connection?
probably quitevent
I mean event when is player connecting
I'd kick them though instead of cancelling as you can customize the kick message however you'd like
You can also do that in the prelogin event tho
oke thx
You mean setting the disconnect message before cancelling?
PlayerPreLoginEvent I think
Cancel and set the kick message/reason etc
^
^^
APPLE, AsyncPlayerPreLoginEvent
🍎
Ah, I guess I learned something today :)
@Deprecated
public static HelixEntity wrap(LivingEntity entity) {
return new HelixEntity(entity);
}```This is my code. It looks like it works, the function goes grey and has is strikethrough (deprecated functions look like that for me). But I still get `Deprecated cannot be resolved to a type` and it says there is an error?
hmm, weird
Yeah, that is why I am so confused. Is there an import I need?
sooo I get god damn [09:18:06 ERROR]: Could not pass event PlayerInteractEvent to You Dont Really Care-1.0.0 when I try to use an PLayerInteractEvent getting the item the player used but I dont have any, if(event.getPlayer().getInventory().getItemInMainHand() == null) return; or it on the actual if doesnt work, why
tl;dr; if I dont use item in the interact server goes crazy
can't help with what we can't see
https://paste.helpch.at/ixayikivay.cs yeah my bad
^^ this is the PlayerInteractEvent
when the player right clicks on air or a block it throws the error
says its on the if
and what's the full stacktrace?
yeah well
the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
and you're checking for the PlayerInventory.getItemInMainHand which...
check what for the actual methods you're using
Object.requreNonNull would work right?
for the if
and wait
I'm stupid
yeah for the check I did it wrong
yeah
Is there a way to get the value of an NBT tag without specifying the PersitentDataType? I want to read a tag and return the value as a string, aka the type does not matter as I will run the tag value through String#valueOf.
Just retrieve it as string then?
Can you retrieve it as a string if it is stored as something else, like a float or double? This is from the java docs of PersistentDataType Type Parameters:<T> the primary object type that is stored in the given tag<Z> the retrieved object type when applying this tag type, which is what the PersistentDataType when using NBT tags is specifying (in my head).
mariadb or oracle jdbc which is better in a plugin?
https://www.geeksforgeeks.org/difference-between-oracle-and-mariadb/ although typically mysql based databases are used in plugins as most hosts provide this. But why not allow both!
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
thanks
jesus don't use Oracle please
licensing fees and bad design decisions alone, there's a reason why every plugin uses MariaDB/MySQL
in entitybreedevent is the breeder the player who helps the animals breed?
Is there some kind of Boolean type placeholder so that people can show certain colors if the placeholder is true/false ?
UserDataHandler.java: https://pastebin.com/P1pWt8Wc
PlayerJoinListener.java: https://pastebin.com/0HYYeu5S
This is in my onEnable():```java
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
Why isn't it creating the file for the player when they are joining the server? (`<uuid>.yml`)
It isn't even broadcasting the message defined in the PlayerJoinEvent. Not sure what i've been doing wrong.
I assume the problem is in the listener or in the on enable where in initializing the listener, but I can’t seem to figure this out
saveResource is usually used for saving default ymls that exist in your jar
do this instead:
pDataF.createNewFile();
also when you do constructor of the user data handler,
you want to check if the file exists before loading the configurations in
pDataConfig.addDefault("Bounty", 0);
pDataConfig.load(pDataF); XXX
-->pDataConfig.save(pDataF);
you should be saving instead.
its probably because you are trying to load a configuration of a file which does not exist yet
Either IOExceptions or nullpointerexceptions has been thrown consequently ,not sure which tho.
public void createPlayerConfig() {
pDataF = new File(p.getDataFolder(), uuid+".yml");
if (!pDataF.exists()) {
try {
pDataF.getParentFile().mkdirs();
pDataF.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
pDataConfig = new YamlConfiguration();
try {
pDataConfig.addDefault("Bounty", 0);
pDataConfig.save(pDataF);
} catch (IOException e) {
e.printStackTrace();
}
}```
Still not creating the file
@edgy lintel
any suggestion what I done wrong here https://pastebin.com/aLmJgbAm ? I´m try out command registrations.
is hard to fix when the error not point to my code at all.
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.
java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because the return value of "org.bukkit.command.Command.getLabel()" is null
yeah but getLabel() should not be null or shall I load the command before onEnable?

Searches what "rub" means 
new word learned, thanks!




