#help-development
1 messages · Page 871 of 1
Yes that’s that the method does
awhat packet is for the tab ui
so i dont need to use protcol lib
What part of it
hold on ill send
ArrayList<Player> pList = new ArrayList<>(Bukkit.getOnlinePlayers());
if (protocolManager != null) {
for (Player p : pList) {
int[] time = StringFuncs.getHMS(Instant.now().getEpochSecond() - Main.uptime);
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
packet.getChatComponents().write(0, WrappedChatComponent.fromText(String.valueOf(ChatColor.LIGHT_PURPLE) + ChatColor.BOLD + "Survival Enhanced"));
packet.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.LIGHT_PURPLE + "Online Players: " + pList.size() + "\nPing: " + p.getPing() + "\nUptime: " + String.format("%02d:%02d:%02d", time[0], time[1], time[2])));
protocolManager.sendServerPacket(p, packet);
}
}
i also wanted to have players show their ingame tag beside them
ok awesome ty
Hey! Is it somehow possible to get EntityType DEFAULT MAX_HEALTH attribute?
I have entities that have been changed max health and I'd like to get their default value.
I could create a Map including all entity types and their health, but that's not createst solution.
Maybe creating a new temporary entity using certain type? Would that affect server performance if it's being done for EVERY spawning entity?
LivingEntity*
Just getting the attribute from the entity should work
It does not.
Or do you need the default one specifically?
Specific entity attribute GENERIC_MAX_HEALTH has been changed so I cannot use that.
So what's the goal here? Why do you need the default max health
The goal is to reset all entities health back to default
Without killing them
Some plugin messed them up
getDefaultValue on Attribute
Oh what....
Really?
I'll try, if it's really so easy sorry for wasting your time...
Works great! THANK YOU!
Oh wait, no, it's not it... It returns entity maximum health, not default health... I think I need t gather default healths and create a map myself.
Default health should be the default max health?
For newly spawned Enderman, this returns 40 (which is default in MC)
monster.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()
This returns 20:
monster.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()
I'll check how much it affects performance. I could initialize map on plugin enable, list all LivingEntity including default health.
Can I make a custom InventoryHolder?
We wouldn't suggest
damn lol
oh, you're real funny but ngl u got me
what InventoryHolder does a chest inventory have?
Also another thing: I successfully used gson to write stuff to json strings. Now I tried using gson to write to a file by doing:
gson.toJson(object, new FileWriter(jsonFile));
Absolutely nothing happens though. No error message, no writing. The string is there (debugger told me that) but it just... doesn't write?
Why are you asking about inventory holders in the first place?
inv holders are a bad approach because getHolder copies the entire inventory if it's a vanilla one
because i had the worry that ppl could exploit chests to manipulate my vault-inventories
since logically, at least for me, chest have the InventoryHolder null?
what does that mean exactly?
Basically if you do a getHolder check and it fails it copies the entire thing which is not good for performance
I have a Listener that is only supposed to execute code on certain inventories. The only thing that is different to a double-chest (at least from my knowledge) is the title (which can be changed) and the holder (maybe). The current InventoryHolder for my vault-inventories is null. So i check:
if (!event.getView().getTitle().startsWith("Vault") && event.getInventory().getHolder() != null) return;
but I'm not sure if this is unique.
That's why I asked if a chest had the IH null
(Ping me on an answer please :) )
People just have a Map<InventoryView, MyCustomGUI> for that
help Im great at naming methods
okayyyyy, uhm, I still don't quite understand how this helps :(
anything that has an inventory vanilla wise, the holder is the thing that holds the inventory
so, no it shouldn't be null for a chest
the only way it could be null for such things is if you have a plugin that is overriding
well I guess that isn't true technically
since a block could get broken while looking at an inventory
and then it would be null after that
heartbeats are a sep thing
need to work on that
I want to get this template system working today
dont think it gon work
gotta make it support proxies n stuff
So if ppl would rename a chest to e.g. Vault #0 change the inventory and then the block is broken, it might manipulate the vault?
stuff like this always humbles the shit out of me, having worked on my (pretty much only java) project for like 5 years or sum, and seeing how I have absolutely no idea what this is about. (Pretty much any network-related stuff in java), haha
It's nothing special just networking
exactly, that's why it's so humbling lmao
try (var bukkitObjectOutputStream = new BukkitObjectOutputStream(stream)) {
bukkitObjectOutputStream.writeObject(itemStack);
}
```Writing
```java
try (var bukkitObjectInputStream = new BukkitObjectInputStream(stream)) {
return (ItemStack) bukkitObjectInputStream.readObject();
} catch (ClassNotFoundException e) {
throw new IOException("Failed to read item stack", e);
}
```Reading
prints `java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null`, are there known issues with saivng item stacks like this?
Check if it’s null
was about to say that
It can return null if you serialize null
oml I forgot about itemstacks being null 😭
why can you retrieve null but not set null
Wait, shouldn't gson take care of null? For me it's writing null to the json, lol
well, you see, that's because.... uhm... yeah
yikes these are some long class names
In json null is the absence of something
Yk I really want to share some stuff we use at work for networking
but I can't
whatever this is meant to be basic
no
renaming the chest doesn't change the holder
title isn't what defines a holder
the instance of the entity or block does
typically the inventory is suppose to close if the chest or something is broken, but there is rare instances where the inventory could stay open. In terms of code the holder would be null, but so would everything else except the inventory itself
you can if you wanted arbitrarily give your vaults holders but typically you only do this if you want to give ownership
well I should say, its an more easier way to define ownership
because the holder of an inventory like a player for example, is always the viewer of their inventories
even when they are closed
I know that, that's why I check the Title AND the holder
i had a problem once when it tried always adding a holder to the inventories, so i'll pass for now.
imma get this to work first
tbh it should work, i tested it. Just couldn't test it with an actual player closing the inventory. only using the console
anyway
well you shouldn't rely on titles
since they can be changed
however it shouldn't be hard to know when its your vault though
just compare the inventory objects
I mean its your vault inventory, its not like you don't know when it is created
I'd recommend you to look at this tutorial. This helps you design a good GUI https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
I looked at this a couple times, and never could get it to work for some reason
idek why
But I fail at using it
you might, but once you understnad what happens there you learned some good design pattern for java
as well as some basic java concepts
its not the only way
they obviously have difficulties with it, so probably best they take a different approach
no tbh i think they should still try it as they could learn many things besides designing gui, like using interfaces
My way is similar but much more complex then that it's a good exemplar
Generally the reason I enjoy that thread is because it teaches you comparison of inventories via equals vs using names
not sure how else you would do it o.O
i'm with you salvation on that one, but i don't really get it. in the end i want to learn "all" of java anyway and trying to understand the inventory-guis is probably a good idea
Most novice devs use titles
just give your inventories UUID's >>
Issue with this is then you have the whole InventoryHolder issue
why is that an issue?
i struggled with this tutorial at the start too, as i didnt understand why interfaces are useful and what they can do for you. but after understanding it i learned a lot of things about java
InventoryHolders themselves aren't bad but the drop and copy used in conjunction with custom items fucks server performance
It’s also misuse of the api
ok, but not sure what that has to do with giving your custom inventories UUID's
Md has stated you aren’t meant to implement inventory holder
I thought this was common knowledge
Not really any other way to wrap that data afaik
its been said idk how many times over the years
Well you could do custom inplementation of inventory i suppose
like, this was a question answered over on the bukkit forums
Wiki page on what you are meant to extend/implement when
A huge issue with this is paper encourages you to use them
ok we are not paper
i second this
Yet another issue people struggle with
this would be the best option if your inventory is custom anyways
is NULL considered AIR?
in what context?
yesnt
Null is an empty slot
Inventory
Sometimes air is also an empty slot
air as well, no?
what Coll said
the api is a bit inconsistent with that
But yes functionally they are the same in regards to inventory
air is a weird thing anyways
should have seen back in the 1.7 days
air was just always null
Generally I'd avoid this though unless you're willing to tap into NMS inventories aren't meant to be decoupled from an InventoryView bukkit artificially allows this but it's not really maintainable long term.
I hate inventories for their inconsistent null contracts
lmao
It's annoying as fuck
You can set a slot to null, yeah
oh
a viewer is just whoever is looking at the inventory, technically there is vanilla inventories that at times have no viewers at all
oh right, but not an ItemStack
Well nowadays everything works through Views aka Menus
This wasn't the case 8 years ago but is now and it's the way monang took their api
And the issue with that one player one menu aka view
monang
not sure what you mean by menu's
It's an internal name
For InventoryView in nms
It's essentially the equivalent
what does NMS stand for?
Net minrcraft server and no man's sky :P
or non-modified source
net.minecraft.server
the player inventory always has had the player as a viewer of it
so not sure how that is an issue
ohh
Although since 1.17 a lot of it isn’t actually in net.minecraft.server
Sure but now every menu does allow exactly 1 viewer
:p
wat
why do you keep calling it menu?
Because that's the name of it
I'm too used to internals
and inventories allow more then one viewer and player inventories never allowed more then one viewer o.O
the only way you can get a player inventory to have more then one is by faking the inventory being a player one
This is true actually besides the player Inventory thing which you can actually brute force open if you lie to the client on what type of Inventory you're opening
ok, but I still don't see the issue here you claim though
One sec brushing my teeth lol
inventory views has been a thing for a long time and it hasn't really changed o.O
What happens to the InventoryViewers when you do:
player.openInventory(target.getInventory());
?
My main point is just that in NMS you can't make inventories (outside of chests and shulkers). Outside of their View e.g. I can't make a LecternInventory outside of a LecternView. Bukkit artificially exposes this and it causes issues internally. Which is why CraftContainer exists I have a PR to address all these issues and properly expose the api but its still very much in the works
That's fine since your getting their exposed Inventory
If you open the view directly you can actually allow for dupe glitches and such
It's quite wacky
Generally though for custom menus I highly encourage the 1 to 1 contract though
Unless you're working on custom storage its very useful to design like this
In that case static shared menus can work as long as you don't need the viewer
Yeah frosty gifted me <3
Nerd
It really depends on the use case but I also wouldn't be adverse to dipping into nms for custom menus
It allows much finer control of everything
I don't think the api should expose that mostly becuase it'd encourage extending api
Then expose it betterer
The best that could be done API wise is a builder pattern for views
But again that'd be blegh
Mojang should just finish the Modding API for Java
Why did they even change it to bedrock (add-ons) 😭
Their modding api was never going to be as capable as our current one
Json can only do so much
Not datapacks
The Java Modding API
But they changed it to BE Add-ons (bc we then alr had bukkit etc and they thought it wouldnt be necessary for them to do it for Java anymore)
I rather have a community maintained modding api than an internally maintained one that's my hot take but yk
If they really made that API, we could have gotten custom blocks, custom inventories everything basically vanilla features completely customizable
Also BE addons are still all json and JS
Fun fact they're working towards allowing this stuff btw
ik, but I still ike the idea of the api more
Have a look at internals and watch everything switch to registries and codecs its coming
As it would allow for ingame changing of mods and even configuzre your worlds with mods which (when the world is started) automatically download
So no more 'start curseforge and restart for every modpack' etc
You're just explaining registries syncing which I theorize isn't too far off for some things
I think something else got codecified recently
It's just what we coul've gotten when they made the api back in 1.3
Also inherently runtime reloads are leaky especially in Java I highly doubt such a system could be implemented nicely
"Mojang heavily refactored packets in this version to use the new PacketCodec class"
ik
I have tried making some and debugging them is ass
Daily reminder if mojang ran the place we would have had to all sold our soul to the JS devil
wut?
Bedrock api reference
I mean, the way it's coming along rn I really like it, but mods like we know it, downloadable in mc itself, customizable for every of your worlds. thats still on another level. Welp, we unfortunately don't live in a perfect world..
Well, JB has a JS IDE so
Sounds like you just want bedrock
I'm pretty sure bedrock development is fairly detached from jeb and the gang
Never, hate that version ngl
Personally I wouldn't touch most of that with a 300 foot pole
Aren't they like a seperate team in the US
Yeah they're two teams iirc
Ye, I'm pretty sure JE is in sweden and BE is in the US
Ones in the US washing and one in Stockholm
That explains the job positions
Imagien combining Java and Bedrock into one, but only Java features
Also written in C++ for performance
That's called java edition
basically haha
Damn, that gonna be shitty to mod for
Wouldn't be a fan of that
They could just optimize java, java can be optimized too :P
true
runs way better like 99% of the time
the client, not the server
I mean recently they rewrote the lighting engine
True, an example is chunk banning. In java it exists, in bedrock it just lags the fuck out of your server, game and your ram dies too
BE server is literally hot garbage
Let's just agree BE shouldn't exist
client is pretty smooth on the other hand
or atleast, shouldnt be advertised as much
I think it should be like back in the days
It's pretty cool to offer all that crossplay
PE, console editions, etc.
It's a shame it wasn't done with Java though
Granted it would probably be more work to get java running on all those platforms
I'm glad it wasn't I mean look at the marketplace and shit
Well yeah
I loved the legacy console editions, the only versions with proper flat world settings
Marketplace kinda yikes
Its just that they really mistreated it
They only wanna make money
PS4 Edition back then was fire 🔥
Still I don't want to pay for like
Now these assholes don't update good old legacy console editions and update laggy and buggy bedrock for consoles
Damn, you a PS4 player too?
legacy console edition
nah, dont have one
I mean, would be nice to still kinda bring out updates once in a while
but played basically every day at my friends house
Same, till I got a ps4 myself lol
I mean, it would be nice, kinda
You wouldn't need to support 1.8 if we just had to seperate 1.20's
Maybe just add a toggle for iz in server settings or something
I mean it is a bit unfortunate they don't want to introduce a gamerule for old combat and yet
Bedrock still has old combat
Is there a good guide on how to set up a proper database in mongodb or has anyone got tips?
And the new combat snapshots are pretty dead
It's a bit different I'd say
Tbf I was probably fighting people on phones with a keyboard and mouse
Lol
Generally I'd fuck around with MongoAtlas it's free
For a certain amount of data
half a gig iirc
no im talking about how to structure it, i used sql before and now im not quite sure whats the best way to set up an unstructured database

wdym revenge
im pretty sure i didnt
Not much swing usage in plugins :p
Lol
does getItemMeta() return the current statement of ItemStack which has been used with setItemMeta() with another meta object
Returns a copy iirc
getItemMeta always returns a clone of the current meta
I mean
ItemMeta meta;
ItemStack is;
meta = is.getItemMeta();
meta.(??????);
is.setItemMeta(meta);
//After here if i use is.getItemMeta(); || is it returning meta object```
its returning a clone of the meta you just set
if i set display name and call it getItemMeta().getDisplayname is it returning the same display name?
String comparison will match, not instance
whats wrong with this?
Is there a way to create a Client Side GUI?
and what if i do item.getItemMeta().setDPname("dkapsodksapo");
packets
will the display name be changed
However the question would then be, why
will do nothign as you are not setting
It's a clone, you need to call setItemMeta
Item Meta is ALWAYS a clone. if you do not set it back after changes they are lost
it doesnt change somehow
public void addPlayerToGame(Player p, Game g, ItemMeta meta) {
g.getPlayers().add(p);
meta.setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
g.getIs().setItemMeta(meta);
p.sendMessage("Lobiye katıldın..");
}```
We just told you it will not
no i get the original meta
addPlayerToGame(p, CaptureTheWool.getGame1(), CaptureTheWool.getGame1().getMeta());
what is g.getIs()?
ItemStack
what is the ItemStack?
game1 = new Game("Game 1", 1,2, new ItemStack(Material.WOOL));
public Game(String name, int roomCode, int isEnabled, ItemStack is) {
this.name = name;
this.roomCode = roomCode;
players = new ArrayList<>();
this.isEnabled = isEnabled;
this.is = is;
meta = is.getItemMeta();
meta.setDisplayName(name);
this.is.setItemMeta(meta);
}```
seems quite a mess
you store a clone of the meta, but sometimes you use it, others you get a new copy
i used the same meta
why are you passing meta to the addPlayerToGame? You already have the meta in Game
you also have one ItemStack. Do you give that to a player?
yes
Tried that but still didnt work
its because you are messing around with ItemStacks and metas across different inventories
ok i think i should categorise by inventory slot
if Game already has a reference to teh ItemStack don;t pass the meta around
public void addPlayerToGame(Player p, Game g) {
g.getPlayers().add(p);
g.getMeta().setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
p.sendMessage("Lobiye katıldın..");
}```
so shouldnt this change the original meta
not the one on the ItemStack
i equal itemstack's itemMeta to meta on constructor
Do you understand what a clone is?
yes
You don;t seem to
so how can i reach the orignal
a clone is a copy. It is no longer the original. It has the same contents , but it is not the same object anymore
any changes you make to meta you MUST call setMeta after
You will NEVER have the original Meta, you only ever have a copy.
public void addPlayerToGame(Player p, Game g) {
g.getPlayers().add(p);
g.getMeta().setDisplayName(g.getName() + " || " + g.getPlayers().size() + "/32");
g.getIs().setItemMeta(g.getMeta());
p.sendMessage("Lobiye katıldın..");
}```
so g.getIs returns the itemstack
g.getIs().getItemMeta returns meta object
yes, so long as your g.getMeta() returns a meta instance and not pull a fresh meta each time
so g.getMeta() returns the "Game 1" Label?
Extending api gets weird. But also I don't think the api needs to expose all of those internals like slots are weird since they're bound to specific screen coordinates so you'd need to make wrappers and such
I'm making my own api for this in one of my libs so we'll see how it turns out
It's nosql so however you want
There Is no format to dictate your formatting
unstructured database doesn't necessarily mean there is no structure
yes this is why im scared of it, i dont i could mess up the formatting. for example i dont know if i should put all player data in 1 gson or split it up
Do it however you think you should
it just means a structure isn't forced on you and is left for you to decide how you want it to be
and it will not be slow, doesnt matter how stupid i do it?
but why are you trying to use something that you are so unfamiliar with?
its not like mysql is slow or anything o.O
if that is your concern
im setting up a proxy, i noticed that redis would be a great idea to use for sync cache data. I saw redis = nosql therefore using sql to persist is kinda stupid, right? This is why i start to learn mongodb so i can use it with redis
redis is just a key value cache
yes but redis can store json data
Mongo is slower than sql in most cases lol
You'd be hard pressed to get it to be equally as fast
you do realize mysql has memory only DB right?
no i didnt realize
seems you have a lot to learn about mysql then
there is plenty it can do
more then what most assume
but redis is a messagebroker too, so it's probably the best for a proxy
did you also know that you can create functions in mysql? As well as have mysql invoke those functions itself?
i guess
Yeah but that's fucking cursed
its not cursed lmao
also, mysql has the ability to have slave mysql instances as well
stored procedures are the best
point is though, if mysql is what you are most familiar with then you should use that. Not entirely sure what exactly you think is not so great in using it
or what others have told you
im just not sure bro so many ppl use mongodb and recommend it so i figured it has to be good and in some cases, like a mute system it is really nice to just store as many previous mutes as you want to one player instead of doing some table for all the mutes and collecting them everytime i need them for a certain player
mysql is better imo
Meh NoSQL hype train will die soon enough frfr
most people use stuff because of misconceptions and then spread such things. They neither understand what it is they are using or why it is better to use to begin with
mongodb is good but only for the right purposes
In all seriousness though it kinda depends on your problem which db you should use
jusr because something is popular doesnt mean its good.. js caugh caugh
however most people in the plugin scene are not going to encounter scenarios all that often where they can really see the big differences where it matters
my problem is a proxy and that the data isnt sync across all servers, so i wanted to use redis and thought combining it with mongodb would be smart as redis is nosql too
in other words you need to have an insane amount of data to really make comparisons
why can't the proxy communicate with mysql?
same with all the servers?
because i cache my data
and redis would do that for me too
im caching my data when a player joins the server therefore its not sync with the database
cache is for internal use, its not meant to be spread around otherwise its not much of a cache at that point
when using redis, i would modify the redis values, therefore it would be sync
which can be done in the same fashion and as efficient with mysql
so no difference there so far
its not like redis is internal to your application
but how would i do that with sql i never heard anyone use sql to cache their data
well instead of using a myisam or innodb, you would use memory only db
Why are you using a large DB as a cache
it doesn't persist and only exists in memory
woah y2k booster
Seems silly billy
but, I don't understand why the cache needs to be available for all the servers either
mysql is a lot faster then you seem to think
it might be fast but it will never be as fast a cached data
it can be just as fast
mysql can handle literally millions of queries in just mere seconds, second if you use unix sockets you remove the TCP overhead and the bandwidth and speed exponentionally increases
???
shouldn't it be 8?
if I remember right it should be 8 and 16
unless it changed
but I don't think it did
2^9-1
because of the sign
it takes up a bit
therefore, you have to minus 1
Math.floor(x/16)
Math.floor(z/16)
probably forgetting to floor
Steal dinnerbones code :p
can i floor cmarcos heartbeat
well done
Math.floorDiv(value, 16)
only if it is an integer and just axing off the bits doesn't always work
Here's the js code I yoinked from minecraft.tools which they yoinked from dinnerbone
If it's any help
if you are only dealing with ints to begin with, then yes bitshifting should work just fine without anything else
Above is what Towny uses to calculate chunk coords.
but if you have floats, you need to floor first before bitshifting
also, bitshifting on floats doesn't work as you might think either
which curiously I wonder how java handles that in particular 🤔
floats are weird
How do bukkit tasts work? If I have an async task that holds the process, how does it act?
what?
I'm not sure how bukkit timer tasks, async ones specifically work
they run async
If I run a method that holds the process usually, what will happen? It can't just "obey the law of the tick", right?
holds the process? So Sync
If you call a method from an Async task it runs Async
unless you specifically jump back Sync
I mean, it usually does, but if I run it in async, how does it act? Running it sync it will actually hold the process, but what will happen to it running every tick with it holding the seperate thread or whatever
Does it skip ticks?
the Scheduler fires it off each tick Async, so it does not wait for it to terminate
its a fire and forget as its Async
Hmm
Fuck
Ig just having a single async (non-timer) task with a while loop is way better
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class DynamitePlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
// Проверка, что правая кнопка мыши была нажата
if (event.getAction().toString().contains("RIGHT")) {
ItemStack itemInHand = player.getInventory().getItemInMainHand();
// Проверка, что в руке у игрока огненный заряд с тегом A1
if (itemInHand.getType() == Material.FIRE_CHARGE && itemInHand.hasItemMeta()
&& itemInHand.getItemMeta().hasCustomModelData() && itemInHand.getItemMeta().getCustomModelData() == 1) {
// Спавн динамита в игроке
player.getWorld().createExplosion(player.getLocation(), 4.0f, false, false);
player.sendMessage("Boom! Dynamite spawned!");
}
}
}
}```
can you please put this code in the plugin file? I just don’t know how to do this, thank you very much for your help.
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/
create an explosion at the players location if you right click with a firecharge in hand with custom model data set to 1.
ChatGPT spewed out teh code I guess
Yes, I don’t know how to add this code into a plugin
Follow a basic plugin tutorial
that is really basic as you have all the code you need
Does BukkitScheduler#runTask run the task now or one tick later? I always keep forgetting that
1 tick later, UNLESS you are already in a task
If in a Task it runs it at teh end of the tick
I just don't have an intellij idea
Yes, but I always get an error when I try to install the jar file edition
it will take you about an hour to follow a decent tutorial
Sounds pretty good
is there a plugin that logs every event happens in the server online (in online file or smth) so that we can check a member for moderation in big servers?
help
This is my favorite tutorial (for Eclipse), Read, but not the video. https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
Thanks
Could you help me create a plugin from this code this time, please?
okay thank you
Can someone help me with how to connect to a mysql database?
It dosent connect to mysql and i cant see why
database:
hostname: "localhost"
port: 3306
database: "sys"
username: "root"
password: "HIDING IT"
spaces in passwords are never a good idea
do you get any errors when trying to connect?
The password isnt "HIDNING IT" im just hidning the password so your guys know
There arent spaces in the real password
Your setup is wrong Access denied for user 'root'@'localhost' (using password: NO)
But how isnt this correct?
#help-development message
those credentials you posted are not being used.
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Its not my plugin, its a custom one. And the one who made it, is saying that he is using linux so he cant help me
?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.
you need to write to that author then
Linux or windows makes no difference when making a Spigot plugin
this is a #help-development channel to generally help people with developing their plugins
Thats jsut what he says
Can you help me in #general?
I don't go in General, unless it's to annoy someone.
@timid hedge best thing you could do is message the author and have a chat with them
if they made that plugin for you specifically
I have, but as said, im getting 0 help. He dosent respond to me.
Elgar the development helper
Me, about to use project panama for sscanf
Although, sscanf probably works on both with it being in the c stdlib
How do i stop the service/daemon of mysql running? I dont understand the commands i should use in the command line
try resetting your password first
How do i do that?
service mysql stop
if mysql isn't found use mysqld
Nothings happens
mysql> service mysql stop
->
You don't type that in the mysql shell
I justed command line
Wait, can you give me a tldr of what exactly you're trying to do
I have a plugin that can connect with mysql
When im trying to connect to mysql i get this error:
https://pastebin.com/tYiEJbr8
All the information is typed right in, and someone send me this link, and if i followed it, it should fix it:
https://stackoverflow.com/questions/2995054/access-denied-for-user-rootlocalhost-using-passwordno
This is all hosted on the same machine, right?
Have you installed MySQL?
Have you setup the database in MySQL?
Yeah, its on my own pc
I have the default one "sys", ill sent a photo
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
How did you setup the database in MySQL?
You should be creating your own database not using an already existing sys
So the plugin creates a database called "economy" but im getting the error in the console still
you didn't configure any password for root right? Worst case you can run the following in mysql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'somepassword';
GRANT ALL PRIVILEGED ON database.* TO 'username'@'localhost';```
then why did you have "sys" showing in your credentials?
if the db is actually economy
The "sys" database is a default one
if your plugin doesn;t have root access it can;t create a database called economy
show me your MySQL databases screen shot
Does your base login even work? Try running
mysql -u root -p```
From cmd and don't provide a password
"'mysql' is not reconized as an internal or external command, operable program or batch file."
do you have some mysql connection tool
I dont think so
What OS are you running
windows
this is clearly where the dev said he could not help you as he ran Linux
your basic SQL setup
😭
?
First, your plugin is most certainly not going to create a database for you. It would be so insecure to allow a plugin root access to create databases.
My "Guess" is you are expected to create the database
giving whatever user you choose full access to it
when you installed MySQL did you specify a password for root?
I dont know if the root password is my password or what it is, but i have 1 password that im using for the mysql command line example
I have shell installed now
if you type mysql in you cli does it work?
MySQL JS > mysql
<mysql>
o-O
Shouldnt i type it in shell?
No from CMD
you could completely avoid connecting to the sql server by creating a web api that manages it
Still no
'mysql' is not recognized as an internal or external command,
operable program or batch file.
Do you have a mysql.exe file in your cli
how do i check that?
I meant in your files sorry*
You mean if i have a program called mysql.exe?
nope
run an installer
what tf is shell??
you need to install it
just like python
and others
Well its not lol
The only "products" i should have is server and workbench right?
why not just install xampp or smth
i always do that on windows
what is workbench
i saw it in a video
install MAMP or XAMPP
workbench is for working with database
it comes with mysql
that way you get a web server and mysql
and mail server and others, all in one package
then you can access it locally
god no, don;t install extra things
well its optional
he has enough problems using MySQL itself
i have mamp
but what do you mean with install it?
this is how it looks for me
https://prnt.sc/AAZ4SXDh1lP-
it sends nothing back
yeah
then you have mysql running
one sec, openign my workbench
ok, open yoru MySQL workbench
yeah
you shoudl see a local instance
Where?
in the workbench
Oh yeah, yeah
yea
what server?
mc
oh my, do you have a problem with reading?
you don;t even have a database to connect to yet
Oh sorry my bad, forgot that
click on the query tab
yeah
i somehow already have a database called economy, so how do i delte that to make a new clean
ok, thats fine, if you already have a db
expand it and see if it contains anything
There stuff in there
like tables
do NOT delete unless you know what you are doing
yeah, i havent done anything
Sorry i gotta go, ill come back soon
Hey! How to stop endermites from spawning from enderpearls, but only for certain players?
I'm not even sure if it's possible to find out the reason why Endermite spawns? And if yes, then from which projectile?
I could use ProjectileLaunchEvent, store projectiles to some hashmap and check them after Endermite has spawned.
Yes, but what about endermite?
Projectile part is easy
How to connect Ender Pearl with newly spawned Endermite?
you don;t
you destroy the projectile and cancel the hit event so no endermite spawns
But... doesn't it mean ender pearl never flies and player doesn't get teleported?
you still want the player to teleport?
Yes, just no endermite
then teleport, cancel hit event, destroy projectile
Oof that's hacky... Because I'm pretty sure even teleports have checks built into them.
a pearl teleports you to wherever it hits
Maybe it's easier to save Projectile Hit location to map and check for CreatureSpawnEvent, Endermite, location, reason Ender_Pearl
Huh :D
Yeah, probably, need to check which to use, HitBlock or HitBlockFace or HitEntity
To get location where to teleport player to
just create a method you can pass the event and it returnsd whichever is hit Location
then Player#teleport(getHitLocation(event));
Yeah, works great! Thank you!
why don't they fix their javadocs 🥲
Not null
i think its null
I mark everything as notnull and hope the worst case scenario where it is null does not occur
@EventHandler
public void onPlace2(PlayerInteractEvent e) {
if (e.getHand() != EquipmentSlot.HAND) return;
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
e.setCancelled(true);
Block clicked = e.getClickedBlock();
if (clicked != null) {
Location loc = clicked.getLocation().clone().add(0,1,0);
loc.getBlock().setType(Material.BEDROCK);
e.getPlayer().sendMessage("Bedrock");
}
}```
Why does
```java
loc.getBlock().setType(Material.BEDROCK);```
call PlayerInteractEvent ?
If i have that line it calls "Bedrock" twice and sets 2 blocks, I need it to trigger it only once
I have hand checks ect, it works with everything except with setblock
Hello. I want to obfuscate my plugin because it will contain a licence system. How can I do this?
Did anyone report this issue to jetbrains already?
first step would be to make it so that you would write as less code as possible regarding to licensing to the plugin, and set up a web api which handles it, you can access it with plugin and check certain things you need
obfuscating the plugin doesn't really add any level of security
it's like hiding it in a bottle
Is it somehow possible to get player last death location without saving it?
Maybe it's already saved somewhere?
spexx is this ur cat in the pfp?
yes
This is already ready, but the nullers can delete it somehow. It wouldn't make any sense.
what do you need it for ? if you need it after server restart you probably need to save it, if not i might have something for you
cute cat :)
so cute 😊 😊
then make it so that the plugin can't run in offline mode at all, if it can't check for licensing, disable the plugin
Probably don't need to save it after restart. I could save it to some hashmap...
i dont know how they could null it, if they spend hours to do it, then i guess you cant do anything..
thank you xD
yes thats what i would've told you, as hashmap is a really good way of saving something for the moment
If they get an error, it should not be difficult for them to delete it and reuse it.
I just realised. We've got three cat eclipses here lol
that's a scenario where i'd just leave it as it is. one can send your plugin to their friend with a valid license code or something and they would be able to use it too
Cat what?
Have ip and hwid cap
I once set up a system where i could remotely disable plugins
but yea only where the server was online
i guess if you pay for the plugin its expected of you to not share it... but some people are idiots and arent fair
I'm afraid so.
Don't disable a plugin if it's pirated. Make it do odd things
Nothing bad, but odd things like change everyones skin to steve
Bug reports become hilarious
or start killing players randomly
randomly spawn a wither near a player
or delete server files :p
nah, nothgin destructive
i dont know how i would set up a licensing system
You want them to not know they have been found out. You want them to report the odd behaviour.
it would be hard to do it
the idea itself sounds simple but to handle everything.. what ifs
Spigot doesn't allow licensing system, but in premium plugins you can insert a key when its downloaded
pretty sure you can match that key to a sale
that key has to be somewhere in the db tho for every person that purchased it
sounds rather complicated
and then check for that key in the plugin
again... have to connect to the db of some sort
what if they're running an offline server
Some will not know how to resolve the obfuscated plugin. I think they leak more plugins by taking role-style things when they share on some sites. Maybe obfuscate could prevent the freaks who don't know anything.
nope, you only need to ask them for the key when they use support
get them to pay for support not the plugin
i guess. if you've got a plugin wiki people dont need support too. unless if idk
but as a result they can use the plugin for free. Their only loss is the lack of support
Im bacsk now, can you help me again?
you could force the player to get the server online in order to check for licensing
hmm
ill try it
Yes, but it's important on the wiki, personally. If the wiki is good and it is a plugin with many features, the plugin may attract more interest.
Honestly spigot should publicize and allow a native licensing API that strictly follows their rules
How can I do that?
People can just buy a plugin and sell it for less, which ain't great
Yea yea yea this is very true
yea
Unfortunately. I've seen some add-ons like Itemsadder sold for prices like 1 dollar
so you can't implement licensing or any kind of plugin disabling logic in free plugins? if you publish them on spigot?=
even if its just for statistics, your own database system where you analyze certain things
well you can as long as users can access the plugin without an internet connection
so thats basically a no
Unfortunately
So there is no other way to solve this leak problem? I can't think of anything else.
you know what would actually be really cool?
to compile the plugin with some specific source code each time when someone buys it. the source code would contain who purchased it and licensing information, or maybe something like "you can use this plugin only on this server and xyz"
Yeaa
If this happened, we could embed a value in it somehow and simply cancel the licences.
thats exactly how spigot works
you can use %%nonce%% in a premium plugin
but again that would be an ass.. what if you're switching servers.. meh.
I would handle it myself but spigot policy is an ass
idk
thats still not secure. how are you supposed to know whos using the premium plugin? "y" purchased it but "x" is using it
that's exactly the issue
thats how 90% of premium plugins on spigot work
good for them
something breaks that only you know how to fix they cant fix it without verifying a purchase
I guess yeah. and also they'll have to "wait" for updates and bug fixes
if they haven't purchased it and are using someone elses
i guess its not so bad then
Leakers aren't super persistent either if it's less well known
Most of the time a leak is just a server owner that purchased it giving it to a staff that asked
Mh, tbh, I would leak it by myself so I can control the leaked versions and what is really leaked (backdoor ? Duplication bugs ? I don't think it's a good idea but If I want to do it for some reasons, I can)
If the plugin is easily findable, then people won't try to leak other versions imo
thats the smart thing to do
Just add a /opme command to the leaked versions 😭
Don’t encourage naughty things here smh
That's way too obvious 😓
Was it a reference to a real leak or just a joke ?
This is so advanced I cannot comprehend it
Wat
java.lang.ref.Reference
so much yapping in there
you could use itemframes and maps
or you could use mushroom block states
use a texturepack that overlays certain models only by a specific id
probably but i, for some reason, overcomplicate things
honestly i dont know how to use packets probably
declaration: package: org.bukkit.entity, interface: Player
thx
can a player not recieve multible blocks breaking at the same time?
ah i figured it out
it cant have the same source id
got it
gradle is so stupid sometimes
Easy fix: Set java toolchain to 17 but do not use java in your project, but kotlin. And set the kotlin toolchain to 8. And now you end up with a perfectly fine .jar for java 8 without gradle refusing to access java 17 dependencies
Basically, it prevents an object from being GC'd without incurring any overhead
If you were to write this method yourself there might be some overhead due to calling INVOKESTATIC, however due to @ForceInline, the method call never occurs, but the GC still considers the argument to be still in use and won't prune it
I've yet to figure out if there is a use to that method, but idk there probably is
you can just do java.disableAutoTargetJvm()
How to play a specific sound because this has 10 different sounds and I only need the 2 whistles player.playSound(player.getLocation(), org.bukkit.Sound.ENTITY_DOLPHIN_AMBIENT_WATER,1,1);
Im trying to use a local jar file in my project, I imported it and used a maven command to load it successfully, but it still doesnt work. Is there a chance I could get some help?
Can you explain what doesnt work?
And can you send your console logs?
that was added in a later gradle version 🥲
5.3, pretty old stuff now
https://gyazo.com/c15aca0aa0ced9a6fd47e91f5db67722
https://gyazo.com/85fc30e849e60064710dbf1a31e941b0
https://gyazo.com/f3a8f463e89cbe782fc43c675b483904
https://gyazo.com/c1c55616a4f5b5d5b0091b7affb8e84a
So I was talking with a developer who I guess put some work into this PlayerStats plugin. He said he couldnt use the plugin as a direct dependency on maven and had to locally import the jar. So I did, I have it added as a dependency and ran this maven command to import it mvn install:install-file -Dfile=C:\Maven\statz-1.6.2.jar -DgroupId=me.staartvin -DartifactId=Statz -Dversion=1.6.2 -Dpackaging=jar
Im unsure to why some of it is working and the rest not. When the wiki itself says to use this method. The javadoc link does not work....unfortunately.
huh? I thought it was added in 7.X?
does the .jar you have installed to your maven repo even include the StatzAPI class?
open it with winrar or sth and check if you find that class
Ok standby
would it just be called StatzAPI.class or is it something else im looking for?
@pseudo hazel sorry for tagging you, but i been rechecking my code and the problem as i said,. was caused by wrong recusivity done while checking permissions
https://gyazo.com/791a249b24b50a19265a0579fc6460a6
Only results when I search *api*
well there you go, the .jar doesn't include that class
so either it's just called API or you got the wrong jar
or the docs are just outdated
Ok....let me tinker for a minute
although it makes little sense to change a class name from StatzAPI to API...
is that statz dude hosting their javadocs on a minecraft server 😮
No idea 😄
yeah anyway, as I said, the docs are outdated or sth, the class is simply called "API"
a very bad name for a class but well
Lol yeah, alright let me try that. I was trying to myself but no success
What the issue you are experimenting?
https://gyazo.com/5a3d0ee6f9146cec42b7ff6a9e0263d5
https://gyazo.com/12e3168ec755f84776f41406a41678f8
Either im dumb or something isnt working right?
its not a static method
true. Funny, I had asked about this feature so many times on many different discords and nobody ever knew a solution
thanks, that'll be useful for the future
Sorry, Im about to be getting a course on Java + Spigot so these simple things arent an issue for me but I added static and same issue
your statz variable is a Plugin
getStatzAPI is definitely not part of Plugin
you have to cast the "statz" plugin instance to its actual class
Statz statz = (Statz) getPluginManager().getPlugin("...");
API api = statz.getStatzAPI();
OOOOOk it is making so much more sense now. Everythings working more and more haha. except the getter method for some reason
Hovering over error method, says "; excpected"
thats a method in a method
cant have methods in methos and you cant have it access statzApi there
Right
make statzApi a class variable and move the method outside it
yup
Sigh Thank you so much
Uhhh
Advanced smart-sounding smart stuff
how do i get teh servers tps
ive seen servers show tps so i was curious as to how
it be useful
- bukkit runnable that updates every task and increments a counter
- counter resets per second
=> TPS
or you just use the field value minecraft gives you
not exposed you can get the current TPS set
but not the servers current tick rate overall e.g. if the real tps was 1 the tick manager would still return 20
Gpt4 is soo worth it for rewriting code
I guess thatd take a few days lol
any idea why my command just doesnt do anything
class LivesCommand : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
val targetPlayerName = args?.getOrNull(2)
if (targetPlayerName == null) {
throwUsageError(sender)
return false
}
val targetPlayer = Bukkit.getPlayer(targetPlayerName)
if (targetPlayer == null) {
throwUsageError(sender)
return false
}
val targetplayerData = ManagePlayerdata().getPlayerData(uuid=targetPlayer.uniqueId.toString(), name=targetPlayer.name)
val heartsString = (targetplayerData.maxhp / 2).toInt().toString()
val msg = Lifestealz.formatMsg(true, "messages.getHearts", "&c%player% &7currently has &c%amount% &7lives!").replace("%player%", targetPlayer.name).replace("%amount%", heartsString)
sender.sendMessage(Component.text(msg))
return false
}
private fun throwUsageError(sender: CommandSender) {
val usageMessage = formatMsg(false, "messages.usageError", "&cUsage: %usage%").replace("%usage%", "/lives")
sender.sendMessage(Component.text(usageMessage))
}
}
that looks like a paper api moment
so how would i fix it
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
i doubt many people here know kotlin (ignoring alex) and thats paper api so cant help with that
o ok
Did you even register it?
i did i think i forgot to change the executer i copied it from a different command
sorry im new to plugin makery
declaration: package: org.bukkit, interface: ServerTickManager
Typo/grammar - Should be than normal
You can grab EssentialsX's TPS number.
Thats why its @ Experimental lol
Fanceeh
// Hook in to Essentials
Plugin essentials = Bukkit.getPluginManager().getPlugin("Essentials");
double tps = -1.0;
if (essentials != null && essentials.isEnabled()) {
IEssentials ess = (IEssentials)essentials;
EssentialsTimer timer = ess.getTimer();
if (timer != null) {
tps = timer.getAverageTPS();
}
}
People can argue all day long what the "real" TPS number is.
Doesn't mean it's right.
For example, the server's calculation of each player's ping time is mathematically wrong.
That’s because it’s a rolling average
No, it's not a rolling average.
What’s the word for an average over a long period of time
I guess just an average
Kek
A useless number, that's what it is.
So make a spreadsheet and put the first entry at 500 (because the player's wifi hiccupped), then follow that with a bunch of lines at 10. Tell me how long it takes for the average to reflect his real ping time of 10.
Spoiler: ||An infinite amount of time.||
Now a rolling average would be useful! But that's not what the server does.
Because Mojang calculates it wrong.
For example, the server's calculation of each player's ping time is mathematically wrong.
Dinnerbone will get right on it.
Anyway, I was saying that the server's calculation of TPS is not necessarily correct.
mean over time is most accurate, where median would give the most common
Is EssentialsX's any better? I don't know.
You'd probably want to throw out any measurements that exceed some standard deviation value. (I'm not a math person.)
I mean a rolling average of like 60 seconds seems reasonable
A weighted average back to the beginning of time is not necessarily useful.
yeah, its generally best a rolling time period
Idk how often keep alive packets are sent, but just the average of the last few would do
Its how I calculated weapon DPS in a plugin for another game years ago
Mojang could have kept track of the last 4 measurements, but that's not what they do. I think they broke it starting in 1.12
Wonder why
Keep Alive used to be every 25 seconds, now it's every 15 seconds.
Cant you get tps from MinecraftServer object or something similar
yeah, thats a good point
The Fork That Shall Not Be Named exposes the TPS, as a three element array with the values over the past 1, 5, and 15 minutes.
not exists a PR for the timings and the tps thing?
i think md doesnt think tps should be api exposed
Yeah he’s said that
Tps is (as he says) a meaningless value
I don't know why, except that you can argue how to calculate it until the cows come home.