#help-development
1 messages · Page 2143 of 1
you HAVE to use the -U flag
yes it gives the error
i tried it again
maybe i try deleting the s
i added on hhtp
doesnt help
Could not find artifact com.nametagedit:nametagedit:pom:4.1.16 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
this is the whole error
This is a very simple setup. I only have kt open rn but its not that different in java:
object CombatTag {
private const val DELTA_MS = 5000
private val KEY = NamespacedKey.fromString("yourplugin:last-damage-timestamp")!!
fun getLastDamaged(player: Player): Long {
return player.persistentDataContainer[KEY, PersistentDataType.LONG] ?: 0L
}
fun setLastDamaged(player: Player) {
player.persistentDataContainer[KEY, PersistentDataType.LONG] = System.currentTimeMillis()
}
fun isInCombat(player: Player): Boolean {
return System.currentTimeMillis() - getLastDamaged(player) < DELTA_MS
}
}
oh yeah I see the reason
oo smile you're kotliner now?
their repository URL is wrong and also insecure lol
what should I used for nametags above ppls heads then
Yeah its quite neat. Still feels scripty to me but it has its benefits. And with Koin i get so much done in no time.
4.5.0 should be working fine
it works now
and tell the author to update their docs if they actually told you to use version 4.1.16
because that version is so old, they don't even have it in their repo anymore
is the package name the group id of a maven project?
no
well, most of the time they match up, I guess
you can use anything you want as group id
for example, I always use com.jeff_media as groupid (or de.jeff_media) and my package names also always start with that. but it's not a "law" that you HAVE to do it this way
my group id is me.fourteendoggo and my package name is me.fourteendoggo.xkingdoms
yeah that's fine, so your artifactId should be xkingdoms
but people do not HAVE to do it like this
for example, lombok uses "lombok" as package name but their group and artifactid is "org.projectlombok" and "lombok"
ye true
i always see that file around when i shade
it's useful if you want to include your current project as dependency in another project
but tbh I don't understand enough of this to explain WHY it's useful in this case lol
just don't worry about it lol
nametagedit didnt work @tender shard can u help use teams for players nametags
no, I can't help with that
ok
ask the author of the lib why it "didn't work"
or better explain what exactly "didn't work"
because "didnt work" is probably the most useless explanation in the history of explanations, maybe ever
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
shall i just remove it lol?
defining a path for the reduced pom version is not really very useful lol
idk lol i was folliwing the guide on the acf page
these just didnt do anything
just remove the <dependencyReducedPomLocation> part
the last one didnt hide the player nametag and the other ones didnt do anytthing either
then ask the author of that library
erm
by using List#add(T) ?
that will add it to the list, yes, BUT
it will not save it to the file
to also save it to the file again, you also have to call Plugin#saveConfig()
oh yeah you also have to do getConfig().set("my-list",myList);
sorry I forgot about that
yep
But usually you dont want to do something like this.
When the server starts -> load your whole config into classes and fields with appropriate names.
During uptime -> Use those objects
When the server stops -> save the objects back into configs
You can also save them every 15min or so just to be safe.
But please: Do not constantly read/write data to files whenever you need it.
It unnecessary, very slow and causes lag really fast if you are not careful.
and if you decide to save a file, do it async (exxept for in onDisable)
Hello all, hope you are good, I've got one question, I've this error in my log when i rightClick on my ATM, I'm using, Vault for the Economy System; ``` at fr.valdara.valdara.VaEconomy.EconomyCore.getBalance(EconomyCore.java:90) ~[?:?]
at fr.valdara.valdara.VaEconomy.BankGUI.atmClick(BankGUI.java:81) ~[?:?]``` and the error is ; ```Could not pass event PlayerInteractEvent to Valdara vBETA
org.bukkit.event.EventException: null```
?paste the whole error message
what's EconomyCore line 90?
my feeling is telling me about a npe
Full exception and then show the code from top of the stack. (EconomyCore line 90)
I think the error message told you that lol
shh
Does anyone know how I can update json files?
I'm guessing these are inside an interface?
Like you update any other files.
Simplest way: load it, change it, write it back
For very big files you can also stream it.
Gson has some utility for both methods.
?paste
okay thank you I am gonna try that
you are trying to turn "27f2b76fc14d€ sur ton compte" into a long
obviously it's a string though
Yes it's the amount of money in your bank
I doubt it
noone in the history of bank accounts ever had "27f2b76fc14d€ sur ton compte" in their bank account
because it's not a valid number lol
even the part in front of the € sign is not a valid number
Is that hex?
Even if we generous 27f2b76fc14d is not a valid number
probably
maybe it's a "crypto" currency lol
But that work until today
perhaps
no, that could have never worked
It should've never worked
they are living in the future
looks like hexcode, could still be a valid number
we are too dumb for that
Yes i know
show EconomyCore line 90
Also, this is part of an UUID
Crypto numbers look like this lol 0000000000000000000000009f8ccdafcc39f3c7d6ebf637c9151673cbc36b88
I think it generally means that the itemstack you are parsing is corrupted
YOU ARE CORRUPTED
At best you do a try-catch and dispose these invalid values
But i said that the code work until today, that return me the good money in my account, i never changed the line code Oo i won't change a code who worked, but i changed line code in an other class
Yes, but the item/block/whatever could have changed
okay what
"€ sur ton compte" <- This wont ever parse to a number
Show source code
this is the third time: Send EconomyCore line 90
he is doing UUID.fromString("what-ever-27f2b76fc14d€ sur ton compte") I assume
no, they are using Long.parseLong(someString)
Look down in the stack
Generally, you could do a substring there
How good that works is in the air though. But given that UUIDs have a strictly defined size it might just as well work
I've aded a .toString and just move next my string and that work
Why does a normal sword show an attack indicator, but my custom sword not?
what material does your custom sword have?
netherite sword?
hm then idk
I have modified the attack_speed, but even without that it doesn't show
its not really custom actually, just modifying base items with attributes and stuff
yeah sorry I have no idea lol
Well what’s the attack speed?
If it’s not showing, then it must be too fast to display
but they said "even without" changing the attack speed, it doesn't show up
Yeah well you’re mother
Not with that attitude
also if I ever had any child, I'd just let it die or sell it
its slow
does the "cooldown" thing show up when you do not change the attack speed at all?
indeed
there is some other thing that is preventing it from showing
well bruh
at first you said it doesn't show up even when you don't change the attack speed 😛
then it seems like you simply set the attack speed too high/low/whatever
?
I said the indicator didn't show up yes
the attribute is there
I can set it to the default or not modify it at all
but the attack indicator doesn't show up
I don't get it
2 minutes ago you said it does show up when you don't change the attack speed
@tender shard
Caused by: java.lang.NullPointerException: Cannot invoke "com.nametagedit.plugin.api.INametagApi.setNametag(org.bukkit.entity.Player, String, String)" because the return value of "com.nametagedit.plugin.NametagEdit.getApi()" is null
i think this the problem
-_-
im saying the same now?
the attack indicator does not show
no, now you are saying it doesn't show up anyway
2 minutes ago you said it does show up when you do not change the attributes
yeah that's the same thing as not changing the attributes
it does not show up however
How slow?
i'm out, I think we have some kind of communication problem lol
D:
I can set it to whatever using an attribute
That is not what I asked
But it works a little bit differently with attribute modifiers, believe it or not
It’s not like modifying the base attack speed of an item
Try -3
hm ok
It’s been a while since I played with it, but I recall the default attack speed being 4 and having to use negatives
Because 6 is like super fast
See? I’m a genius
yes
Never doubt me again
you are
yesterday I saw someone who had -2.415159125671 or something and they claimed that was the default value IIRC
4 is the unequipped default value I thought
But I don’t know, it’s been forever since I messed with it
Unfortunately, the lore for your items will have to be ugly
Because the naturally occurring lore cannot be set on your own
wdym
So what I usually do is hide attribute modifiers and inject my own lore
Good
I used it to check if the values were correct
hmm how would I fix that minus
probably add to the default
This is your plugin, right?
hm hm
Just get the attack speed value and subtract it from 4
Boom
That’ll get you the real value
you sure its 4?
Something like that
Does anyone know how to use NametagEdit
I think there’s an /attribute get command
yeah ill try that
See what the attack speed of a player is without holding an item
yes, the author
See? I’m a complete genius
I am leaving this discord
and I disallow any messages stating otherwise
bro idk how to contact the author
alex we could be geniuses together
yes okay
ok fine
let's do it
because
I did this
custom items with config
with abilities included
also works for armor sets
:D :D :D
shameless self promo
btw I just tried NametagEdit and it seems to be working fine
pls help me
Caused by: java.lang.NullPointerException: Cannot invoke "com.nametagedit.plugin.api.INametagApi.setNametag(org.bukkit.entity.Player, String, String)" because the return value of "com.nametagedit.plugin.NametagEdit.getApi()" is null
at com.hiprison.prisonplugin.OnJoin.onPlayerJoin(OnJoin.java:36) ~[?:?]
did you even add "NametagEdit" as "depend" in your plugin.yml?
if this works ❤️
this ensures that NametagEdit loads BEFORE your plugin does
.plugin.UnknownDependencyException: Unknown dependency NametagEdit. Please download and install NametagEdit to run this plugin.
do i need that jar in my plguins as well
you still need it in your plugins folder
even if im just using the API
aight ok
Caused by: java.lang.NullPointerException: Cannot invoke "com.nametagedit.plugin.api.INametagApi.setNametag(org.bukkit.entity.Player, String, String)" because the return value of "com.nametagedit.plugin.NametagEdit.getApi()" is null
still this
thsi gives null for some reason
did u not get this @tender shard
did you follow their guide on how to use it?
i mean for using its code
are you depending on it in your plugin.yml?
ye just did
or soft depending
doesnt fix
that's the same
probably, otherwise they would get ClassNotFoundException or similar
I think the problem is:
@radiant cedar You accidently shaded that plugin
add <scope>provided</scope>
to your <dependency>
how can you do that accidentely
for example below <version>...
yes
if this works
below he said smh
by adding the maven-shade-plugin without adding <scope>provided
doesn't matter lol
ah so it shades those who dont have a scope
See @hexed hatch ? I'm officially a "dady" now
Ayo, does anyone have any idea how to check if what damages you is not a player?
in what event?
EntityDamageEntity
you can get the "damager"/attacker and then just check if it's "instanceof Player"
if (e.getDamager() instanceof Player p) {
yeah
And
if (e.getEntity() instanceof Player p) {
This is the player that is damaged
The problem is that it is registering mobs as the damagers and the targets ( the ones who get damaged )
I ain't got any solution so anyone wanna help out?
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if(event.getDamager() instanceof Player) {
// The attacker is a player
} else {
// The attacker is not a player
}
}
Oh flk
Ok thx
What is the best way to check if a string value is in a comma separated stringlist in mysql? (string,string2) and need to know of string2 is in: true. And need to know if string3 is in: false
wdym with "need to know of string2 is in: true"?
That should return true
I want to check if string2 is in the list, that should return true. If I do the same check for another string it should return false
.. But it is in a database, and need a query
String list = "firstString,secondString,thirdString";
String[] split = list.split(",");
for(String string : split) {
if(string.equals("thirdString")) {
// "thirdString" is inside the list
}
}
Any android developers here?
You cannot just query parts of a string
you have to get the full string, then check it yourself
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I can't share my question here.
why not?
that won't work
Why not?
because it would return true for "thirdString" if your list looks like this:
firstString,secondStringthirdString,somethingElse
yuh
atho I never worked w/kotlin in android
only java
when that was still cool
Oh yeah
Then I would put a , in front and the end?
then it won't work for the first and last string in your list
You are a weird breed. Write spigot plugins in kt and android apps in java...
... Why is this so hard
just get the full db entry and then use String.split as I said 😛
lol ye
But the database will be big. That takes time
My solution would be to get rid of the db
in-memory storage is a viable option these days
Where to save it then?
But after closing theplugin?
if the db is so big that you cannot query it anymore, you have done something wrong anyway
And restarting it is lost
Write to disk
No that is not the problem
Especially with ObjectOutputStream (don't) it is pretty easy to write data to something
Yes
That being said, if I am getting you right, checking if there is a value in such a string does not take that long
especially if you work with #startsWith and #indexOf
The most expensive thing in java is object allocation, but this does not require any object allocations (except getting the string from the db)
you know what's even more expensive?
There are a bunch of more expsive things, but object allocation is underrated
the most expensive thing is buying a "java management service" subscription
oracle is greedy
what the hell is that
I don't know but it's very expensive lol
they don't name any prices so it's safe to assume that it's very expensive lol
it is aimed at companies however
my company is always in the red numbers lol
Perhaps you shouldn't give out stuff for free?
hi, i can get this package ? org.bikkit.craftbukkit.v1_12_R1.block
well I pay money to myself ofc
NMS is forbidden.
but if the company would have green numbers, there'd be double tax
if a company has green numbers, they're doing sth wrong in germany
yes
run buildtools for 1.12 and then use spigot instead of spigot-api as dependency
and how convert org.bikkit.craftbukkit.v1_12_R1.block.CraftBlockState to org.bukkit.block.BLockState
you don't. they are operationally the same
First is the Implementation, second is the API Interface
CraftBlockState implements BlockState
no need to "convert" it back to it's interface
but how fix this? org.bikkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to org.bukkit.block.Banner
don't cast something to a banner that isn't actually a banner
Banner is interface extends of BlockState from org.bukkit.block
so that is why lufthansa has a 10 billion dollar deficit
It has to BE a Banner before you can cast it
on this position is a banner block
well LH is an "Aktiengesellschaft", it's a bit different for them compared to my tiny GbR lol
an AG is supposed to actually have green numbers unless you want to scam all the shareholders too
I only worked with small companies that "only" want to scam the tax authorities
Material.STANDING_BANNER is not a Material.BANNER ?
no
obviously not, but both blocks should implement Banner nonetheless
Hi there, is it possible to store PDC directly into a block ? I would like when i click on a block to store in this specific block the Uuid of the player, so when another player click on the block that return a message blablabla.. ?
no
Nope. Only TileEntities have PDCs.
BUT @prime kraken you can abuse the chunk's PDC to basically get the same result: https://link.jeff-media.com/customblockdata-spigot
What you can do is store data in the chunk the block is located in
You could store in the Chunk PDC, the location of the Block and the Player
categoryGui category = new categoryGui("Blocks", fixmc);
player.openInventory(category.getInventory());
ConfigurationSection blocks = config.getConfigurationSection("shop.blocks");
//ConfigurationSection food = config.getConfigurationSection("shop.food");
for (String key : blocks.getKeys(false)) {
System.out.println("Block name: " + key + ", display: " + config.getString("shop.blocks." + key));
player.sendMessage("Block name: " + key + ", display: " + config.getString("shop.blocks." + key));
}
isnt sending anything
Thanks you i will check that !
btw if you're going to use my library: it stores the data directly to that "coordinate". so if for example a piston pushes the block that has data, you will have to manually "move" the data to the new block, too
I will use your library but it's for make an housing system like when i click if the door is to nobody, i buy it and no other people can open the door
but i'm asking that is door work with that
it'll work with any block, no matter if it's a door, or stone, or air
Nice, I will check how to use and try that ! thanks 😉
np! it's extremely easy to use:
PersistentDataContainer customBlockData = new CustomBlockData(block, plugin);
just create a new instance of "CustomBlockData" and provide the block and your plugin
Omg so easy x)
how can i remove an arrays value
didn't you already ask this yesterday?
i actually tried your method
They tend to ask the same question pretty often
my method works fine
At some point it just gets tiring
yeah...
Not easily. Use a List instead
IIRC they only need to remove the first element of an array
Oh so that is what they meant
https://paste.md-5.net/picagujihi.cpp i made it like this
First is easy, others not so
you call that "more basic"?
that's like twice the size of the code that I sent you
lemme try it again
also why are you calling arraycopy twice o0
you could have just used the method that I sent
public static <T> T[] shiftArray(T[] original) {
if(original.length == 0) return original;
T[] shifted = (T[]) Array.newInstance(original.getClass().getComponentType(),original.length-1);
if(shifted.length == 0) return shifted;
System.arraycopy(original, 1, shifted, 0, shifted.length);
return shifted;
}
the first one is a NOP anyways
just use this, it works 100% fine
it's a decent name imho lol
@tender shard did i have to serialize with just the name of the player with your api ?
huh what
I have no idea what you're talking about lol
and i have don't idea how to explain lmao
do you want to store a "player" inside a PDC?
I recommend using UUIDs
I have another lib that adds new datatypes, for example UUID. Then you can just store the player's UUID: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
Okay i will check that so
DataType.UUID
yeah that of course also works
what class is this in
Bukkit#sendTitle or something like that
Player#sendTitle
Ah, close enough
ty
where "Players" is of course Bukkit.getOnlinePlayers()
nice but i use, your first library for the block bcs you said that it used the location, did this library used too ?
Well, it becomes a bigger challenge once you want to send it to dead players too
you can just use both libraries, they work fine together
I'ts removing the first element but when i use String.join It still sends.
oh nice so thanks u
?paste your code
Remember that it does not modify the original array
yeah it returns a new array
It just modifies the returned array
arrays are immutable anyway
you cannot change the size of existing arrays
they do
To protect against certain kinds of errors
dead players are removed from the Online P{layers list
whut?
but their Player object is valid
getOnlinePlayers() always returns all online players, doesn't it?
no
This is news to me
if a player is dead they will not be in there
perhaps, not too sure
Ah yes i just realized, i was pasting the strings to the join ty.
Could also just be a QoL decision by the bukkit devs
how would you run a console command in a specific world?
Bukkit.getOnlinePlayers() also includes dead players
everything would make no sense anyway
um, it didn;t a year ago
Interesting that they changed it
@Override
public void onEnable() {
Bukkit.getScheduler().runTaskTimer(this, () -> {
Bukkit.broadcastMessage("Online Players: " + Bukkit.getOnlinePlayers().size());
}, 1, 1);
}
But good to know that this behaviour does no longer apply
I highly doubt that it was different at ANY time tbh
It was, there was a big discussion in trhis channel about it
Thank god
I deeply remember someone having issues with this behaviour a long time ago
We found it odd back then, but accepted it as we all tested it.
does anyone remember the version where this happened?
I'd really love to try it out
probably 1.16.5
very weird lol
wow spigot takes soooo long to start
bump
Starting is okay, stopping is the real deal
It takes like 5 minutes to stop last time I tried
for example, take a command, take X coords of a world and make it run in that world
On an newly created server that is
I call bullshit
on 1.16.5 it also works fine
Bukkit.getOnlinePlayers() always returns ALL online players, regardless of whether they are dead or not, in both 1.18.2 and latest 1.16.5
I just tested 1.18.2 and they are included
it works fine in 1.16.5 too
Yeh it does now and should, but back then it didn;t
hm maybe it was changed in a specific build in 1.16.5
Yeah, that is likely
but at least in latest 1.16.5, it works fine
Given that there are a few months left until the release of 1.17 where it could have changed
I just read back over the conversation. its in the respawn event that the player is no longer in the OnlinePlayers
this was his code ```java
public void respawn(PlayerRespawnEvent event){
Collection<? extends Player> players = event.getPlayer().getServer().getOnlinePlayers();
event.getPlayer().getServer().broadcastMessage(String.valueOf(players.size()));
}```
yep
Wait
We checked his results, saw it did show zero players and that was that. We didn;t investigate further
Hi, is there a way to override base item attributes ? I tried setting a hoe to 0.2 attack speed, but it adds it instead of overwriting, so the attack speed stays 4.
Yep I just tested and it's not all dead players. It's players in the PlayerRespawnEvent are not included in OnlinePlayers
oooh okay, very weird
We just assumed it was all dead players
Good to know what really happened then
lol I just googled the doctor my bf went to a few months ago
the women is the doctor
now I wonder whether the old dude is her husband or just a patient lol
is that your IP in the lower corner?
no that's the website's IP
my IPs are 2A02:908:D70:A60:704B:D8C7:895C:8CAE and 5.147.144.118
huh
how can I suppress typo warnings?
I think typo is not a warning
well I'll turn it off in intelliJ settings then, thx anyways
weird solution but ok lol
😃
I would simply add that word to the dictionary
yeah but that's annoying
I gotta add each word when writing in my language
it sux
@SuppressWarnings("SpellCheckingInspection")
why? you disabled it lmao
got em all 😎
same
niice
but its useless
jff i guess
I was just reading this thread
https://www.spigotmc.org/threads/how-to-cross-server-communication.407298/
but fancy confetti when typing
cool
Gonna ask a question now😂
lol ik jk
?ask faster
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
So I'm working on a plugin where I need to keep track of players stats as well as their "score" which is like a currency
I'm on mobile so i cant format properly
Cyz
Cya
I'd like admins to be able to reset theor stats and whatnot
Problem comes up when they are not online and may be on another server
It'll reset on one server at set it in the db being used but on the other server where the player is online, it'll still have the stats thatbwere loaded originally
Is it okay to use plugin messages to update the stats?
Like to tell the other servers what changes were made?
i would use redis for that
since you can also cache that data over several servers
instead for each
Yeah ibsaw that in the thread but not all servers have redis
I guess for servers that want to use the plugin with bungee redis must be used?
sounded like your own server at first
My bad
well then PMC should be fine
Why some anottations are still on code when they only are need when coding?
Right now all changes to stats are being done with addition/subtraction only so being out of sync isn't much of an issue except for what is being displayed
?
You have some alternatives:
First and better one use Redis
Use a non blocking library
but with that scenario: why would an admin or whatever chose to reset the score of a player which is on another server
When doing global timers on secoreboard?
🤔
player stats
you probably return false
For server help you have #help-server
oh ye
a third party which fails quietly instead of waiting
if a server doesnt have any players on it and a PM is sent, it will wait for players before actually receiving the PM
A non blocking library is part of networking which allow non blocking is the communication between many devices
Hi, how can i remove my player from my PDC when he leave ? I use an api who put PDC directly into the block
elaborate a bit more please
I use the API of mfnalex who able me to put in a block, a PDC, here the player name. In my event, when i click on the block, if there are no player in, i put the player with the pdc like door.set(new NamespacedKey(plugin, "playerName"), PersistentDataType.STRING, p.getName()); and i made a condition when if there is a player in that return the player blablabla.. I just want to know how can i delete the player name in the block when he leave the server
Wait you should never save data with name, always use UUID
Ok, to hard for me i don't know how to do that but i will search thanks
Because name can change, uuid is unique
Yes but no importance if i remove the player name when he leaves ?
Are you trolling?
i just ask
I told you never use use name as key, always UUID
Because if user change the name data goes directly to trash
In other words he lost his data...
shop:
blocks:
0:
material: GRASS_BLOCK
itemName: §7Grass Block
price:
buy: 10
sell: 5
1:
material: DIRT_BLOCK
itemName: §7Dirt Block
price:
buy: 5
sell: 2
food:
0:
material: COOKED_BEEF
itemName: §6Cooked Beef
price:
buy: 1
sell: 1
@prime kraken pls do not DM me. I've unblocked you again now but please do not send DMs again. I get so many DMs, it gets annoying
challenge accepted
Yes of course, but i don't want to store his data when he leave here, i want to delete, nvm i don't know how to explain that, if the player leaves the server, have a "door" wich is like a house is not important, and i don't want to restore them after
That what happen when you have many open souce libraries
yes sorry dude didn't thinks about that when i did
no problem, just don't do it again pls lol
afaik the only way to do it is through packets. Lemme find the old code I have
ohh ok thx man
Firstly the player will need to have full mining fatigue so they can't actually break the block. You'll then manually send the progress of block breaking and when the block actually breaks for them.
You can use ProtocolLib to listen to PacketType.Play.Client.BLOCK_DIG. From its data you can get the PacketPlayInBlockDig.EnumPlayerDigType and then the important flags ur gonna want from that are START_DESTROY_BLOCK and ABORT_DESTROY_BLOCK.
When handling the packet, you need to store if the player is breaking x block and then send the progress throughout breaking said block. You can notify progress with the PacketPlayOutBlockBreakAnimation packet.
I have my DMs disabled, sorry. You can ask it here tho
should i downloads java 16 or 17 for mc 1.17.1?
Yh me and someone else for a server we never released.
17
ohh ok
17, 16 is EOL
its like custom textures stuff like that??
and whats EOL?
It's not since we were making it 1.8 compatible, so it uses vanilla textures, but it still has custom breaking speeds.
end of life. It no longer receives updates.
ohh ok
It shouldn't be that hard to identify what block they're breaking then identify that type of block is that position.
End of life
k
lol
Isn't eclipse temurin Adoptium?
i think ye
wait maybe its a better idea to install java17 for the whole system
i only got 11 dont ask me why
java 17 doesn't add anything useful anyway imho
it makes no sense for me to require java 17
java 7 or java 8, yes those versions really added useful stuff
don't tell me that they have added 9 new java versions for no reason
wtf is internet saying how do i install it by commandline
J17 has a few APIs, but no large scale APIs that one would miss like .readAllBytes
Ehat
well there isn't really anything useful that was added since java 8 imho
maybe records, but tbh they can be easily recreated anyway
maybe some performance imporovements?
Which one
I like Records
i like them too but lombok's @Data does the same thing and has more customization
I really dislike Lombok
same
Oh ok
I don't, it's useful and it doesn't have any disadvantage
also the logo is a pepperoni
and everyone loves pepperonis
requires special Maven settings to compile. Has to be installed in yoru IDE which causes it to take forever to load
nope
does for me
it doesn't require anything except adding it as dependency
also requires a <annotationProcessorPaths>
err
sec, there was a maven thing, just not that
public FileConfiguration getShopConfig() {
if (shopConfig == null) {
try {
reloadCustomConfig();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return shopConfig;
}
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
this is all that's needed
but there are some disadvantages
do it lol
startup speed was my main issue though
none of that is needed except for the dependency
Lombok seems to disagree with you
I always just add lombok to <depdendencies> with scope "provided" and that's it
idk which one your asking for
no idea why they say the "annotationProcessorPaths". maybe that's needed for weird IDEs like eclipse
IntelliJ definitely doesn't require it and compiling it with maven from CLI also works fine without it
Possibly, but as I use Eclipse 😉
hm well anyway. I still don't think that having to add something to your pom.xml makes the library itself shitty 😄
Didn't say it was shitty. I just don;t like it
okay fair enough
I also dislike certain things without a proper reason lol
e.g. kotlin
I just think the syntax is ugly
so I don't like it
I've never used Kotlin but I already dislike it for teh same reasons I dislike .Net
Nice to see you again
can I somehow get list of plugins that use a certain plugin as the dependency?
mye believe thru PluginDescriptionFile, no?
u2 :3
Oh you dont have photo
yup
How do I get the raw string from a TextComponent ?
.getText()
wait, I mean Comopnent
using the ChatEvent of paper
event.message() gives me the Component
can I cast it ? or is there another way
thanks! i'll try
Adventure probably has a dedicated method for this I assume
But if the component serializer does the job, there is no reason to not use the serializer
yeah
PaperComponents::plainTextSerializer just delegates https://jd.adventure.kyori.net/text-serializer-plain/4.10.1/net/kyori/adventure/text/serializer/plain/PlainComponentSerializer.html#plain()
or maybe not
but sth like that
Does remapped mojang 1.16.5 not exist?
1.16.5 used spigot mappings are tuntime and not reobfuscated spigot mappings
So theres no mojang mappings?
I mean, mappings exist for 1.16.5 but spigot did not use them
RIP
Mojmap exists since 1.14.2 or so
How can I use them?
wait lynx, I must ask, does paper use this singleton or does it create a new instance(in case you're aware)
paper exposes its own plain text serializer
iirc there is a PR open to use adventures service registry to inject our version, but right now the paper plain text serializer is available at https://papermc.io/javadocs/paper/1.18/io/papermc/paper/text/PaperComponents.html#plainTextSerializer()
declaration: package: io.papermc.paper.text, class: PaperComponents
ah fair enough thanks for the insight 👍
Yea so PaperComponents.plainTextSerializer does not delegate
mainly because it properly flattens translatables
tho why are people asking questions about paper in spigot 🤔
ah that makes sense
🙌
public class Spawners {
public int amount;
public int amounts;
public void spawnItems(World world, ItemStack item, Location loc, Material material, int max) {
for (Entity entity : world.getNearbyEntities(loc, 2, 2, 2)) {
if (entity instanceof Item) {
Item entitysItem = (Item) entity;
if (entitysItem.getItemStack().getType() == material) {
amount = entitysItem.getItemStack().getAmount();
amounts += amount;
}
}
}
if (amounts <= max) {
world.dropItem(loc, item).setUnlimitedLifetime(true);
}
amounts = 0;
}
}
Can you help me please with this?
When i try to setUnlimitedLifeTime, this is Marked red and says "Cannot resolve method 'setUnlimitedLifetime' in 'Item'" but when i put in a variable with an Itemstack, the code works fine, does someone know, how i can fix it?
Sounds like a problem with your IDE.
Btw: Dont make amount and amounts public.
Dont ever make any fields public for that matter.
okay
there are instances where you can make fields public, but usually that is only for constants or immutable states
do you know how to fix the problem?
?jd-s
You are most probably just using an old spigot version as a dependency
I'd do world.dropItem(loc, item, x -> x.setUnlimitedLifetime(true)); but really it is the same thing
i´m using spigot 1.18.2
Also for building?
Show your pom or build.gradle
forgot to adjust to
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
it was ```java
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
thank you for helping👍
I mean they do as most other crowdin projects
set up the set of translations that needs translates
once they complete 1 language they deploy
they use a similar system to adventure I believe
translatable components
but they're still translated server side
perhaps
wym so I wonder
they have to be translated server sided
I am trying to remove an entity while it is unloaded. I put "setRemoveWhenFarAway()" to true because I need it to be, now I cant get rid of it when disabling the plugin. Anyone know a solution?
I mean you can still use packets
^
There is not much you can do besides disabling persistence for that mob.
This way it doesnt get saved when its being unloaded.
ur probs asleep, it works so ty
just curious, apart from players logging out what events do i listen for? i know you mentioned entity deaths but i dont think they'd exist anymore unless you mean i should clear them from the maps that they're contained in withrelease?
and what is the despawn event
damn ok
might just tag it with something in its pdc in order to remove it on a 5 second timer
Every event that removes an entity from memory. Mostly despawn, death, chunk unload and disconnect
would this be harsh on performance or nah
im not too sure how to measure performance impacts tbh
But if the plugin is disabled then the PDC will have no meaning
disabling to me means onDisable()
is there a method to find out in which direction the player looks?for example North, South, West, East
Everything scales O(1) in the code ive sent. So it doesnt matter if you have 10 or 100 people online.
You can measure performance by using a profiler like spark or timings v2
so the chance of the plugin being enabled again after is fairly high
What are you even trying to do?
u r a king ty 👑
I have a boss mob which I want to keep there until it is killed or the plugin is disabled.
I set the mobs removeWhenFarAway to false in order to keep it there and tag it with some special tags in its scoreboardtags and PDC so that I can identify it. I save the mob inside a list aswell so that I can access it later.
Now onDisable() I am turning on the setRemoveWhenFarAway(), doing entity.remove() and teleporting it to y -100.
None of this actually gets rid of the mob when I reload the server while I am far away, so the mob spawns during onEnable() and now I have 2 of them
If the mob gets out of reach (for example when its being unloaded with a chunk) then the entity in your List is worthless.
so I pretty much have to run a timer which removes all mobs I tag for removal as they are duplicates?
No that would be horrible
every 5 seconds wouldnt be that bad, would it?
Why dont you just work with events?
ChunkLoadEvent -> get all entities -> check if one is your custom mob -> if yes you remove it.
Hi there, is that possible to access to my PlayerInteractEvent contents in my PlayerQuitEvent, the events are in the same class
As long as the List doesnt contain entities.
it contains livingEntities
Dont hold hard references to spigot objects
What do you mean? This awfully sounds like you will be hit with a "learn ..." soon.
may I?
😈 do what you must
?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.
lol
possible? yes. viable? perhaps. does it make sense? no
In order to balance out all the time I spend coding I came up with this awesome time management idea. For every line of code I write I can play 1 hour of video games
so I write 1 line and play 1 hour of video games
perfectly balanced
its called playtesting 😛
a couple more quick questions. are an Entities ScoreboardTags() secure enough to store a little data in? do those tags get removed in any way? (other than other plugins of course) They persist through reloads and restarts, right?
The tags are persistent. Its good for one thing: taggin. I wouldnt exactly store data in it.
Data as in tags which (probably) only your own plugin would use, so you can identify tagged entities with them
Yes like in "BOSS_MOB"
ok thanks 😄
in an EntityDamageByEntity event - if damage cause is projectile, how do i get the damager?
event.getEntity().getShooter()
no
?
You need to cast that is
cast to what
projectile
if (event.getDamager() instanceof Projectile projectile) { projectile.getShooter()```
depends on the java version youre using of course, but yeah
if its an older one I believe that syntax is not accepted
whats Projectile projectile
Java 15/16? creates a local variable called projectile
can i get the consolecommandsender of a subserver with bungeecord?
just ignore that and check for instanceof Projectile, then cast like you always would
The alternative would be
Entity e = event.getDamager();
if (e instanceof Projectile) {
Projectile = (Projectile) e;
ProjectileSource shooterSrc = projectile.getShooter();
if (shooterSrc instanceof Entity) {
Entity shooterEntity = (Entity) shooterEntity;
}
}
I think it was J15
is it possible to short this code that I have not to have four times the same code ```java
public static void SetSpawners(CommandSender sender, String team) {
Player player = (Player) sender;
int X = player.getLocation().getBlock().getX();
int Y = player.getLocation().getBlock().getY();
int Z = player.getLocation().getBlock().getZ();
Location loc = new Location(world, X,Y,Z);
BedWars.instance.getConfig().set(team, loc);
if (team == "Red") {
Basen.BaseRedLoc = loc;
return;
}
if (team == "Green") {
Basen.BaseGreenLoc = loc;
return;
}
if (team == "Blue") {
Basen.BaseBlueLoc = loc;
return;
}
if (team == "Yellow") {
Basen.BaseYellowLoc = loc;
return;
}
}
loc = player.getLocation().clone();
^
probably doesn;t need clone unless you are in a movement event
unless you do not want floating-point numbers, in that case it becomes more complex
switch (team){
case "Red":
Basen.BaseRedLoc = loc;
break;
case "Green":
Basen.BaseGreenLoc = loc;
break;
case "Blue":
Basen.BaseBlueLoc = loc;
break;
case "Yellow":
Basen.BaseYellowLoc = loc;
break;
}```
switch case, do not compare strings with ==, variables can stack
or if you really need it to the block corner coords loc = player.getLocation().getBlock().getLocation(); I think
or use if (team.equals("Red")){
okay, thank you very much
like that
after looking at the source code of some plugins, they seem to use Lists.newArrayList() a lot, instead of new ArrayList<>(). Is there any actual reason for this or is it just preference? Lists.newArrayList() is a single line method that returns new ArrayList() (no <>)
if (team.equals("Red")) {
Basen.BaseRedLoc = loc;
} else if (team.equals("Green")) {
Basen.BaseGreenLoc = loc;
} else if (team.equals("Blue")) {
Basen.BaseBlueLoc = loc;
} else if (team.equals("Yellow")) {
Basen.BaseYellowLoc = loc;
}
switch case :angry_pepe:
This code is shorter
is there a method to get ConsoleCommandSender to a subserver from BungeeCord knowing his name?
switch is fine. lots of is else is ugly 😦
nope
uh, ok
you could send a bmc packet and tell it to do stuff with that
but that requires players online
so you might opt for redis instead if you have access to it
Or just open a side-channel connection
Just some fancy words for creating a TCP Connection
a boolean is a person from the planet bool
would the code work like this (onCommand cases and handing over)?
https://pastebin.com/CDnY0Gkq
yellow, blue, red and green are going to execute exactly the same thing, identical data, is that what you intend?
looks fine
okay, thank you guys
bump
yes
there's less of a reason now
but basically decoupling creation and instantiation
(before it also inferred types passed to type params)
I rarely if ever used that method
what was the point in decoupling them?
if instantiation changes, creation does necessarily not get affected
which can save you from recompiling entire modules by feeble changes
so it was created to prepare for changes made to new ArrayList<>()?
They probably did not intent on changing the constructor
And they certainly do not anymore considering that it hasn't been deprecated for ages
as said not an intent
but thats the static factory pattern for you
I assume the only real reason to use that method is the absence of the diamond operator, but these days (for a decade or more now) it does exist
How do you compile 1.18 mc plugin?
alright, thank you both
a tuto please im annoyed
step 1: install java
There are 4 ways of doing this that I know of, so you have to be more specific there
step 0: buy a computer
Probably 6 if you consider JDT, IJ and Netbeans are seperate
This deployment Java tutorial describes development and deployment of applets, Java Web Start applications, rich Internet applications, and JAR related tools
So first of all, what build tool is this plugin using?
Im using Maven for building
mvn package
I only have on pc Java and JDK 8 installed
Then install maven and invoke mvn clean install
I already done, but then the server shit that im using old java version
🤡
That was my face lmao
newer mc versions require java 16 i believe
So do i need to install JAva 16 for compiling?
yes
Use J18 to prevent doing this again for 1.19
yea
although java 17+ is broken on gradle
doesnt really mater tho since ur using maven
java 17 is broken on gradle since when ?
My big issue is that i hve a multi module maven project, which contains a common module, plugin 1.12.2 module and plugin 1.18 module. So i dont know how to compile each module with diff java version
gradle being gradle
gradle properly supports java 17
Only recent gradle
idk, whenever i tried to use java 17 on gradle it said something like "java 17+ is not supported go back to 16"
maybe my version was outdated
you mean not legacy gradle
gl updating it then
what you do you mean good luck xD
gradle updates take ages tho
This happens when I try to run this code
public void attemptBotCreation(){
new BukkitRunnable() {
@Override
public void run() {
if(bot != null){
bot.restart();
return;
}
//System.out.println(getConfig().getString("token"));
try{
bot = new Bot(getConfig().getString("token"));
getLogger().info("Bot has successfully been created!");
}
catch (LoginException | IllegalArgumentException | InterruptedException e) {
getLogger().log(Level.SEVERE, "Cannot start bot due to invalid/missing token. Please check the config.yml");
e.printStackTrace();
}
}
}.runTaskAsynchronously(this);
}
In fact this my issue
error goes away when I comment out the try/catch
You have to downgradle java first in order to update gradle
by default you do not have to do anything
He?
As long as you build with an up-to-date JRE/JDK, it will be able to automatically compile even with newer java versions
Worst case you'd have to specify sourceVersion & targetVersion or release
whats on line 23 of DiscordServerPanel?
Because the common module contains common things for 1.12x and 1.18x plugin module, so if i compile it with java 8 plugin 1.18x said old version, but its if i compile it with java 18 plugin 1.12x said me using a recent version
So its too much shity
show us the bot class
You can set the version on a per-module basis you know
LOL?
I'm going to try something that I think will fix it if not I'll go back and show ya
Not even specific on intellij website
This is common knowledge
intellij invented coding
(And that guys is why I use recaf as my IDE \s)