#help-development
1 messages · Page 50 of 1
same, I don't know how to use annotations all like that yet
although you can override the save and load default methods to add additional data
I can skip the interface directly
also, same lol.
An easier way to do this would be to serialize the class to a json object and then convert all the fields into database params
but who wants fancy stuff that gets updated when you can make your ghetto version of it
Sounds nice tho how do you deal with integration tests? Or well if you have any
I feel like json is the serialization gateway to anything
Integration tests are not unit tests
But yeah Ig unit tests can be a bit too much sometimes
and then see if my game or server crashes
and by crucial data I mean stuff like world and chunk data 👍
Hmm I presume that could work, fair
if things crash, we fix
or another way to do this is to just copypaste this system (it's self-contained, doesn't depend on bukkit or anything) into another project
make like 5 sample classes
Yeah tho that sounds like mere unit testing
then serialize and deserialize
example
MyObject object = new MyObject(1, "two", true);
Map<String, Object> map = StorageUtils.save(object);
MyObject deserialized = StorageUtils.load(map);
assert object.equals(deserialized);
I mean this will fail for transient data
but rest is fine
I even make ghetto unit testing
and maybe I might toss a
String query = new DynamicTable("data").getWriteQuery(map);
obviously I'd cache the table
just to add: "assert" doesn't do anything, usually
assert in normal code is useless
it only does stuff when you tell java to enable assertions, which are normally disabled
Hello, I would like to know what format to put in mysql. I would like to get all the items with this line [Lorg.bukkit.inventory.ItemStack;@7a80ba30 in a setContents please ?
whut
that's just some generic toString() thing
do you want to store an itemstack in a database?
I dont really understand your question
yes
ah okay. you can turn an itemstack to base64 or similar to store it
one sec
this turns an ItemStack into a base64 string that you can store
then just do fromBase64(...) to turn it into an itemstack again
Ok, Thank you
Does anyone know how to remove the annoying mongodb logs in console? I've been trying to for a while to no avail
crazy frog
for the punch punch guys
so yeah the old dev failed to do his job
figures 
why so :((
DM, i wanna know what type of back end pls
oh well, I've been drunk for the last 3 days or so lol
and haven't eaten anything
so yeah
sounds like you're a developer
that will change soon though
How does hypixel have this second line above the players head?
armorstands
invisible armorstand above head
Would they add the armor stand as a passenger?
no
technically they can but it wouldn't allow for much flexibility
so what do they do instead?
summon an armorstand and move it equally to the player
I wonder if there's a way to do it with packets so there's no 50ms offset
There is no delay when the player moves
listen to player move packet and send armor stand move packet, that gives no delay
yeah that
Is there any plugin Reduces spawn mop the mops respawning too much that make lag in the server!
I swear if I see one more stupid "is there any plugin that ..." question in this channel
what are you going to do
I'm gonna die ok
go after your kneecaps
that as well
yeah that was what I was thinking
It seems you do it so much that you even ask about it to me
Quick question: I have a custom item plugin, when a player uses a give command, it gives an item stack with an ID in the nbt and lore, name, attributes of that custom item. Now I want to add stack instance specific data, for example, a player can modify the name color per item, or upgrade something about the item.
I first thought of extending ItemStack, but like this isn't Forge lol (This doesn't work because minecraft doesn't know how to deal with it and makes it a normal itemStack again)
Do I really have to keep track of every CustomItemStack instance in every inventory, or is there a better way?
PDC?
I've used it in Fabric, didn't know I could use that in spigot ok
Wait
I literally forgor about this
lmfao im so dumb
ok
thanks mate
No worries
btw, do persistentDataContainer entries show in the nbt idk
or can you remove nbt with packets?
I don't want the users to be able to extract data from the PDC
except the visible part of course
Is there a reason https://repo.codemc.io/repository/maven-snapshots/org/spigotmc/spigot-api/1.19.2-R0.1-SNAPSHOT/maven-metadata.xml isn't working?
Maven is having a spaz attack trying to download from it and I cant connect
ffs it just worked, nvm
after 10 minutes
can sombody help me here
don't ask to ask, just ask your question with full detail
?paste
is that what you need?
can i message you it
what cant you show?
You need to be verified to send images
just verify yourself
also, are you sure you are using the correct channel? You asked for help in #help-server as well..
how do i verify
yay
idk there was
check help-server
!verify
Usage: !verify <forums username>
is the command
check #help-server
I am spawning in a packet entity. When I move away from it it does not unload. However when I spawn in a normal entity and move away from it after a certain distance it is unloaded. Do I need to explicitly despawn the packet entity to remove it from the client or does the client handle it by itself?
can somebody help me
I thought that the client doesn't save entity data, so when the chunk gets unloaded the entity just dissapears and the server would have to tell the client again there is an entity there
but from my experiences right now that doesnt seem to be the case
How can I get all the files inside a folder inside my plugin that hasn't been created yet?
like in my resources folder
you're asking how to get files from a folder that hasnt been created yet?
so how to get files from this folder?
or resources/x
the thing is, they are getting a specific file
I need to get the folder and list the files
What exactly do you mean by reading a folder?
trying it now
is there possible way to copy one class to multiple directories in IntelliJ?
File[] files;
InputStream inputStream = getClass().getResourceAsStream("/translations");
if (inputStream != null) {
try (OutputStream outputStream = new FileOutputStream(files)) {
IOUtils.copy(inputStream, outputStream);
} catch (Exception e) {
throw new RuntimeException(e);
return;
}```
I got this
however
whats the way with file output stream with folders?
private void init(){
ItemStack item;
item = createItem(" ", Material.BLACK_STAINED_GLASS_PANE, null);
// item ui setter
for(int i = 0; i < 27; i++){
//info
if(i == 8 || i == 26){
switch (i){
case 8: {
List<String> lore = new ArrayList<>();
lore.add("§7 Click on the offers to §a§lBuy");
lore.add("§7 from the Trader.");
item = createItem("§b§l Make a selection", Material.BOOK, lore);
inv.setItem(i, item);
}
case 26: {
List<String> lore = new ArrayList<>();
lore.add("§7 Click on the offers to §c§lSell");
lore.add("§7 to the Trader.");
item = createItem("§b§l Make a selection", Material.BOOK, lore);
inv.setItem(i, item);
}
}
}
// items to trade
else if (i == 2 || i == 4 || i == 6 || i == 20 || i == 22 || i == 24){
List<String> lore = new ArrayList<>();
lore.add("§7 Click on the offers to §c§lSell");
lore.add("§7 to the Trader.");
item = createItem("§b§l Make a selection", Material.BOOK, lore);
inv.setItem(i, item);
}
// pane decoration
else {
inv.setItem(i, item);
}
}
}
no errors just wondering if this is coded efficiently
please use ?paste
What coding language do you need to know in order to code plugins?
Is it JavaScript
Java
Ok
or Kotlin
Okay I’m thinking of learning one I already know python
who tf is making plugins in kotlin?
public static File getFileFromURL(String folder) {
URL url = ResourceFolder.class.getClassLoader().getResource(folder);
File file = null;
try {
if (url != null) {
file = new File(url.toURI());
}
} catch (URISyntaxException e) {
file = new File(url.getPath());
}
return file;
}```
well coulnt be me either
I got this code, but it keeps giving java.lang.IllegalArgumentException: URI is not hierarchical
ffs I'll just manually input the files
too much bother
what exactly are you trying to do?
get a list of resources to extract from your jar?
how does ClientboundTeleportEntityPacket work? the constructor only takes Entity
it was bad tbh
have you tried setPos on the entity, then pass it to the packet?
I'd guess its to update teh client of the entities position
does protocollib have a skill issue?
SERVER_DATA is supossed to have 2 booleans
but plib thinks its only one
skill issue lol
there should be one for enforce secure profile and one for previews chat
is this for your popup canceller?
i tried to recreate it in plib and couldnt find out how
idk if its just not updated or what
my kod
protocolManager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL,
PacketType.Play.Server.SERVER_DATA) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() ==
PacketType.Play.Server.SERVER_DATA) {
PacketContainer packet = event.getPacket();
packet.getBooleans().modify(1, aBoolean -> true);
}
}
});
and error ima send in a min
btw im on latest 5.0 build
looks like spigot doesnt like setPos for ServerPlayer
index of the boolean?
this kod
or maybe via being dumb
could be a byte possibly??
b is the connection iirc
hello 🙂 Some questions regarding PlayerInteractEntityEvent & ItemFrames
- Is it the correct event to track when some player add or remove item from itemframe
- In the event handler body, after verifying that the event.getRightClicked() is indeed instanceof ItemFrame, and casting it to ItemFrame, and then retrieving the item with itemframe.getItem(), this item will be the one BEFORE the player interaction, correct? If I want to get the state of the itemframe (with the updated item) i have to schedule a bukkit runnable to run next tick, and execute itemframe.getItem() once again, am i correct?
Since it's an npc it doesn't have one
could i somehow do it before via?
i can teleport it wherever beforehand
Override the methods where it tries to use the connection
Why do CB packages include a version number?
🤷♂️ Someone decided to do that
It was like that for the regular nms package too in older versions
yeah, but nowadays those seem to be under mojang mappings too
For fake players (ServerPlayer) you have to add yoru own connection handler so you don;t attempt to send packets
as there is no client
do i need to set that with reflection
then add to yoru constructor this.connection = new NetworkHandler(minecraftServer, new NetworkManager(PacketFlow.CLIENTBOUND), this);
public class NetworkHandler extends ServerGamePacketListenerImpl {
public NetworkHandler(MinecraftServer minecraftserver, Connection networkmanager, ServerPlayer entityplayer) {
super(minecraftserver, networkmanager, entityplayer);
}
@Override
public void send(Packet<?> packet) {
// Empty as we never want to try an send packets to a fake player.
}
}``````java
public class NetworkManager extends Connection {
public NetworkManager(PacketFlow enumprotocoldirection) {
super(enumprotocoldirection);
}
}```
The packet ClientboundSetEntityMotionPacket has xa, ya, za integers in it. I assume this is where the entity is moving to but these are integers. Is there any way to turn these values into doubles to get an accurate idea of where the entity is moving to?
Nevermind, found out it is velocity not location
I believe it represents velocity * 4000
Why do you want to compare the name
I hope you're not planning on using that to detect your inventory
shit you right..
you can just compare inventories using .equals
I recommend comparing inventories by their InventoryHolder or even better the inventory instance
i could just take the inventory and compare them
ignore the entire name thing
Anyone know how to remove mongodb console logging?
i assume you have to set the level
Logger.getLogger("com.mongodb.driver").setLevel(Level.OFF)
Also a small research on google tells that
There are some questions that can be found on stackoverflow with small research
pretty sure mongo logger is funky with spigot
most of the stuff on google doesnt work
Thanks for the reply, unfortunately that snippet doesn't work. I only asked here cuz spigot + mongo never works out
Oh yeah I agree that
Im using mongo with spigot and i have data loading errores
For example all data works perfects during first sever starting and on second it doesnt
Note to self to never use reflections again. This shit gives me headaches
Hi, how am i supposed to get deep in bungeecord?
keep diggin?
Let's suppose i have this
section:
test1:
- value1
- value2
test2:
- value1
- value2
i need to get that values under keys
nested values?
iirrc, getNested?
what's getnested?
or its getConfigurationSection, lemme look at docs rq
i need to do a task that automatically adds the values into a list
that's why i'm asking, i can't do like on spigot using getKeys(true)
I need help with making a plugin dm me
why md5 didn't put the same methods as spigot on bungee, just why, anyway, any solution?
I made a PR to bungee to addjava public Map<String, Object> getSection() { return Collections.unmodifiableMap( self ); }But it was rejected
at least you got the format down
i see, do you have any ideas for my issue?
all you can do is getSection(String path)
I myself use a modified bungee config code to implement my own method
f everytime i need to do that
i just wanted to make a task that every X seconds picks those values and adds them into a list
The only easy way is use getKeys and iterate it
as it returns return new LinkedHashSet<>( self.keySet() );
show me an example if you can and want
i'm thinking something meanwhile, i hate bungee config
I can;t at the mo, too busy RL
no problem
or just mod Configuration.java as I did
can't, the plugin isn't for me
yes you can
you literally import 4 classes from Bungee
include them in yoru code and thats it
ah i tought you wanted to make me mod bungee itself
can you dm me
are gamerules universal or do they only apply to a single world?
I'll totally accept this deal
@quaint mantle I'll accept 500
I mean
if you pay beforehand
this is sooo much money
nah first finish and show me the finishing product and then I'll pay
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/
I cant open it says and error
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Thats not really an excuse though
@ivory sleet You haven't read their extremely detailled error message
obiouvlsy they said it has "error"
Mustve missed sth then, goes w/o saying looked like it turned into a topic that doesnt belong here
what the hell is this
wich ide are you using
Going insane rn
do mixins work in spigot? or any way to modify nms?
no spigot does not support mixins
any way to modify nms then?
beyond reflection ?
Bukkit's goal is to try and prevent you from doing that by providing API
What are you aiming to achieve here?
a lot..
There are projects to load Mixins on your server
ignition or smth
Ignite
Yeah, I mean you can make use of Mixins if you want, they're just... not really supported
You're inevitably going to break something
i think this looks crazy but can we make a plugin that can play cutscene in resource pack file to player? like make player see mp4 file inside game without mod?
You can use maps to play video
ohhhh
Do you have tutorial
is it ok to make a fork of spigot ? and if it is, do i need to set some kind of license or anything?
GPL for bukkit and LGPL for craftbukkit
I'd especially advise against forking spigot as the toolchain was not meant to be used as a fork
ok
Plus bukkit's API is pretty good for many things, but if you want to do some things such as adding blocks I wouldn't even recommend daring to attempt it in the first place
||Custom Models is always a option just saying||
tf
Lmfao
nope, it's GPL
there's no LGPL
there was a mistake in the commit name, but the LICENSE.txt was GPLv3
Yes, de-facto it is GPL given that it depends on a GPL license, but I was sure that it was LGPL...
Lemme check
?stash
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/LGPL.txt exists, so you can say that cb is licensed under both licenses. Though GPL overrides the LGPL
what is the sound for when a block is being broken? like this
the BLOCK_STONE_BREAK sound is the sound of it broken
wait it might be BLOCK_STONE_HIT
nah it sounds like someone is walking lmfao
SPAM HIT Stone Sound
How do I get hints such as the vanilla /time command? I tried using commodore to leverage the brigadier command parser and dispatcher, but couldn't get the hints to show on my paper server (both 1.19 and 1.19.2), I've asked in their discord, but looks like there might be an already open issue on the problem, so I'm looking for alternatives. In the screenshot I'm looking to get the <time> to show, but without it being in the tab to complete options.
Yeah Commodore or using Brigadier directly is how you do it
Fuck you too ❤️
tru luv
I'll have a go at using Brigadier directly ig
Hello, I have a question.
If I don't remove many registered event listeners, will they remain in handler list and cause a memory leak?
yeah it was because i spammed it too fast
i slowed it by 7 ticks and now it sounds good
is is possible to make mobs AI follow another entity?
you should not worry about that
Could you explain the reason?
how is this null :/
because it is not something you should do, handling events and listeners is spigot's (bukkit's) job and just let it do its job
still, you can remove your listeners if you want to but you don't have to, they get deleted after restart anyways
the method returned null
your listeners also gets removed when your plugin is disabled
alright, how do i get when an item is destroyed by fire/lava?
because entitydamagedevent wont cut it
because there is a way of triggering the entitydamagedevent with an item and not have the item get destroyed
when compiling my mojang mapped nms pluggin using SpecialSource I dont get the -remapped.jar (i get the 3 other jars tho). If i look at the output of running package I see that specialsource tried making it
[INFO] Replacing .../target/plugin-1.0-SNAPSHOT.jar with .../target/plugin-1.0-SNAPSHOT-remapped.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------```(btw there are no more errors after that and the `.../target/plugin-1.0-SNAPSHOT-remapped.jar` simply does not exist)
how can i make it so specific items cannot burn in lava or be destroyed?
That means the registered listeners are not removed periodically but removed when the server disabled?
I'm in a position to choose between two options
- Register event listeners in every new instance. This code will be simple.
- Register listeners once and pass event to the every new instance. But code becomes complex.
I'm making a minigame framework plugin.
So if new minigame is created then must be removed. And it needs event handlers.
- you can do some checks in your event listener about the game status and etc
- you can remove and register the event listener
it is up to you but I would go with the option 1 since it is simple and second way may get you in trouble with your code
dont implement a new listener for each minigame objects pls
^
as in an itemstack or item entity?
-
If item entity, just use Entity#setInvulnerable
-
If itemstack, on an EntitySpawnEvent, check if that entity is your item, and set that entity to invulnerable
tf this doesnt give me any errors but it prints out null
does it make any difference that it is a transient variable?
yes hes a girl
uh, anyone?
If listeners remains and can make low performance, it looks need listener management code.
So in every minigame, one listener looks better to me.
Thank you for your help.
Forgot what i say
Do you think I am sexy 🥵
No
where's the outdated build tools pin?
is it possible to add methods to existing spigot classes? its kinda hard to explain but my plugin is made in 1.15 but i want to support 1.12+, but im using .getLocation which was added in 1.15, so when i try to use the plugin in 1.12 it gives an error saying .getLocation doesnt exist, so i want to know if theres a way i could extend a class and make my own getLocation method?
no
kotlin has extensions
in java, no
and in kotlin it is only syntactic sugar anyway
ah thats anoying is there any other way around this?
where does .getLocation() not exist
im talking about the file configuration one
oh, I wrote my own Location parser
easiest way to do this is to depend on the 1.12 api
when i do that i get an error saying config.getLocation doesnt exist
how can i set the state of a wheat seed?
make your own loaction parser
like if it is full grown etc
then id need to redo all of my getLocation code though no?
Location <-> String
instead of get location, you get the string and convert it to a Location
yeah but with that id need to redo all of my code involving setting and getting locations though
"redo all my code" as in changing .getLocation to parseLocation(.getString())
yeah
so umm i deleted my project file accidentaly, brought it back from github but since it is now a new project, i am not able to publish the project changes i just made on the same github repository as the old project, cause the repository already exists. how can i upload my changes to github now, to the same repository?
id be copy pasting stuff for hours
bruh
do you have visual studio?
visual studio code
uhh no?
you are looking for a solution that involves not changing anything then
well sort of i was thinking there was a way to override or modify the method
cause you could copy all the code into vscode, and click ctrl+f and get an option to replace all "text" with "newtext"
this is also an easy way
do you at least have notepad++
intellij
you could ctrlf it
well yea thats the problem
which one isnt deprecated? lol
intellij doesnt allow replacing using ctrl+f
Use Reflections lel /j
also you could change your fileconfiguration implementation
ctrl r srry
ctrl+r
bump
THAT ExISTS?
alright ill try it thanks
thanks, and brandominos too
how do you not know how to replace text and you have a big plugin
idk, also it doesnt work for me
who me?
yes
idk i dont rly pay attention to ide controls and stuff
big plugin != good plugin
if its not good you give up earlier
since its a mess to mantain
totally agree, i have a 400 line code yet the plugin is still a piece of shit 😄
i cant seem to find a way to change the stage of a seed crop
1 class in my plugin has 2k lines :p
what u be doin
how many classes does your plugin have
like 20
bruh.
minigame creator plugin
i do
no you dont
i do
you got a 2k line file
thats 1 file and its for the main library
meh
This is my plugin and I've only been working on it for a lil
https://github.com/Meturum/Centro
just counted them and its 28 classes
nothing close to yall 2k lines
2k is just too much
started this plugin like 1 1/2 years ago on and off so some it could be reduced
do you have copy pasted code?
wdym
same code in 2 different places
no not rly
(same as in basically the same)
so umm i deleted my project file accidentaly, brought it back from github but since it is now a new project, i am not able to publish the project changes i just made on the same github repository as the old project, cause the repository already exists. how can i upload my changes to github now, to the same repository?
check the block type
block.getType() == Material.WHEAT iirc
yeah it works
ty
org.bukkit.block.data.Ageable ag = (Ageable) blockData;
ag.setAge(1);
``` why doesnt this code work? it doesnt have errors but it just doesnt change the age of it
block.setBlockData(ag); according to docs.
No worries, you'll get it.
since Crops is deprecated, what else do i use?
Crops crop = (Crops) e.getBlock().getState();
if(crop.getState().equals(CropState.RIPE)) {
}
ageable
ah thanls
the solution to this was setting the itemstack amount to 0 to force it to despawn
why not just make it invulnerable?
i dont see how that solves my problem
"not have the item get destroyed"
oh read the rest of the pretense above that lol
the issue was that it wasnt getting destroyed
essentially if you:
- put a block over a hopper minecart
- throw item at block
- just before it gets sucked up, set it on fire
this triggers the EntityDamagedEvent and has a chance of the item not getting destroyed due to getting picked up
solution was to set the itemstack to 0 after the check to force it to no longer exist
how do you register a gui in the main class?
Depends on what you mean by register
like its in a seperate class how do i make it work
seems like a hacky method, you should probs look into a more stable way.
Sounds like you have lacking Java knowledge. I highly recommend learning Java before starting with spigot
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Such as Item.remove()
does any1 know a resource for "scrollable" inventories?
otherwise i will have to make one
Does anyone know why the worldfile isn't deleting? It's worldfile.delete() which is not working
I'm guessing the server may still be accessing it?
but which part
I've already unloaded the world
what should I choose here to compile the plugin into projectfolder -> target -> ?
It should be deleting the world folder. Also does the function return true or false?
returns false
hence why I think it's the issue
unloadWorld returned true
I printed this before
got that
oops didn't show the full thing
there was another print of b1 at the end
basically false is the result of delete()
SecurityManager.checkDelete() log this before you delete the world
ok thx
it just checks if you're allowed to delete the file
How do I know what's stopping it from being deleted?
if that is the issue
it's depracated
but I'll try anyway
doesn't that just make it save?
what world are you trying to unload?
from what I read, its required to save it before deleting.
I see
one sec
ide opening
private void deleteWorld(String worldName) {
World world = Bukkit.getWorld(worldName);
File worldFile = world.getWorldFolder();
if (Bukkit.unloadWorld(world, true)) {
new BukkitRunnable() {
int maxAttempts = 50;
@Override
public void run() {
try {
FileUtils.deleteDirectory(worldFile);
maxAttempts = 0;
createWorld();
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage());
maxAttempts--;
}
if (maxAttempts <= 0) {
this.cancel();
}
}
}.runTaskTimerAsynchronously(plugin, 20, 20);
}
}```
got some weird issue lol
this seems to work but when i access the bossbar later on, its null :/
no errors on this code
skillProgressBar?
Is it null when you construct the instance? or just later on?
actually nvm
make sure you're not overriding the field
i added debug code in the constructor but its not triggering lol
Did you make a new instance of the class?
i seem to see this KingdomPlayer constructor every week with a different issue 
i'm makign a new instance when loading the player and currently the loading code works :/
lel
what thats not true 🥵
what’s the purpose of transient there @tardy delta ?
nice debug code doesnt get printed
gson calls the constructor i hope 🥺
actually....
I don’t see any usages
It should say at least 1 usage above your constructor
Right click and press “Find Usages” (on the constructor)
if it’s internal to gson it wouldn’t find then
so gson doesnt give a fuck bout my constructor 🤔
Also, this is kinda nitpick but if iirc doesn’t Bukkit.broadcastMessage() send the message to every player? I’d recommend Bukkit.getConsoleSender().sendMessage()
(It only sends the message to console)
lets try liek this
my old code is hitting me with a knife in my back lol
delayed removal cache smh
ik thats why I said its a nitpick
is there a way to make a loop which will take a value from a database every x seconds and then set a player's level to that value? (bungee) I just need help with the loop part, I need to start the loop when the player joins and stop it when they leave
There might be a better solution to this problem tbh. But you'd just schedule a repeating task using BukkitScheduler.scheduleSyncRepeatingTask
dataPath = plugin.getDataFolder() + File.separator + "data" + File.separator + "playerMenuUtility";
File folder = new File(dataPath);
if(!folder.exists()) folder.mkdirs();
for(PlayerMenuUtility utility : utilities) {
File file = new File(dataPath, utility.getOwnerId() + ".yml");
Utils.createFile(file);
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
config.set("menuMode", utility.getMenuMode().toString());
}
}``` am i need to do something more to write stuff to file? cause my file is empty but it's created
the issue is that I am using bungee, so there is nothing called BukkitScheduler
You need to save your config after changing it
thanks
That requires the scheduler though. Ideally this could occur on shutdown
then do it on startup instead, in onLoad() if Bukkit.getWorlds().isEmpty()
means no worlds have been loaded yet, so you can delete any you want
lets implement a proper database instead of using gson 🥺
.
Bungee has an task scheduler that you can use or you can use Timers
well I cant find the bungee task scheduler
Either way, I’d advise not to implement what you’re asking
well I just want to show a custom value on the player's exp bar which is kept up-to-date
how would you recommend I do it?
just reloading your shit instead of querying it every time3
hmm I guess I could just connect up all the points at which the value can change and just make the level bar change then
That's gross
in other words: i was too lazy to write a db impl
How can I get this name?
isnt there an ItemStack#getLocalizedName or smth?
Probably by getting the brewing stand from the event and reading the inventory
what do i use since event.setCursor is deprecated
whats the screaming sandals nms repo
u need a Location
how would i create a map that worked like Map<Class<? extends Event>, functioToDoWithEvent> mapThing?
So if I did mapThing.put(playerEventClass, getPlayerFunction)
then mapThing.get(playerEventClass) i would get the player from that event back
is it through consumers?
How to setup and use Hikari Pool Connection?
nvm i think i got it, its thru Functions
something like this:
Map<Class<? extends Event>, Function<Event, Player>> test = new HashMap<>();
test.put(PlayerEvent.class, ev -> ((PlayerEvent) ev).getPlayer());
why store under a class? you can only have one instance then
SecurityManager ?!
InventoryView#getTitle()
They might just be the vanilla translation of the inventory
Not a custom title
Which mean they have to include the translation file in their plugin to get the name
server starts up, i want to retrieve all the entities that were loaded for some reason, in what event should i do that?
Does EntitiesLoadEvent covers startup too?
It should yeah
Hello everyone 👋
I have a question about spigot custom events.
What are handlers exactly ? What are they supposed to do ? How can they be useful ?
Do you have a comparison to understand this ?
Thank you ^^'
Do you mean the HandlerList?
anyone listening to the event is in the Handlers list
is there a builtin set containing all the blocks that we can SEE through (not fully opaque), such as glass, cobweb, water, etc
damn really thats making it a lot more easyier for me :d
making custom ray tracing (i don't like the RayTrace classes of bukkit)
Yeah
Alright, so I don't have to use handlerlists, I mean that's useless ?
you just have to provide it in your custom event
Yeah I know, but I was wondering If I could use it to do something
no, its not for you to do anything with
well, you could see every plugin thats listening to your event
Whats wrong?
java version
Hi are you allowed to request plugins lol
?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/
serialize items
ah thank you
just save a list of itemstacks?
Custom Inventory
inventories aren't seriazable
they are basically only an array of itemstacks + a title anyway
so just recreate your inventory
I'm trying to make some methods < 1.18 compatible, would this be a good method to get the max build heigth?
public int getMaxBuildHeight(World w) {
if(w.getEnvironment() == World.Environment.NORMAL) {
return Bukkit.getVersion().contains("1.18") || Bukkit.getVersion().contains("1.19") ? 319 : 255;
}
return 255;
}```
What would the best GUI library be?
I'm pretty happy with Triumph
I'll take a look :)
Use World#getMaxHeight in older versions
"int getMaxHeight()
Gets the maximum height of this world.
If the max height is 100, there are only blocks from y=0 to y=99."
I wanna get the max build heigth, means the last block you can place a block
Yeah it's that
doesn't sound like that
wouldn't that return like 120 if the highest block is at 119?
Then just use - 1 on it?
but i dont wanna get 119
i wanna get the maximum allowed building height
256 or 320 since 1.18
Which is what that method does
-1
Then the method's description is nonsense
^ in the properties file
ahhh now we talking
didn't know that
so since this method is also available in 1.19 I can just always use it I guess
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
for (Player players: Bukkit.getOnlinePlayers()) {
System.out.println(players);
List ents = (players.getNearbyEntities(500,50,500));
for (int i = 0; i <= ents.size(); ++i) {
if (ents.get(i) instanceof ArmorStand) {
System.out.println(ents.get(i));
}
}
}
}
}, 0L, 100L);
}```
any reason why this code would only be printing the result of 1 player in the server (the first person on the list for Bukkit.getOnlinePlayers)
cause even if my friend joins the server, it only prints my name, and the two armor stands i have placed down, and stops there, it doesnt do my friend at all
and if i leave it switches to printing his name and the stands every 5 seconds instead
even if i join back
i also screenshotted my server console if you need that but theres no errors
Few things
to figure out the issue
You don't need the longhand syntax for runnable
also lambdas are a thing
ah okay
Instead of
lambda cring
new Runnable() {
@Override
public void run() {
// Your code here
}
}```
The two are identical in this context
lambda is love
and about the for loops? i still dont know why theyre broken and not printing right
i have code i want to run and stripped it all to figure out why its not iterating through all players
.
It's running every 5 seconds
ik
?jd
i did that to figure out why its not printing all players
Why don't you just do System.out.println(Bukkit.getOnlinePlayers());
Oh wait a second
I know why it's only printing one
You get an exception, don't you?
because i want it to print the first player, list the nearby entities, and then print the next one, etc
redempt brain moment
Oh you are alive, how have you been doing?
Oh no bruh dont use shities index for
your mom started at 0 when she born
Meaning you're trying to access an invalid index at the end of this iteration
sorry but thats the best thing I could come up with
You can also replace the online players for loop with
Bukkit.getOnlinePlayers().forEach(player -> {
getLogger().info(player.getName());
//do more stuff
});```
So your code prints one player, runs into this exception, and exits
No
It prints the player before attempting this loop
But this loop always fails
So it only ever gets one player in before throwing an error
For future reference, if an error is being shown in console you should always include it with your code
It's pretty vital information that would have made debugging this easier
Seeing <= vs < is a pretty minor difference and many people here will only skim the code, not read it that closely
I would have missed it if I didn't read it extra closely
But if you had shown the resulting exception, we'd have all been able to immediately identify where the issue is
well i screenshotted it but i cant add images for some reason :/
i wouldve added it
You can just copy-paste the text
oh yeah thats true
screenshots are cringe
?paste
To post images you have to verify your spigot account
thanks for the help
As in, link it to your discord
Bukkit.getOnlinePlayers().stream().peek(System.out::println).flatMap(p -> p.getNearbyEntities(500, 50, 500).stream()).forEach(System.out::println);```
oh alr thanks
As I haven't touched it in years, are there built in commands to change a server's motd?
Or is it like in some configuration file?
Bruh what the fuck https://i.imgur.com/3h2UlRh.png
server.properties
IIRC you can only set it using NMS
Bukkit and Server have a method "getMotd" but no "setMotd"
so, yes, you need to change it using NMS, there's no other way
There's an event to change what shows when pinged
yeah but it wouldn't actually change the motd
Ye but it exists
well, I mean
of course it would change it, for the player who just "pinged"
which is probably what they are looking for lol
so
yeah
What are you trying to do exactly @iron glade
ServerListPingEvent
hello. i am trying to code a simple /discord command. i am extremely new to this stuff and a lot of times, i have no clue what im doing. everything worked perfectly until i tried to make it configurable. i watched around 2 or 3 tutorials however all of them said different things. what im trying to do is grab text from the config and add it on to a message that im sending to the player. whenever i load into my test server and do /discord, nothing shows up. not even in the console. i am very confused about what i did wrong. if anyone could help me in the right direction, that would be amazing. i can provide my code if needed
.setMotd
How can i make wait a player from right clicking another player, for example i click another player with a stick and i have to wait 10 secondo to re click the player
save the time in milliseconds on first right click, check if it's been 10 seconds if they click again
Ok, thanks
what's the exact problem you have? Please send your current code
just do ?paste
then paste your code there
Just set a simple motd in the server overview
listen to this event @iron glade
aight, will do so, thx
basically what hyperdefined said. I'd suggest to write some tiny Cooldown class that you can reuse whenever you need it
sth like this https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/data/Cooldown.java
why do one get a win error on creating yaml configuration
whut
gimme sec tired
ok 😄
/paste
!pastebin
i forgor
@tender shard how i get the md5 paste
i forgor command
ty!
wtf is java.io.WinNTFileSystem error
sorry i just came back after so long to code
i had similer problem before
Is there a way to report sth without going through JIRA?
I'm lazy as fuck
Well if anyone wants, i think that Material.BARRIER.isOccluding() should return False (it's a block & we can see through) and that Material.GLASS.isTransparent() should return true (light can go through)
How can i open an inventory, then the player puts some items in it and on close it gets saved. After the close a message get send with all the items so like "1: Grass Block, 2: Stone 3....". Do you guys have any idea how that could work?
Is it possible to use persistentDataContainer on a player?
or another way of saving data on a player without the use of external databases
ik it might be screwed tf up but im a beginner and i only understand a little bit
the message in that code is not sending at all and im not getting anything in the console
OH a player
message link
https://paste.gg/p/anonymous/fd55a673906a43d3bbd9cce0e6639587 how can I see where this error is being caused from?
I can send the wild code if needed too.
Huh
Oh, wait, I may be dumb
One second
Yep, I just forgot Teleport teleUtil = new Teleport(this); :P
Fair enough, I'll do that, thank you!
Abusing static methods make you looks a bit unexperienced also
We are not swearing you, just given recommendations that you learnt from experience
sorry for late reply, I was busy
did you already get it fixed?
its perfectly fine. i did not. ive been at it all day haha
what exactly is the problem?
any error messages in console?
btw why are you using a list for the discord command?
I assume that you only have one discord link, right?
and not like 20
i wanted to make it configurable to release. i have a youtube command, twitter, youtube, and im gonna add more. i just wanted to make it configurable to give to other people.
there is absolutely nothing
you did register the command, did you? please show both your plugin.yml file and your main class
?paste
https://paste.md-5.net/bozajipami.java theres the main
https://paste.md-5.net/abazategum.makefile and the plugin.yml
i went off of a youtube tutorial so it might be a little odd
okay, looks good. You are on 1.19.1+ right? Because IIRC they added a weird thing in 1.19 that basically suppresses stacktraces
im on 1.19
try to wrap your whole onCommand method into a try/catch block
Dumb why did they do that
like this:
public boolean onCommand(....) {
try {
doYourStuffHere();
} catch (Throwable t) {
t.printStackTrace();
}
}
idk
but it's really like that
you now have to manually try/catch all your onCommand stuff
otherwise it simply ignores any exceptions
if you do this, we hopefully get a proper error message
where it says doYourStuffHere, thats where the actual code would go, correct?
exactly
okay ill try that and hopefully ill get something in console
basically everything you already coded goes into "doYourStuffHere()"
alright. ill attempt that
if I have a private class hashmap and a public getter. if I do class.get("bleh").replace("bleh", "blah") will the private change too?
is it the same object
if I have a private var in a class
and a public class.getPrivateVar
it would normally return the exact object
If I change something in the .getPrivateVar() will it change
yes
so if I change it both will be changed?
yes
nice, thanks
nice
np
You can use something called encasuplation for not allowing to modify it
but I want to modify it
i am getting this little error. not sure if its something with my ide or what
I think its something:
Map<Key, Value> bla = new HashMap<>();
public Map<Key, Value> getMap() { return new HashMap<this.map>()} ```
Sorry for saying it but you are you new into programming?
I dont want to sound rude
Just add }
just add "return true;" at the end of your code
and return
i dont mind lmao. im extremely new
the onCommand method WANTS YOU to return a boolean. So yeah, add "return true;" at the end, and then add the missing closing } bracket
if it still doesn't work, show your whole class please
i fixed it
Oh ok, nice to hear that i will say some useful recomendations:
-
Learn about the IDE you are using
-
Is to learn java like correctly (Watching tutorials or reading about it features, etc and by coding project practicising what you have learnt)
-
Start learning about apis and libraries (Database ones, utilities ones, etc)
i will definitely do all of these things. i am not sure if java should be the first language i ever learn because ive been told its one of the hardest. programming is something ive always wanted to do so im gonna actually try my best.
alright so after doing that, im still getting no response in game and nothing in the console.
https://paste.md-5.net/ixulazonic.cpp heres the code
There's a guy who has seemingly taken upon himself to go around asking devs to tag Russian translations of plugins with [terrorist state] on spigot
whut
are you drunk
that is weird
do you get NO RESPONSE AT ALL?
not even the plugin sending it's usage string?
Me?
Who knows maybe Mr Putin really loves elitemobs and upon reading that I tagged the Russian translation would immediately stop the war and see the error in his ways
Not sure if this is the right channel, I lost access to my paid resources? It says I have none but i definitely purchased some
Not really anything we can do; Contact the plugin author, if not, contact the Staff Team
Thank you
Double check that you didnt use another account or email address, I've definitely had 2 accounts for some services before
lol that's uh... that's a creative review
uwu hi mr chocolate
I used to say it all the time
It's not even a review, he decided to post it on my user page
Lol
uwu
idk if my question belongs in here or in #help-server but I posted it in help-server so if anyone could that'd be great
lol
i really dont get the hate on russian people
it's not their fault if the government does shitty things
but yeah probably not the right channel to discuss this haha
I mean I had half a mind to say he was spamming people but it's really just two messages from what I see , the only messages he ever sent as far as i can tell
Just doesn't feel appropriate to bring that to spigot plugins, it's not like the people in Russia can go protest against this or vote Putin out, that's about as good as an idea as asking Chinese users to stand up against their government at this point
And even if they could it's just not the place for politics imo, that has always been my stance
I don't know enough about either side so I'd not comment
when the invasion first happened, people were asking us to block Russian users lol
I was like ??????
Didn't you check Putin's Twitter? He's constantly promoting his spigot server on there
i dont think such a method exists
tbh I think its extremely stupid that spigot continues to allow putin to promote his minecraft server 🤦♂️
what lol
(/s) ^
It's because he made the skyblock variant where when you expand your world border you expand it into another player's island extremely popular, it drives a lot of traffic
Disgusting
horrible
speaking of skyblock. the ONE server I actually liked that the owners ran into the ground, CosmicSky(block)
nope not at all. also sorry for responding so late lmao
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
public class BlockPhysics implements Listener {
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
Bukkit.getConsoleSender().sendMessage(event.getBlock().getType().toString());
if (event.getBlock().getType().equals(Material.SAND) || event.getBlock().getType().equals(Material.GRAVEL) || event.getBlock().getType().toString().contains("CONCRETE_POWDER")) {
event.setCancelled(true);
Bukkit.getConsoleSender().sendMessage("Cancelled a block fall");
Bukkit.getConsoleSender().sendMessage(Boolean.toString(event.isCancelled()));
}
}
}
Gray Concrete Powder falls, sends all proper messages to console but block still falls. Anyone know why?
Am I doing something wrong here? I'm trying to store a list of item stacks, but nothing in the config ever changes.
@Override
public boolean saveChanges(ConfigurationSection groupSection) {
ArrayList<ItemStack> list = Lists.newArrayList(Arrays.stream(this.inventory.getContents()).iterator());
if (Storage.get().isConfigurationSection(groupSection.getCurrentPath())) {
Storage.get().set(groupSection.getCurrentPath() + ".items", list);
Storage.save();
return Storage.reload();
} else {
logger.warning("Group \"" + groupSection.getName() + "\" was not found, unable to save contents");
return false;
}
}
These are my save and reload methods
public static void save() {
try {
storage.save(storageFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean reload() {
storageFile = new File(plugin.getDataFolder(), "storage.yml");
if (storageFile.exists()) {
plugin.saveResource("storage.yml", false);
storage = YamlConfiguration.loadConfiguration(storageFile);
return true;
} else {
logger.warning("Could not reload storage, file was not found");
return false;
}
}
get just returns the FileConfiguration
I need to know when a thread is done to start some other code, how would I achieve this?
this code is never going to execute on teh first run. It will only work when the file already exists, which means saving from resource will do nothing.
if (storageFile.exists()) {
plugin.saveResource("storage.yml", false);```
that's why it's in the reload method lol
it shoudl be if (!storageFile.exists())
teh file will not exist before you create it
File is only a pointer to a location. Ther may be something at that location, or there may not
.exists() will only be true if there is a file or a directory at teh location
no shit
Your code is saying, If there is a file here (be it an actual file or a directory) copy the resource, but don;t overwrite
So nothign gets copied
why the hell am I event running saveResource there
that's not supposed to be there
No clue, thats what I'm saying. it will do nothing
still isn't saving, nice
add some debug to see if you are even calling save
I specify my GUI items like this: java GuiItem guiItem = ItemBuilder.from(Material.STONE).asGuiItem(event -> { event.setCancelled(true); String test_message = main.getConfig().getString("test-message"); player.sendMessage(MiniMessage.miniMessage().deserialize(test_message)); }); How could I add a certain CustomModelData/nbt to it?
Just ask ur question
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player p) {
if(((Player) sender).getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= Integer.parseInt(args[0]) * 2) return false;
if(((Player) sender).getGameMode() == GameMode.SURVIVAL) {
ItemStack heart = new ItemStack(Material.NETHER_STAR);
ItemMeta heartMeta = heart.getItemMeta();
heartMeta.setDisplayName(ChatColor.RED + "Coração");
heart.setItemMeta(heartMeta);
p.getInventory().addItem(heart);
double pHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(Bukkit.getServer().getPlayer(args[1]).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + Integer.parseInt(args[0]) * 2);
}
}
return true;
}
he doesn't realize that ... instanceof Player p gives him a Player variable that he can use xd
@rapid aspen just use p.getGameMode() etc, in place of ((Player) sender)
ok
That's just code, is there a problem with it or why did you send it?