#help-development
1 messages ยท Page 2231 of 1
:kekw: I just looked back up
this is legit like the perfect instance where you create an object for it
so uh
FileConfiguration yConfig = YamlConfiguration.loadConfiguration(getPlayerDataFile(player));
yConfig.save(getPlayerDataFile(player));
``` do you know whats wrong with this ๐
i dont know if I want to know whats wrong with it
you could put getPlayerDataFile as a variable rather than calling it twice
is the file not being created?
it is being created?
yea
so it just not saving?
so in your class up there you have getPlayerFileConfiguration which does the same thing but you are loading it via yamlconfiguration but returning it as a fileconfiguration
if you switch that to return a yaml config, you might be able to remove the overhead of having to create a new instance of it to save
I am also very tired so I probably will miss something sooner than later lol
and should I keep yConfig.save(getPlayerDataFile(Player))?
your good dont worry, any help is appreciated
even if its wrong, atleast I still learn
I would set a var of yamlconfig to the getPlayerFileConfiguration previously mentioned, then call the var.save(var)
I find it interesting that it doesnt use the stored path
actually for the save your getplayerdatafile might be fine
hmm nope still at 2 deaths (which was 0 before I changed it manually)
which var would be the new one?
or is it just the same
var being the new yamlconfig
but in var.save(var)
so var.save(getPlayerFileconfig)
try that thingy
gonna be honest if it doesnt work ima let someone else hopefully give it a shot as I am tired, and not great with yaml configs lol
hmm nope, but tysm for the help! Ill look into that static abuse too ๐
have a good day!
Show some code. It seems to be loading fine, so show your saving code
looking now
I'm storing items in a database and am currently using MEDIUMTEXT since i convert the ItemStack[] to a byte[] and then to a base 64 string however mediumtext has a limit of 16mb which is probably not enough since i want to offer the opportunity for the plugin to have "infinite" storage. I saw LARGETEXT has a limit of 2gb which is unrealistic to surpass so should i use that or should i use Blob?
from what I can see your savePlayerDataFile(Player player) loads the data before saving. so its wiping out any changes you made.
so remove that and replace it with something else?
you have static methods but never use them?
you need to pass back the FileConfiguration you loaded and altered.
Then save that
You are currently loading a fresh copy from file and saving
this method never stores anything java public static File getPlayerDataFile(Player player) { return new File(dataFolder, "player data" + File.separator + player.getUniqueId() + ".yml"); }
static abuse :)
it just returns a FileConfiguration. You need that instance passed back to a save method
The statics are not too bad. if you got rid of most (as they are not needed) and remove the static FileConfiguration config;
If its a static class you shoudl not be storing that
If you want to keep the static you should change public static void create(Player player) throws IOException { to return a FileConfiguration
would that be causing any issue though? as it isnt used
or is it just in general for the future
one sec
kk
OOps wait I thought you said saveDataFile my bad
what would go right here then? since I can only change a config file if im correct
and if I get the fileConfig then it would load the file
?paste
This is doing it without static abuse https://paste.md-5.net/babogujoya.java
you hold a reference to the returned FileConfiguration and return it to be saved
you can actually delete + File.separator from the end of the folder field
not needed
choco can u help me out here?
should i even be using text or should i use nvarchar?
Fill a max size inventory (modded chest) with stacks of stone and serialize it. See what size teh data is. add 20% on top for variations (enchants etch) and that will be your max data size
MEDIUMTEXT should be fine for saving inventories
they should not be storign 1000+ items in a single table entry
an inventory, yes. 1000+ items in one blob, no point
sorry i dont understand
what do you suggest then?
control how many items you are storing in a single Base64
i hate putting a hardcoded limit
What are these 1000+ items you want to put in one MEDIUMTEXT?
Then it should be limited by a players inventory capacity
what a vaults size limit?
then save each page
then i need a column for each page?
each page will have a hard cap then
yeah but where do i store the page?
an entry per page
a table with owner, page and contents
a key pair of owner and page
no, just so you don;t have a mega blob of data pumped into sql
why is this a bad thing
it probably wont ever go past like 30mb
its not what sql is designed for
you may as well save to file if you are blobbing everything
isnt that the point of the blob datatype tho?
BLOB stands for Binary Large Object and this type of storage is generally used for storing media like images, videos, etc.
Yours is not a true blob
yours is lots of individual items
ok hear me out, what is bad abt this? because splitting into pages vs throwing it into one entry it's the same end result right?
not really. If its all one blob you have to read and write the whole thing at once
i'm going to cache it all at once anyways
for online players
most servers using the plugin probably wont even go that far
Well in the end its upto you how you store it. Myself I'd not go above MEDIUMTEXT for this
max like 500 items maybe
I'm trying to make a gui with a clickable rewards claim system, ```Player p = (Player) e.getWhoClicked();
if (UUIDs.contains(p.getUniqueId())) {
p.closeInventory();
p.sendMessage(ChatColor.DARK_RED + "You have already claimed your rewards!");
} else if (!UUIDs.contains(p.getUniqueId())) {
switch (e.getRawSlot()) {
case 4:
UUIDs.add(p.getUniqueId());
p.closeInventory();
p.sendMessage("AAAA");
break;
default:
return;
}
sender.sendMessage("give " + p.getDisplayName() + " cobblestone 1");
p.closeInventory();``` problem's I'm having is that the player can take items in/out of the gui and nothing happens when you click on the EnderChest in the middle
if (sender instanceof Player) {
Player p = (Player) sender;
//Functionality for the gui.
Inventory inven = Bukkit.createInventory(p, 9, ChatColor.GOLD + "Trailer Repost Rewards!");
ItemStack MonthlyCrate = new ItemStack(Material.ENDER_CHEST);
ItemMeta meta1 = MonthlyCrate.getItemMeta();
meta1.setDisplayName(ChatColor.YELLOW + "Monthly" + ChatColor.RED + "Crate " + ChatColor.GRAY + ("(Click to claim your repost rewards!)"));
MonthlyCrate.setItemMeta(meta1);
inven.setItem(4, MonthlyCrate);
p.openInventory(inven);
}``` my gui
I think I tried that, should I write it under: if (ChatColor.translateAlternateColorCodes('&', e.getView().getTitle()).equals(ChatColor.BLACK.toString() + "Trailer Repost Rewards!")
&& e.getCurrentItem() != null) {```
so something like if (e.getClick().isLeftClick(){ }
Not necessary, just cancel it when the conditions are met
Or items will be taken out of the inventory
ok and in the switch method, my outcomes aren't working when I click on the 5'th slot of the gui
e.setCancelled(true);
UUIDs.add(p.getUniqueId());
p.closeInventory();
p.sendMessage("AAAA");
break;```
e.setCancelled(true);
UUIDs.add(p.getUniqueId());
p.closeInventory();
p.sendMessage("AAAA");
System.out.println(e.getRawSlot());
break;``` this is what I added, tested and nothing came out to console or in chat
Print it before the switch
That will never get fired if its not the right slot
So you gotta do it before the switch by printing the raw slots
From there make ur assumptions
I'm wanting case 4 to be the only thing the player clicks, when they click it then I want to run a console command that /gives player rewards
Read what I said above
Its a simple debugging
And u can use #broadcastMessage instead of sout
should the players be able to remove anything from the inv?
no
if not, cancel as soon as you check that the clicked inv is yours
how can I get an arrow's modelData in EntityShootBowEvent?
custom model data?
yes
getConsumable
what
k
declaration: package: org.bukkit.event.entity, class: EntityShootBowEvent
yes event.getConsumable
gives the itemstack
then get custommodeldata frm that
item
ok thank you
click the link i sent
is there a way to get an arrow itemStack from an arrow entity?
I can't use getConsumable() this time because it's in entity death event
When using ConfigurationSerialization, is it normal that you will have this this ==: me.mrgeneralq.sleepmost.models.Dream <-- being the class path always there? My concern is if I ever re-organize the structure of my classes, it would break
So you want to kill a arrow entity and want this entity to drop a arrow item?
i want to check if an entity is killed by a custom arrow
Wdym with costum arrow?
an arrow with a custom name and modelData
Oh okay
I don't know but I think when a arrow is fired (it is now an entity) it loses its itemdata because it is not a item anymore
yes that's the problem
im gonna save the fired arrow in hashMap with EntityShootBowEvent and then check if the arrow that killed the mob is in the hashMap
But you can check it otherwise you can just check if the number of the arrows in the inventory with this specific data is getting lower
and how do I get the inventory before the arrow is fired?
Is there a way I can make a player send a command upon completion of a certain condition?
You can add metadata directly to the EntityArrow that has been shot
Right in the event, everything you do in this event is done before the arrow is shot (that's why you can cancel the event)
There is an event for tab completion or you can directly use a TabCompleter on a command. (see https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/command/TabCompleter.html)
I think I got it figured out, I wanted console to send it anyways
There is a packet for it but you can't directly send it to the player that you want to lay down as I know.
Other solution if you want to make it : create a fake entity, lay down that entity and make the player invisible
In this episode of the Spigot MC Plugin series, I start a new plugin called Bodied. This plugin makes it so when a player dies, an NPC is spawned using NMS and is made to lay down and have no nametag. In the next parts of this plugin's development, I will show you how to put items in the body once the player dies, and if no one claims it after a...
find the part you need
theres a part 2
just like skim through it
i dont know exactly how but ive watched this before and it shows u how to
Didn't really understand what you want to achieve
its for entity player but should in theory work for regular player if u cast
ArrayList<UUID> UUIDs = new ArrayList<>();
if (ChatColor.translateAlternateColorCodes('&', e.getView().getTitle()).equals(ChatColor.GOLD.toString() + "Trailer Repost Rewards!") //This is a conditional checking for the opened inventory.
&& e.getCurrentItem() != null) {
Player p = (Player) e.getWhoClicked();
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "mcrate give " + p.getDisplayName() + " june 1";
e.setCancelled(true);
if (!UUIDs.contains(p.getUniqueId())) { //Checks for the players UUID in the arraylist to add protection from players claiming rewards over and over again.
UUIDs.add(p.getUniqueId());
TrUUIDs.add(p.getUniqueId());
if (e.getRawSlot() == 4) { //Functionality of the gui.
if (UUIDs.contains(p.getUniqueId())) {
if (p.isOp()){
p.closeInventory();
p.sendMessage(ChatColor.GRAY + "You have claimed your rewards!");
Bukkit.dispatchCommand(console, command);
} else {
p.closeInventory();
p.sendMessage(ChatColor.DARK_RED + "You have already claimed your rewards!");
}
} else {
p.closeInventory();
p.sendMessage(ChatColor.GRAY + "You have claimed your rewards!");
Bukkit.dispatchCommand(console, command);
}```
//Checking the player's permissions.
if (sender instanceof Player) {
Player p = (Player) sender;
//Functionality for the gui.
Inventory inven = Bukkit.createInventory(p, 9, ChatColor.GOLD + "Trailer Repost Rewards!");
ItemStack MonthlyCrate = new ItemStack(Material.ENDER_CHEST);
ItemMeta meta1 = MonthlyCrate.getItemMeta();
meta1.setDisplayName(ChatColor.YELLOW + "Monthly" + ChatColor.RED + "Crate " + ChatColor.GRAY + ("(Click to claim your repost rewards!)"));
MonthlyCrate.setItemMeta(meta1);
inven.setItem(4, MonthlyCrate);
p.openInventory(inven);
I'm making a custom gui for when a player clicks my item in the gui it will give them a monthly crate
if they have the permission that is,
and it works
amazing
why are you translating the inventory title?
do you still have this question?
surely you aren't setting the title to &4Monthly &3Crate
when you get it
it has the formatting
to be fair this is how I've been doing guis, since i watched the stephen king udemy course
so its just how I've been writing them
and you dont need to use ToString on chat colours since the + keyword does that
alright
well string stuff can get pretty heavy if you do it a lot
Well I'm just surprised I got everything I wanted to work
first try?
no def not lol
ah
this has been a day project
first try's never work in spigot ๐
30 hrs mostly just tweaking and debugging it to be honest
I had the majority of this working yesterday
but now its done
so im happy
(usually) Never works in programming ^^
Thanks for the help guys
You have to change the GameProfile
Is craft player the entity you're creating or a real player ?
Exactly what you did
What is the lign you get this error ?
Looks like you're maybe sending a too long player name
yeah
you cant add the color without removing some of the other string
otherwise the string length will exceed 16
maybe hide the name and place an armor stand above it
and then put the full name in there
Or do colour with a team
Is there really no way to know if a player was damaged/killed by another player apart from parsing the death message?
๐
I mean
is playerdeathevent and getLastDamageCause not sufficient?
getKiller exists
^^
oh you want to cancel a death event?
then listen to a damage event instead and check if the players health minus event.getFinalDamage() is less than or equal to 0
you can cancel that damage event
declaration: package: org.bukkit.entity, interface: LivingEntity
Thanks so much I have tried to find this for so long lol
Ig my searches were not right
I mean
Remember to use getFinalDamage
that will only work if the last damage was actually the player, so like
player shooting another won't work with that
or player knocking someone to death won't trigger that either
then you need to get the shooter of that projectile instead
im also gonna need some help, im trying to get nms to work so currently im using mojang mappings but the maven specialsources plugin isn't re-obfuscating my nms code so on servers it doesnt actually work
keep getting nosuchmethoderrors and all
If you're not targeting a specific server, I recommend you to use reflection
i know i have the specialsource plugin installed and im packaging with maven but the plugins dont seem to actually be obfuscated
can you share your pom
whats the paste command again
?paste
?paste
lol
why do you have multiple mapped spigot deps
I mean, are you sure that you are using the right one ?=
wtf
the plugin will only reobf one
use modules bro
^
I mean, this might have worked on old versions, where the NMS version was in the package name
here's how I use modules. probably it's not the best way to do this, but it's working fine. https://github.com/JEFF-Media-GbR/JeffLib
With an event events are always called before the action happens
not always
so its not working because i got duplicated dependencies
for example PlayerChangedWorldEvent is just a "monitor" event. You cannot cancel it etc, and it gets called AFTER the palyer has changed worlds
though most of the time yeah it is the case that events are called before they actually happen
yes, most of the time that's true
are modules something that i can get it to generate automatically or do i just manually copy that file structure you linked
is that something maven just does for me
you need to do it manually
maven will handle the compilation
The event he needs is called before action I think
You just have to add it to your maven dependencies, and shade it into your plugin
what are you talking about btw
haven't read the full conversation
i just nuked the whole thing, im starting over lol
why's nms gotta be such a mess to work with
try the obfuscated one lmao
because you are not supposed to work with it
i mean i would like to not have to work with nms but unfortunately i have to due to a spigot bug
what bug?
like im trying to make an extra attack range attribute but under specific circumstances no interact event is being fired
1.19
so i cant actually detect when a player is left clicking a weapon
Can someone explain please, why compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' should be compileOnly and not implementation?
Doubt there is a bug with the interact event 
dependency that use compileOnly, the code will be available at the runtime.
idk how to explain it properly
Isn't it opposite?
like i said, it's a specific
you gotta be just barely out of range to actually attack but in range to be able to target blocks
and if an entity were to block that line of sight no event is being fired at all
i don't think so, compileOnly is like provided in maven.
afaik implementation is runtime + compile
so my extra range attribute sometimes doesnt work
implementation is like including the code into your final jar, so it will affect your file size.
and potentially cause issues when there is abi breakage in impl details
i have a question
ask and ye might receive
if i blacklist word on AsyncPlayerChatEvent will it also blacklist commands which contains blacklisted word?
i dont believe so
hm
commands use a different event from chat messages
ok
i have also another question
how to get command as a string
like
if i execute /i am greened
it returns iamgreened
i mean just listen to a command event and combine the command name plus args i guess
how
wdym how just listen to the event
seems that PlayerCommandPreprocessEvent has a getMessage() method too so you can just get the raw message i think
dont u use this? public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
you'd need to register the commands for that
but it seems that you're trying to specifically look for any command the player sends
what are you trying to do
cancel
commands
which
contains
blacklisted word
yeah then you want to listen to the command event
not use CommandExecutor
if you want to cancel only your own commands with blacklisted words then yeah you use CommandExecutor
use this PlayerCommandPreprocessEvent event?
yes
is it
just make a listener for that event
working on any cmd?
hm wait
No, if they are your own commands then censor them in your own commands
If you are wanting to censor every command for every plugin you use pre process
anyone know how to get the person who lit tnt
like say i light tnt and it damages another player how would i get the person who lit the tnt in the EntityDamageByEntityEvent if that is at all possible
declaration: package: org.bukkit.entity, interface: TNTPrimed
its working now thx
thank you
what would be the best way to make multiple plugins be able to use the action bar at the same time?
i made a library plugin that allows doing that, but obviously that requires all plugins to use that library instead of sending action bar messages manually. is there like an already standardized way of doing this?
sometimes you want smt thatโs temporary
but not good for idโs / storage
True
Well, would not call metadata too temporary either
you have to manually clean that up on entity removal
where as the PDC is removed with the entity
I assumed metadata resets automatically as well?
And doesn't persist through restarts
metadata does not persist
store all player stats in metadata ๐
I mean, metadata does not reset itself on entity removal
if your projectile dies
you need to remove the metadata from the server, otherwise you are leaking
When the entity is removed the metadata goes with it
Are you sure about that
I have doubts
metadata does not live on the entity
it lives in a giant hashmap on the server
no
it is not
each "metadata" thing basically just has a method to convert itself into a unique id
which is thrown into a giant hashmap as a key + the metadata key
Like yea it is a weak hashmap
but that is for the plugin unloading
not the entity reference
Has anyone experimented with custom shaders mixed with some server trickery yet?
I have seen a server literally do a functional minimap server-sided with nothing but a resourcepack, and I have no fucking idea how
And custom HUD elements that don't rely on all that font trickery is something I am very interested in
why font trickery is bad? since 1.16 client accepts custom fonts, by not overriding default ones
The problem with fonts is how akward it is to actually position and update individual elements
Hell, you need to do some weird negative width character bs to position stuff
well you cant do custom UI's without some hacky trickery
Shaders exist
And based on what I've been shown, they can do some impressive stuff even on clients
I just checked and you are correct MetaData is leaky
๐
moral of the story. Don't use metadata for anything
just PDC it
or have your own Map<UUID, Data>
or remove it when finshed
just use
or that, but dunno if spigot has the entity removed from world event stuff yet
nbt compound tags

Oh yes the meta data implementation is intriguing in many ways 
I guess its best to not use Meta that much
This is so cool..
I've been trying to figure out how to do it
But there is very little to none documentation or source available
https://www.youtube.com/watch?v=RthXDciwLH4
There's also this which just straight up has a honest to god minimap
Demo of an early version of Gauntlet, the roguelike dungeon crawler server
No client-side mods required!
With no client mods
btw its a LinkedHashMap, not even weak.
So, anyone got any clue how this could work?
isn't the inner map a weak one
and w/e, on paper the outer one is a concurrent one anyway ๐
Damn, that's really impressive.
any way to create Custom Fog?
and what exactly is meant with this?
Rendering graphics like this via a shader, and updating it from the server in a consistent way
Because you can't serve custom data to shaders on the client
But clearly there seems to be a way to do so, as the minimap rotates in sync with the camera and moves with the players position, and that little circle not only takes rotation but also distance into account
I try not to come here but I'm really not sure of how to make it work. So, I'm unsure of how to get a target into my menu listener. So, pretty much I want to make a punish GUI. I've made the GUI and it all works as I want that to, but in terms of the listener to actually perform commands I am unsure of how to get the target into that part as well, any ideas? (Information: I'm using 1.8 and I'm a complete noob with Java but the little experience I have with making Discord bots with it)
Ah the bane of all devs. 1.8
isnt all of this entirely clientside?
e.getWhoClicked()?
is that YT Bedrock? I've never seen Bedrock
the target in what way? who clicked or what player is being punished?
The player who is being punished.
Nope, that is Java
And a completely unmodded client
Only a server resourcepack and a minestom server
do you open that gui with a command?
you have to store it somewhere
(The latter of which doesn't really mean much)
Yes
Oh okay.
Mobs coming up out of teh ground, really slow arrows. Those are not valilla (unmodded) client
The server has no concept of vanilla mob behaviour
It's a Minestom server, meaning all entity behavior is custom made
It's all armorstand animations and resourcepack resources
Ok, once I've done this how do I get it to go into the listener to actually take the target's ign?
and whats the question?
Show code
how to make a minimap?
Rendering a minimap like that via shaders, and how to control the parameters
thats all clientside
Because you can't directly pass parameters to a shader
a shader is also just code which gets executed
What about the dash? Vanilla client doesn;t send any packets for those keybindings
...yes, and I am asking how one would approach that with respect to the minecraft rendering system
?paste
maybe im just dumb rn but i dont get behind what you mean
They probably have a empty item in the offhand to register the click
is this listener in its own class?
Yes
And removed the offhand slot texture
You should put the listener in the same class as the gui
They are using the S and F keys for dash
then make a private variable for the target inside of its constructor
Okay, thank you
Then they likely listen to two movement packets in quick succession
How? S and F generate no packets
You handle packets manually and individually in minestom, they are not consolidated into things like a move event
The client sends a move update packet every time the key is pressed
Not just every tick
We are talking about client to server packets here. The server can;t MAKE the client send a movement packet for pressing S
...you know pressing s makes the player entity move right
And thus sends a move packet
Pressing D moves right. Pressing S does nothing

What
i love english
you are getting boomer'd rn
...you know pressing s makes the player entity move, right? *
Oh for fucks sake
actually S is backwards
Yes, S is backwards
Any kind of move action on the client sends a move packet to the server, which the server processes as necessary
right at teh start of the video he demos his dart
The vanilla server and derivatives consolidate move packets collected every tick into a single move event and process that
But in a enviroment where you handle packets yourself as they arrive, you can instead queue up something like the dash, rather than the normal behaviour
it's not exactly rocket science
Regardless, that's not really the question
The question was on shaders
I need to find at least a starting point to be able to control properties on the client as the server, which allows the shader to render in respect to those clients
But since you can't directly pass data like that, there has to be a trick to it
it's not font UI, because smooth rotation like that is not possible through it
Spooky mysterious minimap
Bukkit.getServer().getPlayer(args[0])
@halcyon mica so he's using Minestom?
Looks like it
That explains a lot
But minestom is just a server implementation
The magic here is happening in the shader
Because the protocol does not provide a way to control the parameters of shaders
why does the player not have the suffix in their name tag?
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Team team = board.registerNewTeam(player.getName());
team.addPlayer(player);
team.setSuffix("test");
it just doesnt show up anywhere
is it possible to call superclass, superclass method?
BaseClass -> AnotherClass -> ThirdClass
I need to call BaseClass method from ThirdClass
that's not my bad design
im just trying to inject some behaviour to nms
I do not use scoreboards anymore, but my guess is to change the Team settings
maybe you should activate "show suffix" or smth
it works when doing getMainScoreboard() instead of getNewScoreboard()
but now i have a new problem
how do i make the suffix show up in a new line
isnt BaseClass.super.callMethod() a thing?
just wondering
assuming it has an impl
this doesnt work
god damn im tiredsuper gives a Class
super gives you a superclass
does it not inherit that method?
i need to get super superclass
that you can just call
it overrides the base method
and in the third class i need to revert that change
Im just hooking NMS
ik, there's no way to do this unless with this way, since the handling of the container is hardcoded
inside Packet handling class
it needs to be that exact instance
if its not, it wouldnt work
by specs iirc no
might be with reflection
eh i just copied the method
it seems not to use the superclass fields at all
thank god
Bad design
no problem
^^
You should resgn it
i can't this is NMS
Oh
Nms is so shity
I think that they should make the api better
Also Implement support like protcol lib but already integranted
NMS is no api
NMS is internal guts of the server. Its unsupported, but sometimes API just doesnt cut it
I was experimenting with my plugin and all i did was kill a sheep and then this happened. i can't type messages and command anymore, wtf?
well it tells u what's wrong
go to settings
i don't see anything related in chat settings
i relogged and it is fixed now but wtf was that?
it still happens when i kill mobs
I have this code: ``` public static void turn(Entity entity){
Random random = new Random();
int chance = random.nextInt(1,4);
if (chance == 1){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.COD);
} else if (chance == 2){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SALMON);
} else if (chance == 3){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.TROPICAL_FISH);
}
entity.remove();
}
@EventHandler
public void diamond(EntityShootBowEvent event){
if (event.getProjectile() instanceof Arrow && event.getEntity() instanceof Player){
if (event.getConsumable().getItemMeta().getCustomModelData() == 500){
event.getProjectile().setMetadata("fish", new FixedMetadataValue(plugin, true));
}
}
}
@EventHandler
public void fish(ProjectileHitEvent event){
if (event.getEntity() instanceof Arrow){
Arrow arrow = (Arrow) event.getEntity();
if (arrow.hasMetadata("fish")){
turn(event.getHitEntity());
}
}
}```
When I hit a mob the mob is supposed to turn into a fish but when the mob is turned to fish, i get a bug which doesn't let me type anything in chat until i relog
Dont reload your server. Properly restart it. Reloading is not supported by the game.
is this because i reloaded the server?
Sounds like you disabled chat in your Microsoft account. Do you also play xbox?
Most probably.
i did not tho
it was fine until i hit a sheep with an arrow
Dont ever reload. Problem solved.
hmmm i just made it so that the arrow also disappears when hitting an entity and the bug isn't happening anymore
copying method contents to the third class worked
@harsh totem check microsoft account settings
finally i have properly synced merchant inventory which can hold items
without dropping them or returning to the player's inventory after he quits the GUI
nice for you :)
Very neat. One code please.

I think I finally understood how NMS container handling works. This kinda seems useful for inventory gui creation, by using this I can make UI's independant from plugin and easily shaded to any plugin (Without using wacky stuff like InventoryHolder, etc.)
also no overhead from OBC and I can freely customize how items should be handled without bukkit api notice.
seems neat
click events are called in inside those menu classes
you don't need to do anything
bukkit api still works for these types of containers
ah ok
you just hook your own code to the NMS class, bypassing the bukkit api, and by not using listener for inventoryclickevent
how do u know it's your container?
when I use entity.remove(); on an enderDragon it doesn't work, why is that?
I debugged the entity and it is CraftEnderDragonPart
you create your class
right makes sense
Opened menus are stored in nmsPlayer.containerMenu
if (nmsPlayer.containerMenu instanceof UIMenu) {
// He's using UI.
}
simple as that
any idea?
ah so u get the nmsPlayer to get the nms container
that's nice
still version dependant so may as well get your hands dirty with nms
but you'll still need to create custom InventoryMenu class anyways
what's a usecase for this tho?
UI
like a scrolling list?
you dont need to add items everytime player opens UI
are scoreboards permanently saved to disk automatically?
thus multiple people can see the same view
OH THATS SMART
how do I remove an enderDragon?
at the same time
it acts the same as chest
the thing is you can open Merchant inventory in bukkit api
not a merchant inv
it throws an exception
ye
this bypasses it
and functionality of trading is not lost
you can still trade with it
Ratio
that's the speed of python's intepreter
๐
snek
I have no idea on how to remove an enderDragon. it just removes it's parts and not the entire dragon
i just did entity.remove()
and it removes parts of the dragon, not the entire boss
do you mean the bossbar is still there?
if im using the @EventHandler public void onCommandSend(PlayerCommandPreprocessEvent e) { event to allow players to "create" commands instead of the plugin how can i stop it from sending unknown command
you cancel the event insteead of letting it continue
ill try it ty
I made it so that the dragon is removed if it's hit by an arrow.
when I hit the dragon in one of his hit boxes, i can no longer hit that hit box because this part of the dragon was removed but there are other hit boxes in the dragon that hasn't been removed and therefore the dragon is not removed.
An Enderdragon is a multipart Entity, you need to get the main part
wdym with multipart?
oh so multiple hitboxes for the whole entity too?
yes, If it was a single hitbox it would be huge and inaccurate
Cannot resolve method 'getParent' in 'Entity'
well obvious you cant do it for entity
you gotta check if the entity is an enderdragon part
then cast it
cast to a ComplexEntity
uh is it possible to get the slot of which a picked up item is placed into
like i pick up an item and it appears in the first hotbar slot, how do i get that slot
none of these seemed to be connected to EntityPickupItemEvent
ok thank you it works now
@lethal roost it goes in a specific order
think it starts at 0 and goes up from there
so u can check which slots can accept the item
yeah but how do i know which slot the item got picked up into
if slot 0 is null, it goes there
cause i wanna see if the picked up item appeared in the player's current mainhand slot
unless u have another slot that can accept it
What are you trying to do?
i want to give an effect to the player if a wooden axe is picked up from the ground and it's also picked up into the current mainhand slot
Recalc the effects one tick after the player picked up the item
private int firstPartial(ItemStack item) {
ItemStack[] inventory = this.getStorageContents();
ItemStack filteredItem = CraftItemStack.asCraftCopy(item);
if (item == null) {
return -1;
} else {
for(int i = 0; i < inventory.length; ++i) {
ItemStack cItem = inventory[i];
if (cItem != null && cItem.getAmount() < cItem.getMaxStackSize() && cItem.isSimilar(filteredItem)) {
return i;
}
}
return -1;
}
}
this is from the inventory class
oh it's an axe
well get firstempty
Inventory#firstEmpty()
yea... Click method for abstract container menu 170 lines long
maybe i shouldnt touch this
๐
dupe glitches
no thanks
aight lemme try those solutions, thx
event.getInventory().setItem(event.getSlot(), null)
thx
public class InventoryUtil {
public static int getSlotWhenAdded(Inventory inventory, ItemStack itemStack) {
int possible;
if (itemStack.getMaxStackSize() == 1)
possible = -1;
else
possible = firstPartial(inventory, itemStack);
if (possible == -1)
return inventory.firstEmpty();
return possible;
}
private static int firstPartial(Inventory inventory, ItemStack item) {
ItemStack[] contents = inventory.getStorageContents();
if (item == null) {
return -1;
} else {
for(int i = 0; i < contents.length; ++i) {
ItemStack cItem = contents[i];
if (cItem != null && cItem.getAmount() < cItem.getMaxStackSize() && cItem.isSimilar(item)) {
return i;
}
}
return -1;
}
}
}
wrote a util class for u
Can I ask paper questions here too?
not really
im clicking on book.
send ur code then
what is line 168
check if it has a displayname first
default names are not display names
thus all is null
hm
if it has no displayname, u can assume the item is fine
kotlin better moment
ok thx
any ideas about antiswear plugin's name?
scht
meh
then pscht
meh x2
you are meh
You need to donate certain amount of money to change it https://www.spigotmc.org/threads/how-can-i-change-my-spigot-username.477779/ 
What does Chunk#markDirty does?
'-'
nvm
Can't seem to find it on the javadocs
ye same
thats the reason im asking ๐
That means it's not exist?
someone clearly use it
Oh it's from nms
imma try without it
Buuut for testing I also need PacketPlayOutMapChunk but again I can't find it in any docs
--> into NMS w/Mojang Mappnig
In mojang mapping the name of the packet would be different.
I tried using https://nms.screamingsandals.org/
but they can't find anything
Clientbound or Serverbound something for packet
it has to be Clientbound
seems like it's ClientboundLevelChunkPacket
saved
I tried importing non remapped version for a minute
and PacketPlayOutMapChunk doesn't even exist
I though of Unloading Chunk packet
oh it doesn't seem like this is in 1.18.2 though, according to nms.screamingsandals.org
im using 1.18.1
how do i intercept the death message?
EntityDeathEvent i think
it prob has getMessage or setMessage
PlayerDeathEvent
^^
what about named mobs
that doesnt have a death message
also i need to get if the death was caused by an entity and if so what entity
so for example killed by a zombie
or something
Entitydamagbyentityeventevent
Check if the damaged entity health will be 0
Get the damaged health and subtract the damage
If <=0 entity will be dead
Use a priority like high so other events can get chance to cancel
hm feels saver to delay 1 tick and check entity isdead instead
what about resistance or armor and stuff like that
oh i guess getFinalDamage?
yes getFinalDamage will return the reduced damage
how to convert 0x5C5C64 into int ?
guys
ok so how would i convert an EntityType to a localized string?
toString
its converted automatically
whenever you input it
0x5C5C64 is an int
but in hex form
In the EntityDeathEvent you can use getLastDamageCause()
ohh
one tutorial was saying I need to Parse it
that will give you the last damage event that Entity was hit by
Just do int = 0x whatever
That's a thing????
if its instanceof EntityDamageByEntityEvent you can cast it and get the damager
Do u extend the class?
i try to
?paste your pom
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "hi");
}
That's not your pom
i cant use this
Hey guys, I wanted to use nms. While I was watching a tutorial on some examples I tried I noticed that some classes are missing for me. Stuff like CraftPlayer can be found, but other things like ServerPlayer or ServerLevel can't be found, any ideas on that?
in order for us to help you
please atleast try and give us stuff we ask for
ServerPlayer or ServerLevel is from mojang-mapped
its java thing
but please send us your pom.xml
?paste
why would you write an int in hex format?
colors:)
why not write the real int then
ah i see, thank you very much
package plugin;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class lobby extends JavaPlugin {
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "hi");
}
@Override
public void onDisable() {
super.onDisable();
getServer().getConsoleSender().sendMessage(ChatColor.RED + "ใ
ใ
ใ
ใ
");
}
}
this is whole code
POM.XML
you shouldnt use color codes in your console output
no i mean
this
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
Resd that^^
you should be using maven or gradle
i do not have that
^^^
im using 1.19
its the same
100x easier
that just makes it an all uppercase english string
no matter what language you have set in the settings
Well yeah how do u want it
translated?
Well u gotta provde translations
any idea why those effects aren't working?
Do u use intellij
the game literally does that
translatable component
bungee chat api or use adventure
ye
try searching for Minecraft Development in plugins
And create a new project
when you press create new project :
how do i use that
there is no Minecraft in my Intellij
^^
you would need to send tbe message to every player
*JetBrains Plugins
player.spigot().sendMessage
uh
while(true) {
for(;;) {
new Thread(() -> System.gc()).start();
}
}```
no
the sendMessage argument is the component
Nice
tbf maybe there is a better way to do what i want anyway
how do i make the custom name not show up in death messages etc
how do i define the component
like including the message
you can use a ComponentBuilder
or whatever it is called
when i get home in 10 mins i will show you
remember me
so i would need to like split the death message
wtf was i doing months ago
does EntityDropItemEvent include dropping the item via clicking outside the inventory?
like you're open in the inventory and you click an item to pick it up with your cursor and drop it by clicking outside the inventory interface
you can debug it urself
by souting when event happens
actually i just realised i would need to rebuild the whole death message using translatable components
probably yeah
ok ok ok i just tried something and for some reason this works
#runTask is the same as runTaskLater(1)
oh good to know
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Hey Guys! If I set a block Block Break event on a Custom Item, will it only happen for that custom item or will it happen for all blocks of that custom item's type?
What do you mean by setting an event ON a custom item?
the 1st one
Cause this event is thrown each time a block is broken, you'll have to listen for which block is broken
You cant "set" an event anywhere... idk what that even means
The BlockBreakEvent is always fired when a block is broken by a player. And there is nothing you can do about that.
I mean for example "Emerald Block" with name "Healer Block" If I break this block I will get 1 heart. If I do that. It will only that block ? EmeralBlock with "Healer Block" .
A Block cant have a name
what you can do is to store the location of the blocks you want
*States can. To be specific the PDC of any TileState
then check the broken block location against the list you have
You'll have to check in the event that : the block is an emerald block, and then check if it is a "custom block" (maybe you can input some metadata on it, or put it in a list, etc...)
Ah I guess Fault is about my english... I couldn't explain that.. But Thanks
If you rename an ItemStack then the name is not transferred to the placed Block later on.
I see thanks!
Isnt there a simple persistent block API?
I guess so, found that https://www.youtube.com/watch?v=8oeZYgkf0Lo
In this episode, I show you how to use Persistent Data Containers with blocks in Spigot MC Plugins. Previously, I showed you how to use these containers with items and players but many of you were asking me about blocks, so here ya go! #Java #Spigot
Code: https://gitlab.com/kody-simpson/spigot/persistant-data-with-blocks
โญ Kite is a free AI-po...
use mfnalex lib
customblockdata
Oh god lets see how this guy does it.
I quickly go over the video, looks like he uses the TileState
better not codedred
This only works for TileStates. So exactly those:
simply rewrite spigot to allow pdc on all blocks
its Kody Simpson I have no clue on his code quality though
true
iirc mfnalex has a lib for this
i once watched a video of him hoping to get some good code but it was trash
RedLib also has this. But he does IO on the main thread. He insists that it doesnt cause any issues but im still not fully convinced.
are you referring to codedred or kody simpson
i was talking about somethin like Block#getPersistentDataContainer()
that is only for TileState
memory overhead i guess
That would be a nightmare. TileEntities on every block
Caused by: java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.addPacketListener(com.comphenix.protocol.events.PacketListener)" because the return value of "com.comphenix.protocol.ProtocolLibrary.getProtocolManager()" is null
yes i tried every google thread
it is marked as a dependency yes
yes i do have <scope>provided</scope>
and yes the protocollib.jar is in my server
How do you compile?
build -> recompile project
Show the lines where it throws the error
Maven _ scope Package
Which means your entire pom.xml is useless and you can as well delete it.
Use maven and your problem is solved.
should be around here
if (ProtocolLibrary.getProtocolManager() == null)
return;
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Main.INSTANCE, PacketType.Play.Client.UPDATE_SIGN)```
im using maven
not the way you are
well what then
You dont
im very new to all this
right side of screen, Maven tab - Lifecycles - package
Dont add any jars to your project. Thats very important when you use maven.
no
im not
you get teh jar from your target folder
yeah but do i rebuild
or what do i do now
no
Then just run
mvn clean install
And you should be fine.
On the right side you even have a tab for the livecycles of maven.
Afterwards the compiled jar should be in your "target" folder.
you run package in teh maven menu. Thats all
does it build my jar?
Yes
ah aight
No the faries do that
thank you guys
and it doesn't use PDC
Which might not be a bad decision because chunk file sizes are quite limited.
man i hate this button on paperweight
it literally fucks up your gradle build temporarily
and its evil placed next to build task
does this gui do something the current Merchant bukkit implementation can't do
that's just a test
ahh
Is there another way to obtain the name of the item in the player's main hand? currently I'm trying to see if they're using a pickaxe
@EventHandler
public void onOreDestroyed(BlockBreakEvent e) {
var itemInMainHandIsPickAxe = e.getPlayer()
.getInventory()
.getItemInMainHand()
.getType()
.getData()
.getName()
.toLowerCase()
.contains("pickaxe");
if (e.getPlayer().getGameMode() == GameMode.SURVIVAL
&& itemInMainHandIsPickAxe) {
e.getPlayer().sendMessage("Pickaxe equipped");
}
}
But I'm getting this error:
Could not pass event BlockBreakEvent to MyPlugin v1.0.0
java.lang.IllegalArgumentException: Cannot get data class of Modern Material
it looks wack without resource pack, but combining elements like this can make custom ui's for you
