#help-development
1 messages · Page 657 of 1
There's a file you can add items to for that.
Although that might be resource packs only.
no that's not it
a wooden sword burns in lava
I'm trying to check if it will burn if i throw it in lava
so netherite items would return false and everything else would return true
this should not work. Every Item is an Entity but not all Entities are Item
Item is a wrapper for a dropped Item Entity
That's what he's trying to do
So in fact, it will work
I made a plugin about this, basically applying a shield to an item each time it got damaged
I put the new version. I have to wait because it reload?
did you update the version number
yes
1.0 1.1
in update there is it
did you change the jar name
bc currently your version is the mc versions supported
yes StaffSystem-1.0 -> StaffSystem-1.1
now its 1.1
and the jar is 1.1
is good 5 dowload in first 1 hour?
meh
hцanyone knows how to get the desert fortress structure in the world?
/locate
in code
NMS but i am not good in this
Altranative?
screach API
aaa
well, that's all, I will NEVER say the price for the plugin in advance
how can i check if anvil is damaged from being used?
you can simply check the block type id imagine
Hello, in bungeecord how i can make an inventory sync?
you can
you can in spigot
How i can
Bungee has no idea what an Inventory is
Yeah i want make a plugin dor that
I'm assuming you want to sync inventories between servers, in that case just save inventory somewhere on Leave and load it onJoin
won;t work using bungee
On backend servers ^
as the server where the player exits won;t get teh disconnect event until after teh second server gets a join
Player will already be in the other server before the inventory is saved from the first
Oh, right, didn't know
So how i can do ? Using database ? Pluginmessage ?
moving inventories between servers is no simple task
args[0] == -1 ? Integer.MAX_VALUE : args[0]
there a way to do this without accessing args twice?
is args[0] and integer?
yea
Accessing array by index is O(1) action, it doesn't really matter
But save it in variable ig
thats the same thing with extra steps
i know this but when i should check this? in which event?
wasnt this what link is used for
#setAttributes iirc
👍
unsetSetAttributes would be more logical /s
Hello,
I need help with interpolation for display entities. I want to create an item that rotate 90° on the X axis in 2s. In vanilla, you have to modify the nbt of the entity with your translation, then interpolation_duration:40, then start_interpolation:-1. I did this with Spigot assuming that interpolation_duration is set with Display#setInterpolationDuration and start_interpolation with Display#setInterpolationDelay but it doesn't work: the transformation is applied instantly.
Here's the code with a test command :
public boolean onCommand(@NotNull CommandSender sender,
@NotNull Command command,
@NotNull String label,
@NotNull String[] args) {
if (!(sender instanceof Player player))
return false;
World world = player.getWorld();
Location location = player.getLocation();
ItemDisplay display = (ItemDisplay) world.spawnEntity(location, EntityType.ITEM_DISPLAY);
display.setItemStack(new ItemStack(Material.DIAMOND_SWORD));
Vector3f translation = new Vector3f();
AxisAngle4f leftRotation = new AxisAngle4f((float) Math.PI / 2.0f, 1.0f, 0.0f, 0.0f);
Vector3f scale = new Vector3f(1.0f, 1.0f, 1.0f);
AxisAngle4f rightRotation = new AxisAngle4f();
display.setInterpolationDelay(-1);
display.setInterpolationDuration(40);
Transformation transformation = new Transformation(translation, leftRotation, scale, rightRotation);
display.setTransformation(transformation);
return true;
}
Idk depends on what u wanna do
check if anvil is damaged from being used
is there a default for Enum PDC or do i have to use alex library?
tried googling but ended up on his spigot page
by the way i know i can just store a string but i thought if theres a native way to store enum using that would be smarter
if your Enum is never changing you can use the index
yea it aint changing, just maybe grow
oh wait
which would change index
string it is
BlockGrowEvent
Can someone tell me what this error means?
[23:34:28] [ForkJoinPool.commonPool-worker-2/ERROR]: Failed to encode map: {ItemStack{GRASS_BLOCK x 1}=0}
org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when encoding using the AutomaticPojoCodec.
Encoding a ItemStack: 'ItemStack{GRASS_BLOCK x 1}' failed with the following exception:
An exception occurred when encoding using the AutomaticPojoCodec.
Encoding a CraftItemStack: 'ItemStack{GRASS_BLOCK x 1}' failed with the following exception:
Failed to encode 'CraftItemStack'. Encoding 'enchantments' errored with: Can't find a codec for CodecCacheKey{clazz=class org.bukkit.enchantments.Enchantment, types=null}.
A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
It means you're trying to encode things that can't really be encoded
So you need to make your own codec
Specifically for enchantments
why are you creating a new Random everytime
also please spawn the creeper properly instead of just spawning it normally and then changing it later https://blog.jeff-media.com/use-consumers-when-spawning-custom-entities/
no
that's not true
only if you seed it
even if, it's not the same number everytime
no, i don't know what your issue is, probably you havent registered the listener at all
then debug it
is the listener called? is GG == 7?
I can see that
as said, debug your code, e.g. add System.out.println statements into the listener and inside the if block
then see if it gets called
sure, that works too
Pretty sure there’s a tag for slabs and buttons
There ya go then
Tag.BUTTONS.isTagged(…) or sth
It does tell you the error
Player has disconnected so there is no ProxiedPlayer
Remember when nullpointers didn’t tell you what was null
Back in the Stone Age
Okay
What’s not working
How do I get the information if the player is not on the server?
thats going to try to apply a LOT of potion effects
I want to get the uuid of the player that performed the disconnect event
do it in the PlayerDisconnectEvent on bungee
@EventHandler
public void onLeft(PlayerDisconnectEvent e) {
LocalDateTime now = LocalDateTime.now();
PrettyTime p = new PrettyTime();
String is = p.format(now);
DatabaseVariables databaseSettings = new DatabaseVariables();
ProxiedPlayer player = e.getPlayer();
ManaObjects playerInfo = databaseSettings.findPlayerByUUID(player.getUniqueId().toString());
playerInfo.setStatus(is);
databaseSettings.updatePlayerVars(playerInfo);
}```
im doing this
looks fine to me, so long as yoru database has a player for playerInfo
why are you creating a new DatabaseVariables?
if it's instanced surely it will be empty
😕 wdym
DatabaseVariables databaseSettings = new DatabaseVariables();
new indicates it's a fresh instance, so by that logic it's empty with no data
depends on your design
it sounds more like it's a DatabaseAccessor not settings/variables
actuyally
does yoru findPlayerByUUID return any data?
its saying it returned null
public ManaObjects findPlayerByUUID(String uuid) {
try (PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM variables WHERE uuid = ?")) {
statement.setString(1, uuid);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
String name = resultSet.getString("name");
long discordid = resultSet.getLong("discordid");
String discordname = resultSet.getString("discordname");
int crystals = resultSet.getInt("crystals");
String status = resultSet.getString("status");
String server = resultSet.getString("server");
int friends = resultSet.getInt("friends");
boolean friendrequests = resultSet.getBoolean("friendrequests");
boolean privatemessages = resultSet.getBoolean("privatemessages");
boolean mentions = resultSet.getBoolean("mentions");
boolean teleportrequests = resultSet.getBoolean("teleportrequests");
ManaObjects playerInfo = new ManaObjects(uuid, name, discordid, discordname, crystals, status, server, friends, friendrequests, privatemessages, mentions, teleportrequests);
statement.close();
return playerInfo;
}
} catch (SQLException ex) {
ex.printStackTrace();
}
return null;
}```
you do not need statement.close(); in that code
To be fair, no guarantee this is done on the main thread lol
Caller could be async
Use maven
Or gradle
Okay
Add the dependency via maven and set scope to provided
And make sure your plugin.yml has citizens as a depend
What’s the error
don;t add the jar, add it as a dependency in your pom/maven
use teh maven package option not artifacts to build
right side of screen, maven -> lifecycles -> package
Even my friend who graduated from university couldn't do it
if i send my codes
can u check ?
i didnt
You need the citizens repo
you broke your findPlayerByUUID
you stopped using try with resources
then your player does not exist in your database
looks fine to me then
when i change my server
my friend said so
he doesn't really understand them
he shoudl also have seperate variables in hsi twr for connection and statements
delete the type entry and add the repository for it
The link I provided
How could I open the player's armor and 2x2 crafting inventory?
[19:16:01 ERROR]: Error occurred while enabling ArenaCreation v0.1 (Is it up to date?) java.lang.NoSuchMethodError: 'com.fasterxml.jackson.core.StreamReadConstraints com.fasterxml.jackson.dataformat.yaml.YAMLParser.streamReadConstraints()' at com.fasterxml.jackson.dataformat.yaml.YAMLParser._parseNumericValue(YAMLParser.java:1109) ~[?:?] at com.fasterxml.jackson.core.base.ParserBase.getDoubleValue(ParserBase.java:746) ~[?:?] at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer.deserialize(NumberDeserializers.java:671) ~[?:?] at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer.deserialize(NumberDeserializers.java:655) ~[?:?] at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129) ~[?:?] at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:313) ~[?:?] at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:176) ~[?:?] at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:609) ~[?:?] at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:437) ~[?:?] at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32) ~[?:?] at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129) ~[?:?] at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:313) ~[?:?] at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:176) ~[?:?] at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322) ~[?:?] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674) ~[?:?] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3494) ~[?:?]
Would anyone know how to fix this? I thought it might be related to SnakeYAML since my testing environment is Spigot 1.12.2
Did you add it to your depends on plugin.yml
And is citizens on the server
Well it needs to be
No
depend: [Citizens]
That should work too, yes
just use java sockets to send packets from server A to client
thank you! 🙂
Is there anyway I can extract a list of all Items to a json file. I don't have access to NMS or Spigot /Bukkit I just need a raw list of all items. I don't really feel like pulling from a 3rd party website is there some mojang download I can pull from
the fact you can do it from models/item folder makes me thing you should beable to download it from mojang
I kind of want to automate the process which is why I'm wondering if there's something I can download to pull it from
Do you think there is some fragment of the client download that has it myabe
Idk
I wonder how WE does it
this makes no sense at all
because its in the client jar mojang should host some kind of resource so you can do something? lol
I figure they maybe split their resources
which they do just not the resources I need which is fine
unfortunately they do not except for dependencies
they have their music tracks separate
yeah that makes sense, otherwise the jar for the client would be super large XD
WE doesn't do anything special since it needs the server to run?
it has a list of all the ItemType's though for its API
well there is like an item list json file somewhere
can't remember if it was in the client or the server jar
yeah tryna find like something official and up to date
for the loot generation stuff
maybe, but it wouldn't surprise me if WE just hardcoded it
I think there was a command you can do to output the items json
like you execute on the command line
I think I'll just approach my API with a different approach
I wonder if its even worth it to improve ItemMeta in my own api rather than just work around how it just is
probably not tbh
Hear me out
Bet
Just do it
I decided I'm going to just fuck around with the idea tonight and see if what I do is any worse or better than what we currently have
i don't really have any structure Ideas yet so its time to just fuck around and find out I guess
Good lad
I mean realistically I'd just wanna change ItemMeta I feel like fixing ItemStack would be way too much
Go one step at a time
i gotta come up with my dinner plans for the week first though, ig I'll just be up till 3 toinght fucking around xD
I still have to code the meal 😭
Could anyone help me out?
you're not shading jaxon
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2'
Is in the dependencies section of my build.gradle file and I'm using shadowJar to build my jar. Am I missing something?
I tried gradle clean to no avail :(
?paste your build.gradle
I believe that happens when your command returns false
oh fuck
thanks, I'm so dumb
no problem, had that problem today lol
It prints whatever the „usage“ is set to in plugin.yml
I have a problem that I haven't been able to do for 2 days, can you help me?
o.o
obviously there must be if its not doing what its supposed to
this is code
this is warning
after disconnect event
i can't rejoin my server
hikariCP closing
and im getting this warning
printing to database btw
obviously your query isn't producing results
and therefore it returns null
which is fine, but you don't test for null being returned either anytime you use that method
hence NPE being thrown
you also never close the statement if something fails
now, that doesn't necessarily fix your problem, but it does fix the NPE being thrown
use a try-with-resources block
what is npe ?
😄
null pointer exception
well you returning null if the result fails, which means anything outside of your method that wants to use your method needs to check that it doesn't return null before using it further
you return null if your SQL stuff fails. you should have a stacktrace in your console BEFORE the null pointer exception
so that fixes the exception being thrown, however as for why its failing, you need to investigate why your query is not producing results
chances are you are not inserting properly
so
the problem with your query is this line here
calling next() moves the cursor forward which will cause it to always miss the first row
since your query produces 1 result
when the cursor moves to the next result
there is no more thus its false
well
its an easy fix
im watching video now for jdbc and database operations
what did I do wrong to refresh my knowledge again
I'll fix it based on what you said after I find out.
all you need to do since your query produces 1 result or there should only be 1
you need to just check that ResultSet isn't null
if it isn't there is a result and just pull the info
you only need to check for more if you expect there to be more
alright 👍
Welp now you have gotten the info you finally sought for 😛
frostalf what do you think of my fancy regex for Bukkit.getVersion()?
\(MC: (?<major>[\d]+)\.(?<minor>[\d]+)(\.(?<patch>[\d]+))?\)
why does it need a regex?
Because it returns sth like „git-spigot-8362ab74 (MC: 1.20.1)“
ah
Im getting this error when placing/destroying a block (specifically Oraxen blocks)
No references to my code at all
Don't know what to do
?whereami
well i watched some videos and check my code, i did what you said
how my resultset if wrong ?
i use my sql codes in other events
worked flawlessly
there is my other methods
@EventHandler
public void onJoin(LoginEvent e) {
ManaObjects playerInfo = databaseSettings.findPlayerByUUID(e.getConnection().getUniqueId().toString());
if (playerInfo == null) {
playerInfo = new ManaObjects(e.getConnection().getUniqueId().toString(), e.getConnection().getName(),0, "yok", 0, "Çevrimiçi", "lobi-1", 0, true, true, true, true);
databaseSettings.createPlayerVars(playerInfo);
}
else {
playerInfo.setStatus("Çevrimiçi");
databaseSettings.updatePlayerVars(playerInfo);
}
}
@EventHandler
public void onJoinGame(ServerConnectedEvent e) {
ManaObjects playerInfo = databaseSettings.findPlayerByUUID(e.getPlayer().getUniqueId().toString());
playerInfo.setServer(e.getServer().getInfo().getName());
databaseSettings.updatePlayerVars(playerInfo);
}```
Is there code in the SpigotAPI that stores which players are in a specific chunk? Or do I need to write code to track which players are in a particular chunk?
I found it:
for (Entity chunkEntity : chunk.getEntities()) {
if (chunkEntity.getType() == EntityType.PLAYER) {```
Unfortunately it's going to do a bit more looping like this (due to looking at each entity in a particular chunk instead of just the players), however it may be better than tracking what chunk a player is in as they enter it 🤷♂️
looping over that is not an issue
i wouldnt bother to keep track of that, just loop over the entities when you need it
or just loop over all online players and use getLocation().getChunk()
Hello I watched this tuto to understand the plugin messages https://www.spigotmc.org/wiki/sending-a-custom-plugin-message-from-bungeecord/ but I do not understand in onPluginmessagereceiver that it expects a player. However when the message is sent by the bungee it does not specify a player if?
you always need a player
the wiki article also mentions that
Remember, for the plugin messaging channel to work you need atleast 1 player online at the server.
Would anyone be able to explain what this error means?fix [10:37:33 WARN]: [7 Realms] Plugin Realms v1.0-SNAPSHOT generated an exception while executing task 32 java.lang.IllegalStateException: EntityDeathEvent may only be triggered synchronously.
it means you have called an EntityDeathEvent from an async thread
Yeah sorry I meant to ask what's wrong with doing that 😅
you have to call it from a synced thread, e.g. like this
Bukkit.getScheduler().runTaskLater(yourPlugin, () -> {
Bukkit.getPluginManager().callEvent(myDeathEvent);
}
plugins using entitydeathevent could propagate async in unsafe methods
@true perch most of Bukkit API methods cannot be used in async threads
But does it take a random player? (Because when the message is sent from bungee, no player is specified).
When I think about it logically, you wouldn't want the death event to be called async anyway.. You'd want it to happen on the main thread
makes sense, I'll need to rethink my code a bit
public void start() {
new BukkitRunnable() {
int healthRegenTimer = 20;
int despawnAttempt = 600;
@Override
public void run() {
if (realmMob.getEntity().isDead()) {
this.cancel();
return;
}
despawnAttempt--;
if (realmMob.isInCombat())
despawnAttempt = 600;
else if (despawnAttempt == 0) {
realmMob.attemptDespawn();
despawnAttempt = 600;
}
}
}.runTaskTimerAsynchronously(this.main, 0, 1L);
}```
that method has no reason to be async
that code no matter the system will take very little time
consider async when you're running with info over internet or disk
I was hoping adding it to an async thread would help with server performance since this will be added to every Mob that gets spawned.
I see now why that's a bad idea.
Ah I planned to add quite a lot of stuff there.
why don't you just use one global runnable instead of one runnable per entity?
you'll end up with thousands of scheduled tasks if you do it like this
I understand that overloading the main thread causes performance issues, and am under the impression that adding things to an async thread will prevent crashing.
If my previous statement isn't that, then I suppose not
counting down an integer isn't exactly overloading the main thread
I planned to add quite a lot of stuff there.
like what?
I completely agree and understand that though
Lots of code doesn't necessarily mean it's heavy
as I said, you are free to do your stuff async but you'll need to go back to a synced thread to call most of bukkit api
I'm a bit confused by this. Can I call things on the main thread from within an async thread?
^
i suggest it's best to keep in sync, if it runs poorly improve it and if it still runs poorly then consider async
That sounds like pretty solid advice.
new BukkitRunnable() {
@Override
public void run() {
// This runs async
System.out.println("async");
Bukkit.getScheduler().runTaskLater(myPlugin () -> {
// This runs synced
System.out.println("synced");
}
}
}.runTaskAsynchronously(myPlugin);
I mean you can always monitor how long your calls take. You should probably take care that a single plugin doesn't use 35 out of 50 available milliseconds each tick
I agree, that's very helpful guys thank you!
I will absolutely play around with this. Thank you
is there any other event then the player click event being triggered when a player clicks on a fireplace
async is mostly a scam
people use it as marketing tactic
or the devs are clueless when it comes to concurrency
if I save a text display's UUID will it also save the text displays text?
and don’t realize that async used wrongly can be worse
no
so that means I have to save it's text as well?
if i do block.setType(Material.CAMPFIRE); will it be lit on fire or not
try it and see ig?
dont wanna boot up a server for such a small thing but if no one knows ig have to
no worries im already on it
sure
what do you need help with
do you already have a method that changes the players hearts when he gets killed?
chatgpt ah code
well at the point were the player get his hearts removed just check if he will have any hearts left and ban him if not
if (newKilledPlayerHealth < 2 ) {
//Ban the player
}
wait
no
more like this
sorry i just coppied ur code snipped and messed that part up xd
but yh that will work
or even
this nopw makes more sense regarding your existing code
why would you do that
this code is enough
you dont need this
well you still could put the entire thing in one class
or more like one event listener
hey guys
should I split my databases into their seperate file or just use one central databse for everything?
what makes more sense
i would seperate things makes it easier to find stuff
well its preety easy theres like 0 possibility for a bug with this plugin
if you have basic java knowledge at least
I found the problem this morning can you help me?
My server crashes when there are fast queries in the database
When a player enters the server, I print the status online in database
but when I exit without connecting to the server and enter quickly, the server crashes
Is there a reason the included bungee chat API version wasn't updated beyond 1.16? it's missing some important new features
Open a bug report
Will do, just wanted to make sure there wasn't any specific reason it's this way before opening one
https://hub.spigotmc.org/jira/browse/SPIGOT-7091 there is this one actually
I assume I shouldn't open a duplicate? or should I still make one as that one's referring to updating for a specific bugfix?
How can i change the size of the BlockDisplay entities?
Through the Transformation (Display#get/setTransformation)
thanks
Set it to null
inv.setItem()
or yh thats probally the error
anyone have an idea to check if a item is a specific entchant book
guys how do you abstract your database calls?
do you have some kind of framework to execute queries agnostically or what
i cant think of good solution which works efficiently
agnostic wrapping can lead to performance issues imo
since with queries you can specify in what kind of way you want to store that object
and agnostic wrapping could lack some info, since it could depend on the context of object which is stored how it should be stored
I'll look into it thanks
anyone? i cant find anything when i look it up
why do you want to abstract your databse call, its like you said, if you want the best performance and wahetever you mostly write the queries yourself anyways, making that abstract only adds to the complexity imo
maybe the meta has the enchantment?
enchated books use EnchantmentStorageMeta and the enchant is inside getStoredEnchants()
please help me how to make a fake time not in h,m,s and in ч,м,с I use a placeholder %statistic_time_played%
Oh, it's not fake time, but the time spent by the player in, I need to translate this into Russian
as I said, String#replace
String replaced = myString.replace("h", "ч").replace("m", "м").replace("s","с");
☝️
it will work for the placeholder %statistic_time_played%
it will work for whatever string, obviously
you first of all get the placeholder
that returns you the result string
then you do replace on that string
thank you very much!
could you please explain how to do this? I'm just new to creating servers and don't know how to add it
is this even a java / coding question?
this channel is for programming / coding questions
otherwise #help-server
yes, I need to change the placeholder on the server, whatever it is ч,мс
are you a programmer
obviously not
or you're trying to edit config files
so you are making the plugin then correct?
why do people always think "development" means setting up a server
well development is a broad term
estate development for example isnt about programming 😄
%statistic_time_played:hours%ч %statistic_time_played:minutes%м %statistic_time_played:seconds%с
thank you!!
yeah but it's pretty obvious that when there are two channels, one is called "help-server", and one is called "help-development" which has a channel description of "Spigot and BungeeCord programming/development help" that it's neither about setting up a server nor about "estate development" 😛
am i need connection pool ?
bcs when i use cp
cy server crashes when 2 queries occur at the same time
yeah I highly recommend using HikariCP if you are using mysql
and I don't think the crash has something to do with connection pool
maybe how you use
can u come dm ?
yea hikaricp is awesome
i would probably abstract hikaricp though since i need to read configuration data
hikari has its own properties file but i would like to read it from yml instead
sure
hello, the my plugin on spigotmc if i go in https://api.spigotmc.org/legacy/update.php?resource=111796 the version is 1.1 but is 1.2
so the updateceker dont go
Cached
wtf???
.
my pc is sus??
More like cloudflare
hahahah
Well check again later today, it will have expired by then
Because the original URI is cached
There have been times where Async really helped me out personally though.
No leave your code alone
It will work for you eventually
Just wait until the cache expires
ok
Why do you use the outdated legacy API
I mean on google
Use the new API
.
https://www.spigotmc.org/threads/spigotupdatechecker-powerful-update-checker-with-only-one-line-of-code.500010/ Check the source, new API link is in the mein class
i try
@tender shard Just put the dependencies? because it says that the .jar is needed but where is it?
Help
slot 13 is in the player's inv and in the gui inv, how can I fix it
public void onClick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
if (p.hasMetadata("AflixUpgradeInv")) {
if (p.getItemInHand().getItemMeta().getCustomModelData() == 69) {
if (e.getSlot() == 13) { }```
wtf is this gif
me and my friends
just use java sockets to send packets from server A to client
@tender shard tanks it go!
maven downloads it automatically through the repository
yes yes
whne using Material.getMaterial will it look only in minecraft namespace or in every?
would this work if its on server which support forge mods as well?
so there are custom items
is their a way i can set item durability so a leather helm as the same amout as a diamond one
that depends on the other server. mohist and catserver did not even support looping over Material.values() back when I tried it last time
I'd probably use a PDC tag to store the true durability, then use some math to display it correctly to the client (e.g. if leather had 100 durability and diamond had 1000, and now it has 500 durability left, I'd make the client think it's at 50)
effort unbreaking it is
Hey, I'm coding a spigot plugin for 1.8.8.
In config lists in yaml, it doesn't properly read the permissiosns I save for my rank system because they contain dots and aren't enclosed in ''.
If i manually enclose them with '' in the config.yml, copydefaults and safeconfig just remove them on plugin enable, so they aren't enclosed in '' anymore.
How can i make spigot save these strings in '' so I can properly load them?
You should use saveDefaultConfig on enable not copy defaults
pvp
ah yeah pvp in 1.8 is just "who can spam click faster". yeah it makes sense to use it if the players aren't good enough to actually time their attacks
and parkour also. Parkour is usually done in 1.8, but ig that's mostly client side
I'm bad at combat so 1.8 was good for me, but I never PVP so I was just panic clicking to kill mobs
ranks:
default:
name: default
display-name: default
prefix: '&7'
suffix: ''
chat-color: §f
priority: 0
permission-priority: 0
allow-permissions: []
deny-permissions: []
inherits: []
allowPermissions:
- bukkit.command.help
- core.worlds.world
- essentials.help
- essentials.msg
- essentials.rtoggle
^ for example. as you can see the permissions aren't enclosed in ''
what's the problem about the missing quotes?
yea but if someone removes the default values isn't copy defaults also useful to have?
when i load them it doesn't load any permissions unless they are in ''. I think because . messes with paths
why do you even have allowPermissions and allow-permissions ?
Copy default wont readd that stuff, if they remove something and it breaks direct them to support somewhere
I'm just stupid then, i'm sry for wasting your time i didn't see that. I used a script to convert luckperms json to my config and accidentally used wrong name. Thanks for the help though. (replying to @tender shard )
np
copyDefaults() does nothing other than tell you the settings. copyDefaults(true) only adds sections if they are missing, IF you actually add some defaults.
Ah i see
after query am i need to close connection ?
Hi! I need some help implementing world guard into my plugin. When I try to build my plugin it says " package com.sk89q.worldguard does not exist ", but IntelIj was able to recognise world guard when I imported stuff from world guard to my plugin.
Before i bash my head up the wall, anyone know of open source attempts to do custom xp orbs?
did you add worldguard as a dependency?
Hi ! I'm trying to set negative amount on an itemStack but when im opening player inventory, no item is showing up, Im using spigot 1.20.1
do you use maven to build?
Why?
Im doing that to show player owned items in my shop
and preventing him to buy again, its like for UI
Yeah a negative amount aint a thing on item stacks as far as i know chief. Someone else please prove me wrong
At first I tried to, but it showed errors when I put it to my pom.xml, so I tried manually adding the jar to the external libaries and that worked, but now this error happened.
Ive already done it in 1.8 but doesn't seems to work in 1.20
Yeah i know but maybe someones already done it in 1.20
Never heard of it personally
Also do u have any idea to show player that he already bought the item ? Like a visual thing
you gotta use maven
an item in a gui
It showed errors in the pom.xml
When I tried to add it as a dependency there
I put this to my pom.xml: https://worldguard.enginehub.org/en/latest/developer/dependency/
the " Example: Configuring a Maven pom.xml "
VERSION
7.0.9
did you change this to the latest version?
yes
okay I changed the version to LATEST and i have no issue with it
but the groupid and the artifactid still shows error
yeah thats why I put LATEST
What does ```java
sign.getSide(Side.FRONT).getLines();
Return if some of the lines are empty?
I copy pasted everything here and still nothing
try 7.08
lmao it magicly fixed itself
Does an empty line return an empty string in the array?
you probably didn't reload
Like if all are empty would it be {"","","",""}
what exactly is the issue you're facing?
Trying to figure out what sign.getSide(Side.FRONT).getLines(); returns if a line is empty
it always returns an array of length 4
and you can know which one is missing since arrays are indexed
size is always 4
i still dont get the problem lol
yes?
wait huh
Deprecated
in favour of lines()
Returns:
Array of Strings containing each line of text```
mfw paper javadoc
ok so empty lines are empy strings in the array
yeah
where is our dearest paper representative
asleep
bro why do u even care its the exact same javadoc it'
it's just annotated with deprecated
i don't
and u can use java streams to get the empty lines
or just iterate through
or just check manually
Where did ur booster role go
my nitro ran out
Hello I watched this tuto to understand the plugin messages https://www.spigotmc.org/wiki/sending-a-custom-plugin-message-from-bungeecord/ but I do not understand in onPluginmessagereceiver that it expects a player. However when the message is sent by the bungee it does not specify a player if?
it uses a players connection to send the message
Damn



But is it a random player?
im pretty sure it is
How to add advancement to player without experience reward
I got something like this
When the player into the server, I print online to the database offline when out
If the player constantly rejoin the server or 100 player
Will there be too many queries in this database?
Hi i am trying to make it so player cant make a claim insde a town and a town inside of a claim. But i cant figur out how to find out if it exspands the town or are making a new one, this has much to say beacus it does take the money even tho i am cancelig it. so i am trying to give the player money back but it does not give the right amount to the player if it does create a new town
public void onTownCreate(TownPreClaimEvent event) {
Player player = event.getPlayer();
Chunk chunk = player.getLocation().getChunk();
// Check for overlapping GriefPrevention claims in the chunk
boolean hasClaim = false;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int blockX = chunk.getX() * 16 + x;
int blockZ = chunk.getZ() * 16 + z;
Location location = new Location(chunk.getWorld(), blockX, 0, blockZ);
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
if (claim != null) {
hasClaim = true;
break;
}
}
if (hasClaim) break;
}
if (hasClaim) {
event.setCancelled(true);
if (event.getTownBlock() == null) {
// New town is being created
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco give " + player.getName() + " 250000");
} else {
// Town is being resized
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco give " + player.getName() + " 25");
event.getPlayer().performCommand("town deposit 25");
}
}
}
Does use https://www.spigotmc.org/resources/towny-advanced.72694/ and https://www.spigotmc.org/resources/griefprevention.1884/ got both apis and is stuck
pls tag me 😄
?nms
hi guys, I've tryed to get player head like this:
public static ItemStack getPlayerHead(String playerName) {
ItemStack skullItem = new ItemStack(Material.PLAYER_HEAD, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta skullMeta = (SkullMeta) skullItem.getItemMeta();
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
skullMeta.setOwningPlayer(offlinePlayer);
skullItem.setItemMeta(skullMeta);
return skullItem;
}
it's working when im placing the head, but in the inventory, the head doesn't show up player's skin
Do u know how to do that ?
pretty sure u dont need to use SkullType.PLAYER.ordinal() 
not that i know/think itll have an effect that may lead to skins not showing up, but try just new ItemStack(Material.PLAYER_HEAD, 1); @dusk cipher
In computer programming, a magic number is any of the following:
A unique value with unexplained meaning or multiple occurrences which could (preferably) be replaced with a named constant
A constant numerical or text value used to identify a file format or protocol; for files, see List of file signatures
A distinctive unique value that is unlik...
Yeah, I've originaly tryed with this method but same result
weird, i have nearly the same code in my plugin (minus SkullType.PLAYER) and it works fine..
public ItemStack getHeadByOfflinePlayer(OfflinePlayer player) {
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
headMeta.setOwningPlayer(player);
head.setItemMeta(headMeta);
return head;
}```
Like the skin showing up correctly in the inventory ?
yes
maybe
idk how heads behave in offline
💀
it is 100% the problem lol
Yeah 10 players on my server and that 1 friend who doesnt want to buy the game ruin my life
boolean
true
I got a lil problem. I'm trying to get the config from the yml file and it config.get(<path>) obv returns an Object that it won't allow me to cast to Inventory though. How do I get around that?
its gotta be offline mode then
the strange behavior here is that when im placing the head, the skin show up correctly
what the boolean means ?
i dont think you can do that
use gson
well okay
abstact method with no docs 💀
i feel kinda embarresed but how do i add gson to the project?
Returns:
true if the owner was successfully set
add a type adapter for itemstack
have an object SerializedInventory or something
store the data there then serialize it with gson
and deserialize it into the object and have an adapter to convert it back to inventory
mmh so probs the Offline mode.
Thx
How would I make this work? (I'm new to SQL)
well okay ill try that
what exactly doesn't work?
also
ur uuid field
well I dont know if this works and testing it takes like an hour (more like 3 minutes each test)
why does it take 3 minutes each test what
ur uuid field is of type uuid, so I dont think u can check it against hi
bhecause the database is hosted on pterodactyl
got it
so what if it is
do u not have the credentials?
line 75 to 79
i am so confused
im trying to get a players language using mysql
EthanNetwork
nice
and its used in a bungeecord plugin messaging
private String getPlayerLanguageFromDatabase(UUID uuid) {
try {
PreparedStatement statement = connection.prepareStatement("SELECT Lang FROM Players.PlayerData WHERE UUID = " + uuid);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
return resultSet.getString("Lang");
}
} catch (Exception e) {
e.printStackTrace();
}
return "en"; // default language if not found or error
}
the query is a string
Also I just wanna know how you guys design your Listeners ?
Are you settings Listeners in concerned class, or you settings all your listeners in same Class ?
Like if you need listeners for a custom Player Class and for a Custom Mob Class How u done that ?
so should I change it to string in mysql?
but are minecraft uuids technically uuids?
alr
also @wary topaz
that's not right usage of
parameter binding i think it's called
the statement.setString
Yes but when u got lot of custom Inventory for exemple, listeners on Players Click is gonna be very very fat
for that to actually work u'd need to do something like this
statement.setString(1, uuid);```
use a dynamic listener library
separate ur listeners how u deem fit
im not sure if im allowed to say this here
but lucko has a nice helper
with a bindings system and event handling system
if u were to do this
u can
but this statement will work? PreparedStatement statement = connection.prepareStatement("SELECT Lang FROM Players.PlayerData WHERE UUID = ?");
seeing the mysql phpmyadmin setup
have ur inventory object as bindable, then when u load it u cache it and bind the listener to the inventory
Interresting.. You have a link or something ?
but yeah no u if u thonk they can benefit from using an api or service then u should absolutely recommend it
what
no gatekeeping here
bad for performance to have dynamic listeners
how so
Listeners have to be re-baked every time you add or remove
Cannot resolve method 'setString' in 'ResultSet'
i dont use bukkit event handler it sucks
true, that code is scary
have a generic listener then pass off to your own accept methods.
.toArray()
so dont even use it
have the uuid in the query string directly
u dont need the wildcard
i was just showing what that method would be for, i assumed it existed
i guess it doesn't
How u bind a listener to an itemStack ?
what are you trying to do exactly
very carefully
private String getPlayerLanguageFromDatabase(String uuid) { try { PreparedStatement statement = connection.prepareStatement("SELECT Lang FROM Players.PlayerData WHERE UUID = " + uuid); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { return resultSet.getString("Lang"); } } catch (Exception e) { e.printStackTrace(); } return "en"; // default language if not found or error }
remove the .setString u dont need it
where is the .setString
in your code
oh
The thing is that i have a lot of custom inventory for GUI purposes. And my PlayerClickEvent listener is getting fat. So how u design it properly ?
well
so this will work?
^
ah thanks
Empty string used in concatenation
A single listener and store your inventories in a map with a Consumer function
so the code works now?
i suggest u use a menu library
or make your own
what i do is
I have one methode for each inventory so I guess it's should not be hard to refactor that :), good idea
have a custom implementation of inventoryholder and in the constructor u register it in a static map, by uuid
and then you use the menu's uuid to handle clicks
there's many ways to achieve that
unless you want the Block that has the Inventory you shoudl not use the holder
every time you use InventoryHolder and getInventory it clones so much it should not be used
the file is in the jar
why would it clone
It shouldn;t but it does
really
avoid InventoryHolder
The Inventory Instance is perfect for a Map
just somethign along the lines of Map<Inventory, Consumer> or whatever you want to parse the event
cant u just extend inventory and have the consumer inside?
that doesnt really explain my question
No need, but extending Bukkit Objects is frowned upon
it literally does
read the documentation
`private void setupDatabase() {
try {
String url = "jdbc:mariadb://" + "172.18.0.1" + ":3306/Players";
String username = "*";
String password = "*";
connection = DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
e.printStackTrace();
getLogger().severe("Failed to connect to the database or load the configuration!");
}
}`
Why is this erroring?
sendthe error
17:52:46 [SEVERE] java.sql.SQLException: No suitable driver found for jdbc:mariadb://172.18.0.1:3306/Players 17:52:46 [SEVERE] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706) 17:52:46 [SEVERE] [Bungeemanager] Failed to connect to the database or load the configuration! 17:52:46 [SEVERE] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) 17:52:46 [SEVERE] at me.bungeemanager.Bungeemanager.setupDatabase(Bungeemanager.java:31) 17:52:46 [SEVERE] at me.bungeemanager.Bungeemanager.onEnable(Bungeemanager.java:21) 17:52:46 [SEVERE] at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:266) 17:52:46 [SEVERE] at net.md_5.bungee.BungeeCord.start(BungeeCord.java:295) 17:52:46 [SEVERE] at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) 17:52:46 [SEVERE] at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
looks you dont have a jdbc driver installed for mariadb
citizens supports that version I think
its in the maven?
did you shade it
i might be doing something severely wrong... i don't have maven or gradle, also no idea how to use those... damn
(use hikari cp)
`dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version> <!-- Make sure you use the latest version -->
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>`
yes citizens is paid
you can get it off jenkins for free
citizens2 is opensource
ah
its on their jenkins
they have a support discord server
set up a gradle project
or maven
spigot people say spigot is made for maven so maven
oh well, just gonna do 3 years of work in a new project again?
you need to explicitly include maven-shade-plugin in your pom.xml
i think
never used maven so idk
its on their spigot page
<dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.5.0</version> <type>maven-plugin</type> </dependency>
works
if you are on a current Spigot build use the libraries feature of plugin.yml so you don;t need to shade mariadb
you didn't register the listener
18:00:29 [SEVERE] java.sql.SQLException: No suitable driver found for jdbc:mariadb://172.18.0.1:3306/Players 18:00:29 [SEVERE] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706) 18:00:29 [SEVERE] [Bungeemanager] Failed to connect to the database or load the configuration! 18:00:29 [SEVERE] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) 18:00:29 [SEVERE] at me.bungeemanager.Bungeemanager.setupDatabase(Bungeemanager.java:31) 18:00:29 [SEVERE] at me.bungeemanager.Bungeemanager.onEnable(Bungeemanager.java:21) 18:00:29 [SEVERE] at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:266) 18:00:29 [SEVERE] at net.md_5.bungee.BungeeCord.start(BungeeCord.java:295) 18:00:29 [SEVERE] at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) 18:00:29 [SEVERE] at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
I installed the shade plugin but im still getting this error
do you Class.forName the driver
what class are u doing this in
also this should be done async and rather with a connection pool
which hikari cp provides
which extents JavaPlugin?
yes, no need to cast either object
if his ide doesn't grey up the casts then something else is wrong
you dont load the driver
no
that's not the problem
send both of your classes
the main class and the listener class
spgito
i meant rafin
the bungee only has one class
you still dont Class.forName the driver
your if is indented which makes me think you cut some code out which you are not showing us
ill brb
?paste
i knew that
move inside a freezer
get an industrial freezing room and sit inside it
yeah like in "the 100 year old who climbed out of the window and disappeared"
i got an deja vu
why is there a wikipedia page about that
because it's a book
it's a great book, can recommend
i only read minecraft guide books
i read forrest gump today, book is meh
wait i know the author
is it forest gump
MY EYES
omg
AHHHHHHHHHHHHHHHHHHHHHHH
We cannot help without the full stacktrace; Please paste it here: https://paste.md-5.net
Wtf
hello how can I make armorstend pet plugin so it will be following player using velocity?
the casts are unnecesary
theres a lot in your main class which needs removing, but the Listener looks fine
it needs optimizing so it only runs when you actually move, but the code is fine
🤦♂️
Look at it with f3
have you tried placing slabs and walking on them? Lower slab, not upper
It shows the tags in f3
@quaint mantle
public void OnMove(PlayerMoveEvent event) {
final Player player = event.getPlayer();
final Block block = player.getLocation().getBlock().getRelative(0, -1, 0);
final Material groundType = block.getType();
if (!Tag.PREVENT_MOB_SPAWNING_INSIDE.isTagged(groundType)) {
System.out.println("Block is not tagged");
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 2 * 20, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 2 * 20, 5));
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 2 * 20, 100));
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5));
}```
change ur event handler to this
and see if the print is in the console
if it is, then the material is not tagged
and then also think about optimizing this
cause this event is fired every single time the player moves
and includes pitch and yaw
i'm so stupid... i'm trying to convert my project to a maven project. i added the spigot 1.19.2 api but it can't find any of the bukkit imports anymore..
that main class is gonna mark the rest of my week 💀
and also a useful thing u can do with listener classes is
use dependency injection
from the new project?
pass ur main class as a parameter in the constructor, then inside the constructor u can do
mainClass.getPluginManager().getEventHandler().registerEvent(this, mainClass)
and in ur main class u only do new ListenerClass()
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ServerSystem-1.19</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
u dont have the spigot dependency
you need teh spigot repository and dependency in that pom
lmao okay
?maven
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
whats the best way to detect durability change
i cant find any event thats close to that
PlayerItemDamageEvent
i think its called
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ServerSystem-1.19</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
like this?
thx
cuz rn the dependency is displayed red
refresh maven