#help-development
1 messages · Page 124 of 1
report this to jira, and upload the Crash.jar you sent me
Yea, I did
now sleep before I slap you
I wanna spam "I can confirm" at least once
I still have half a beer so I'm online for 10 minutes anyway
oh btw the jira rules say "you also gotta test it using craftbukkit!" but NOONE ever does it so I guess it's fine
but I'll test it with craftbukkit too
now to upload to spigot cause why not lol
I've added a comment with some further clarification and the full stacktrace
and including confirmation that it also happens in craftbukkit
well even if it'd be 6am now, I'd still have like 8 hours to sleep
but yeah really weird
that it's working in paper
typical paper thing though, fixing stuff without contributing upstream 😛
#howrude
please ping me if there's any stuff about this because yeah it's really interesting
usually it's either paper that has a bug, or both paper and spigot, but never have I seen that's only existent in spigot but not in paper
btw erm
you attached the wrong video, didnt you?
wait what
yeah exactly
but I really wonder "wtf is wrong with you" that you didnt include the stacktrace in your report ahaha
ode it causes a crash with the following exception: https://paste.md-5.net/eqaqupayeh.md.
usually people paste it directly
fite me
if at all, i'd fyght yuh
fun fact
I recently bought 2 new frying pans
and they are so much better than my old one
now I got three frying pans
:p
comparing our stacktraces is interesting
you used spigot, I used craftbukkit
the first three lines in the stack have the same source code line numbers
but in playerconnection, it happens in spigot on line 1724 but in craftbukkit on line 1688
I didnt know that spigot messes with the connection class
There is a discord group designing a new language...
yeah fuck windows, but also fuck discord
why does everyone have gradient profiles except me
I mean i dont care about gradients, its just unfair that I dont have it
The fk is a gradient profile even?
Unfair
ikr
Geh mal schlafen du Hecht

how would i listen for a player right clicking an NPC I created with NMS
Is the npc server side?
no
public void createNPC(Player p, String name, Location location, SkinWrapper skin) {
CraftPlayer craftPlayer = (CraftPlayer) p;
ServerPlayer sp = craftPlayer.getHandle();
MinecraftServer server = sp.getServer();
ServerLevel level = sp.getLevel();
GameProfile profile = new GameProfile(UUID.randomUUID(), ChatColor.translateAlternateColorCodes('&', name));
profile.getProperties().put("textures", new Property("textures", skin.texture(), skin.signature()));
ServerPlayer npc = new ServerPlayer(server, level, profile, null);
npc.teleportTo(level, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
sendPacket(sp, new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
sendPacket(sp, new ClientboundAddPlayerPacket(npc));
npcs.add(new NPC(npc, p));
}```
that's my code
i'm relatively new to NMS so feel free to correct some stuff
Then you need to store the int id when you create it and listen for incoming entity use packets which have this entity id as your target
that's the thing, how do i listen for incoming entity use packets
and i already create an id so that's fine
PersistentDataContainer zombiecustomdata = zombie.getPersistentDataContainer();
zombie.getPersistentDataContainer().set(new NamespacedKey(/*here*/).PersistentDataType.INTEGER , 1000 );
@lost matrix what i should use (here) ?
declaration: package: org.bukkit, class: NamespacedKey
tnx
i want use (string , key) key is custom but what about string . its custom too ?
how do i make a ServerPlayer face a direction
I need help with my library https://github.com/KyTDK/NeoUtils When I shade it into my project the relocations don't work and its not a minimized jar.
my pom for the project using thje librarys pom is https://hastebin.com/ninohuzuca.xml
also its shading all the dependencies inside my library to my project
use the rotation packet
ClientboundRotateHeadPacket
and body rotation is part of ClientboundTeleportEntityPacket
Location location = mirrorEntity.asBukkitEntity().getLocation();
double mirrorX = location.getX();
double mirrorY = location.getY();
double mirrorZ = location.getZ();
byte yaw = (byte) ((location.getYaw() % 360) * 256 / 360);
byte pitch = (byte) ((location.getPitch() % 360) * 256 / 360);
asNMSEntity().moveTo(mirrorX, mirrorY, mirrorZ, yaw, pitch);
PacketUtils.sendPacketGlobal(new ClientboundRotateHeadPacket(this, yaw));
PacketUtils.sendPacketGlobal(new ClientboundTeleportEntityPacket(asNMSEntity()));``` complete code if you need
a question is possible to give a sort of NPC the attribute of health and a hitbox?
definitely
because i have a system of weapon that need this and making npc with citizen doesn't support it
you just have to setup a packet listener
buoobuoo any idea why my project is shading all the dependencies of my library?
because they are already shaded and relocated, however, it reshades it without relocating so I get two of the same dependency
is your parent module also shading it
of my library or my project?
neoutils shades kyori
it has a parent module
then
I download it from my repo
to my project
my project shades the library
however, it shades all the dependencies inside of it as well
yeah
and like I said, my library relocates kyori
but my project shades it, so I can two kyori packages
well it minimized the relocated kyori package
but not the new shaded one that my package shaded
I can remove the shading inside my library and the project shades everything
however, I would also have to instruct devs to relocate the packages inside of my library
and thats just annoying and a bad design
can you show both poms
Dont minimize relocated dependencies.
this is the pom of my library https://github.com/KyTDK/NeoUtils/blob/master/pom.xml
and this is the pom of my project using the library https://paste.md-5.net/ilajirasod.xml
why not?
so this is my minimization and relocation and shading inside my library
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>com.neomechanical.neoutils.kyori</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</plugin>```
PersistentDataContainer bossdata = skeleton.getPersistentDataContainer();
bossdata.set(new NamespacedKey(CustomBoss.getPlugin(),"isBoss"),PersistentDataType.STRING,"true");
```this is in first class and
```java
@EventHandler
public void onskeletonDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Skeleton) {
Skeleton skeleton = (Skeleton) event.getEntity();
if(skeleton.getPersistentDataContainer().has(new NamespacedKey(CustomBoss.getPlugin(),"isBoss"),PersistentDataType.STRING)){
event.getDrops().clear();
event.getDrops().add(new ItemStack(Material.DIAMOND_BLOCK , 10));
event.setDroppedExp(100);
}else {
return;
}
}
}
```this is from 2nd class but it didnt work .HEEELP
else {
return;
}
Useless. Delete.
2) Add sysouts in your listener to check if A) the event is fired and B) All conditions are met
pls show me an example
Of what? Printing debug statements?
is there a way to send a brigadier suggestion without having to register the command or anything, just so when something is being typed or something
because doing it with the packet requires some type of id, and i am not sure where i can get that if i wanna send it myself.
You cant send suggestions for just chat messages
no no it's for a command
i just don't wanna use the brigadier api
or i'm wondering if i can adapt a bukkit command's tab completion to use brigadier suggestions
The player asks for a command suggestion and generates the transaction id. You can answer by sending a packet back
with a matching transaction id.
does it ask for a suggestion only if the command is a brigadier registered one?
I dont understand what you are trying to do.
If you have a custom command system then you need to hook into brigadier to properly support it in spigot.
You can intercept the command packet and let the player think that there are more commands than actually registered.
ok ok so if a player is tab completing any command will it send a suggestion packet, and only if the command is registered it will respond to it and do something?
There is one packet which sends all the commands to the player.
It will ask for suggestions if the client knows this command. So if the command node was send in the Commands packet.
okay so if the command was just a bukkit command it wont ask for the suggestions packet, it has to be a brigadier registered one which the client knows of
No it also asks for suggestions on bukkit commands. Those are send in the command packet as well.
Spigot even has a command completion api.
okay so if i have a spigot or bukkit command, can i send a brigadier suggestion on tab complete?
Sure
Intercepting packets
mind elaborating please :>
What do you mean by tooltip?
Ah i see. Yeah this is only possible with components.
So you need to listen for requests for your command and intercept them before they reach
spigot. Then you answer with your custom packet. Its probably easier to just use brigadier.
haha gosh sounds like it, except that brigadier doesn't really have what i want it to have and adapting it to is iffy- so i'm gonna have to do the first route.
Literally no one hovers over that
public void update(Player player) {
String updatedText = ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, getFormat()));
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) armorStand).getHandle();
nmsEntity.setCustomName(CraftChatMessage.fromString(updatedText)[0]);
sendPacket(player, new ClientboundSetEntityDataPacket(nmsEntity.getId(), nmsEntity.getEntityData(), true));
}
public void sendPacket(Player bukkitPlayer, Packet<?> packet) {
((CraftPlayer) bukkitPlayer).getHandle().connection.send(packet);
}```
how come this doesn't update?
i call the method upon player joining
it worked like 5 hours ago too
it's for holograms
?paste
hello guys, i am using intelliJ to make my plugin (to add spigot to it)
everything is fine
Hey guys, anyone know why I'm getting null when trying to retrieve a registered service from service manager? I'm trying to get my API service that was registered on my core plugin and use it on another plugin. If I loop through the registered services, it's there and registered all good. The class type I'm trying to access it with matches up perfectly, but still getting null when trying to get the instance. Any ideas?
how come this doesn't update?
can you help with this?
Make sure your plugin depends on your code (plugin.yml) and register your service provider in onLoad just to be sure.
It does depend on it, but I will try the onLoad and see if that works. Thanks 🙂
And dont shade in your core!
How do you view https://wiki.vg/ for an older version?
Wasn't shading the core in but I wasn't shading in the API properly, so you've saved me from spiraling into chaos. Fixed. Thank you 🙂
You dont need them. UUID has a constructor that takes 2 longs
Index's are different for different versions
Thanks
im using a boss bar but the .setProgress method doesn't work
what are you setting it to?
1.0
so full
im trying to make a timer using the bossbar but the progress doesn't update
the timer itself works
is your boss bar not already full?
How to let a user walk 1 block forward with plugin?
default is full when created
.
Players have no AI to walk, so teleport
Yeah I understand but it isn’t smooth
public void update(Player player) {
String updatedText = ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, getFormat()));
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) armorStand).getHandle();
nmsEntity.setCustomName(CraftChatMessage.fromString(updatedText)[0]);
sendPacket(player, new ClientboundSetEntityDataPacket(nmsEntity.getId(), nmsEntity.getEntityData(), true));
}
public void sendPacket(Player bukkitPlayer, Packet<?> packet) {
((CraftPlayer) bukkitPlayer).getHandle().connection.send(packet);
}```
how come this doesn't update?
i call the method upon player joining
for ANY player, or just the one joining?
Full class: https://paste.md-5.net/nihebuvodu.java
Wdym
It runs for the player joining
if a player is already online and another joins
any reason?
If you are triggering it IN the join event you may need to delay it a few ticks.
It also happens every 20 seconds for all players
you'll need to show some code. I can;t guess any more.
What exactly isn;t updating?
The text
this.bossBar = Bukkit.createBossBar(Utils.chat("&aTime Left: "), BarColor.GREEN, BarStyle.SOLID);
this.bossBar.setProgress(0.5f);
Is there a reason you are using NMS to change the stands name?
nothing wrong with that code, on its own
if i add the players after i update does it matter?
It needs to be different for each player
ah ok
Read whole class for more context
this line looks wrong nmsEntity.setCustomName(CraftChatMessage.fromString(text)[0]);
it should not be an array returned from my knowledge
nevermind it works now
nope you are correct
i iterated over the wrong list to update the holograms 💀
anyway how do i hide an NMS npc in the playerlist
you send a remove packet
wouldn't that remove the npc
not a remove entity
sec let me pull up my ide
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, npc);
that removes their skin unfortunately
is there a way to avoid that?
it shouldn;t remove a skin
not if you sent their info packet
send info packet, add player packet then remove info packet
how can i give a player leggings and auto equip them?
like that? player.getInventory().setLeggings(leatherLeggings);
yea
thx
why not just do it the easy way?
event.getPlayer().getEquipment().setLeggings(CraftItemStack.asNewCraftStack(net.minecraft.world.item.ItemStack.EMPTY.getItem()));
way more readable and it uses kewl nms "features"
then you could write that in the plugin title 
lol 😄
Anyone have an idea how I could hide a player from other plugins?
So other plugins think he’s offline even though he’s online?
Why would you want that
"vanish plugin"
Exactly
if you're really crazy you could set the server field in the Bukkit class to your own custom Server object which uses reflection in getOnlinePlayers() to check what plugin called this. Which is a terrible idea.
lol
Doing that is going to require much more work than it's worth
Terrible enough to try it lol
exactly and it would only work for plugins using Bukkit.getServer(), and not for ones using the getServer() method in JavaPlugin
as said it wouldnt even work properly
it was just a joke
Are they not pointing to the same field?
no
So there are multiple Server instances?
no ?
but the fields used are different
a plugin has its own reference to the server
the Bukkit static state has another
Yeah but if they point to the same instance it’s enough to change that and inject another one
but you cannot change the server instance itself
it doesn't delegate to anything
that is already where the logic resides
Well that’s right
well well well
you could loop over all running plugins and change their field too lol

I'm just gonna add every other plugin as a dependency
that's not gonna help anything
the proper way is to make your plugin so popular that all other plugins query your api and check if a player is vanished
Yeah good luck with that one
Why do you need to touch the server instance for a vanish plugin what
the only other alternative is to hack into all plugins and change their server field lmao
so yeha these are your two choices
well e.g. imagine you have a private message plugin that shows all online players in a GUI
Or use a mixin to inject code into the Server class
Ahhh I guess
I've never done mixins before that'd be a fun project
Well actually I have with fabric but not with anything else
I’m gonna give it a try and test around
i know exactly nothing about mixin
That could work actually
That'd be a better option
It shouldn't be too bad to pull off I believe in you
I say you can figure out mixins in like an hour or 2 at most
I've done like 2 hours of fabric modding so I'm basically an expert at mixins already :P
Damn, looks like I'm a C++ expert too
don't call yourself that your essentially slandering yourself
hi, player.getPing() is not accurate enough to me, it takes too much time to update, i think it follows a refresh rate or sth, or its taking into account a too long period before measurement, which is more a Δt than a dt, so not sensible enough to the instantaneous variations of latency
Is there a way to retrieve the timestamp of the last time that player did respond to the server? Like the last received heart beat from the player or sth?
Or maybe is there a way to know how many ticks late the player is?
Or maybe is there a way (with or without NMS) to retrieve the whole packet queue and the size of all packets sent to the player which haven't been processed by the client yet?
See, I'm just imaginating scenarios that would help me have a more accurate/instantaneous connection status of a player, so please be open minded to anything similar scenarios i haven't stated
player.getPing returns the ServerPlayer's latency field. The ServerPlayer has a ServerGamePacketListenerImpl field, which in turn has a private static final int field LATENCY_CHECK_INTERVAL = 15000, so yeah that's the ping updating thing. the ServerGamePacketListenerImpl also has a field "Connection" which indeed has a Queue<PacketHolder> to the current packet queue, if that helps
oh yes that helps a lot thank you mfnalex!
np!
(that's all the mojang mapped names, and only for 1.18+, in 1.17 it's a bit different)
How to break a block as player?
declaration: package: org.bukkit.entity, interface: Player
thanks
1.17 also has remapped, but in 1.18 they changed the connection stuff
For example to get the "Connection" object in 1.18, you do myNmsPlayer.connection.connection
But the block just vanish, it isn't breaking
in 1.17 you only need ".connection" once, since ServerGamePacketListenerImpl and PlayerConnection are "one class" where in 1.18 it's split up
so you want the break animation?
then sendBlockDamage beforehand
Also, but it must cost some time to break it
yeah use sendBlockDamage then
- sendBlockDamage https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendBlockDamage(org.bukkit.Location,float)
- Do this in a repeated runnable, raising the "progress" from 0 to 1 slowly
- when you've reached one, you can break the block and stop your runnable
declaration: package: org.bukkit.entity, interface: Player
Thanks, but how to break it like normal broken. if using pickaxe going faster..
you have to calculate that yourself
yeah, some fancy math lol
yeah I have some VERY UGLY methods in BestTools to calculate this
better dont look into it, the whole code is a huge mess, it was one of my first plugins from 2018 >.<
also do you know if its possible to get the remap through reflection too?
remapped names dont persist on runtime
so, spigot class names and obfuscated method names etc
is there a page/document that explicits every mapping?
like obfuscation + translation
thank you!!
e.g. here you see:
mojang class name is MoveToBlockGoal, spigot class is PathfinderGoalGotoTarget. Mojang field name is "mob", obfuscated field name is "a"
so yeah check the "Spigot" tags for classes, and the "obfuscated" tag for fields / methods
I explained it the other way around here 😄 https://blog.jeff-media.com/switching-from-spigot-mappings-to-mojang-mappings/ Like how to get the mojang names from spigot names
alright, tysm 🙂
very useful yeah
(cuz i like a lot messing around with dynamic java its nice for debugging :D)
I wish the specialsource plugin would also understand reflections
but like, what would it do when using string concat'ing etc
it possibly can't work properly for reflection 🥲
what is specialsource plugin
it remaps your NMS stuff automatically
you code in mojang mappings and your .jar uses spigot mappings
then when you switch from 1.18 to 1.19, you only change your dependency from 1.18 to 1.19 and choose the new mappings file
https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/ the specialsource plugin was written by md5
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
yes, you should use a try-with-resource thing instead
or close the connection in the finally block
try (Connection con = DriverManager.getConnection(myConnectionURL);
PreparedStatement ps = con.prepareStatement(sql);) {
ps.setInt(1, userId);
try (ResultSet rs = ps.executeQuery();) {
while(rs.next()) {
users.add(new User(rs.getInt("id"), rs.getString("name")));
}
}
}
sth like this
People be like
Why don't work?
that's called "try with resources"
try with resources
basically closes any variable within the perenthesis after the block is executed
yes, but you can combine it
try(Connection con = ...) {
con.doSomething();
} catch (SQLException e) {
e.printStackTrace();
}
i did my stuff with a consumer so i only need to do withConnection("SELECT * FROM WHATEVER", (connection, statement)) {/* bla bla bla */}
syntax looks weird sometimes but anyways
I'm adding custom status effects to the game (essentially like potions effects and you can't get custom ones to render so i did my own system)
Does anyone have any ideas on how i could render the current status effects to the client?
anything, scoreboards on the side wouldn't look the best, bossbars would get too much when you have multiple effects, thoses kinds of things
alo
nah i know you can't do that
already have one so no biggie there
you familiar with custom unicode?
nope, never touched any
give me a min
didn't even know you could add your own, i though there was a fixed set of chars minecraft's supports and that was it
in minecraft/font/ create a file called default.json
{
"providers": [
{
"type": "bitmap",
"file": "yourexampleimage.png",
"ascent": -10,
"height": 10,
"chars": [
"\uF801"
]
},
{
"type": "bitmap",
"file": "yourexampleimage2.png",
"ascent": -10,
"height": 10,
"chars": [
"\uF802"
]
}
}```
you could send toast messages but they disappear after like 5 seconds 😄
that would actually work for my usage
status effects dont last a whole lot
and they have particles
but then you would only see 1 at a time
huh....
achievements can show by groups of 4 tho can't they?
/advancement grant @s everything
ah yeah thats definitely viable then
they show 4 at a time
and i mean, if you have more than 4 you're probably about to die anyways
aight, but it requires annoying NMS, or you could use my lib lol
like, really annoying NMS
never touched any so i didnt know
which one is that?
declaration: package: com.jeff_media.jefflib.data, class: ToastMessage
wait that's all there is to it?
yep
damn, i though that would be more complicated xD
just change file, ascent, height and chars
simple
you can do some really cool stuff with it
i've seen some ressource packs use it to display potions icons on the potions themselves
or even enchants
you can also do custom inventories with them
resend actionbar?
it however always says "Goal reached" or "Advancement made" etc, i dont think that can be removed
yeah can't
action bars are already used by a season plugin unfortunately
ah rip
i've made some with retextured items
those yellow icons on the bottom
yeah retextured items suck
you lose a slot + they are glitchy
arent those carrots on a stick lol
its supposed to be a flail lol
waiwaiwait
you're telling me
that with a unicode char in like, the inventory name, you can texture the whole thing???
yep
ofc you can
template if you need
i made a spigot resource for that method a while back
ill try and find it
Yo guys I'm new to these things and I found something like this. How can I get player's head / or an entire skin into a char so I could display it?
What
it's not one
?paste
it's all of them
you can do some pretty cool stuff with heads aswell
they actually store the entire skin data
so you can theoretically show the entire player skin
Alright thanks
Will try something like that
you can do some really col stuff with it
but i cant disclose what I've done elsewhere yet 😮
Origin Realms also uses unicode for their invs
Wait, but does it override current player head?
Okay!!
can you make custom model displays with heads a customPlayerData?
https://www.spigotmc.org/threads/convert-org-bukkit-world-to-net-minecraft-world-level-world.572818 this dude gets a bit annoying tbh
like
idk
oh shit i'm stupid
i can already do that with literally any item and custom model data
lmao
i was actually working on a system recently to display any image with heads
without loading it onto the RP
but doesn't work super well unfortunately
to avoid having a too heavy RP?
yeah
Someone help him
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
someone send him this
returns null on getPlugin() Why don't work?
wants to crash the server
doesnt it take 2 variables
delay and period yea
it defaults to 1 iirc
oh then i guess that's fine
the period?
yeah
would be good ye
people are allergic to the docs i swear
apparently he's 13 yrs old, should still be able to read when his IDE highlights something red, idk
i absolutely love this, my current systems has all the cons of yours and not all of the pros
its literally just an upgrade xD
yeah its a great system
you do need negative characters though
*if you dont have them already
to align it properly?
yeah
height is the char itself tho right?
can be
wait
AHHH
ok let's go on a coding frenzy i want this thing implemented by tonight
cuz i absolutely hate this
yeah its pretty ugly lol
does the char render above or under items btw?
under
YEEESSS
so buttons and such would have to be an invisible item
or a retextured item depending on how you approach it
or be a retextured item
yeah
and the ui not have them
yeah exactly
or do something like this
where the button is isolated
then just render is separately
actually i think it's better this way, if you wanna move a button all you need to do is move the item and theres no need to update the char texture
yeah its up to you tbh
quite long
lol
theres a lot of factors
including nbt
so theres no one answer to that
^
so literally infinity
just use longtext if on sql
practically your game crashes tho
varchar(10k) should be fine tho
chests? do you mean shulkerboxes? or can chests meanwhile keep their contents?
yeah I made this for everything that has an "inventory"
enchantment tables, furnaces keep burning in inventory, etc
have you considered the player burning when having one in their inv
xD
good idea lol, unless they have a potion
also stepping on a furnace should give fire damage
or stepping on a stonecutter.....
holding a campfire for too long should start burning the player
is this good way to update lines in scoreboard? because I ts not working to me. I have check to see if the method triggers using println to console and number is showing in console, but lines are not updating. I don't now where is mistake. And sorry for my english.
Here is my code and my update method is updatePerLine(): https://pastebin.com/YRwGCmZK
and I am triggering this method in setScoreboard() and then I am using for (Player p : Bukkit.getOnlinePlayers()) {villagerCount.setScoreboard(p)} in my main class (villagerCount is another class)
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.
damn
you should stick to english names 😄
compiler probs shitting itsel
it was just joke for my friend I am using english names
shift middle click retains the nbt data
why? its no problem
identifiers can use basically uncide char
i hope that not an actual variable
you can even call classes $class
would be a fun way to obfuscate code
so is it setting the variables at all
or just not updating
who needs obfuscation when you have german
hm not really
its setting variable good but not updating
i think its shift middle click
are you verifying the runnable is executing?
scoreboards are such a pain to deal with lol
You can deal with this easily lmao
yes I have check. It print out number to console every 20 ticks.
also when are you creating an instance of the class
ScoreboardManager board2 = Bukkit.getScoreboardManager();
Scoreboard board3 = board2.getNewScoreboard();
in the class scope is sussy to me
another nice way would be to just put names that means something but just doesnt correspond
just switching function names
this was for test only, Idk why I didn't delete it
Meh, normalize method names and it's no longer a problem
no I mean ust creating a new scoreboard on the class scope in general
but its not static so ig its fine
ok
cry about it 
[14:50:32 WARN]: java.lang.IllegalArgumentException: Can not set final java.util.UUID field com.mojang.authlib.GameProfile.id to java.lang.String
[14:50:32 WARN]: at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
[14:50:32 WARN]: at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
[14:50:32 WARN]: at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:83)
[14:50:32 WARN]: at java.lang.reflect.Field.set(Field.java:764)
[14:50:32 WARN]: at me.rhys.general.disguise.DisguiseManager.disguise(DisguiseManager.java:65)
[14:50:32 WARN]: at me.rhys.general.disguise.gui.DisguiseGUI.lambda$handleClick$1(DisguiseGUI.java:201)
[14:50:32 WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[14:50:32 WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[14:50:32 WARN]: at java.lang.Thread.run(Thread.java:748)
I'm trying to set the player's uuid, but its final and I can't change it. Is there any way to get around this?
try {
GameProfile playerProfile = ((CraftPlayer) user.getPlayer()).getHandle().getProfile();
Field ff = playerProfile.getClass().getDeclaredField("id");
ff.setAccessible(true);
ff.set(playerProfile, uuid);
} catch (Exception e) {
e.printStackTrace();
}
you are setting it to a String
not uuid
and why are you trying to change it anyway lol
uuid is a string, for a nick system
Can not set final java.util.UUID field com.mojang.authlib.GameProfile.id to java.lang.String
not according to your error
it needs to be UUID
how do I make a chunk of code execute every 10 ticks?
BukkitScheduler
is there any way for an egg to bounce instead of breaking when hitting the ground?
Is there another way to check if it's raining on a player besides checking if he has absolutely no blocks above him while it's raining?
check the sky light level at his location
kinda unexperienced with light levels. 15 is max iirc?
16 is max i think
15
Doesn't placing a torch under the player set it to max?
SKY light level
oh
cancel the ProjectileHitEvent and apply positive Y velocity
so I'd need to check if it's max value for his location to know that there's nothing above him?
for int y = player.y; y < world.maxHeight; y++
block block = getBlockAt(..., y, ...)
if block.isSolid -> its not raining, break
how?
how what?
how do i do that
what exactly? cancelling the event? applying velocity?
both
looping through all y values from player y to 320, right?
i mean i know how to use e.setCancelled(true);
@EventHandler
public void onHit(ProjectileHitEvent event) {
event.setCancelled(true);
Vector velocity = event.getEntity().getVelocity();
velocity.setY(1); // example
event.getEntity().setVelocity(velocity);
}
thanks!
yeah, you could also stop at World#getMaxHeight()
and ofc you can ignore world's with a Dimension of NETHER or THE_END type
Could also check if block under the player is the highest I guess?
for his x-z position
yes sure, but even if this is FALSE, there might be rain
rain falls straight down. You only need to know if you can see sky
So just stick with the sky light level thing?
Then another thing. Let's say I check if it's raining in the player's world, that wouldn't guarantee it's raining somewhere around the player's location. right? Only somewhere in his world
Then I'd only have to check whether the biome he's standing in is affected, right?
but skylight also comes from nearby blocks, doesnt it?
you need :
To check if the highest block at XZ is under the player
If it's raining in the world
If it can rain in the biome
Yes, noted all those, I think that's it?
To check if the highest block at XZ is under the player
Sylight doesnt work because glass
yup
that's it
or glass above
glass
I believe
elo, im having some problems about variables, i should have a variable that is different for other player. imagine an int variable, for Ryad095 the variable will be 5, for Emma45 8
um, glass
then use isPassable and continuously check down until you meet a non passable block
or reach the player's y level
or -64
whichever comes first
well
you have two ways of doing it
start at highest block y and go down to player
start from player and go up
starting from down probably breaks the loop earlier
not if you use getHighestBlcokAt(x,z)
yeah usually you have a roof near the player and not 200 blocks above
Ok so did I get it right that the sky light level won't work?
yup
there is tho
So just check if block at player location is the highest?
there's isOccluding but that's only for fully blocking light, so useless. There's isSolid but that makes no sense, e.g. fences are solid but let rain through
Paper?
spigot
oh you call it on the block
ye
I only checked Material
isPassable still doesn't work
Alright, I'll give it a try and let you know if I have some issues
fences are not passable but let rain through
that's a gate
the only proper method is to take this list:
fences arent passable and dont let rain through?
I meant fences
oh
Do you have me the link to that?
I wanna see how long that list is
uffff
so check if blocks above player are either air or one of those blocks letting rain through, otherwise it's not raining on the player?
|| block at player loc is highest
can someone help me with this method? I'm having trouble understanding what the boolean does? I originally thought it was if the player could use the command or not, so for example "registers hello.perm but in a way where it outlines that the player can't use it (for wildcards)", does it remove the permission instead or something? https://gyazo.com/9bec30cedc58fd288eb75c5b98b9613b
private static final Set<Material> RAIN_PASSTHROUGH = Set.of(...);
public static boolean isInRain(Location loc) {
int highestY = loc.getWorld().getHighestBlockYAt(loc);
if(highestY <= loc.getBlockY()) return true;
for(int y = loc.getBlockY(); y <= highestY; y++) {
Block block = loc.getWorld().getBlockAt(loc.getBlockX(), y, loc.getBlockZ());
Material type = block.getType();
if(!type.isAir() && !RAIN_PASSTHROUGH.contains(type)) {
return false;
}
}
return true;
}
haven't tested, but yeah, something like this will definitely work
Improved it a bit:
private static final Set<Material> RAIN_PASSTHROUGH = Set.of(...);
public static boolean isInRain(Location loc) {
int highestY = loc.getWorld().getHighestBlockYAt(loc);
if(highestY <= loc.getBlockY()) return true;
// Check highest block directly. Most of the time, the highest block will already be occluding rain
if(!letsRainThrough(loc.getWorld().getBlockAt(loc.getBlockX(), highestY, loc.getBlockZ()).getType())) return false;
// Loop from player Y to highest Y
for(int y = loc.getBlockY(); y < highestY; y++) {
Block block = loc.getWorld().getBlockAt(loc.getBlockX(), y, loc.getBlockZ());
Material type = block.getType();
if(!letsRainThrough(type)) {
return false;
}
}
return true;
}
public static boolean letsRainThrough(Material mat) {
if(mat.isAir()) return true;
return RAIN_PASSTHROUGH.contains(mat);
}
Ty! Currently adding those materials to the set, will try it after that
you could also use an EnumSet but 1.18 announcements said "dont do that"
hm
because everything that implements "Keyed" will "soon"(TM) be replaced with normal classes
Ah yea, heard of it
so uh this doesnt bounce
why is i set this tag on my block:
When i check if the block i clicked has this tag it says me false?
why if i created this tag that says me that the placed block is true, when i check the tags says me false?
Hm, what's the official nomenclature for the @p, @r, @a, etc things?
Target Selectors: https://minecraft.fandom.com/wiki/Target_selectors
actually it kind of does its just it doesnt do it in the first try
It can only rain in the overworld right?
yea
is there some other double value like Double.NaN which cannot be obtained from somewhere without explicitly assigning it, and can be negated?
basically looking for a Double.NaN which can be negated
maybe i can use Double.POSITIVE_INFINITY
Any idea how I'd check if a player is standing inside a cauldron filled with water?
check the block at their location?
Oh sick there's a WATER / LAVA CAULDRON material
though there's only CAULDRON and I'd have to check somehow if it's filled with water
meh i dont think Double.POSITIVE_INFINITY will work
Is there a common interface/class between Player and CommandBlock that I can use to cast CommandSender to?
hmm Double.POSITIVE_INFINITY == Double.POSITIVE_INFINITY is true
Permissible and ServerOperator
why
I need to get the Location from where the command is called, and it needs to work with CommandBlocks and Players.
if the console sends it, theres no block
Yeah, i'll block it from the console, I was trying to get a common one for specifically cblocks and players
I can't just cast Player to ServerOperator right?
The player has to be op for that i'd imagine?
you can afaik
do the NMS entity classes have a method that runs every tick
a player is always a server operator
if you'd be looking at docs
Yeah I just checked
the fact that Player class extends it doesnt mean it has op permissions automatically
Welp, I can't get the location from there anyways, so i'll just have to go for something else; Thanks anyways!
lol
NaN = Not a Number so and only numbers can be negated...
damn you actually used the correct annotation for micro-seconds
did i?
normally I just do "micS", to lazy to use the actual thing
🤡
how do i do a tick() method for a custom NMS entity?
ij will yell at ya
Override it
Just make sure you call super.tick()
yeah i am thanks
Can a server process multiple player commands in a single tick?
Because I'd like to check if a piece of code was called as a result of a command and then get the player that issued the command
is the piece of code going to get executed any other way ?
not understanding here
the from your command class have it set a boolean or some value of sorts
then you can easily check from the piece of code where it is coming from
or use an enum that gets passed
The command is not executed from my plugin
Asking about your attempted solution rather than your actual problem
you can still listen for commands regardless
also, how fast the server processes something is generally not a concern unless timing is important
But I need to know how often the plugin called that method
so make a counter
But what if it gets called from somewhere else as well
at this point I really don't understand what you are trying to accomplish here
I‘m having a method in my plugin
And I need to know when another plugin calls it from a command
Because I need to know who issued the command
How would another plugin's command call your method?
If you dont own the other plugin
Well I mean but why would it
That is not what I mean.
API
basically they want to know if a method in their plugin they created is called from another plugins command executor method
I think my point is that it's poorly designed if another plugin is calling your method but the method doesn't require all the parameters to make it useful. I still don't understand what the problem is or what they're trying to solve.
and this is achievable
So, I'm making a mutechat command and everything is okay until I check whether the chat is muted or not in the chat listener.
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
Bukkit.broadcastMessage(String.valueOf(mutechat));
Player p = e.getPlayer();
if(mutechat) { // <<< variable mutechat is predefined
e.setCancelled(true);
plugin.send(p, plugin.getConfig().getString("chatMutedError"));
}
}```
I don't know why but whenever I chat the variable just sets itself to false.
if you didn't understand something lmk
yeah I don't know the problem either or the purpose behind it
Thats why I sent ?xy earlier lol
Because I used mixins to change a Bukkit method
but good news is that what they asked or I think what they asked is achievable, but without further information I can't really direct to an appropriate way
So I cannot pass any information to that method
public class MutechatCommand implements CommandExecutor,Listener {
private final CleanChat plugin;
public MutechatCommand(CleanChat plugin) {
this.plugin = plugin;
}
public boolean mutechat;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender.hasPermission("cleanchat.mutechat")) {
mutechat = !mutechat;
Bukkit.broadcastMessage(String.valueOf(mutechat));
String chatMuted = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("chatMuted"));
chatMuted = chatMuted.replace("{sender}", sender.getName());
String chatUnmuted = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("chatUnmuted"));
chatUnmuted = chatUnmuted.replace("{sender}", sender.getName());
Bukkit.broadcastMessage(mutechat ? chatMuted : chatUnmuted);
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.noPerm));
}
return true;
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
Bukkit.broadcastMessage(String.valueOf(mutechat));
Player p = e.getPlayer();
if(mutechat) {
e.setCancelled(true);
plugin.send(p, plugin.getConfig().getString("chatMutedError"));
}
}
}```
idk just sent the whole class
but why do you need to know if a plugins command executor uses said method?
it kinda sent it weird in here
or better yet, why do you need to know what plugin it belongs to?
Because I wanna change the return value of that method depending on who wants it
alright, well then the easy way to achieve this is to listen to all stack traces and then filter them for what you are looking for
public static void foo(){
Thread.currentThread();
Map<Thread,StackTraceElement[]> allLiveThreads = Thread.getAllStackTraces();
Set<Entry<Thread,StackTraceElement[]>> entries = allLiveThreads.entrySet();
for(Entry<Thread,StackTraceElement[]> entry : entries){
System.out.print("Thread: '"+ entry.getKey().getName()+"'");
if(entry.getValue().length>1) {
String nameofMethod = entry.getValue()[1].getMethodName();
System.out.println(" and method name '"+ nameofMethod+"()'");
}
else {
System.out.println(" with no methods.");
}
}
}
Yep that was exactly what I was thinking
But I don’t know if that’s too resource intensive
I just gave you the code above to do just that
Since it’s called multiple times per tick
needs some tweaking
and not its not resource intensive because stack traces are always being created
just the only time its made visible to a user is when there is an error, but they are still created for successful things too 🙂
That doesn’t mean that it’s going to be resource intensive
i kinda need to practice commenting my code but this is what i got https://paste.md-5.net/evuhulizej.java
But iterating over the entire stacktrace multiple times per tick?
stack traces are created regardless if you fetch them or not
you would need a FIFO que so you are not storing all of it, and you can do all this from another thread as well
The mute chat Boolean needs to be static if you want it to carry across instances
Okay so you mean fetching the stack trace, processing it on another thread and then going back to the main thread?
yes
Why not?
wot
That’s DI
thats kind of what i saw on youtube a lot lol
this is how DI works btw
You're doing it right fireroz dw
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
OOP-speaking DI is probably more correct than singletons
singletons should not be used unless you really need it
Someone never learnt Java
purpose of a singleton is when you need to ensure the best you can that there is only ever a single instance of something
most objects don't need this requirement
Loggers are a good example of when singletons are more justifiable
Well Ig libs like slf4j technically provides a multiton
I'm gonna try that, thank you
@wet breach And how would I know which player issued the command?
Also doing it on another thread won’t work I think because I need to return the result
depends on the size
for breaking blocks in a big area, I make 1 snapshot per chunk, and have 1 thread per snapshot for processing it all to a concurrent queue
So all the processing is done async
Then I have a queue that sets the processed blocks
you could create another queue that monitors commands executed by who, and then you can figure out the command executed from the stack traces, and as far as the separate thread goes you only need it to capture and filter the stack traces and then once you get the one you are looking for, send it back to main thread
But what’s the point in moving it to another thread if the main thread needs to wait for the result?
And how would that work if e.g. the method is called twice after a command has been issued
How would I know when that particular command execution is done?
well you didn't specify all these extra requirements
so because of that, you might need to instead go with a ASM
and look at bytecode of plugins to see if your method sig is in there
and then record the commands it is associated with
damn its getting too complex
can someone help me with: 0x803f8001

sign in
specifically of not being signed in
either they are not signed in, or the family member that bought it is not signed in
but of all places though, they chose to come to a minecraft discord for windows issues
windows store issues
maybe they were trying to launch bedrock 🤔
that still doesn't fit for here either way XD
obviously they are also using gyser
but fortunately for them, there is someone here who knows windows 😛
Its fucking cravk Minecraft
Go buy new one 😡😡
this is not necessarily true
poor soul xD
the error code provided specifically relates to not being signed into microsoft account on the windows store
What the wuck is windows store😡😡 who uses it
for windows apps
not sure what do you mean who uses it. Lots of people do for windows store apps
ily
I thought it was pure java version
lord I stay out of the windows store I only ever have issues with it
its laggy as all fuck and minecraft always has stupid issues
why the Anvil Container still requires XP when I have set their Level Cost to 0?
Hi I am trying to fetch multiple rows of data from a table. This code is doing nothing when i run the command. No errors in the console
https://paste.helpch.at/elimaravaz.js
the reason is because your query is incorrect
it is correct in the sense it does indeed execute
you are just doing it the incorrect way to use a ?
so what is happening is that the query being executed is looking up a user of ? which returns no results, thus your while loop doesn't execute and thus no errors
because it all executed fine
Oh I got it. Thanks
PreparedStatement stm = connection.prepareStatement("SELECT * FROM chat_logs WHERE username=?";);
stm.setString(1, "the name");
this would be what you want
Yep
create code to parse it and input it into a DB
you can use anything of your choosing for this and doesn't need to be in a plugin
you can even do it from bash
while true, there is a lot more tools out there to conver sqlite to mysql then there is from yaml to anything else
how would i make a player completely invisible
including their armor
i tried p.hidePlayer(plugin, p);
but it didn't work
ah
sql files are essentially just a bunch of sql queries to build a DB or table. So those programs that convert to an sql file actually convert into a fancy sql backup text file that you can use to then import. Mysql has a command for importing sql files and so does sqlite I believe.
does player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() get the current max health?
sure
wouldn't be efficient but yes you could do that
no making a script or program to pull all of the data and have it organized the way you want then batch insert/update
there are many ways to do this, just go with the route you know how to do, because I doubt you will need to do this constantly 😛
Is it possible to make player be able to draw a bow without arrows?
I don't want to use tricks like adding an arrow temporarily.
I'm afraid to delete player's stuff
Might be possible - If drawing a bow is completely clientside.
Will test it, thanks!
it's weird become I managed to get an error of setting a value that is too high by a few decimal points using getValue
Any ideas why I'm getting a java.lang.NoSuchMethodError: on location.getNearbyEntities(radius, radius, radius) ?
which?
that is paper-api
spigot docs have this method tho
you obviously cannot run paper-api only methods on spigot
it does not on a location
paper re-exposes this method on the location type
declaration: package: org.bukkit.entity, interface: Entity
shit
it's too late here uff
what's my best bet to get nearby players in a radius on spigot?
- of a location
