#help-development
1 messages · Page 929 of 1
tf is that code
what is setLock in Chest class? What kind of lock?
Represents a block (usually a container) that may be locked. When a lock is active an item with a name corresponding to the key will be required to open this block.
hm
i mean, it looks like it should work. could also be, that something is null or whatever and he is just not looking at the console
he should def debug since we can only wild guess
Yeah that's definitely it
And the code is way to dense to understand quickly a thing
yep
Only solution here is some debugging
And maybe a CTRL + Alt + L
what does that do
Reformat and Rearrange on IntelliJ
You should really stop hopping in and out of streams like that.
It gets confusing. You could do all of hat in a single stream. But i recommend splitting this into multiple methods for readability.
Also: Very important to not use single letter variables.
p ftw

i remember all the old spigot tutorials using e and p as variable names
Well with small methods its not really an issue
My naming can get quite explicit at times. But it just helps me understand my code every time i read it without having to use comments
I use single letters all the time but not if i have too many variables lol
Or if the variable comes from a parent class
Naming well your variables usually avoid the necessity of using comments
should be always descriptive imo
if i get back to a project after a year i dont wanna have to guess what q is
besides qs, qr, k, l and p
Especially in a 100 line method at the bottom
My life consists of solely streams and single letter variables
I find myself wasting too much time thinking of variable names
You will get that back in with the time you waste thinking about what the code does
Just give them names like we do people. You know have an object named bob
not me writing a plugin to auto complete variable names to people on here
I am on another level, I started this up again after a few days identical to the way I left it off
double frostalf = Math.min(7smile7, GodCipher);
No thinking I know exactly what everything does
I essentially have a signature on my code because of how unique it is
"looks like code from of0.." "how did you know?" "because its bad"
Because it intentionally goes out of it's way to use streams over regular loops
Thats fine, but then dont jump in and out of streams
You are hurting your performance a lot with that because the pipeline cant heat up
And you are creating a ton of objects that need to be collected for no reason by the GC
Example?
and how would I fix that
Internally there is some over head with streams as it needs a buffer. Jumping in and out just duplicates this over head
The array stream is immutable
Send me your code in text form and ill show you
Everything?
Whole method
Being immutable is not relevant to a stream needing a buffer internally.
?paste
?paste
If you have more than maybe 30 lines in a single method, then its time to split your code up
A lot
It was split up but the cancelled event wasn't working in adjacent methods
I learned at least 90% of my java by example
The other 1% was from a class I took in school
I guess you also learned maths in this school
At least
I said
I learned how to make a loop to repeat a string because the online compiler ran java 8 and there was no string.repeat(times);
Still working on that. Its quite a handfull to refactor without an IDE...
why isn't the inventory updating of the chest?
I'm using getInventory() because there isnt setInventory, there is only setBlockInventory or something like that
Remove the chest.update(true);
If the average danger level of your armor pieces is too high, one random piece should be dropped, right?
Why not drop the piece with the highest danger level?
That's the way my client wanted it
I made this as my very first plugin because we found ourselves rewriting it in skript too often
?paste
if i add return false; to a command it wont send usage right
yeah
yeah
cries in 40 line long method
how do i broadcast a message to players in specific world
since Bukkit.broadcastMessage is deprecated
what?
Use a custom permission. This method will broadcast to users with the specified perm.
declaration: package: org.bukkit, class: Bukkit
Anyone know what Error code 1 for Buildtools means?
It means it failed succesfully
Jk. Try clearing out the buildtools directory except for the jar and restart fresh.
If still failing may help if you use the paste site and show the build log
how do i do the in world part
loop over the world's players
okay cool sounds like smth im too lazy to do
You can dynamically give players permissions. So listen for world change event. Then give them the perm. Use said perm in the method i linked here.
is there suck a thing as default permission?
ion mind shit gettin broadcasted everywhere
The permission things is way harder to realize ahah
looping over players is so easy how can you even be lazy of that ?
because ive never done that
Well they wanted a broadcast message. The only method that would work for what they want is the one i linked above
Oh I think it just fixed itself wierd... Not complaining too much tho.
Yay, sometimes that happens too lmao
for(Player player: world.getPlayers()) {
player.sendMessage("nyaa uwu mrrp~ :3");
}
Isn't broadcast short for looping over players and checking permission before sending ?
Now that makes sense, I'm still stuck in older versions it has been a lonnnnnng time I haven't touched mc
What alex showed, wouldnt appear as a broadcast but as a message from server
Yeah in older versions the method i linked above doesnt exist and you either have to mess with packets for a true broadcast or just use server messages lol
How do they represent that in the game ?
It shows on top of the chat area as red and is prefixed automatically with the world broadcast
Oh that's interesting. I didn't know they added this feature
Finally a readable chat (for some servers)
Its been there forever like almost near the beginning of mc
Then came the second broadcast channel
Which is for players joining and dying etc
Which is similar to server messages. Server messages are prefixed with the word server
How did I never noticed that ahah
Probably because the api removed the prefix when you send players messages if i recall
And only notice server messages when you use say at the terminal lol
Thanks for this explaination
if(m.containsValue(damageEvent.getDamager().getName())){
m.get(damageEvent.getDamager().getName()) += damageEvent.getDamage();
}
so im tryna sum doubles in map M
Map<String, Double> m = new HashMap<String, Double>();
but im not doing smt right
:(
First: use UUIDs instead of player names
Second: You should make some check to be sure the damager is not null, that it's a player.
Third: Map#get returns a value and not a reference, you need to use the method Map#set to change the value of the map
so if i make a new sum variable
where i put current value and add onto the new value
and put it back in?
that wasnt a question im sorry ugh my english lacking
if(m.containsKey(damageEvent.getDamager().getName())){
Double sum = m.get(damageEvent.getDamager().getName()) + damageEvent.getDamage();
m.put(damageEvent.getDamager().getName(), sum);
}
like this?
or no thats gonna create a new entry
or will it
ig ill do the try it and see method
map.merge(damageEvent.getDamager().getName(), damageEvent.getDamage(), Double::sum);
thanks
question of dilemma. Should exceptions be created when there is no harm to the logic? But the user will not know the result
Exceptions could be used to jump in the code. It's also meant for that so ofc !
i no need to jump in code
Stopping the code earlier is a kind of jump
that's not the problem
exception stuff should typically not be used to handle actual logic but usually just when something goes- or is done wrong
is that what you're asking
For example, deleting data, if the data is present, then delete it or? Ignoring it will not result in an error. This is the crux of the matter
this is a good read https://blog.jeff-media.com/dont-jump-off-bridges-or-why-you-shouldnt-use-exceptions-to-control-code-flow/
Exceptions are a wonderful thing. They can let your code recover from unexpected situations in a nice and clean way, if you use them properly. That does not mean that you should always rely on them though. For example, imagine this: Most highways have guardrails in the middle to avoid cars going into oncoming traffic....
@upper hazel
they are fine to use there in as the name sais "exceptional sitations"
for example if data doesnt exist i woulnt throw an exception
if a query cannot be completed for some reason on the other hand i would
There are many kind of uses of Exceptions. And sometimes it could be useful to use exceptions especially for efficiency (for instance to stop an algorithm before it does it all).
But those case should be handled carefully (basically if you are the own creating and using the exceptions, it's totally fine)
exceptions should only ever be thrown if your programming logic can't decide in what to do about some other input you don't have much control over. For example, take the relationship of spigot server and plugins. There are some things the server could do but then the server is invoking control over the plugins or making decisions that otherwise the developer may not want to have happened. So instead you throw exceptions to let it be known that something did or did not happen but the parent application doesn't know how it should be handled and thus you are allowing the next thing in line to handle it instead if it can. Throwing exceptions is only beneficial for other things or other applications and debugging, but not necessarily to your application itself because exceptions should always be handled where ever possible and following that logic it makes no sense to throw exceptions just so you can handle it yourself.
exit(0xAAAAA)
How can I customize the hover player name? I mean on top of the player
you cant with the spigot api, there is a way around it tho
it takes more effort tho
i can tell you if you want
Well, with modern spigot display entities work well for that
yes, thats what i was going for, it isnt possible by just player.setname or something
thats what i meant by not "possible"
Depends on how much you want to customize it
You can add prefix and suffix with teams
And you can change the player name text color
just that yeah, there is any guide?
Yeah, no, they appear inside the player head and you can't translate it otherwise it goes ballistic
Are there any good FoxSpigot developers?
If so DM me
Me when <name>Spigot doesn’t use the normal Spigot API and requires special knowledge
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
what is the best solution to block player from entering certain area
There are two ways:
- Listen to the PlayerMoveEvent
- Use a scheduler to run and check position every tick
which is better
depends how much "checking" you have to do
Send barrier blocks to the client
additionally you can check using code in a repeating loop
yeah maybe you can check if player is near area every idk x sec and if its true start task every tick
someone can help me? error: 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type ```java
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.animal.EntityBee;
import net.minecraft.world.level.World;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.entity.Bee;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
public class BeePet extends EntityBee {
public BeePet(EntityTypes<? extends EntityBee> entitytypes, World world) {
super(entitytypes, world);
}
private void spawnBee(Location location, Player owner) {
Bee bee = (Bee) location.getWorld().spawnEntity(location, EntityType.BEE);
String customName = "§6Méhecske §8(§7" + owner.getName() + "§8)";
bee.setCustomName(customName);
bee.setCustomNameVisible(true);
bee.setAI(true);
bee.setSilent(true);
bee.setCanPickupItems(false);
bee.setInvulnerable(true);
bee.setMetadata("owner", new FixedMetadataValue(this, owner.getUniqueId().toString()));
}
}
Use Mojang mappings
Like we told you to yesterday
but i dont know
If you're going to ask for help don't ignore what we say
I need a help.
I purchased a 24 GB RAM paid hosing though.
I will send my requirements here for plugins.
If u guys help me to find bestest plugins for server. It may Premium or Free. I prefer free more . But if u think premium one is better than free then plz plz plzz suggest.
I will appreciate.
Ask in #help-server
just use maven to compile, it's something out of your control
or use the remapped spigot
Try it and see
But I think it also depends on the characters
What about W or M
Yep
Yep
It should specify "up to 798, depending on the characters" ig
Docs are incorrect ye, it was recently fixed so the limit uses vanilla limits.
Do we have the Font class on the server side? Or whatever tf it was called
@EventHandler
public void trySword(PlayerInteractEvent event) {
if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
if (event.getItem() != null && event.getItem().getType().equals(Material.WOOD_HOE)) {
if (event.getItem().getDurability() == 16) {
Snowball snowball = event.getPlayer().launchProjectile(Snowball.class);//org.bukkit.event.EventException: null
snowball.setMetadata("ballType", new FixedMetadataValue(SumeruRpg.plugin, "custom"));
}
}
}
}
@EventHandler
public void catchSword(ProjectileLaunchEvent e) {
Player p = (Player) e.getEntity().getShooter();
if (e.getEntity().getType().equals(EntityType.SNOWBALL) && e.getEntity().getMetadata("ballType").get(0).asString().equals("custom")) {// java.lang.IndexOutOfBoundsException: Index: 0
}
}
```why?
when i try to compile, it says "newPosition < 0: (-1 < 0)"
it's very weird, it only happens if "config.yml" in resources is named "config.yml" and if it has any text
here's config.yml
randomX: 0.1
randomY: 0.05
randomZ: 0.1
text:
basetext: "&c{damage}"
crittext: "&c✧{damage}"```
i tried restarting my ide
how to make it so that it code executes a method every 15mis?
Bukkit.getScheduler().runTaskTimer(plugin, this::method, 0L, 20L);
this executes this.method every 20 ticks (1 second)
for async timer just do runTaskTimerAsynchronously
alr
what does async timer do
it's like a clock, runs the code every ? ticks
if it's async it runs it outside of the main thread, it's helpful to make it lag less but sometimes it's not recommended
someone can help me whats next to a PathFinderGoal? ``` private void spawnBee(Location location, Player owner) {
Bee bee = (Bee) location.getWorld().spawnEntity(location, EntityType.BEE);
String customName = "§6Méhecske §8(§7" + owner.getName() + "§8)";
bee.setCustomName(customName);
bee.setCustomNameVisible(true);
bee.setAI(true);
bee.setSilent(true);
bee.setCanPickupItems(false);
bee.setInvulnerable(true);
bee.setMetadata("owner", new FixedMetadataValue(this, owner.getUniqueId().toString()));
CraftEntity craftEntity = (CraftEntity) bee;
net.minecraft.world.entity.Entity nmsEntity = craftEntity.getHandle();
EntityCreature creature = (EntityCreature) nmsEntity;
}
}
}
hey do you guys know a lot about plugins and stuff?
🫡
for implement a librarie i have to implement the jar file of the plugin right?
you implement it in maven and then you can use the methods
i updated maven plugins and still 'newPosition < 0: (-1 < 0)'
i'm having problem by implementing the librarie of crackshot can you gave to me an hand?
?
can you show a custom toast notification?
add a custom achievement and complete it
Found a plugin that does this
Alrightt
how u guys can send photo and not me
should i use the new text display or the og armor stand method?
A. Best Anti-Cheat plugin to block Meteor and also to block
other hacks.
B. Best Anti-Redstone plugin to prevent crash.
C. Best Anti-Dupe plugin
D. Best Anti-Exploit plugin
E. Best Plugins for: -
- Custom Enchantments
-
Shop -
Auction -
Job -
NPC -
Money note -
Cosmetics -
Mobs -
Kits -
In-Chat Reaction, Puzzles - Chat
- Prevent Curse words
- Custom tools
- Crates
- Vouchers
- Manage timed Ranks
- Manage limited time any commands (ex.= /fly)
- For Gui of Multiverse.
- Level up, Playtime Gui and reward system.
- Lobby, Hub, Jumping Pads
These are my Plugins requirements.
If all of u guys help me to suggest me the best plugins .
I will very very appriciate you .
@chrome beacon And specially you broo plz
I am sendingg there ... plzz help mee
yaaaa i put .... thmmm .... I buy spartan and put .....
I need other plugins also ... SO , i just send
TNT dupe ... and carpet dupee and what about others
1.20.1
these r all patched
woooo huuuuu ......
why the bot showing .... Command not found when i try to verify
are you typing !verify name
yesss ...
but i need to remove my these id
!verify
Usage: !verify <forums username>
how do I set the metadata for this which I will handle in projectilelaunchevent and projectilehitevent player.launchProjectile(Snowball.class);
setmetadata does not work after launchprojectile
scoreboard tag or persistent data container for quick data?
data that stays for ~15 seconds
PDC
For the PlayerEvent, I see two constructors, one requires the player, the other wants the player and true or false for being async.
So my question is if the PlayerEvent is default Asynchronous or Synchronous, or do you have to use the boolean parameter to make it Async?
Hopefully I asked that clearly.
For context, I am extending the class and making my own event and I want to make sure it's Async as it will be called multiple times at once.
i think the playerevent has that so events that extend from this can define themselves
you dont listen to the playervent
oh i didnt read everything sorry
pretty sure PlayerEvent does not have a constructor like that
the Event class does have a contructor taking a boolean though
any constructors like that without one assume your event is synchronous
This is the constructors; That's how I came about with the question.
public abstract class PlayerEvent extends Event {
protected Player player;
public PlayerEvent(@NotNull final Player who) {
player = who;
}
PlayerEvent(@NotNull final Player who, boolean async) {
super(async);
player = who;
}
}
its odd that thats not documented here https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerEvent.html
declaration: package: org.bukkit.event.player, class: PlayerEvent
Oh I just saw this, okay, so I would need to use the constructor to define it to be async.
jup
Interesting. I wonder as to why they don't just have one constructor and make you just define it?
just do super(player, async)
That's what I am going for sense I need it async haha
well make sure u take these things into account @half bluff
basically some events are sometimes called async, I think AsyncPlayerPreLoginEvent and AsyncPlayerChatEvent are two decent examples, (well any event prefixed Async), however if a plugin simulates a player to chat non async, then the AsyncPlayerChatEvent is fired synchronously, which is why that variable "needed"
is there a slower PlayerAttemptPickupListener? i'm cancelling the event and sending a messgae, it's sending 1 message a tick which is pretty fast and spams the player's chat
you can impl a cooldown
Btw if you only want a single player being able to pickup the item, then you give it an owner tag.
This prevents the event from being fired in the first place.
scoreboard tag?
owner tag?
oh
declaration: package: org.bukkit.entity, interface: Item
That's a good pointer actually.
My dilemma currently is if I do two different actions at once, one succeds and the other does not. It's not until I stop the succeeded action that the second action then succeeds on triggering my event.
Currently it's just using the constructor passing the player parameter, which is why I am thinking that specifying the Async to true would resolve the issues given the "Simultaneously" capability on async.
ic, but can i make it send a message when they try to pick it up
I wonder what the owner tag is used for in vanilla
Simply prevents other players from picking it up
I mean yeah but where
Probably just used as a tool for map makers
iirc its used in the /give command when the senders inv is full
then it drops the stack binds owner to sender
pretty sure there's a method like getAsBukkit
or smth
public static Block getBukkitBlock(net.minecraft.server.BlockEntity nmsBlockEntity) {
net.minecraft.server.World nmsWorld = nmsBlockEntity.getWorld();
World bukkitWorld = Bukkit.getWorld(nmsWorld.getUID());
int x = nmsBlockEntity.getPosition().getX();
int y = nmsBlockEntity.getPosition().getY();
int z = nmsBlockEntity.getPosition().getZ();
return bukkitWorld.getBlockAt(x, y, z);
}``` u can try smth like this
Should I set my plugin price to 19.99 GBP instead of 19.99 USD to maximize profits?
Bluds are limiting the pricing of plugins 😭
As if that hasn't been a restriction since the start of premium resources like more than a decade ago
This isn't a surprise lol
20$ for a plugin is kinda crazy
they prob dont want 100$ plugins or smth
Why is section null?
what does it look like in config
what about the one on the server
also you probably need to wrap the one in quotes
why do you capitalize Rewards, it's gonna kill me
ooh
fuck
i'm so dumb
if that doesnt work print out rewards.getConfig().getValues
The problem was that I had a wrong sub-section lol
nvm is solved now thanks
Is it possible for a client to modify their PlayerLoginEvent.getHostname() to anything they want?
can someone remind me how to pass from async back to sync
yeah
I believe so
would scheduling a task inside of the sync task using getScheduler#runTask() do it?
If you mean inside the async task then should be a yes
oh wait I'm dumb
I forgot to cover one of the if statements
that's why it's not working
What is PrepareItemCraftEvent, doesn't have a description?
And what event could I use for when a player crafts an item
Ok what event could I use for when the item is picked up
guys how do i stop blockupdates, for example a flower getting destroyed by water, or a floating flower being destroyed cuz no block under it?
Hello how I can get in a PlayerInterractEvent if the player shift right click ?
Check if the player is sneaking
You can't
Ok thx
if you mean sprinting by this, you can player.isSprinting();
There's events for this. BlockChangeEvent etc. Have a look in one of my projects, there's many block update events used you may wanna also use
(yep the map reset is not yet region based, was just a temporary thing)
thank you for providing this ressource, i will have a look :)
Maybe just cancel the events that fire when these things happen
i dont know of an event that handles this
BlockFromToEvent fires when a torch or something similar is destroyed by water or lava.
And maybe BlockPhysicsEvent does something similar with blocks changing states
In Bukkit, the BlockPhysicsEvent is an event that is called when Minecraft physics affect a block, such as when a block is updated due to changes in its surroundings.
nice
thanks
Hi, i wanna make a Server with my friends with some custom Weapons which can only be crafted once. I am trying to figure out how to send a message in the chat when the custom weapon got crafted like: (username) has just crafted (weapon name). Can anyone help me?
I asked the same thing here, can't find any event for when an item is crafted
Should be CraftItemEvent
Ok thanks
Ok idk how I didn't see that earlier
HI everyone! New with the spigot/bukkit api. For a high-level overview, I am working at creating an rpg system (just for fun and the experience of doing it). I want to save data to the character and I see most people doing this by storing player values etc in either a database or in a YAML file. Would a database be better for storing and dynamically updating experience / levels / stats etc? Or is this something I should be adding to a player save file (that I would create and store locally on the server). Any general recommendations on handling this task?
well I think for starters its wise to write an abstraction over whatever storage system you're picking, since it becomes easy to change later on
if you can afford it, I think a database is of huge beneficence
That's what I was curious about. I was thinking of just releasing this for people to use. Not for my own benefit or servers etc. If its a database connection, I could see how expensive that could get overtime by making continuous calls. Which is why I am asking what is more practical to do.
well there are many ways to limit resources to the database, if you're afraid of too many connections considered a connection pool such as hikaricp (a java lib), else there is other ways to limit it by using a semaphore for example.
Why didnt i think of that -__
and ofc its a given that you probably aim to save the data async more or less
I was looking at more of an Async setup originally
So that way, the plugin has less chances of losing data.
well async more means that u're able to do the data saving (and potentially loading) without blocking other code that needs to be executed
Yep! Running concurrently along with the process.
That gives me some ideas to work with, thanks!.
Hey what is delay and period in runTaskTimer again?
delay is a delay between periods?
period means interval
period is how much time it takes?
and delay is basically initial delay
ohh I see thanks Conclube the Dog
yeah, there are some fairly good open source projects you could look at, I think a classical one is LuckPerms, look at the common module, in the storage and model package specifically iirc
I totally forgot about LuckPerms. Thats even more wonderful to share. Thank you.
I need to create a thirst system, how do I go about doing this?
create a list of every player and their thirst then every tick check if they are too low?
then i set the thirst level with an event that runs when food goes down
Relating to the inventory drag event's getNewItems() method: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryDragEvent.html#getNewItems()
I'd like to ask, will all the items within this list be the same "type"? As in, will there ever be a scenario where the player drags both a stick and a piece of paper into the inventory?
I'm wondering whether I need to check each item within the method, or if I only need to check the first one.
declaration: package: org.bukkit.event.inventory, class: InventoryDragEvent
If you're using an event for this, perhaps a hash map would be better? You could possibly use the players as the key, and then their thirst level as the value?
yeah I have this
public class ThirstSystem {
private final Map<UUID, Integer> playerThirsts = new HashMap<>();
public void addPlayer(Player player) {
playerThirsts.put(player.getUniqueId(), getPlayerThirstLevel(player));
}
public int getPlayerThirstLevel(Player player) {
if (playerThirsts.containsKey(player.getUniqueId())) {
return playerThirsts.get(player.getUniqueId());
}
return NBTEditor.getInt(player, "thirstLevel");
}
public void removePlayer(Player player, int thirstLevel) {
NBTEditor.set(player, thirstLevel, "thirstLevel");
playerThirsts.remove(player.getUniqueId());
}
}```
but sets say i want to give nausea to players under 20% thirst
ig i do it on the setPlayerThirst level
Anyone know a plugin for giving time limited permission of /fly or smth like this
You could set a cron job for something like that to remove the fly permission you have
i wouldn't use a cron job, aren't those like added to the system? why not just a timer
depends on how long
cron is just a timer
thats what i meant at least lol
since i see them the same, sorry.
Two options here I can think of:
First would be to use a bukkit runnable to repeatedly check all player's thirst level, and act based on that.
Second option would be to check the given player returns whenever the lose hunger event is fired, and apply nausea then.
yeah i was going to do the first then i realized the second one makes more sense
Wooooo wooo ... yesss I just need that timer type plugin ...
Wait i will explain u ...
I will make a voucher that calls 5 mint Fly Voucher
And it gives permisssion to players to fly only for 5 mints after that they need to earn
idk i could be wrong but i was doing something in javascript and i wanted to run a function every 10 minutes, even if i stopped the script the code would still run because at least 1 job was scheduled before i stopped the script
https://www.spigotmc.org/resources/command-timer.24141/ I think this would work
Thankss thankss a lot ... I am checking it
if player duplicates an item through anvil, is PDC transferred or not
Item don't tend to duplicate via anvils
Even if it did, a duplicate would also duplicate whatever values it had. So it would have a similar PDC?
Yes ™️
yes ™️
alrightly
easy test is to just throw lore at the item
see if lore transfers
and that usually means the PDC also is kept
can I check if the foodLevel went up or down?
because i dont want the thirst to go up if they eat food
i jsut want it to go down if they are running and using energy
FoodLevelChangeEvent
it just says what it is
not what it was
or rrrrr
will the player's food level be different
IF you use that as a EventHandler
it will run whenever it changes
or are you just trying to check randomly?
that would be really inefficent
we have listeners for a reason
Thats my point ^
i just want thirst to go down around 2x the rate of food, so if i jsut set the thirst level to go down if food changes then we good
or actually exhaustion would be better right?
If you are trying to check for the food level
you need to use FoodLevelChangeEvent
then do checks in there
if it goes up / down
If a player eats something, that will run.
same if it goes down.
but the event.getFoodLevel will be different than player.getFoodLevel
so i can see which changed?
?jd-s
How can I send a "message" (like tell a thing needs to happen) from bungeecord plugin to spigot plugin?
cache it?
this is on event
using plugin messaging api is one option
"should be set to"
HashMap<Player,int(PreviousFoodLevel))
That sounds good, can you give me some more explanation for that
yeah but he wants to get the previous one too
though it does have the drawback of requiring at least a single player online on the spigot server
so he can see if it went down or up
if u can work with that it will work fine
actually tbh i dont even need the food level
yeah but u need to know if it went down
My plugin should be perfectly compatible for that.
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ documentation here.
the only way is to compare previous and new one
and to do that you need to cache the old one
which is fairly simple
1 hashmap is all it takes
really what i need is exhaustion level but there are no events for that
i dont even play mc how does exhaustion work? from what i can tell when you do actions and stuff like sprint and punch it removes a small amount from it, but when it hits 0 it removes a food level but resets exhaustion?
Exhaustion is just when foodlevel == 0?
So you are looking to track the values of each action?
Exhaustion? Is that the little gray bar appleskin adds
Sorry, would someone mind helping me with this? I don't mean to request twice!
probably saturation
It's impossible to drag more than 1 item at a time between inventories
or at all
Alright, good to know. Wasn't sure if there would have been any edge cases there then. So, just to confirm, all item stacks within the returned map will be the same "type"?
As in, they will all have the material Paper, or all have the material oak_planks, or they'll all have the same display name etc?
Yeah it will be an item that was dragged
presented as ItemStack so you can get the full data
Alright. I wasn't sure if it may have been possible for the player to drag multiple different "types" of items over multiple slots or not.
Thanks a lot! That answers my question :)
I realised this is probably better to do without messaging things.
I want to give a player a map in Bungeecord (I can't that's why I'm making a spigot plugin thing for that). I want to disable the "standalone plugin" if it detects that the plugin is also in Bungeecord. Then just do the map thing. And if it's not installed on Bungeecord, the plugin will do the same thing as if it would be on Bungeecord but without extra bungeecord things. Also if you know how I can give items in Bungeecord, that would be awesome.
Also if there's a better way to do that please let me know
I'm pretty sure you can't give items on the bungeecord unless you have some communication with the backend server
Test it out, loop through the Map on the drag event and see what it prints out :)
yea you can't give items thruh bungeecord, whats wrong with your original approach of using bungee messaging?
To be honest, I'm not 100% sure how I'd even go about dragging multiple item types lol, so wasn't sure if there was some edge case I wasn't aware of. I guess we'll just roll with it and wait for a null pointer exception to appear one day :P
Well, I would use it for the other part, but how do I check if the plugin is running under Bungeecord and the plugin is also installed there?
how do I tell IntelliJ that I don't use gradle?
Like I deleted all gradle files
but it still indexes it at start-up
oh.. yeah.
even tho I don't use it in any way
Could happen though, if you double left click on one item in the inventory? I guess that's drag event as well, but they're all the same type also, they're probably split into different ItemStacks based on the slots..
Ooh thanks so much for checking that for me! I'll have to do a bit of further testing then in that case. Thanks so much for all the help!
I'm confused
I just once created a module with gradle and deleted it later on
but now it thinks that I use it
The wiki page doesn't tell how to listen in bungeecord or how to send one from bungeecord
but of course 😄
any1 knows if i can create ghost items with the spigot api?
or does it require packets?
ghost items?
items t hat the player can see that dont actually exist server side
yeaa you are prolly going to have to fiddle with packets for that one
OCP........
😔
my new favorite principle is actually dependency injection 🤓
my favourite DI method is putting things in a public static field and accessing it whenever I need it anywhere
my favorite thing is to drink coffee and smoke while preparing to code
firing up intellij...
and then procrastinating untill its time to sleep
telling my cat to move away from my keyboard..
😂
where do i get a cat like yours?
you cant its impossible my cat is the smartest and prettiest
btw is this your cat in your profile pic? 😂
no sadly not
i'd like to have one tho
like yours or the one in my pfp
your cat is so beautiful
cats are cute tho
that's how they get you at first
did... you not know about autoindents?
java.lang.NullPointerException: Cannot invoke "....sendPluginMessage(...)" because "player" is null
what did I say
argh
can I send without a player?
A player needs to be online for plugin messages to work
can i register commands like that?
i want to have different classes for each command
does this one work? ^
okay this one should work
mhm
what about the question
i know
yea but i can with arguments
but then i need to do all my commands in one class
you need to handle the arguments in the command executor
is there some alternative
the command is just arenaprotection
i know but i have two executors
command frameworks or have some Map<String, CommandExecutor> in the arenaprotection command and handle that there
maybe
map the argument to the executor
map reload to reloadcommand, map bypass to bypasscommand, etc
then just get by the argument and execute accordingly
im actually trying to "command reload" and "command bypass"
?
onCommand
how can i execute the commandexecutor
Just run method
how
executor.onCommand(blah blah)
what does that code do
i dont understand
the exact same way you call any other method in abyb other class
it calls the method
so.
if the argument is "reload"
executor.onCommand("command reload")?
no
class CoolCommand implements CommandExecutor {
Map<String, CommandExecutor> subcommands = new HashMap
public boolean onCommand(whtaever the parameters are) {
if (args.length == 0) {
sender.sendMessage("you stink");
return false;
}
subcommands.get(args[0]).onCommand(sender, args, idk);
}
}
....
in that map
there is some other commandExecutor class right?
how do you execute that class in that onCommand?
a
very much pseudocode, you should null check to see if it's a valid subcommand etc
and add the subcommands you want to handle to the map as well
and then in your onEnable just getCommand("cool").setExecutor(new CoolCommand())
What's the point of making plugins have all commands in the plugin.yml instead of registering it directly with all the shit? Is it something left over from the ancient days or what
there's a PR open for that, creating commands at runtime
oh discord cdn is back alive
i mean it depends
if the command holds state then you'll want to reuse the same instance
ideally it wouldn't
Why do we need to implement that so late
better late than never
command holds state? wdym
True
by having them in a map you don't need to check the argument
if (arg.equals("reload")) callreload
else if arg.equals("something") callsomething
etc
yea but
that's ugly
if theres not the command in map
player will get help message
and help message is ugly
but its easier
hm
i mean what else are you gonna do if you don't have a command in your if-else chain?
would it cause problems if i pass current onCommand's parameters to the executor?
it's fine but you'd have to be aware of the implications of that in the subcommand, e.g. args[0] is the subcommand name and not the argument following the subcommand
for the rest it's fine
i can just remove the label from command?
you can get fancier and better by introducing your own command interface, something like
interface SubCommand {
void execute(CommandSender sender, Queue<String> args);
}
less parameters that you don't need and you could pop args out of the queue before passing to the subcommand
but this aproach is fine
i only need to add the commandexecutors to the map in onenable right?
you can add them anytime but that's fine
dont expose that executors shit
wdym
map
its changed a lot since 1.8; theres no current good way to create an actual fully custom tab list without having a billion mental breakdowns, so you're better off using Player#sendPlayerListHeaderFooter
with a library like packetevents, you can hide all regular players and create fake players (only in the tab list)
or you can rely on another tab library
Is it possible to somehow remove the glow of an item’s enchantment?
not for items
wdym
i dont think thats possible
((
You would have to remove all the enchantments and re-add them with lore
Client side only
Or wait for 1.20.5
1.20.5 is gonna be really fun for resourcepack stuff
isnt that the new multi resourcepack thing
That is in 1.20.4
is there a link to see what changes come with 1.20.5?
Cookies are meh
The client controls them so you can't store anything important in them
yeah
Okay so I'm working with someone on a github repository and whenever we merge the project, i get this:
<<<<<<< HEAD```, how do I fix the HEAD?
And why does it keep appearing?
that is a merge conflict
you should try using e.g. the intellij conflict viewer
makes it a lot easire to visualise everything
Oh okay, thanks, i'll try that right now and see how it works.
?paste
if you say you have a script containing something, we need to know what it contains
also
where are you registering the command
well
we need to know what the sword class has
no
commands auto register to the main class, unless registered elsewhere
you need to implement CommandExecutor and call JavaPlugin#getCommand#setExecutor
wait what!??
he doe snot
okay i didnt know that
log errors?
it is null then
send us your sword class
onEnable?
you ned to use constructors
onEnable and onDisable are only for plugins
is BlockFormEvent the right event to be using when trying to detect copper block changing
if I already have an EntityDeathEvent listener in my code, is it going to be better if I just make a new PlayerDeathEvent listener, or just add an event.getEntity instanceof Player in my EntityDeathListener?
makes no huge difference as long as you exclude players in the entity death event
can you send the class
because then you didnt do it properly
^^
is there any difference between ignoreCancelled = true and !event.isCancelled()?
lmao
ImmutableLists does not exist
idk you use chatgpt for a lot of stuff.
List.of instead
its a guava dependency
why would you use it
or well, google commons
How is that type not deprecated
List.of has existed for like
an eternity
Well, I guess java 9. My poor java 8 compatibility

oh no java 8
who can help me? look, I created velocity, grief, hub, downloaded java 11 for grief and hub 8 java for minecraft, 17 for velocity, but I have a question: how to set the path to java? please help
just fully define the path to the java binary
disgusting
exhaustion level is what im looking for. since there is no event for when it changes what can i do? check every tick???
instead of using java as command, use e.g. C:\Program Files\Java\bin\java (idk the exact path, just a guess)
windows server????
probably windows
but just used to host, im not gonna assume they use windows server
appdata?
java.exe
im pretty sure it was program files
@echo off
java -Xms512M -Xmx512M -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -jar velocity.jar
pause Please respond to the text how to create the path to Java 17
most use adoptium
we just told you
you will need to read and learn
and find your JRE
I found mine JRE
adoptium is C:\Program Files\Eclipse Adoptium\
or escape it
?whereami
@echo off
java "C:\Program Files\Java\jdk-17" -Xms512M -Xmx512M -XX:+UseG1GC -XX:G1HeapRegionSize=4M -XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled -XX:+AlwaysPreTouch -jar velocity.jar
pause ?
Do you understand that it’s difficult for me to understand you because I don’t know English and the CIS countries and I communicate through a relay?
how can i see what spigot version something was added in?
thanks guys I did it, good luck to you
i want to use this but it's not in 1.12.2
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityExhaustionEvent.html
i dont see why they wouldn't have it
sigh @since tags. my beloved
Unfortunately not available.
Poor darthmango being used as a bad example
https://helpch.at/docs/1.19.1/org/bukkit/event/entity/EntityExhaustionEvent.html
this is the oldest version with it
why wouldn't it exist in older versions
Because no one contributed towards it before then.
no backport?
Spigot doesn't backport features. Never has.
The only exception to this was the security fix for the Log4J vulnerability
just the event class?
or, upgrade
not my server, server runs on 1.12.2
does a snake game need a Continue to continue from your last save? or is that pointless
pointless
but if you want to create it as a challenge then it could be a good idea
pointless? I want to continue from apple 40569675909345 ofc.
Not really. But you should keep it reasonable
That's not reasonable.
XD
Especially for public plugins. That data stays even when your plugin gets deleted
1 tb of data
Therefore it uses all the memory without being of use
i'm joking, I guess around 120 bytes is alright?
yes
how can i check the region at player? i arleady imported world guard api, i can't find nothing on google plz help
Hello, can I find someone who will make me a plugin using gpt chat? Please, I need it for a server for my friends and I don't know how to make them
you mean all regions at a location?
yeah, the region the player is standing in
public Set<ProtectedRegion> getRegionsAtLocation(Location loc) {
ApplicableRegionSet regionSet = regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));
return regionSet.getRegions();
}
at "regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));" the "regionQuery" is red
Yup that's part of the api.
regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
regionQuery = regionContainer.createQuery();
But I can send you that piece of code, too
omg its all reed D:
im new to spigot plugin development, that's why
Do you know basic java?
yup
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
Then here's all the imports you might need for the code above. Add them to your class and then assign the data types to regionContainer and regionQuery
okay tysm
Haters would tell you to use a wildcard import instead
Personal preference
I dislike *
Haters would be wrong
i couldnt find anything online, how would i leash 2 entities together?
Can you explain that a little bit more?
i have 2 locations and i wanna create a leash between those 2 but ^ will probably help
Hey, so for some reason I got Duplicate entry error while trying to replace a data in sql database, from my understanding, REPLACE INTO will delete and insert a new one if there is already a row with the same exact unique key, but it throws an error this time anyone know why?
Code and errors: https://paste.md-5.net/bosepetizo.cs
@eternal night look at what you could be getting
I have it in my bookmarks 😊
You’re the bestest
I have you in my bookmarks
alongside all the other docs sites that show up in auto complete anyway

yes
I prefer the Yatopia docs
I always preferred Coll1234567 docs site
Ah the infamous Coll1234567 spigot fork
Whenever I am coding, I always have it open in my browser
It reads my mind whenever I need something browser automatically switches to it
lol
Yep, just keep em running in the background
lollll
?jd-s my first guess would be interactEvent
How can I send a player a message using the selection sign for colors? I have a lengthy method that I do not plan on refactoring for a single use
does the & symbol work?
for wat
if you translate the color codes yes
I recommend \u00A7 instead of the ampersand. But everyone has their own tastes
intellij recommends converting it
Yeah that is all good and all until some moron uses a different encoding
Which is the main (if not only) argument for the ampersand pretty much
But you can safely use § in source code for as long as you know what you are doing
My strings are all usually in translation files so I'll use & please
how do i check when any item is added to a player's inventory without looping all players every second or smth (if that's possible)
Do you consider checking if item is added through another plugin or /give ? Or is it just getting drops and from inventories?
including /give
I'm scared you would have to loop among every player's inventories
theres an item pick up event, idk any others rn
?jd-s
You'd need to intercept all inventory manipulation method which plainly speaking cannot easily be done
Or you can maybe hook to the method that is responsible for adding an item to the CraftPlayer inventory (don't do that)
not directly possible
you need to listen to multiple events
you can check out my ItemLimiter Plugin on GitHub which should have all of them
Its called InventoryCap
whats the best way to get plugin ideas
yeeeeeeeeeeeah no
what's the best way to make a "scripting language" like skript (i dont want to make smth like skript)
that would take more time than the actual plugin in my head rn
well what is your intention
i want to make a custom enchants plugin where you can code your own enchants or use premade enchants
You can make thats with a confif too
use a config language
yaml?
Yes
what if they want to for example
set the player's health
there r MANY cases of what they would want to do
You dont needs cusrom objects Take a Look at @icy beacon custom enchsnrs
i literally get tens of ideas for plugins but they all require a custom language
No
https://www.spigotmc.org/resources/⭐-underscoreenchants-⭐-create-custom-enchantments-2-guis-⚡.97002/
You can create a config and read IT to create enchants on runtime
well the thing is
i have to make the actions
from scratch ._.
there r like 260 methods in player class or smth
Isnt that what a plugin is about? Making Something from scratch
well yeah, but 260...
And you dont need to implement all
This really depends on how much control you want the user to have.
The most extensive examples are MythicMobs and SkillAPI
you dont have to implement all 260 player methods
just create some wrapper methods for actions you think will be used
ok
Is there a way to attach an event to an item stack or entity without havingto call it in one of your event class?
I wouldnt go that deep. Enchantments dont have to be stateful. You need to break them down.
An enchantment has:
- A trigger
- A target
- An action
Example, an enchantment for flaming attacks:
Trigger: ATTACK_PLAYER
Target: ENEMY
Actions:
- Damage{5.0}
- Particle{ENEMY, Flames, 1}
Trigger can also tbe block breaks, interactions, etc.
You just need to design rules which targets are available and how to evaluate different parameters.
Delegation, is what you need i think
the issue is the trigger and the action
Why
there r hundreds
Nope, you need to build a custom system for that
Thanks ill take a look
Smile He wants the Thing you showes me before
One listener calling events in all the objects of an interface
Those are MM triggers
do i just make those
I would not
Those triggers are mostly mob specific
You need to create a list of all triggers you want to have for yourself
ok, last thing
some triggers can have outputs
like player damage
and you can set stuff
Wdym?
like they might want to increase damage
Btw creating a plugin like that is pretty much a magnum opus.
Only tackle it if you are very experienced.
I know that this would take me weeks and a bit of planing.
Action.DAMAGE
Thats simply an action
ok
The thing you are looking for was used in a tut
?gui
This one here used the concept you are looking for
Was already questioning if I could wrap entity/itemstack In class with a listener interface
No dont do that
Dont Register a listener per item
You want ONE listener calling all the objects that might want to have this Event rn
Thats Delegation
Yea that's what I meant, like the gui tutorial
Yes
English is hard, I'll try to be more clear next time
Okay, is english Not Ur native languafe?
It isn't
Ok
typically native english speakers don't say english is hard
Oo
The plugin you were discussing is just like my underscoreenchants 😄
so enchants that are the opposite of over scored?
or are they enchants that are underwhelming ?
custom enchants are fairly easy to impl
🤔
I did it at work in like 20 min
all fun and games until you get to the actual logic of like
swords can only have XYZ
And anvil merging
rest is too simple
pretty sure you can apply any enchants you want to items, just some of them just won't do anything
My style is just naming everything Underscore something
The custom enchantments just as a concept are easy. When you start expanding on it is when it gets difficult
Should I?
Let it exist https://discord.gg/bBge7bj3ra
Hello do you know how I can get a block behind another block ?
if(((TextComponent) sign.line(2)).content().startsWith("§7Stock")) {
Player seller = Bukkit.getPlayer(String.valueOf(((TextComponent) sign.line(3)).content().replace("§b","")));
Material material = Material.getMaterial(((TextComponent) sign.line(3)).content());
int price = Integer.parseInt(((TextComponent) sign.line(3)).content().replace("§7Prix: §e", ""));
int stock = Integer.parseInt(((TextComponent) sign.line(2)).content().replace("§7Stock: §e", ""));
if(event.getAction() == Action.LEFT_CLICK_BLOCK ){
if(stock > 1){
if(KingdomShop.econ.getBalance(player) >= price){
sign.line(2, Component.text("§7Stock: §e" + (stock - 1)));
sign.update();
player.getInventory().addItem(new ItemStack(material, 1));
//Here I want to get the barrel behind the sign
I konw I can use blockFace but if i put a barrel on the left of the sign he can get It and I only want the block behind
grab the block data of the sign
its either a Sign or a WallSign or a WallHangingSign
or Directional in general
do i use papi or custom placeholders for placeholders?
Btw signs have PersistentDataContainers. I would store any data like price and stock in the PDC.
Its always a good idea to strictly separate user accessible data from your actual backend data.
Eg. if you have 3045 items in stock, then the user might only want to see 3k.
Papi is a de facto standard currently
^ also makes parsing of those values SOOOOO much nicer
?
He was slow
wow
Its for the msg above
maybe you are just too fast
lynx is a slow boi
good things take time
ha?
is it possible to make a custom damage cause? instead of the damage cause being fall for example, is it possible to make it something custom
just store somewhere your own last damage cause
and then whatever after can check for it
or even better, make your own event
can anyone help
what r u trying to do?
get keys
of the config
all keys
so i need deep option
okay and what doesnt work
r u trying to use the bungee api on spigot
no
im just trying to rewrite from some spigot code to use for my bungee plugin
so
how do i get deep keys of config in bungee api?
Hello i have a probleme using Protocol Lib in 1.20.4, i've this code that takes a player and show all the other players a glowing to him. But when i try i got this weird cast error :/
public static void addGlow(Player viewer) {
ProtocolManager protocolManager = StealTheCrown.getPlugin().getProtocolManager();
// Iterate over all online players
for (Player target : Bukkit.getOnlinePlayers()) {
// Ensure we do not try to make the viewer glow to themselves
if (target.equals(viewer)) {
continue;
}
PacketContainer metadataPacket = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
// Set the packet's entity ID to the current target player
metadataPacket.getIntegers().write(0, target.getEntityId());
List<WrappedWatchableObject> watchableObjects = new ArrayList<>();
WrappedDataWatcher watcher = new WrappedDataWatcher(target); // Create a data watcher for the target player
WrappedDataWatcher.WrappedDataWatcherObject statusWatcherObject = new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
// Flag 0x40 is for ENTITY_GLOWING, modify as needed
byte originalByte = 0; // Default value if not set
if (watcher.getByte(0) != null) {
originalByte = watcher.getByte(0);
}
// Then you proceed with the bitwise OR operation to set the glowing flag
byte modifiedByte = (byte) (originalByte | 0x40);
watchableObjects.add(new WrappedWatchableObject(statusWatcherObject, modifiedByte));
metadataPacket.getWatchableCollectionModifier().write(0, watchableObjects);
try {
protocolManager.sendServerPacket(viewer, metadataPacket);
} catch (Exception e) {
e.printStackTrace();
}
}
}
WastMc lost connection: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.ClassCastException: class net.minecraft.network.syncher.DataWatcher$Item cannot be cast to class net.minecraft.network.syncher.DataWatcher$b (net.minecraft.network.syncher.DataWatcher$Item and net.minecraft.network.syncher.DataWatcher$b are in unnamed module of loader java.net.URLClassLoader @4e515669)
If someone can help 🙏
.
Okay i'will try thx
hello everyone, i've been having quite a lot of issues with integrating vault economy into my plugin, im very new to coding and minecraft plugin development. Is there anyone that is willing to help me out a bit?
Issue:
my plugin keeps disabling because it is not recognizing vault as a depencancy but i have added it to my plugin.yml as a dependancy, i also added it to my pom.xml.
The error
[16:15:48 INFO]: [Nexussmp] Enabling Nexussmp v1.0
[16:15:48 INFO]: [Nexussmp] NexusSMP has been enabled!
[16:15:48 ERROR]: [Nexussmp] [Nexussmp] - Disabled due to no Vault dependency found!
[16:15:48 INFO]: [Nexussmp] Disabling Nexussmp v1.0
[16:15:48 INFO]: [Nexussmp] NexusSMP has been disabled!
if any file or piece of code is needed let me know please.
In default vault code, the "no vault dependency found" means you don't have a backing economy plugin
You need some plugin that provides implementation for vault economy, like essentials
yea im using essentialsX


