#help-development
1 messages ยท Page 301 of 1
is it better to name my variables
player, p
inventory, i
entity, e
long term or short term
nono
like
Player (player or p)
okok
thx
if u want to make ur own life easier in the long term. indeed use the full word
Can you cancel opening of an inventory or is it client-sided?
The player inventory is client sided
if I want to "cancel" opening I close it 1 tick after?
The server doesn't know when it's open
I know when
hello somebody have this plugin ?
I have an event where it detects if the entity clicked was a villager
if it clicked a villager I close it
If you're not talking about the player inventory you can just cancel the interact event
hmm
let me try
it worked
This one is a recommendation, I am making a villager view inventory plugin, should I make tht you can remove the items inside a villager inv or notยฟ
look at the screen silly!
Great idea!
Is there any way to get the item that a player is offhanding from a
PlayerSwapHandItemsEvent event
player.getInventory().getItemInOffHand()
@idle loom ?
Wouldn't that get the item after the event is done, I'm trying to stop certain items from being offhanded at all
Hi i had make npc can be damage by this guide
https://www.spigotmc.org/threads/custom-entityplayer-class-with-skins-that-take-damage.437594/
but i want this npc can move and attack nearest player can someone help or share the guide please
try and see
Alright
Okay, I've figured out my issue now
The event doesn't fire when someone does it in a GUI
I have it cancel the inventory click event for the GUI, but you can still offhand items
Despite the inventory click event still firing
And also the event still fires if the person's offhand slot is empty, so the solution above doesn't apply here
I need to stop an item from an inventory from being offhanded
I'd use something along the lines of this: https://paste.md-5.net/nizisuwode.java
Instantiate this class once when your plugin loads and then reuse it, to avoid having to iterate all recipes in order to find furnace-type entries and generating the map over and over again.
Hey, I need some help. Ill just say that Im really new to this and I will probably ask dumb questions
I want to make a plugin that makes it so on death you drop only lets say 50% of your inventory
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
e.getDrops()
}
hi, i want, when a commande is runed with an external plugin, change player amount in ping ( - 1) its possible with spigot api?
I got this far :')
i hope this image is correct, but you should loop over those slots
Okay...
and then calling player.getInventory().clear(slotNumber)
does clear make the items drop or does it delete them?
I dont want to delete them, I want half to drop, half to just get kept in the inventory
Can you do that?
ye
just call getItem() with the slot, remove item and drop it
For some reason the PlayerSwapHandItemsEvent doesn't seem to fire while in GUIs, or at least in my case.
Players are able to take items out of the GUI by offhanding it
Is there a different offhand event?
how to fix ?
[13:49:08 ERROR]: Could not load 'plugins/BlockCubeFly.jar' in folder 'plugins': uses the space-character (0x20) in its name
You can't have spaced in the command name, I assume
you used a space somewhere where a space should not have been used
o its works
a list is like
- 1
- 2
i believe
๐งโ๐ง
InventoryClickEvent would be my guess
I tried that, for some reason it still duplicates into the offhand
Even in survival
can you somehow randomize that number? the slotnumber for the inventory
@tardy delta
use a Random yes
Duplicates?
toArray(Integer[]::new);
Yeah, I'll press F and it puts it into my off hand but never leaves the inventory
primitives in generics when
int[] arr = list.toArray(new int[0]);?
when ever it says "cannot resolve symbol" I should just alt shift enter it right?
And the offhand event never fires, as if it never happened
But the item is very real
Maybe it's the way I'm doing it, lemme test something
new int[0] should work
declaration: package: org.bukkit.event.inventory, enum: ClickType
i believe the internal impl just creates a new array cuz that one is too small
anyways impls are always weird
Looks like it's part of the InventoryClickEvent like I said
If it doesn't work you need to show your code
?paste
The event is completely canceled, so I'm not sure how that would make a difference
and you registered the listener?
also make sure you're in survival mode
didnt i cast the pre-existing list to array?
Probably won't work in creative
Yep, I'm testing, hold on
why are you doing an integer list to an array?
oh wait
i did .getIntegerList on the yml
does that even retrieve data
since it is in array format
so im browsing through NMS and there were some mentions of com.mojang items, and when i do control + P in intellij, it brings me to a decompiled .class file, is there any way i can modify the source code of those class files and will that be included when i recompile the server jar from buildtools
.get on the yml?
yaml doesn't care if it's a:
- list
- like
- this
or
[list, like, this]
It has to do with the fact that yaml is a superset of json
Which means valid json is valid yaml
Yep, my testing returned the exact same result
It just duplicates into the offhand
hmm
I'll test it in a bit
It might be the inventory lib I'm using
I'm using triumph to format the GUI stuff, but I'm using normal listeners to stop it from being taken
.
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
Fork time
I did, that's why I thought that might be the issue
It was not
e.getDrops().remove()
uhmm... So this works for items right? If I add NewItemStack.Material all that
Can I make it remove an inventory slot rather then the item stack or is that just not possible?
I get this yaml error every server restart. https://pastes.dev/UxMmEqqC9N Can anyone figure why
people keep saying contribute any time i mention files other than main nms but i find those links confusing as to which ones to click and how to set it up. that one to README.md literally talks about BuildTools, which is missing all the special files i want to change :/
its my plugin causing it
lol
Do you have a config.yml within your resources?
yes
The second link, the guide, covers everything you need
my plugin auto updates the config when a new version is available. this is the config
For some reason it always adds MemorySection[path='language', root='YamlConfiguration'] which breaks the plugin
And i have no idea where that MemorySection comes from
How are you updating it
very well hidden
thank you
lmfao
is there a way to tell the player he uses wrong arguments while tab complete ?
is brigadier spigot api ?
oh god
is brigadier that stuff that uses .then() and whatever for command constructing?
hm ok well thats what i didnt want to touch xD lets try to figure it out and maybe create PR
yes
brrr
well i created something just like that but easier and raw .... but the tab complete api is kinda bad
what the hell is that
looking at the comments, something what alex made
?stash
imagine not typing that in your browser
It's faster
String value = main.getConfig().get(node).toString(); is the line causing your issue @naive bolt
How on earth someone thought that that wouldn't go wrong is beyond me
yesen't
Spigot uses brigadier for it's commands
but doesn't let the plugin use it directly
which is just bullshit
and probably changing it to allow api use it will break versions :/
yes
Why keep backwards compatibility to stuff like beta is beyond me
or whenever the first version was made
Might as well make mods then
Breaking changes should happen once in a while
like announced a week before or something
๐
so like modding
They should be announced a year before, not a week
what? you'd rather be stuck with the same spigot API for however long spigot lives for
would be sooooo nice to have a breaking update again ... there are so many things that need to be implemented to handle cutom stuff
With pre-release APIs being given out in advance
Additions are generally never breaking
Rewrites are
and I want at least one chonk update
where they just rewrite the shit that is the api
or at least improve it
there are a lot of things that a stuck with enums and thats why they cant be used for custom stuff... for example Environment or Biomes
Yeah, and a rewrite should have a warning multiple months prior to it's release
(ex tabComplete method returning things like TabCompletionElement which also has tooltips and stuff)
that would be nice
And a beta API release multiple months prior too
Which is the main thing why I don't like the material refractor. I have 0 clue what it looks like and 0 chances to adapt to it correctly before it hits production
Oh god.
tbh I just want a command refactor, even a tiny one
Some things never change, like noone having an idea that that refractor is on the horizon and will hit prod in a few years
I did know
Forgor
pog
ofc
tab completion is actually pretty good
it's just missing some things
like tooltips
I mean the thing with command handling in bukkit is that it is really the minimum complexity one can afford for such a system
Is it possible to programmatically get a list of all Event classes?
probably
Why?
you can
it's not that hard, surprisingly
I mean
it is hard if you do it through the bukkit api
I'm trying to register listeners based on the events specified in a config.yml and I'm struggling to devise a way of doing so without mapping all of the possible events to strings that might appear in my config.
You can do that?
yes
ever wondered what that registerEvent method did
on the plugin manager
that has like 5 params
That's a really inefficient thing to do though surely, 'PlayerMoveEvent' must fire thousands of times a second, for instance.
and you always think it's a typo
Nah, I know that
you can use it to listen to all events
I just thought it accepted a Class<? extends Event> too
you can also do some fancy code
Class.forname
do some checks
and make those specific listeners
then use a lil clever class to get the player (for example) present in those events
that just does some checks
like
instanceOf PlayerEvent -> PlayerEvent#getPlayer
etc
Oh yeah, then that is what I had in mind
However you'll have a hard time enumerating absolutely all event classes unless you know a piece of wizardy I suspect could be possible
Hmm.
you don't need to enumerate
config#getString -> Class#forName -> registerEvent
lil reflection with some caching
gets a Class<?> from a class name
example: Class.forName("org.bukkit.Bukkit");
Returns a Class<?>
You can then use it to do stuff like
getMethod, getDeclaredMethod, getConstructor etc
The event names are reasonably short and logical so I don't think I need to abbreviate.
Getting all classes loaded by plugins and spigot is easy enough. But anonymous classes loaded via the sun Unsafe are harder to trace
You need fully qualified names
I.e. with the package
Yeah but they're all org.bukkit.event prefixes so that'll be easy to substitute in.
Issue would be collision handling and so forth if you drop the package, but I guess one could use the package in that rare case
Ah well if you just want to listen for bukkit events, then yeah
Yeah, sorry, I didn't specify did I?
just make people pass in the bukkit name
if you're making something that "modular" then your target audience must be technical already
Well plugins can define events too, which to me was only logical that you want to listen to them too, but apparently not
Well it's not something I'd considered.
You severely underestimate the stupidity of the average user
+1
If the user has to read anything, it's too hard
95% of my support requests can be solved by reading
I spend more than half my dev time coding to make stuff break cleanly when the user messes up.
Yeah
Well thanks for the pointers, I'll see if I can figure it out from the info given.
Sorry ImI, I'm struggling to make the leap from getting the event class with forname, to registering a listener to it, any chance of an example?
pass in the Class.forName(config value) as first param ig
if im understanding your question correctly
Oh, so I should be registering my own event, rather than registering a listener to the existing events..
That's registering a listener
Ahh, I see...
My brother gave this code and he said to make plugin from this code
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class AntiCheat implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
// Check if the player has moved more than 5 blocks in a single tick
if (event.getFrom().distance(event.getTo()) > 5) {
// If so, cancel the event and kick the player
event.setCancelled(true);
event.getPlayer().kickPlayer("Cheating is not allowed!");
}
}
}
this is code
That won't work well
Lol this seems like the worst anti cheat ever just use something like grim
In which case, what would I put as the argument for the @EventHandler method in the listener?
Oh he is trolling
public void PlayerJoined(DynamicEvent e) {}
Use the method FourteenBrush sent
instead of annotated method
Any possible way to set multiple values in spigot api Config?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
help me pls
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Also be quiet If you aren't going to ask a question dude
so i need to make loop for set()? bruh
Yeah that's one way to do it
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Hire someone
So is there other way to do it
๐
Whats the best way of handling checks per level? So I need to check if player has x amount of essence, and to also set essence requirements for 500 levels...
But then under what method does my listener logic go?
you see that you have to pass in a listener
Yup
I could use like level * x for the requirements tbf
actually never used that method, ig you put to put your event handling method in there
dunno actually
ig it assumes that you will write a listener for that event class ๐ค
Time for ASM 
Hmm.
Listener listener = new Listener() {
@EventHandler
void onJoin(PlayerJoinEvent event) {
event.setJoinMessage("boo");
}
};
Bukkit.getPluginManager().registerEvent(PlayerJoinEvent.class, listener, EventPriority.WHATEVER, (listener0, event) -> {
if (event instanceof PlayerJoinEvent myEvent) {
listener.onJoin(myEvent);
}
});```
like wtf is an eventexecutor
I need some advice off someone. I'm using one inventoryclickevent method and it's starting to get quite large... Should I make another one in a different class or?
ah maybe listener::onJoin
Split things up in to methods
like handling all guis in one listener?
work with a Map<Integer, Consumer<InventoryClickEvent>> for handling input per inv
basically defines how to execute the event from the listener
by default it uses an event executor which reflects @EventHandler annotated methods yk
would event -> listener.onJoin((PlayerJoinEvent) event) work?
weird syntax
Never seen this done before??
actually (listener, event)
And yeah i've split a lot of my code into methods but still gets big with all the if statements etc
Then it's split enough
Perhaps I can use an annotated listener and use generic Event as the input, then figure what to do with it from there.
I'll test that and see if it works.
@tardy delta that map you use, the "InventoryGUI" when you put the class inside the map does it refer to any inventories inside the class or? Like how does it work?
InventoryGUI is just an inventory wrapper
Ah, so I need to use the Event Executor to handle the event.
Yeah so it's just an inventory creation inside the class
and it holds functional interfaces that gets triggered when clicking on buttons
I wonder what the point of the Listener is in this case, when we're passing in the event handling logic manually anyway.
Holy moly, it worked.
Many, many thanks for the help
๐
is there a way to pull updated data from yml files from inside of a bukkit runnable
my list aint updating
@tardy delta Any thoughts on what the Listener instance might be for? I've just created an empty GenericListener class with no methods to pass in and it seems to work just fine.
yeah just use getters
like those methods?
Methods like these
ye i remember now thx
uh show code
?img whatever
Not verified? Upload screenshots here: https://prnt.sc/
?pastebin
?paste
Yeah, it seems entirely redundant because the only method override in the listener would be the EventHandler, which would be the same logic as the EventExecutor is currently performing.
Hi, I'm having some troubles using CorpseRebornAPI (a corpse plugin), basically there is a CorpseSpawnEvent, I need to get the entity that handles the corpse, and in the Corpse object you have a .getEntityId() method, I've made a .getEntityFromId() method but it didn't work. After some testes and debugs I've found that the problem was the id itself, for example the .getEntityId() method gave me 277, tho id of the entity was 279
@last bolt isnt it supposed to work like this?
I've looked the src but the object doesn't have an entity field, so I can't use reflections
the entity that handles the corpse?
is there a way to break out of nested forloop but not the method containing it?
break?
Hmm, I'll have a fiddle.
I mean, the entity which the corpse refers to (CorpseReborn uses cows to spawn a corpse)
that thing breaks out of the method
show code
im pretty sure
me?
no
๐
its stupid code
ik
idk anyway to change it
and that thing sits in a method
with like 6 other nested forloops
When Brush said "break?", they meant the keyword break
what triggers me is that youre calling get three time on a list, remember list lookup can be slow asf
That's the keyword you're looking for lol
You want to break only 1 loop?
damn lol
that looks like an exercice theyll ask me at the java exam in two days
you cant ๐
ye
wdym i cant
break does just one loop
hmmmm
How can i get the gui to update automatically instead of having to close it and reopen for the level change?
The lore
change the item
It updates but I have to go in and out of inventory
setItem with the new item
I don't seem to have access to the listener methods (onJoin in your example) when I do this.
it doesnt know which one to break
i dont even see a loop
oh couldve expected that
its just a nested if inside a method idk
you can always create a class instead of an anonymous one ๐
just make a method
sec
try making a method that accept an event param and then instead of 'listener' in the registerEvent thing you give it, this::myMethod
no clue actually, dont have an ide
Lol, I'll give it a try.
Weird setting the item isn't updating for me
feels like c#
what about removing it and setting it back?
setItem only seems to do smth for updating the quantity
ah okay ill try removing
I'm creating a redis-sql system so that I can communicate and sync data across servers better. Since redis has pub-sub, I'm using channels to send "packets" which are byte arrays across servers as well as using the redis to store cached data.
I just need ideas for how the packet system is gonna work
This is what I currently have
?
Still nothing
dunno if Player#updateInv does anything
hang on i had error
Isnt there an update inventory method
@quaint mantle what's the problem?
very useful
You dont need to updateInventory
just get the itemstack, modify it and then set it to the slot
thats what i said
what should i replace it with?
depends on what you need?
its baso a config updater to just update the config to newer versions
?paste
do you have nested items?
Just using this in a method to remove and set, all paths are correct, no errors https://paste.md-5.net/anadocijix.cs
no
well ye
search for the lang.yml
got an enum with all the paths so not really actually, just iterating over all paths
ah yea, I want to update everything including comments yk
if i use this will it set the players max hp to 1 heart Player#getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(2);
im very confused how my plugin.yml is incorrect, https://paste.md-5.net/simomonadi.sql, with it looking like https://paste.md-5.net/esofehowov.http
looks like it
you have all of the required stuff
yeah thats the part im confused about
is the version parsing
yeah
checked that
okay im more confused
ive just re-built the plugin even after building multiple times and now it work
what the
maybe you got a bad output the first time
How to program an anti-ban listener
I asked you last time...why?
?
Why do you need an anti ban listener
So that I can not be banned. First what is this question second why do you ask questions just help me
Because it sounds almost maliscious
Top help
it is, they're helping you at not being a bozo
can I somehow extend the time a player takes to connect and login by blocking the netty channel?
why?
thinking blob
i don't want players to login before their profile is loaded (the profile is queried from a db)
block the async login event
so can I just put Thread.sleep in there?
also is AsyncPlayerPreLoginEvent the correct event?
Does anyone have any ideas how I can change the height at xz coordinate in the world using a ChunkGenerator, I want to keep the vanilla generation just change the height at which it goes to based on a 2d array that I have with height data
What is the best way to have 10-15 maps, in a spigot server. Im making a prison server and have a world for each rank, how should I be running these maps in the server.
Im not hosting for many people, should I try combining all maps into one world?
having 10-15 different worlds is just a cause for lag
put them all in 1 world and just spread them apart a thousand blocks or so
yes thats what I was thinking lmao but to put all these weird big spaces into one world
im gonna have to block them from walking out lmao
plus world management is tricky I worked on a minigame a while ago where I was loading in and out different maps from folders and there is a lot of tricky stuff
use mv and fawe
put barriers around the area you dont want them to go
i still have a world for hub/plot/pvp combined and 3 worlds for survival
fast async world corruption
you would need to load each one and then world edit select it into the combined world
use worldguard and make regions they cant leave
facts new versions of fawe are super unstable
waht the hel isthis
fawe = fast async world exception/corruption
so i would have few worlds, 1 for hub/plot/pvp combined, 1 for rank maps, 3 for survival. But they r gonna be running all the time so i dont wanna use mv + it just does some stuff about spawns i dont want it to
what it do lmfao
And then there's awe... worse than fawe, paid and breaks worldedit license
they have a free version
https://www.spigotmc.org/resources/fastasyncworldedit.13932/ this is what im talking about
that is identical to the paid version
so should i use this version of world edit. Save parts of maps into schematics and paste all into one world
what version are you on?
If im gonna copy pretty large spaces should i be using fastasync
1.19.2
The spawns issue you are referring to can be avoided by editing the config
i know above 1.17 fawe gets very iffy... make backups
oh aight i have backups so its fine
is it better for large spaces then
to use fawe
unless its over like 500k blocks you dont need fawe
ok it might be
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
you can use normal worldedit on single player
but i only know of a fabric version
would it be over 500k blocks
if your copying them client side you might have issues
most servers can get up to like 750k blocks
maybe sometimes a million
Guys, I'm new to the subject and I wanted help on how I download a plug in and how I get it to run
this is for developing plugins and making them, #help-server would prob be better,
how can i check if a ProxiedPlayer is already connecting to a server?
isnt a proxied player a player that would have to be connected
nah
events like PostLoginEvent can return a ProxiedPlayer even if they haven't been connected to a proxied server yet
can i store this in a config file?
getData is probaby null
Because VanishData is a custom made thing
getData returns a FileConfiguration which is working in another parts of code
idk how you get an npe on a null check
make it implement config serializable then you can store it
?stash
look at bukkit
maybe i don't know the correct usage of yaml files
lemme explain what i'm doin
I'm storing player inventory in a yml file, and then i restore it to him
it gives me the null error in here:
show the config
in which time
and a note
when player has at least 1 item in hes inventory
this error does not happen
the one you get an npe on
but when he do not have any item, and i store & restore it this happen
like this? if (Utils.getData().isSet(player.getName() + ".inventory")) return;
and ofc a !
yeah
thanks, lemme test
ah yeah mine defo doesnt work
did you implement config serializeable
you would need a serialize and deserialize method
serialize to config, de returns the vanish data
and what would they do
if i have a ```yml
location:
==: org.bukkit.Location
world: world
x: -10.047613860387923
y: 80.50737205198925
z: -38.78100253597351
pitch: 11.169121
yaw: 72.890205
getLocation
hey, if i have two plugins which both shade the exact same dependency, will that cause any problems if i don't relocate them?
it can
k thanks
How do i use colors in console?
getLogger().info(ChatColor.GREEN +"[Staff-Spectate] Plugin Version: "+pluginVersion +" has been enabled!"); doesnt appear to work
actually colored console ugly
console colour ugly
- dont
- See 1.
if i put something in a map and the key already exists would it overwrite the value there before what im putting
Yes
It also returns the value that was there previously
so if i were to add something to a string location map then get the key it would return 2 locations?
unless it's a multimap
No
It removes the previous entry
Puts the new one
ah, perfect
And returns the previous entry
What does the strikethrough mean
maybe deprecated ?
It is. Use AsyncPlayerChatEvent instead
why tf doesn't gson allow serialization of anonymous classes
Okay, i created 2 plugins, and they work fine, BUT, when i start the server with them together, it says: "org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!"
But they individually work fine
they have the same name
no
Full error and full code
look at the name in plugin.yml check if they are the same
of both plugins?
Well the error first
This ^
@tall citrus Now bpth plugin.yml
How can i safe change names?
?main
You using IJ?
yes
Itโs called refactoring
So useful
ye ik ty
It is if you read it
i've got a bit of a strange question. When people make thier plugins how do you check it on so many server versions to ensure it works
do you just change the server jar loads of times
if it doesnt have nms they test it on the lowest version
if it works there
it works on higher
Depends
how would one change the output directory of a JAR and then run a .command file using maven
You test on all version you intend to support
aka put into plugins folder and start mc server
You using IJ?
yep
thats so much effort tho innit
Donโt do it through maven and just do it through a run profile
Only initially.
The .command can also move the jar @hard ether
what about every update tho
You test on every update, or you are a bad dev
I just leave it till someone tells me itโs not working
๐คฃ
Usually we will be able to know what versions to support based on our api usage etc
oh
like
lemme look up commands
and jsut use a run comfig?
Yeah
Not really
Go up to top right
Next to the start thing
Click the dropdown
And create new
they dont have embed perms
oh lol
u need to link ur acc to spigot for that
What's the best way to send an HTTP request asynchronously using spigot? Completeablefuture or bukkit runnable?
why would you need spigot for that
Just wondering if there's an advantage to using spigot's built-in runnables
it doesn't use maven at all?
completeable futures imo
Help! GetServer not working in Plugin messaging channels!
You can make it run maven
the fact that my username is now my 8-11 year old username ๐ญ
hi
hi
yo
?paste the erroor
Is spawn a valid world?
yes
i in the world with the chest and the config save with the world name
but when try load give me error
Yes, fix your plugin load order
Or just do shit only when absolutely needed
i.e. as late as possible
sure
i put dependecy of multiverse and solved
๐
now a big problem xD, the config save x,y,z,world
this is on file
-3,63,-25,spawn:
this is game
-2.569,63,-24.518
@Override
public void onDisable() {
// Save the chest and task information to a file
File file = new File(getDataFolder(), "data.yml");
YamlConfiguration config = new YamlConfiguration();
for (Map.Entry<Chest, Integer> entry : chestTaskIds.entrySet()) {
Chest chest = entry.getKey();
int taskId = entry.getValue();
String id = chest.getX() + "," + chest.getY() + "," + chest.getZ() + "," + chest.getWorld().getName();
config.set(id + ".taskId", taskId);
}
try {
config.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
so I have a terminal file named start.command
the contents of said file is
Mv ~Desktop/Unexpected Development/Minecraft/Player Management/target/PlayerManagement-1.0-SNAPSHOT.jar ~Desktop/MC Server/plugins/PlayerManager.jar && java -jar spigot-1.19.2.jar
I get this error when trying to run it
me@2019-iMac-2 ~ % /Users/me/Desktop/start.command ; exit;
/Users/me/Desktop/start.command: line 1: {rtf1ansiansicpg1252cocoartf2639: command not found
/Users/me/Desktop/start.command: line 2: syntax error near unexpected token `}'
/Users/me/Desktop/start.command: line 2: `\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}'```
if I need an hashmap with multiple keys correlated to a single value and the multiple keys have to be of different types, can I just have a map like <Object, MyValue> instead of making 2 different maps?
you say instead taskId and chest create only a 1 map?
what do you mean by incorrectly
^
i don't really get how are chests supposed to have decimals in their coordinates
they are blocks
proper way to make bukkit runnable timer?``` Bukkit.getScheduler().runTaskTimer(instance, new BukkitRunnable() {
private int time = 1;
public void run() {
if (time == pluginManager.getTimer()) {
player.teleport(pluginManager.getSpawnLocation());
messageManager.sendMessage(player, "spawn.success");
cancel();
}
messageManager.sendMessage(player, "spawn.time", String.valueOf(time));
time++;
}
}, 20, 20);```
and also don't save locations like that, use config.setLocation
that spacing ๐ญ
return; after cancel() probably
but ye
the spacing is ๐
also yes add a return
the entire method executes even after you call cancel
setlocation not exists
i have a small font ;p
private int time = 1;
public void run() {
if (time == pluginManager.getTimer()) {
player.teleport(pluginManager.getSpawnLocation());
messageManager.sendMessage(player, "spawn.success");
cancel();
}
messageManager.sendMessage(player, "spawn.time", String.valueOf(time));
time++;
}
}, 20, 20);```
more readable
๐ฅบ
ah yea right, just use set and put the location as the second argument
then use getLocation to get the location
How would I get a specific item stack in a recipe and cancel it if it contains that specifc itemstack
i wanna make sure no one uses my custom items in a recipe
wdym cancel it
like remove the recipie?
or stop the player from crafting it
Whats the difference between <BookMeta>.setTitle() and <BookMeta>.setDisplayName()
yes, and send a message and close inventry
stop player
ok
uh
ItemStack bannedItem = null;
@EventHandler
public void onCraft(CraftItemEvent e) {
ItemStack item = e.getRecipe().getResult();
if (Bukkit.getRecipesFor(item).contains(bannedItem)) {
e.setCancelled(true);
e.getInventory().getViewers().get(0).closeInventory();
}
}```
should work
then you have to send them a message
will this work even with my custom item?
i wanna make sure no one crafts with my economy moneys
oh
it should be the Consumer<BukkitTask> one
I believe one sets the title of the book and the other sets the name that it appears as
ItemStack bannedItem = getterForCustomItem();
@EventHandler
public void onCraft(PrepareItemCraftEvent e) {
for (ItemStack item : e.getInventory()) {
if (item.equals(bannedItem)) {
Player p = (Player) e.getInventory().getViewers().get(0);
p.closeInventory();
p.sendMessage(ChatColor.RED + "You can't do that!");
}
}
}```
thats not my code
this should work btq
btw
replace getterForCustomItem() with the method to fetch your custom item.
thx
yes
it loops in the craft inv checks if it is the banned items closes the inv and sends msg
to get the PrepareItemCraftEvent
yea
used this comment of a thread
I believe there is an event called PrepareItemCraftEvent or the like. You can use that to check the recipe and put your own item in the resultant item slot.
I've set up a plugin message listener class so I can get the server the player is currently in.
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
if (!channel.equals("BungeeCord")) return;
ByteArrayDataInput input = ByteStreams.newDataInput(message);
String subchannel = input.readUTF();
if (subchannel.equals("GetServer")) {
serverName = input.readUTF();
}
}
public static String getServer(Player player) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("GetServer");
player.sendPluginMessage(GameManagerPlugin.getInstance(), "BungeeCord", output.toByteArray());
return serverName;
}
This is so I can use getServer in if statements, if (getServer(p).equals("lobby")) {// do something}
I ran this in a command, but weirdly enough, 1st time the command runs, serverName is null, then the 2nd time it's the actual server name. What the hell is going on?? Please help
You're returning serverName in your getServer() method but those plugin messages aren't instant. They're sending packets. They're going to take a while
So the first time you run it you send the packet but return what the value is currently (in this case, null), but the next time it returns what the message finally received a few ms later from the message listener
Basically your second call is returning the result of the message received from the first call
With that being said, the only possible way you're ever going to be able to call getServer(Player) is if the player is online... because that's an online player. So they're going to be on whatever server you call that method on ๐
Can anyone help fix this
?paste it, i cant open or read files on phone
Looks like an issue from running fabric +bukkit, also probably has something to do with skript uses spigot not bukkit so uses no existent methods to bukkit
looks like an NMS issue lolz
Yes, it could also be version mismatch
how do me & spending get spigot for the combat test snapshots to work, because the closest thing we can find is Bukkit4Fabric
I have an issue where people can offhand items from a GUI
I have the inventory click event canceled in the GUI but they still can offhand it
The weird thing is, the item remains in the GUI but still ends up in the offhand, also the PlayerSwapHandsEvent or whatever isn't being fired while in the GUI
I'm using Triumph to format the GUI btw
I doubt spigot made versions for that and if they did you will probably have to look at commit history or prs and see of anythings been made
?stash
spigot doesn't do those you'd need to fork the server and make your own
We didn't
i'm trying to fork spigot.jar, is there any way to re-compile after decompile?
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
so I can find a recompiler there?
What are you trying to do
i'm trying to automatically add a list of plugins to the plugins folder
and i figured I could do that via the jar
Or ya know your start script
lmao didnt even think of that
What's the NMS version string for 1.19.3? Is it the same as 1.19.2?
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
Cannot resolve org.spigotmc
1.19.3-R0.1-SNAPSHOT
Works for 1.19.2 though
Did your run buildtools for 1.19.3
NOO!!!
WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
GameProfile gameProfile = null;```
The first two imports work, but the gameProfile is not importable and is missing. I'm clueless on NMS
are you on 1.18.1 or higher
Yea
also isnt it called player profile
what you need the game profile for
an EntityPlayer
isnt that just HumanEntity
That's the spigot class I believe
Nope this is from net minecraft server
you shouldn't need to use GameProfile anymore
Bukkit has the PlayerProfile api
Oh ok thx
is the spigot jar opensource
?stash
what are you looking for .class files for
you want those files
just make patches if you want to modify NMS
a .class file is a compiled java class
i forget how to build spigot tbh
why thouhg
as md5 said up here this should give you a guide
thats what spigot, craftbukkit, bukkit do
they all work together to give you the spigot.jar and an api
Looks like playerprofiles and gameprofiles are different
My NMS is missing the gameprofile import
what do you need the game profile to do
use NPC, HumanEntity?
declaration: package: org.bukkit.entity, interface: NPC
you could probably even use entity
also citizens api is probably easier
I have to spawn an entityplayer
what does this entity player need to do
To spawn
I can't use it, this is the solution I'm looking for
Yea that's my entire problem, I can't import GameProfile like I stated above
you use player profile
There's a difference
this is how i do playerprofile or game profile
because you are on a higher version that 1.18.1 i doubt it exists
look at how i use player profile
just look at the jds for the rest of the fields
Found the import I was looking for if anyone else finds this
import com.mojang.authlib.GameProfile;
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>```
```<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>provided</scope>
</dependency>```
I'm getting an error message stating: org.bukkit.plugin.InvalidDescriptionException: libraries are of wrong type
I ran my plugins.yml through a yaml validator and nothing came up. I even tried the example provided on the wiki and didn't work as well. Is this a bug or am I missing something?
?paste plugin.yml
is org.apache.commons:commons-math3:3.6.1 on maven central
yes
paste the full error
yea I tried the example from the wiki and that didn't even work
Should I report this as a bug?
?jira yeah
fun ComponentBuilder.hoverText(text: String): ComponentBuilder {
val hoverText = ComponentBuilder(text).create()
val hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)
return this.event(hoverEvent)
}
```*(This is a kotlin extension function, allowing me to call `<ComponentBuilder>.hoverText("text here")`)*
How I am doing this in my plugin says that this HoverEvent constructor is deprecated, what proper/alternative/not deprecated way should I be doing it?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
On that page, they also seem be using the deprecated constructor
this is what they have:```java
TextComponent message = new TextComponent("Click me");
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org"));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Visit the Spigot website!").create()));
No, I'm building against org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT
i can use the java code here perfectly fine
its not deprecated
oh wait it is
use it anyway
deprecation means nothing pretty much
it doesnt stop you from using or doing anything
I'm using PacketWrapper & ProtocolLib to attempt to spawn an EntityPlayer
Whenever I try using the SpawnEntityLiving packet, it shoots this error out
Caused by: java.lang.IllegalArgumentException: Could not find packet for type SPAWN_ENTITY_LIVING
Am I using the wrong packet? Is it outdated?
im pretty sure it will be something like PacketType.Play.Server.SPAWN_ENTITY_LIVING
Yea that's what I'm using
* @deprecated Removed in 1.19
*/
@Deprecated
public static final PacketType SPAWN_ENTITY_LIVING = new PacketType(PROTOCOL, SENDER, 244, "SpawnEntityLiving", "SPacketSpawnMob");```
Look like it was removed, should I use SpawnEntity instead?
if your on 1.19 then yes
Will it work for living entities
That's why I was asking, it's a packet related to mc, not protocol in general
could always check the protocol docs
