#help-development
1 messages Β· Page 19 of 1
When working with NMS there's a lot you need to figure out yourself
There won't be a tutorial for everything
So some practice could be to take a look at some of the nms classes and see if you can understand what they do
hi im having problems with this code there are no errors but it doesnt work:
package net.plutocraft.minigame1;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.concurrent.TimeUnit;
public final class Minigame1 extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Minigame1 plugin enabled.");
}
@Override
public void onDisable() {
getLogger().info("Minigame1 plugin disabled.");
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
Player player = e.getPlayer();
if(block.getType().equals(Material.MANGROVE_WOOD)) {
e.setCancelled(true);
block.getDrops().clear();
player.getInventory().addItem(new ItemStack(Material.MANGROVE_WOOD, 1));
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
block.setType(Material.STONE);
}
}
}
Why are you thread sleeping π
i need to wait 5 second
You're pausing the server for 5000ms ever block break
You don't want to pause the server
?scheduling Use this
use a scheduler and you also forgot to register your listener.
^^
ok so how would i make it do:
e.setCancelled(true);
block.getDrops().clear();
player.getInventory().addItem(new ItemStack(Material.MANGROVE_WOOD, 1));
and then after 5 secs make it do:
block.setType(Material.STONE);
also how do i register the listener? thanks
use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/PluginManager.html#registerEvents(org.bukkit.event.Listener,org.bukkit.plugin.Plugin) to register your listeners
Bukkit.getServer().getPluginManager() to fetch the PluginManager instance.
declaration: package: org.bukkit.plugin, interface: PluginManager
and check this link out for how to schedule things
thread sleeping is always fun
looks like your not registering the event listener
how would i right that in code? im new to this
does someone know why deleteBossbar() doesnt remove the bossbar from the player?
https://pastebin.com/5ttxVDhR
its in the main class tho
Anyone know why https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java isn't available as an import?
ah damn
trying to set the skull's signature without nbt any easy ways?
or can i use pdc
you cannot use PDC
which spigot?
version?
yes
1.19
?paste
I'm able to use retextured heads to "render" a player's skin so theoretically i can generate my own signature and texture string and render anything i want right
thats a sample class with making skulls
ah so have to use reflection
can id be random for getHeadByProfile?
yes
if you find a way to use your own embedded textures/signature let me know
I've not looked into it but it has to be possible
Dumb question but its possible to render a QR on minecraft?
yeah you can use maps
but yes you could in thoery render a QR to a map
I was just going to ask if was to me hahaha
That would be for displaying the QR code
And what about for creating it and parsing it?
Allright thanks
Something like that right?
Just taken from a random plugin i decompile
yeah
works with any texture/signature so now i just have to figure out how to generate the base64 strings and can have custom textures without having to load them in a resourcepack
this is whacky
If I send a plugin message to a server (from proxy) how does the server know from which "player" it is coming from?
because for plugin messages to work, it has to use a player connection
therefore, all one has to do or really the server, is see which connection the plugin message is coming from
Yea but I am sending it via ServerConnection or ServerInfo
That sounds like as if bungeecord would send it directly to a server
which doesnt work i know, but that would mean each server connection is just a simulated player?
no, for plugin message channels to work, a player has to be connected to the server you want to send messages to
because it literally uses the players connection to the server to send the messages
Yes I know
Bad design, they shoud use erver connection itself
I mean why are the classes called ServerConnection or ServerInfo if its just the connection of a player to a server through the proxy
Inded
So there can be multiple "ServerConnection's" to one server for each player on that server
the naming is just confusing me
Also you its a bad design because you should use the server connection, not player one's
I mean how would you do it otherwise? The servers dont even know that they are connected with a proxy right
are u sure?
of couse they know hahaha
no
Because you don't need a player connection to initiate a connection to a server or for a server to initiate a connection to the proxy
That why there is a section called SERVERs on the proxy config
they do
I mean, not sure if you remember in the spigot.yml you have to set bungee to true and all
Yea, the proxy knows which servers are inside of the network but one individual server does not know that it is part of a network
So why plugin messages are not sent thru that connection its really weird
I agree that the packet should be sent from server to proxy thru a player connection but not for receiving it
because those connections are different kinds. For instance, from the bungee you can query the servers. This makes use of the protocol still however it returns things like server address, player counts etc
then, there is the connection from the server to proxy
which serves a different purpose and is not reliable for sending messages
So is there a simple way to make pmc to work without players connection and also not modifying the src
sockets
just use any form of pub sub lol
oh that shits no please i really hate them cuz of their blocking design
threads exist
you need extra infrastructure
only way would be to make use of a fake player that derives from the proxy. PMC is part of the MC protocol, so to make use of that feature specifically requires a player connection or a simulated one. Otherwise just create your own socket connections between proxy and servers if you want more freedom/control
Why not all can afford!
I was trying to do that but the player was getting kicked from the server
exactly
the simulated player connection, needs to send and respond to ping packets from the server π
otherwise it gets dc'ed
I mainly did the player connect thru proxy and being redirected to server
But it joined as a normal player and them seconds like 40 get kicked
I am pretty sure the player always connects thru the proxy
yep, because you didn't send a keep alive packet and didn't respond to the servers ping packet
But the main issue is that packets are diff on versions that the most amazing shit ever seen bruh
they are supposed to, however not strictly required.
Protocols should not change a lot on diff versions because them it mess working with it
um...the MC protocol changes when it gets updates to it
because keep alive packet is no the same on 1.13 and 1.19
π
If there is no update to the protocol, the most that happens typically is a minor version bump and that is about it
So keep alive packet identifier is the same on all versions?
packet ids are constantly updated, even if the packets dont change at all
it is the same between many versions, can't say it is the exact same in all versions
So that a shit
Yeah I mean they remain the same unless justifiable reasons
Sorry for being like thi
thicc
So what do the ServerConnection and ServerInfo classes represent now?
But i really want to achive my own aproach for making PMC better so i really get mad when protocols are diff because is even more work for us
ServerConnection doesn't exist in later versions if I recall
it got broken up into smaller parts
Atleat on bungee exists on lastest
well Server then
I also dont really understand how the protocols are implement
Because they use 0x28 and varInt shits
instead of using normal numbers btw
thats just a number in hex
it represents a Server and has a convenience method to send data to it
and var int is pretty smart actually
In fact i think im not really prepare for prtocols
they are normal numbers, just not numbers you understand
sending data to it but from which 'player'?
Also my big question is why big brains didnt thought about doing a good deign which doesnt require a player for PMC?
because they were/are big brains wokring there
π
Because pmc is part of the protocol which is designed to work Server <-> Player
That doesnt join into my head
which ever is connected, typically utilizes the connection of the player that first connected or should say, which ever player has the oldest connection due to how lists and what not work. Haven't quite looked at the code for the proxy, but I don't think it really picks a random connection to utilize just which ever one is first.
are you asking why mojang doesn't actively design their product for third party modifications ? xD
true lol
Ohh that why i always thoguht it was something like proxy-server
then why dont you understand it
Now that you tell that PMC was design for player communication its pretty more rasonable
PMC was not developed by spigot or bukkit, that is a Mojang implementation and it was mainly for mods to give mods the ability to communicate to the server without having to have all these mods implement their own stuff between client and server. However for plugins, it can be convenient to use, however it really isn't suited for server to server communications.
PMC was developed mostly with Forge in mind
Okay so is there any mc protocol that you said oh wow that lib is amazing for protocol
just to make them feel like they were in the loop, like bukkit was π
I mainly look for one which implement the major versions not only shity new ones
Because that my personal opinion im mostly a 1.8 player
So should I implement the player inside the plugin message's data instead of trying to utilize the connection?
Are you trying to achive something like me? To use PMC without players?
π
not entirely sure what exactly you are asking, or why it matters which player connection specifically the PMC uses
no
I also have seen 3 posbiltiies for doing that
- Modifying source code
- Making a fake client
- Injecting into proxy and server netty
all of which are dumb
For example if I want to do something with a player from the proxy, which by default the proxy is not able to do, can I utilize the connections to specify which player i want to perform the action on or should i include the player inside the plugin message's data
you should include the players UUID in the message data
The most better and simply would be the Netty because it just declaring your own channel, the handler, the protocol somethings extra and you are done
Alright, thankyou π
Hey I'm having issues with a command that is supposed to spawn an NPC.
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (commandSender instanceof Player) {
ServerPlayer sp = ((CraftPlayer) commandSender).getHandle();
Location loc = ((CraftPlayer) commandSender).getLocation();
MinecraftServer server = sp.getServer();
ServerLevel level = sp.getLevel();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), sp.getDisplayName() + "'s corpse");
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
npc.setPos(loc.getX(), loc.getY(), loc.getZ());
ServerGamePacketListenerImpl ps = sp.connection;
ps.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, npc));
ps.send(new ClientboundAddPlayerPacket(npc));
}
return true;
}
When running the command it just says "an unexpected error occurred"
nothing is printed to the console
command not registered?
commands:
spawncorpse:
description: spawn a corpse of yourself
usage: /<command>
``` in the plugin.yml
and getCommand("spawncorpse").setExecutor(new CreateCommand()); in the main class
then your plugin is not loading, or you didn;t remap using specialsource
did you remap?
what do you mean with didn't remap with specialsource?
you are using remapped classes ServerPlayer
those don;t exist on a live server
you need teh specialsource plugin in your pom to remap them
Is there somehow to test the plugin without always need to build it and sending it to a server?
use teh normal jar
okay i'm trying
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
unless you use something like Jrebel no
thats it, couldn't remember it lmao
still same error
I'm new a making plugins what is Jrebel?
read above, and read that post thoroughly, it will walk you through in how to appropriately setup your pom
I see
basically, what you are wanting concept wise is called hotswapping
Is it a sort of reload?
jrebel is something that is already made to do such things, unfortunately costs money, there is free alternatives out there if you search for them, however I have no idea how good they are or if they work
not even remotely close
i got all of that in my pom.xml already
hotswapping, is where it swaps out the class files in the plugin that has changed without having to reload or stop the server
here is my pom.xml if you want to check it: https://paste.md-5.net/atoheyahif.xml
Ow ok
its not something for someone who is new with java as it is a relatively an advanced thing
Jrebel used to be free and cheaper and is an awesome pre-built tool that provided that functionality easily
Ok thanks
Hi, im completly new to plugin development. I was wondering how i would replace the block next to the block i just placed? Currently i have the functionality for checking if i place a sea lantern, and if so i return a message to the player. How would i replace the blocks around the sea lantern? I know the setType(), but i dont know how i would get the block surrounding the block i just placed. Can i get some help? Sorry for bad explaining, i can explain in more detail if anyone can help
You should have the location so you can do location + or - 1 in every direction?
you need to get a Location, which you can get from the sea lantern block object
event.getBlock().getRelative(BlockFace.SOMETHING).setType(Material.SOMETHINH)?
from there, you can then modify the location object z and x axis as well as the y to get the blocks you are wanting
that would only work for the blocks directly next to it
would miss the blocks that are diagonal
Yeah, and i wanna change the blocks above it too
declaration: package: org.bukkit, class: Location
Bassicly, my idea is that you place a sea lantern as a "generator". When you place the sea lantern block, it makes like a monument? so when i place it, it make a custom structure 3x3, so i need to know how to change the blocks above too
Oh, thanks!
I will try!
How would this look? I got the location of the block i just placed
ye dunno what blocks next to it
e.getBlock().getLocation()
not calling your parameter event π’
go to the shame corner
But how would i then get the block next to it from the location?
ServerListPingEvent for some reason doesnt get called
Im sry, i just started today with plugin development
that's as much info as I can give lmao, code: ```java
public int IJ = 0;
@EventHandler
public void onServerPingEvent(ServerListPingEvent e) {
IJ += 1;
System.out.println(IJ);
e.setMotd(String.valueOf(IJ));
}```
i have it in my main JavaPlugin file
uh, don't know?
Γ€lr, weird that AsyncPlayerChat events etc still work in JavaPlugin
// import stuff
public final class OCMEssentials extends JavaPlugin {
// onEnable, onDisable, etc...
public int IJ = 0;
@EventHandler
public void onServerPingEvent(ServerListPingEvent e) {
IJ += 1;
System.out.println(IJ);
e.setMotd(String.valueOf(IJ));
}
}```shortened
I DID IT!
Thank you!, I DID IT!
yippee

whole
Also, if i wanted a custom item? How would i do that? Cause rn, i just have it set so if i place a sealantern it builds around that, but like what if a player just buys a sea lantern from the shop, they just get it. How would i create a custom item/block, that i can place?
why would I need that?
literally the only thing that doesnt work is the ping event lmao
Fix it yourself then, when you clearly know everything
okay?? ill just move it to a Listener class, im literally just confused why I need to send my whole java file
To see, if you register your events correctly
you could've literally asked for "send me your onEnable function, or wherever you register your Listener classes"
You can use the persistent data API, then add a key there saying it's your custom sea lantern, so when the player buys at the shop they will get the special item, and when you're placing check the item data if it has the key saying it's a custom item
Hello, how can I setup a server in the Development Env?
Whauw thats alot xD. I just started today learning this xD. But i think i know what you mean. Like make some data with a key, and apply it to my custom sea lantern. Then when i place a sea lantern i check if it have the key, and if so i can run the code for the special sea lantern?
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
you can get the persistent data of the item with #getPersistentDataContainer
then use the #set method to add the key, and #has method to check if the item being placed has the key
Butttttt, some objects dont work when i place them. Like glas panes, arent connected to the blocks next to it. And the chest is facing the wrong way
Damn thanks!
WHY EVERYONE SO HELPFULL HERE LMAO
I love you all β€οΈ
it is what a community is for
WHY EVERYONE SO HELPFULL HERE LMAO
first time someone said that in the spigot discord xD
yeah usually they are complaining of the opposite
it's-a-me again, how would I change an ServerListPingEvent's MOTD after the event was resolved? I've seen a lot of people on spigotmc.org just delay event.setMotd using the scheduler, but that just doesnt work for me
Well all because you don't tell me why my 1.8 server does not work with my outdated plugins !!!
the event def does not allow you to do that
generally no event is valid to modify a tick later
My problem bassicly is: Glas panes are not connected to the blocks next to it, and like how would i make the structure rotate towards me? Like lets say i have a chest in the the front, and around it i have dirt, EXCEPT the front of the chest, no dirt there. How would i make it so when i place the chest, it would face towards me, and it would not place the dirt infront of the chest, but the other sides
true. Everyone is usually complaining because they ask for code and we won't spoonfeed xD
LMAO
you get the block meta and you set the direction
You dont learn from spoonfeed
hmm, this is an example of someone's code, it worked for them for some reason ```java
@EventHandler
public void countDown(final ServerListPingEvent event){
if(gameHasEnded == true){ //if the game is in where it should countdown (lobby)
this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable(){
public void run(){
int countdown = 60; //count down for a minute (60 seconds)
if(countdown > 0){ //if the countdown isn't at 0
countdown--; //take one away from the countdown
event.setMotd("Next Game: " + countdown + " seconds"); //set the motd as the time until the countdown hits 0
}
if(countdown == 0){
gameHasEnded = false;
event.setMotd("A game is currently in session!");
//here you put your code to start the hunger games
}
}
}, 20, 20);
}
}
== true :(
What about the glas panes?
how do i make them connect to the blocks next to them when placed
declare the countdown before the runnable
yeahh, that's the weirdest thing lol
there's like 100 other people in this discord with < 7 days of programming experience in this discord that pretend they do
lol
and this is the exact same thing
https://bukkit.org/threads/automatically-change-servers-motd.107389/
Yea just look at frost, at best 2 days of experience 
still beats me tho, just started my udemy course
Anyone know why itemmeta is null even after assign one using bukkits item factory?
same thing using the block meta and setting their direction, they will auto connect to blocks or to other panes if the direction is set appropriately
glad you try to figure things out alone and just ask for starting pointsβ₯οΈ
Nobody minds you asking questions as long as there's at least some self effort
would it be better creating my own impl?
what is the xy here
usually you get the item meta using getItemMeta on the item stack
the xy is that z is missing
That's correct, but i'm trying to assign the itemstack a display name but unable to get an item meta
nah cuz why is everyone so scared of Β§
using that method
why does everyone jsut type \u00a7
an item stack that does not return you an item meta does not support item meta
encoding
specifically because that item stack is air
Might just be your IDE tho
intellij works when I use Β§, dunno
ah that could be it since i'm getting random materials, i'll check thanks
because java understands unicode directly and it prevents java from misinterpreting the character code of the section sign
Yea basically every item stack should return you a valid item meta instance when calling getItemMeta
beyond the different air types
how can i listen for a dropped item hitting the ground?
don't think there is an event for that
raytracing the dropped item
what is that
then do gravity yourself basically
or just scheduler and a set lol
true, but i am checking isSolid isItem isTransparent and isInteractable beforehand
i have an idea
java class files can be in other other character encodings other then UTF, therefore the character point for the section sign could be different if you use the actual character versus using the utf character code itself which guarantees java knowing its the section sign
hope that clarifies the issue on that
No please don't
Worst way to do it
yup that works
check what material yields you a null return value for getItemMeta then
there should really not be any beyond air
unless I missed something
yeah will do
(maybe some other debug materials ? or block only materials)
sugar_cane_block or how it's called if that's still a thing
but then again it's not solid
I'm trying to make a command that spawns an NPC (mostly to just mess around with both commands and NMS to learn how they work), but whilst running the command I just get "an unexpected error occurred" No errors are printed to console.
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (commandSender instanceof Player) {
ServerPlayer sp = ((CraftPlayer) commandSender).getHandle();
Location loc = ((CraftPlayer) commandSender).getLocation();
MinecraftServer server = sp.getServer();
ServerLevel level = sp.getLevel();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), sp.getDisplayName() + "'s corpse");
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
npc.setPos(loc.getX(), loc.getY(), loc.getZ());
ServerGamePacketListenerImpl ps = sp.connection;
ps.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, npc));
ps.send(new ClientboundAddPlayerPacket(npc));
}
return true;
}
pom.xml: https://paste.md-5.net/atoheyahif.xml
Using both the normal and remapped .jar with no difference.
it usually means an input wasn't handled appropriately but there wasn't a null either
you should make it a habbit to return false at the end of your commands, and return true in the various check block statements
or wait is it because i'm not doing an if statement to check the command name?
in this way, you will always know if your command actually didn't run
so in your example above, at the end in the if block
put return true
change the return true on the outer to false
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (commandSender instanceof Player && command.getName().equalsIgnoreCase("spawncorpse")) {
ServerPlayer sp = ((CraftPlayer) commandSender).getHandle();
Location loc = ((CraftPlayer) commandSender).getLocation();
MinecraftServer server = sp.getServer();
ServerLevel level = sp.getLevel();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), sp.getDisplayName() + "'s corpse");
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
npc.setPos(loc.getX(), loc.getY(), loc.getZ());
ServerGamePacketListenerImpl ps = sp.connection;
ps.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, npc));
ps.send(new ClientboundAddPlayerPacket(npc));
return true;
}
return false;
}
there you go
now, if that section for whatever reason doesn't run, the server will tell you the command didn't run π
oh and should you be using the normal or remapped jar?
normal jar for running the server
remapped is only for development purposes so you can compile your jar
oh and one other quick side question, using /reload in development should work fine for commands?
or might they break?
usually, but sometimes it still breaks for commands
just depends on whether or not the plugin is designed to handle such things
i don't have anything special that i'm storing/doing so i should be fine
with the updated code it still says unexpected error
its how the plugin is coded. You should always do your best to handle reloads in your plugins
in other words, handle when certain things magically go null
null checks are super important
did you register the command in plugin.yml and the server?
I also go for always true because return false creates some weird default error message (like /<command> in plain white text). Atleast it did so in 1.9 or whenever I started using return true.
Did they change that?
commands:
spawncorpse:
description: spawn a corpse of yourself
usage: /<command>
public final class Corpses extends JavaPlugin {
private Ticker ticker = null;
@Override
public void onEnable() {
// Plugin startup logic
PluginManager pm = getServer().getPluginManager();
this.saveDefaultConfig();
pm.registerEvents(new DeathEventListener(this), this);
pm.registerEvents(new CorpseClickEvent(this), this);
ticker = new Ticker(this);
getCommand("spawncorpse").setExecutor(new CreateCommand());
}
not sure, but generally false shouldn't be encountered is the point I was making. If at some point false is hit, then you should get that message saying you don't have perms to run the command or whatever the default message is π
this makes it easier development wise to know your commands are running and the appropriate check blocks are being ran
yeah the "not be encountered" part makes sense. The default message from spigot was the one I just mentioned^^
dunno if it still is
probably is
But regardless super handy to see it when making plugin commands lol
especially if you get a command that is a bit lengthy code wise
just for some random test i made it ALWAYS return false and is still gives unexpected exception. So something is going wrong lower down then no?
ServerPlayer sp = ((CraftPlayer) commandSender).getHandle();
Location loc = ((CraftPlayer) commandSender).getLocation();
why are you using CraftPlayer here?
Just use the normal Player
using NMS so i'm going to the mojang version (ServerPlayer)
just because you are building against the server jar, doesn't mean magically you lose access to API stuff π
in this case yes i could just use the normal spigot API version for what i'm doing, but i might do more with it that i need the mojang version
you can just use normal player stuff there, only time it wouldn't make sense to is if you have some specific reason you need those NMS classes
highly doubt it
always stick with API unless you actually need NMS
otherwise you are just over complicating unnecessarily
oh yeah wait i needed itfor the new ServerPlayer
that one requires NMS classes and not spigot API classes
new ?
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
it uses the NMS classes
it doesn't accept spigot API classes
is that your class you made?
nop that's NMS
so ServerPlayer is Mojang then
?entities
but anyways still the command doesn't work for reasons
latest.log shows no error on loading either
if i wanna check an item is a bed how can i do that? Bc bed now have all diffrent material types like Black_bed so how can i just have BED
doesntwork?
what doesnt work3
Where i can find all entities from mc 1.19?
watch EntityType enum?
I cannot find a link which contains all mobs and animals
Im looking on it but doesnt contain all of the mobs and animals
ctrl f
??
item.name().endsWith("BED")
ty
Sorry for asking, but whould the name should be lower case or uppar case?
I'd use a set for that
private static final Set<Material> BEDS = new HashSet<>();
static {
Arrays.stream(Material.values()).filter(mat -> mat.name().endsWith("_BED")).forEach(BEDS::add);
}
enums are uppercase
EnumSet
π€‘
no
you shouldnt use that
because it soon will no longer be an enum
True
I think it was announced in 1.18 that one shouldnt use enumsets anymore, which is sad D:
I wonder how the protocol will adapt to that
Should them uppear case?
namespaced keys are lowercase
Hmn
but then again you're just wrapping NMS's EntityType
Never heard about them btw
fuck you intelliJ
yeah it's only when ctrl+b'ing into the material class
finally i can run ij and minecraft together
middleclick
i never use middleclick because I had a mouse for 2 years where middle click was broken. so now I am used to not use it
π
middle click and side buttons go brr
yeah my new mouse has 12 buttons on the side lol
decompiling the material class still doesn't that much from the cpu honestly
my intellij always crashes
1 sec
So how would i need to setup my enum to doing this:
for (String name : Entities.values()) {
if (!event.getEntity().getType().name().equals(name)) return;
event.setCancelled(true);
}
first i gotta restart IJ
my intellij usually crashes when decompiling some spigot enum
okay so i added a log message here
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
plugin.getLogger().info("Received command " + command.toString());
if (commandSender instanceof Player && command.getName().equalsIgnoreCase("spawncorpse")) {
``` Which is logged in console, yet there's still "unknown error"
My enum should be in upper case, lower case?
oh, IJ survived the material class this time
instructions unclear, am staring at bsod
2 projects?
you're one of those
BUILD SUCCESS Total time: 2 s?
click "open in new window" instead of "open in current window"
hehe
i hate this, when buying a new pc they always switch the ctrl and fn key
desktop pc with external keyboard
yeah it takes a good 20 seconds or so lol
lmfao
4 up-to-date
only problem I have with my keyboard is accidentally locking the pc
copilot auto complete this
Any way to make this more in a more efficient and simplified way?
there's a single key at the corner that locks the pc
oh i just realized from this video you're jeff_media lol
?
I got the logitech mx keys
lol
no he isnt, you are confusing him
normally it's in my profile pic
just look at the layout
bold of you to assume i look at pfps
mfnalex do you think i could simplify this more, and if yes, how ? :)
anyways aahhhh why won't this command work or show me any useful error message
I hate that lol
damn you NMS
yea i was told it was ass, but how could i make it more simple?
bruh havent you simplified it yet?
real programmers dont sleep
dont use Enum#values()[index]
but EnuM.SOME_CONSTANt
smh this keyboard sucks
another month to get used to it
public void promoteTeamMember(UUID member) {
Team playerTeam = teamRegistry.getTeam(member);
if(playerTeam != this) {
// Player is not in current team
return;
}
TeamRole role = getTeamRole(member);
if(role == LEADER) {
// Player is already leader, can't promote
return;
}
if(role == CO_LEADER) {
// There is already a leader, can't promote
return;
}
// Fall through
memberList.put(member, TeamRole.CO_LEADER);
}
not much better but overall cleaner
How would i cancel entities damage inside a claim/region/cuboid?
Without disabling damage in general
with the help of too many log messages i found out that the line ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null); is causing an error
by checking if they are inside that region before cancelling the event?
if (role == LEADER || role == SUS) hup another optimisation π€€
I'd return some result enum, like "Result.ALREADY_LEADER", "Result.PROMOTED", "Result.NOT_MEMBER" or similar
yeah
yo guys apparently maven thinks i m no longer cool so it exlcludes my resources folder from the jar
different error messages, fourteen
Yeah that is the first thing im doing but im stuck because i dont know which is the one being damager and the damaged, so then i cannot get the claim object
mye hehe
try to add the resource directory manually in your <build><resources>
listen for entity damage event > check if entity is inside region > cancel event
do yo uhave sth like this in your pom?
Im new to Enum, do i make a new Enum class called result ?
I already know that im not that dumb bruh
π¬
then why are you askjng
how can i edit slime block jump power?
oh now i see i was usin some absurd path
alex comin in for the save once again
public enum Result { instead of public class Result() {
because i cannot find a way of casting to Player object without getting the cast exception
π
wtf are you trying to cast
instancecof: lemme introduce myself
To get the uuid of the region owner? π€
i'm so used to IDEA just writing it for me it's difficult to remember manually lol
what, not why
I know bruh but there 2 methods hahaha
How would i check if they are inside a region if not
but what's your question then
what kinda of region do you have? a BoundingBox? Your own "Region" class? a worldguard region? ...
Mainly how to get their uuid
but can i but this in the class with the promoteMember method?
Or do i need to make a new public enum Result {} class?
whose UUID?
My own class
The owner of the region
compare if the player's location's x is < region's min X and > region's max X, same for Y and Z
Because i have a method like:
ClaimManager#getClaimAt(uuid)
if you make it public, you should make it a separate .java file. If it's private, you can make it a class within the same .java file
I cannot because Cuboid class is inside the Claim object and to get the claim obj i need the uuid
whut
How do i add color to a message when i do player.sendMessage
if at all, the claim should extend cuboid
No no you dont understand or im bad wit henglish
check the corners of the box with the players location
I explain again
ChatCOlor.SMTH + "hello"
a claim is like a cuboid with an owner, etc etc
so cuboid should be the super class of a claim
or ChatColor.translateAlternatreColors('&', "&aHello")
or "Β§cI'm into naughy stuff"
myes
public class Cuboid {
private String world;
private double x1, y1, z1;
private double x2, y2, z2;
public Cuboid() { }
public Cuboid(CLocation first, CLocation second) {
this.world = first.getWorld();
this.x1 = Math.min(first.getX(), second.getX());
this.y1 = Math.min(first.getY(), second.getY());
this.z1 = Math.min(first.getY(), second.getZ());
this.x2 = Math.max(first.getX(), second.getX());
this.y2 = Math.max(first.getY(), second.getY());
this.z2 = Math.max(first.getZ(), second.getZ());
}
public boolean contains(Location location) { return this.contains(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ()); }
public boolean contains (World world, int x, int y, int z) { return world.getName().equals(this.world) && x >= this.x1 && x <= this.x2 && y >= this.y1 && y <= this.y2 && z >= this.z1 && z <= this.z2; }
}```
Everything works hahaha
Just dumb with the damage event
I'd just extend BoundingBox and add a world field
then call it WorldBoundingBox
or similar
1.13 == true && BoudingBox == null
π
Thanks!
That the issue mfalex
wdym? boundingbox exists in 1.13
1.13 smh
the plugin wont be on 1.13 up!
So dont orry about my cuboid the class
you are on even older versions you mean?
Is there any way I can make villagers act like vannila when it comes to curing?
The thing is that works perfect
I hate that long contains method
No no, im coding on 1.13 but i need to work on all as pposible
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
Do have that but still the plugin.yml doesnt exist in the jar
Also this might help, I dont think intelliJ detected that resources folder cause if it had, it would show a diff icon
ugly but otherwise fine I guess
spanish detected!
right click on resources -> mark directory as -> sources root
does that change anything?
eeerm
I mean not sources root
but resources ofc
can also be porutguese
recompeinsas is portgues i thinkg
oh i just work on a project that was coded by a spanish dude so a lot of the packages are in spanish
oh lol pretty ugly that type of people that name things in spanish
can agree
right click the resources folder -> mark directory as -> resources or whatever
my man
I have learnt a lot of english from just workin on the code
it should look like this
How do i check if the block i place have a specific name? Like that its not just for example: dirt, but it have to be "dirt123" and if its that, then it execute the code
eyyyy alex you legend it worked
oh idk im 1200km away from Foz do Iguazu
pretty sure that's brazil
in BlockPlaceEvent, get the used itemstack and then check if it has itemmeta and if yes, if the meta has a custom name
how can I set item in anvil?
So dont care about the version and im annoyed because i need to protect damage in diff ways, first player pvp, secondly killing mobs, animals. So i have 3 diff flags, Combat, Animals, Mobs
lets compare items on pdc instead
unless you want to allow players to name the dirt "dirt123" to turn it into some especially dirty dirt
mye
but
yeah that's probably a very rare occurance lol
using pdc > checking item name
?paste
admins love this
Thanks man!
But does this work with color too? or does that not matter?
Does it matter if then name of the block is in green but its still dirt123?
it wouldn't work with color. YOu should NEVER identify your custom items using their name
you should use the ItemMeta's PersistentDataContainer instead
it's like NBT tags
but using spigot API
fun fact
I got a contracted job at a minigame network
we had a beta test round with 3 minigames made by another dev
well otherwise, you'd have to do something like this
if(customName.equals(ChatColor.translateAlternateColorCodes('&',"&adirt123"))
it legit felt like there was a 1 in 100 chance of enderpearls actually throwing
someone else said that too. Like a custom data tag for the block, so when i place a dirt, it checks if it have the data tag, and if so it will execute the code
and like a 1 in 5 chance of any of the features working
the worst things are when you compile your plugin 10 times and it always fails to use an inputstream to read a resource with some weird ZipException. you check the .jar and the resource is there and perfectly readable. but when compiling the 11th time, it now works
Okay so how would i do this lmao? You dont have to spoonfeed me with code, i need to learn it myself too. Bassicly right now, when i place a sea lantern it does the code i want it too, but i dont want it to be a normal sea lantern, have to be a custom one. So as you say, i need it to be a unique custom block kinda?
gradle does some clown shit
There's this PDC tutorial by lynx:
?pdc
half of my compiles just say "Failed to clean up stale outputs"
also a bunch of videos on youtube
videos :X
Well i would just end up copying the code from the person, so i think reading it will be harder, but i learn it better
well but you always have to watch 30 minutes to learn stuff that a 3 minute text could have explained
at least that's my experience with tutorial videos
Well, text usually leads to people just copy pasting
and not understanding shit
at least in my experience
Anyone by chance known with NMS for 1.19.1 who would know why this causes a command to fail with "unknown error"?
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
``` All values are not null (except the literal null). I verify this
when you have to manually type it out that at least gets stuck in your head a bit better
well
the last value obviously is null
what's the actual stacktrace?
no stacktrace
wrap it into a try / catch(Throwable t), then do t.printStackTrace()
yeah on 1.19.1, commands do not print proper stacktraces
I also had this problem, so yeah try/catch it yourself
then you get a proper error message
neither on paper, nor on spigot. no idea why
the console just doesn't print ANYTHING
huh weird
yeah I have no idea why this is the case
I've tried it yesterday on latest spigot, and latest paper o0
any ideas?
there we go now got a trace
[19:57:52] [Server thread/WARN]: java.nio.file.InvalidPathException: Illegal char <<> at index 137: .\world\stats\literal{sebkuip}[style={clickEvent=ClickEvent{action=SUGGEST_COMMAND, value='\tell sebkuip '},hoverEvent=HoverEvent{action=<action show_entity>, value='net.minecraft.network.chat.ChatHoverable$b@44062209'},insertion=sebkuip}]'s corpse.json
[19:57:52] [Server thread/WARN]:at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
[19:57:52] [Server thread/WARN]:at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
[19:57:52] [Server thread/WARN]:at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
[19:57:52] [Server thread/WARN]:at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
[19:57:52] [Server thread/WARN]:at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
[19:57:52] [Server thread/WARN]:at java.base/java.io.File.toPath(File.java:2387)
[19:57:52] [Server thread/WARN]:at net.minecraft.server.players.PlayerList.getPlayerStats(PlayerList.java:1238)
[19:57:52] [Server thread/WARN]:at net.minecraft.server.players.PlayerList.getPlayerStats(PlayerList.java:1224)
[19:57:52] [Server thread/WARN]:at net.minecraft.server.level.EntityPlayer.<init>(EntityPlayer.java:307)
[19:57:52] [Server thread/WARN]:at me.sebkuip.corpses.CreateCommand.onCommand(CreateCommand.java:41)
[19:57:52] [Server thread/WARN]:at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:57:52] [Server thread/WARN]:at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[19:57:52] [Server thread/WARN]:at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:831)
[19:57:52] [Server thread/WARN]:at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:44)
[19:57:52] [Server thread/WARN]:at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264)
...
BlockFormEvent
yes but how can replace the block?
Cancel the event, then set the block yourself I guess
how can I set an item in anvil
what is your game profile name xD
that seems pretty fucked
this happens when i spawn a new ServerPlayer with npc = new ServerPlayer(server, level, gameProfile, null);
and the gameProfile is defined as GameProfile gameProfile = new GameProfile(UUID.randomUUID(), sp.getDisplayName() + "'s corpse");
Whats the players name?
how set block ?
You cannot have special chatacters in the name IIRC
did you set a component as the player's name or something
Bruh, using Block#setType
that ?
it's trying to fetch some files from your computer with color codes and all
huh that's annoying. I was able to use ' for setting a name on a zombie mob
spaces will also completely smack that
how can I get the anvilinventory as a var
Maybe im wrong, idk
is this dude trying to make a skyblock plugin without any prior experience
cast it
imma give it a try see if that solves it
like AnvilInventory inv = (AnvilInventory) event.getInventory; ?
π₯£
A fancy word for βforkβ is βeating hookβ
that was in fact it ffs
NMS i will find you, and i will kill you
that not work
brah i hate the fact that java 8 NPEs exist and that people use 1.8.9 for their servers
oh wow i found out why. In NMS the ServerPlayer class has getDisplayName as a Component and not just a string....
Have you registered your event
yes
output something to make sure it's running the event
okay
Donβt cancel the event
?paste
okay, i test
https://paste.md-5.net/ekutapakiq.bash big ass error when loading classes ;(
PlacerholderAPI installed?
?paste
check whether the inventory actually is an anvilinventory before casting it
and upgrade your server, you're like 7 years behind
bug reports via youtube, I love it
its not for my server its favor for someone
Is there any better way to save a List<?> to yml file using FileConfiguration, I need to make itemStack property ignored
check if the inventory is an anvil inventory first
how do you even serialize PianoSkin? It doesn't implement ConfigurationSerializable
i just make fileConfiguration.set("customSkins" ,new ArrayList<PianoSkin>())
https://paste.md-5.net/gasijaweyi.bash
Cant find some weird ass class
No
fuck
Only if you save it all manually
Are you sure the plugin was originally made with Java 8?
yes i m sure af
Then you need this: https://github.com/java-native-access/jna
That not work
Then try cancelling it and then setting it to your block 1 tick later
yes i missed setCancelled after setType
I have that
You need to have it on the server or shade it into your plugin
oh ok
How do i shade it
How do I get the default world?
Bukkit.getWorld("world");
attempting to get a skin for an NPC. Got this code (the requesting part is stolen from SO, just changed to gson instead of whatever they used)
https://paste.md-5.net/acuqelimag.java
Got error
https://paste.md-5.net/uhisumokit.md
line 63 (which it shows in the error) is Gson properties = skindata.fromJson("properties", Gson.class);
oh i think i see why. You can't have Gson as the new type when doing fromJson
you spelled yosoykute wrong in your spigot.yml
because looking at your class structure, your main class is in com.yosoykute.kadete.KADETE
you're reading a regular JsonObject
not com.yosoyute.kadete.KADETE
@ripe urchin read up on how to use Gson, because you're doing it all wrong
yo, anyone know what I could use to show text on screen?
what do you mean by this?
globally*
Title
you're attempting to read a Gson object and get it from fromJson
you will never have a Gson object serialized
that makes no sense
thought so, main issue was finding it
you need to read a JsonObject, not Gson
nested json?
Gson is the utility class for the library, JsonObject is the actual json
no
that's not what Gson (object) is
wait so gson can't deserialize nested json as a new gson object?
player.sendTitle()
i'm literally looking at the docs and it appears to just be that gson is a json object with some more fluff/fancyness
it can
π
butr you're doing it wrong
I knew that "K" letter in keyboard not going good was a problem lollll
remember to use int
why exactly?
player.sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut);
public static JsonObject readJsonFromUrl(String url) throws IOException {
try (InputStream is = new URL(url).openStream()) {
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
return JsonParser.parseString(jsonText).getAsJsonObject();
}
}
private String[] getSkin(UUID uuid) {
String[] skin = skinCache.get(uuid);
if (skin != null) {
return skin;
}
try {
JsonObject skindata = readJsonFromUrl("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString() + "?unsigned=false");
JsonObject properties = skindata.getAsJsonObject("properties");
String signature = properties.get("signature").getAsString();
String texture = properties.get("value").getAsString();
skin = new String[] {signature, texture};
skinCache.put(uuid, skin);
return skin;
} catch (Throwable t) {
t.printStackTrace();
return new String[] {"", ""};
}
}
compare that to what you were doing, try and figure out why it was wrong
you don't use the Gson object to deserialize Json strings, not necessary
Gson object is meant for serialization & utility
Gson is not a JsonObject, two different classes with 2 different purposes
api version should just be 1.16
is the int in ticks or seconds?
Gson is a library, but also a class, and in the library we have a JsonElement which represents json objects, arrays, and primitives (string, int, etc). JsonObject is a json object ( { ... })
always ticks
yours isn't correct either since JsonParser.parseString returns a JsonElement not a JsonObject
btw if that code doesn't work it's because you have given me the wrong json schema represented in your old code
1 second = 20 ticks
what java version are you compiling to?
How to check?
it's in your pom.xml
there I've updated the code
There is no pom.xml
along with the correct schema because your old code was getting another property "skindata" which does not exist
are you using gradle then?
Ye
Please use maven or gradlew
^
How
Maven is better for spigot development
if you wannt develop with Paper iirc Gradlew is easier
this is what the object is that i'm parsing btw
I know, I ran it on my own uuid afterwards
I've edited my codeblock which'll work now unless i've forgotten a semicolon somewhere
the value is an encoded base64 string btw
^
i just called it "skindata" since it's data for the skin
I need to start the project from scratch?
you decode it and it gives a json value
yeah i got that it's encoded haha
right but you were trying to get a property called "skindata" inside of that object, which doesn't exist π
but the server uses the base64 encoded string to display the skin for what i know
was i? that must have been a typo then
yeah, that's just set on the "properties" area of the gameprofile
if your project isn't very large, then i would just create a fresh new maven project and copy everything over
unless there's an easy way to convert a project to maven that i don't know about
i'll improve the skin cache too but right now just want skins working
oh nevermind that's my fault
you can put unsigned skins
you were reading "properties" (which is correct)
feels like
Like this?
do you have the minecraft development plugin for intellij?
if not i would install that
ah there's one thing i didn't see in the data
Where to install
because it can create a brand new spigot plugin that already has everything in the pom
Im new into java development, i came from other languages
properties isn't just another object with name, value and signature
properties is an array with inside objects
you can also install straight from intellij
authlib serializes the object to an array
idk why
it's weird
How to use it?
and it's no longer considered a secure algorithm
I wonder if we can crack the skin keys somehow
JsonObject properties = skindata.getAsJsonArray("properties").get(0).getAsJsonObject(); that should do it lol
then do JsonObject properties = skindata.get("properties").getAsJsonArray().get(0).getAsJsonObject() (unsafe because we assume the array will always have just 1 element, but it's a pretty safe assumption)
yes
perfect
group id would be what you put in before
groupID is just something like me.sebkuip or net.minecraft
so com.yosoykute.kadete
and artifactID is the name of whatever you're making
yep
generally the name of the plugin
no
keep it at 1.0-SNAPSHOT
oh gosh the skin doesn't have the second skinlayer rip
K
would anyone know how to enable the second skin layer by chance?
wdym
entity metadata
it's a bitmask
id field depends on the server version
but it's somewhere between 14-17 depending on the server version
this.getEntityData().set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
1.19.1 in my case
ah lovely
this will enable everything, should be what you want
i do want all the extra layer ones, but that enum does not seem valid
at least the bitmask is correct, dk about the API part
thats nms ServerPlayer
yeah it's not an enum, it's just a static field which is there in your screenshot xd
import net.minecraft.world.entity.player.Player;
don't mind the misspelling
hm doesn't exist for me with that data type
I seem to be talking to two different peopel about the same thing
you have the wrong player import probably
he's directly referencing the one you told him to lol
npc.getEntityData().set(net.minecraft.world.entity.player.Player.DATA_PLAYER_MODE_CUSTOMISATION);
he's using the fully qualified name and it's protected
then do it In teh class that extends ServerPlayer
https://imgur.com/a/w7DWdSC do i need to change something here or can i just start coding
that's your basic plugin structure
pom.xml for maven, resources for your plugin.yml (and anything else you might add later), and your main class
Ye but, i need to modify anythign there?
i'm not quite understanding
it's your basic plugin structure, everything to get started is there. That's your plugin you're looking at. the minecraft development extension makes that all for you
do you have a class extending ServerPlayer?
if you wish to add more dependencies, do so in pom.xml, if you wish to add commands, add them in your plugin.yml, if you wish to go coding go to your main class
no
all caps :/
if you want to put events in it, yes
Please take in care the java name conversions!!
Wym
Why everything red
why upper case?
alright thanks. I've moved over a bit more to the class than just what you showed but at least the idea is the same
there's an error in your events class
Have you learned java?
I think you are new
π
Forgot about importing
vents
Me too bro
Lmfao
I think he is new
To java yes, to programming no
So why using upper case?
That my question
You MUST follow class name conversions
Tbh idk neither
I just started making utils for first time
Basically methods
Instant of writing the same thing for many times as I used to do
You shouldnt be naming classes like "MYCLASS", it should be "MyClass"
I was thinking make an util for custom files itβs fine to do?
Camel Case
Upper case is the same
UpperCase = Camel case same thing