#help-development
1 messages Β· Page 62 of 1
and call saveDefaultConfig()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityBreedEvent.html you mean this?
declaration: package: org.bukkit.event.entity, class: EntityBreedEvent
That's called when the breeding happens, not when the targetting occurs
Yeah I was unsure if you just worded it differently
Np
does the targetEvent fire before breeding?
Because there certainly isn't a seperate one for "target before breeding". You can however achieve it with the right if conditions
Yeah I'll do that
so umm i used my last brain cell, i get this error: https://paste.md-5.net/vukukaxawe.cs
With this code:
try {
@SuppressWarnings("unchecked")
Class<? extends Event> clazz = (Class<? extends Event>) Class.forName("com.github.sirblobman.combatlogx.api.event.PlayerTagEvent");
getServer().getPluginManager().registerEvent(clazz,
new Listener() {},
EventPriority.NORMAL,
new EventExecutor().execute(new Listener() {}, clazz),
this);
} catch (Exception e) {
throw new RuntimeException(e);
}
what am i doing wrong?
uhm what are you trying to do?
Can't you just create a new instance of "PlayerTagEvent" without the Class.forName()?
ok i fixed my previous issue, how can make it so that when the arrow hits a block the task ends
but i want it to work universally, for any plugin
will i need to store all the tasks in a hashmap with their entity ids
and cancel if that reoccurs in projectile hit event
(config defines what events are listened to, what i put is just an example for debugging
ah I see
thanks
woo looks like it registered
what did you change? :D
instead of inline listener i made inline event executor and custom listener
basically i swapped them
I see. Yeah that looks cleaner aswell
next thing is to make it do something XD
i have no idea how my listener class should look like
depends on your usecase I guess
wait one small issue though
if I were to host the twitch bot on the server
how would I keep the credentials to the twitch app confidential
huh? Why wouldn't they be by default?
Unless someone can access your server/code
With access I don't mean play on it but access the files and plugins
don't i have to log in to my bot from the server
I'm trying to host the twitch bot on the server that the plugin is loaded on- wouldn't that mean I would have to store the twitch app credentials in the plugin itself?
Yes that's exactly what it means
Or in a database
and the plugin can retrieve it from there
but then the plugin has the DB credentials - so same thing pretty much
but doesn't that mean anyone do anything with the bot
they just decompile the jar
or read the database
Who is "anyone"?
anyone who downloads the plugin
would just be able to decompile it and look for the app id and secret
ohhh it's supposed to be a public plugin
In that case you have to have a server urself
And basically they tell your server what to do via the plugin
you make it a configurable thing in the config.yml for people to put their credentials, you wouldn't code the credentials into the program itself
damn
and your server holds the credentials and handles the bot
on the brighter side: You don't have to update the plugin on every server but you can just add functionality on your own server
here's the thing
I have a twitch app
which I plan to send messages to twitch chat with
unless you're saying have the user use their own token
and make the bot chat through their account
If you want to use your credentials there is no way around having your own server
you could make such things if you wanted
mod is not the same thing as a plugin
and then the bot chats through your twitch account
i'm talking about a beat saber mod lmao
different game
point is that they use the owner's twitch token
and different concept of providing functionality as well
if that's a valid option for you - you would save yourself a server :p
it'll look weird but i'm fine with that
you can do this with a plugin for a mc server as well
yes thats what im thinking to do
conversation api in spigot exists
i have barely any experience with the twitch api though so wish me luck
you can allow players to put their own tokens in, and then encrypt them in the file
Encrypting them doesn't make much sense when the plugin has access to the key that is needed to decrypt. So unless they enter it every time you can save on the encryption part
Yeah good point
It would keep people with no coding knowledge from getting the token. But not anybody else
i can just store the token in a separate file
And put a fat warning saying do not share this with anyone
Can I restrict that tnt cannot destroy some area?
yes you can cancel the https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityExplodeEvent.html or clear the blocklist
declaration: package: org.bukkit.event.entity, class: EntityExplodeEvent
plus people with no coding knowledge wont even be able to do anyone with the token anyways
That's only partly true since there's other bots that request a token for an input
So those are already coded :p
uh
new EventExecutor.execute is void...
how were you even able to compile that?
@onyx fjord make a method that has Listener and Event as its parameters
and then use a method lambda
i.e.
public void myThing(Listener listener, Event event) {
// do thing with event
}```
and then
try {
Class<? extends Event> clazz = (Class<? extends Event>) Class.forName("com.github.sirblobman.combatlogx.api.event.PlayerTagEvent");
getServer().getPluginManager().registerEvent(clazz,
new Listener() {},
EventPriority.NORMAL,
this::myThing,
this);
} catch (Exception e) {
throw new RuntimeException(e);
}```
all good now
thanks
CombatLogX API spotted π
whats your current code snippet, just curious? @onyx fjord
using api is lame
Why are you using it like that?
i basically did what you told me before, just moved executor and listener to their own class π
there is a good reason π
my plugin will be able to hook on any plugin without me coding a hook
with simple config
itll only have to dispatch a command
Just move things to a new class_
ill have hooks made by me + this as Plan B so nobody has to wait
- i can say my plugin supports around 100 thousand plugins π
yea just remember
what do you guys think about my approach?
this is all youll have access to
as soon as you want to do anything more complex
it will be a headache
ill just do it like this, user will have to specify other stuff in the config
like umm
idk we'll see
cuz also like
what does handler list contain?
HandlerList contains a list of all the registered listeners and their priorities
so when you ΓΉse callEvent
am i at least able to get player from event ? (if one exists)
it knows exactly which EventExecutors to use
i mean not reliably
This doesn't cancel damage to a Minecart, any idea why?
@EventHandler
public static void onAttack(EntityDamageByEntityEvent event){
if(event.getEntity() instanceof Minecart){
event.setCancelled(true);
}
you could do something like
if (event instanceof PlayerEvent playerEvent) {
Player player = playerEvent.getPlayer
}```
helpful π
use VehicleDamageEvent
thats all i need bro
but i mean
thats unreliable
cuz if that doesnt extend PlayerEvent
it wont work
Thanks
what if i do event.getPlayer()? (assuming player exists)
getPlayer doesn't exist in Event...
because i can just add config field telling server owner to decide if event has a player
ouch
declaration: package: org.bukkit.event, class: Event
you have 3 methods to work with
i wonder how kiteboard accesses all methods
a lot of effort right?
i mean its
getClass().getDeclaredMethods()
gives you all the methods
then method.invoke(event) will invoke it (if it doesnt require params ofc)
mhm
im still confused as to why you need this functionality
because the user would need to know the source code of the plugins they want to use
and events should be for API access only
Β―_(γ)_/Β―
thank you for the help
ill play around with it tomorrow
glad at least the concept works
if (player.getWorld().getBlockAt(x, y - 1, z).getType() == Material.GOLD_BLOCK) {
}
How do I ensure the code only executes once?
(ie. the player can keep standing on the block, but it doesn't execute again)
you would need to keep track of which players stepped on which blocks
Ok, but I do know that there is only one block of that type per world
And I only want it to execute in that world
Please elaborate. I'm unsure whether I understood that right
only in one world, only once per block and there is only one block?
I think I can just use a variable to set something like "allow" to false once a player steps on the block
yeah you can use a Map
ye
wanna hear a really wierd bug guys
this one?
nah i resolved it now lol
event.getEntity().setVelocity(event.getEntity().getVelocity().add(new Vector(0, 5, 0)));
event.getEntity().setBounce(true);
why does this not work
Who at mojang made it so light blocks make a sound when walked over π¦
Any possible way I could fix this?
there is any way to install data pack in entire server? instead of specific world , or any plugin like skript but in minecraft datapack language
Don't use a data pack use a plugin 
does any one know how to make a TNTPrimed explosion bigger?
reminder that after a certain size with explosions, the only thing that increases is the length/amount of shockwaves
Mojang also capped them recently
I'm getting death threats
creepers are good at those
you are IGNORING
πͺ πͺ πͺ πͺ πͺ πͺ πͺ πͺ πͺ
you shouldn't overdo it however
What is the best way to create a world from a template?
Define "template"
another world
They probably mean a generator?
you wanna copy it?
yes
with everything
I tryed copying the files and everything but need 9 seconds to do it
What's your goal
I have one map for my minigame, and want to create instances of this game
Why don't you copy the map beforehand
You could load the world fully into memory and use a custom world manager for the rest
and store what was broken - then reset those blocks?
but copying a small minigame map shouldn't take 9 sec
But uh, that is a LOT of work if you haven't done anything like that before it
If it's a minigame, maybe make empty world and paste schematic?
no I never worked with worlds and spigot before
I hear this have a lot of resoruce cost
Copying entire world is expensive
Are the minigames on seperate servers or is it one server with multiple worlds?
this too
one server with multiple worlds
Do it async I guess
you could disable the world save
and unload it after the game
then load it again
that might work
when u unload the server save the world
Hypixel made slime world manager afaik
I didnt find the way to disable it
Not if you disable autosave
You could use that
I did
And?
I mean I disabled autosave but it doesnt work
Oh
I'll check slime wolrd manager
I heard it's performant
that is not very resource expensive tho
unless multiple hundred thousand blocks change
how long should it take for jenkins to start
cause its been starting for like 10 minutes now
He can do it lazy
yeah there's also more performant ways to change blocks when there's no players in the world
it did error when trying to install it...
Few dozen megs in worst scenario
Building dependency tree... Done
Reading state information... Done
jenkins is already the newest version (2.363).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up jenkins (2.363) ...
Job for jenkins.service failed because a timeout was exceeded.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
β jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: activating (start) since Sun 2022-08-14 22:06:03 BST; 11ms ago
Main PID: 45769 (jenkins)
Tasks: 1 (limit: 780)
CPU: 2ms
CGroup: /system.slice/jenkins.service
ββ45769 /bin/sh /usr/bin/jenkins
Aug 14 22:06:03 raspberrypi systemd[1]: Starting Jenkins Continuous Integration Server...
dpkg: error processing package jenkins (--configure):
installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)```
Jenkins should be at most a minute if your computer is a potato. Read the logs
https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/ nah I'm talking about these
hmm. where can i find those? also i am running it on a raspberry pi
Well you can check the journal like it recommends
but checking which region files changed and only copying those again also seems like a good way
it seems to be "an illegal reflective access operation has occured"
do u have any example or smth to look at it?
Send the full error in a paste or something.
org.codehaus.groovy.vmplugin.v7.Java7$1 did the accessing
I asked for the full error not snippets
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats the entire journal
jenkins is also maxing the cpu when trying to start
yea its a ras pi
ima try to reinstall jenkins
Make sure the version it's installing is up to date and idek if Jenkins is supported on the pi
Yeah, that should work then
hes ugly as shit
What has Material.MONSTER_EGG been changed to, I'm trying to check for spawn eggs not a specific one
most materials have been split up in 1.13 for good reason
Material.LEGACY_MONSTER_EGG
no.
geol you are stupid.
No.
while yes that is the answer, but it is not what they really want
fuming?
well how would I check for spawn eggs in general
?jd-s
;-;
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/SpawnEggMeta.html is a hack-workaround
declaration: package: org.bukkit.inventory.meta, interface: SpawnEggMeta
Does that work for all types that got grouped now? Fences? Wood types?
Because usually I string compare their enum. I wonder if there's a better way for all of those
There is https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Tag.html for a lot of those things
A must-have when the material rewrite comes
does anyone know how to give players screen effects like what you see when their spectating a mob like a creeper/spider/enderman?
Not without a resourcepack. All you can do is use the effects available like pumpkins and the frost effect.
ah, ok. thanks
im working on a night vision plugin, is there anything that you think would work to make a green like effect?
what about the nausea overlay? I know they recently implemented a green vingette if you have distortion disabled
Thats client side
That depends on the client settings.
makes sense. if i were to use resource packs how would i toggle overlays?
Is this discord used for protocol lib questions?
most of us don't use it, but...
?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!
How can I change a players name through NMS?
I might be able to edit GameProfile actually
You have to create a fake profile and apply it
how do i change the dye color of a leather item using ItemStack?
ive tried using itemmeta and adjusting the material but i cant find much
oh wait, just found a solution using LeatherItemMeta
*LeatherArmorMeta
LeatherMeta or something like that
forgot the exact cast
damn :( so close my memory was just slightly off
man serializing and deserializing items is a cursed endeavor
I made my own item serializer lmao
need that pdc
I did that too in several different ways in several different plugins according to the needs
but uh now I want the most generic one possible and I am dealing with that specifically
can you put attributes onto a piece of paper to make it strong like a netherite helmet?
sure
base69 when?
mfnalex β€οΈ buoobuoo
I have a ProtocolLib related issue
[19:08:09 WARN]: Exception in thread "pool-7-thread-1" FieldAccessException: Field index 1 is out of bounds for length 1
[19:08:09 WARN]: at ProtocolLib (1).jar//com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49)
[19:08:09 WARN]: at ProtocolLib (1).jar//com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:289)
[19:08:09 WARN]: at andonia-shadow.jar//me.gleeming.tabey.packets.PacketTeam.sendPacket(PacketTeam.java:62)
[19:08:09 WARN]: at andonia-shadow.jar//me.gleeming.tabey.Tabey.lambda$onJoin$3(Tabey.java:54)
[19:08:09 WARN]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[19:08:09 WARN]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[19:08:09 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
ooga ooga β€οΈ
public void sendPacket(Player player, ProtocolManager protocol) throws InvocationTargetException {
var packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
packet.getStrings().write(0, teamData.name);
packet.getIntegers().write(1,action);
// Add/Remove from team
if (action == 3 || action == 4) {
packet.getIntegers().write(9, teamData.players.size());
packet.getStringArrays().write(10, (String[]) teamData.players.toArray());
return;
}
// create team/anything else
packet.getChatComponents().write(7, WrappedChatComponent.fromJson(String.format("{\"text\":\"\"%s\"\"}\"",teamData.getPrefix())));
packet.getChatComponents().write(8, WrappedChatComponent.fromJson(String.format("{\"text\":\"\"%s\"\"}\"",teamData.getSuffix())));
packet.getIntegers().write(9, teamData.players.size());
packet.getStringArrays().write(10, (String[]) teamData.players.toArray());
protocol.sendServerPacket(player, packet);
}```
what am I doing wrong?
I cant help exactly with this problem, but why don't you just send the packet directly using NMS?
that way you know exactly what arguments are needed instead of doing weird stuff like "getIntegers().write(1,action)"
protocollib is like 12 times more complicated than just using the packets directly imho
NMS?
yes
"vanilla code"
you dont need protocollib to send packets
you can just use the NMS classes
e.g. net.minecraft.network.protocol.ClientboundScoreboardPacket (just an example packet name, I dont know exactly how its called)
hello mr magma
I guess there are no silver bullets but anyone know what the most generic and likely to work itemstack serialization process is? I'm using base 64 rn but it doesn't seem to like chests and potions already
ItemStack implements ConfigurationSerializable already, what's wrong with that? You need it to be a string, I guess?
wdym with "it doesnt like chests and potions"?
I'm using paper so I don't have vanilla packets
seems to error when I do those
thats why I was asking about protocol lib
works just fine with book enchants
I serialize itemstacks like this ^
that's the one I adapted
hm and what exactly is the error you're getting?
you can just add spigot as dependency, too
oh
wrong copy/paste
?paste
https://paste.md-5.net/joyovehiku.md hm did I mess up my implementation then
yeah
show your code pls
either your desirliaztion code (sorry, cant type properly today lol) is bugged, or you don't have a valid base64 string in the first place
ngl I'm a bit dead rn
I've not managed to spend more than 20 continuous minutes without a support request today and that was the least of it
hm okay sooo
you're using Base64Coder
I just used java's builtin base64 stuff
but that probably is not he problem
try to use the builin java base64 encoder
I mean it does work for enchanted books is the thing that throws me off
erm wait wait wait
two types of entries and I'm lazy
if it has material it's a simple item, if it has serialized it's a headache
seems like a dirty workaround π does it work if you simply copy/paste my exact code?
because the potion thing is definitely valid base64
so the reader would be in the wrong here
?
generation settings but they're not decoded
the amount part shouldnt be there
at least shouldn't be
are you sure? how are you reading it? print out the string that's passed to your decode method
If I want to save the data folder path to a string would it be
String folderPath = plugin.getDataFolder().getPath();```
or getAbsolutePath() ?
I mean, your error clearly says "length of the string isnt a multiple of four" so I guess you accidentally pass more than just the plain base64
I always use getAbsolutePath
getPath is a "local" path
e.g. it could be ./plugins/MyPlugin
ahh I understand
getAbsolutePath would be /home/minecraft/myserver/plugins/MyPlugin
np
you should consider using a proper formatting thing for your stuff π
wdym this is my totes legit certified to work most times format
e.g.
myitem1:
base64: asdasdasd...
amount: 1
chance: 1
info: POTION
eh but that's really annoying to make into a list
why?
requires whitespace formatting and stuff
hm I dont really understand what you mean
I mean you're using FileConfiguration right? You can just get each item's ConfigurationSection inndividually
I mean for users, adding whole new entries is not as immediately accessible and tends to cause confusion which I then have to spend time clearing up
that's true but users obviously also don't add base64 strings manually, I guess π
yeah but they will probably add/edit the simple ones
well not probably, they are doing it
uh
ngl things would go much faster if I wasn't falling asleep at the wheel
ye totally works
thanks for the help!
why maven spigot artifact doesn't exists anymore?
i need to use nms and craftbukkit
Install 1.17 with BuildTools: https://www.spigotmc.org/wiki/buildtools/
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
π
always welcome!
so like java -jar BuildTools.jar --rev 1.19 --remapped [mojang]?
HANNNAH IS HERE
does anyone know what permissions Minimessage uses for the like
colors
im Gone
none
so only ops can use it?
no
minimessage doesnt interfer with the server at all
well, it does, but not "on its own"
idk how to explain it lol
hi Gone
well I can use the colors but if I remove perms from myself I can
i thought mm is just a library for coloring text
and it messes with my chat format cause certain people cant
are you developing a plugin?
not actual colored chat
yeah
and you are using minimessage to parse messages?
MiniMessage is a library that plugins depend on. It simply formats chat colors.
If you wish to extend that functionality or modify it a little bit, you would make another plugin that makes use of it.
I believe so
That's how I would explain it anyways.
you don't. disable all other plugins and you'll see that mininmessage doesnt do anything on its own
if you just write "<red>test" in chat, you'll see that it will NOT print "test" in red, ubt it will actually just show "<red>text" in chat
minimessage doesn't use any "permission" system
I mean it's not even a plugin afaik
oky, then I need to figure out what DOES allow me to use colors
your chat plugin
I'm making really good progress on my command library, it's got two styles it can be used in
The new one is the builder
Chat is formatted by me, I have essentials and luck perms and vault though
you need to toss your string you wanna format into minimessage
one sec
idk if it helps, but I once wrote this to turn strings into "formatted" stuff using mininmessage https://github.com/JEFF-Media-GbR/Oyster-Message
I use a library my friend made its easier
so yeah look at the code. or, even nbetter - just look at the adventure docs
they explain perfectly fine how to use MM
metal solid gear
public static void
what konami game is that
do you prefer longhand?
Hm
lol
Message.java >
hannah switched sides again, I see
im literaly bi
bi or pan?
yes
yoghurt
yogheal
pudding'nt
mcdonald
borger kong
mcdonalds has better fries, but burgerking has better burgers
yeah
it's not gay if you add a //NOHOMO comment
gay if u take me out to dinner
dick.suck(); // NOHOMO
I mean it is called Burger King
// TODO: NOHOMO
it will be hetero eventually
assert !dick.action(Action.SUCK).isWithHomoIntent();
fun fact: sea horses dont have any gender
theyre just trans idk
yeah but they have it builtin biologically
two sea horses can always mate and get children
like in MC
looks like JDA
JDABuilder.withIntents(...)
assert !dick.action(Action.SUCK).intents().contains(IntentBuilder.SEXUAL_INTENT.withModifier(Modifier.HOMOSEXUAL).build());
wait
Intents.WITH_MOTHER
dick.action(Action.SUCK)
does that mean that this dick sucks another dick?
if so: interesting concept
btw why does the gas station in carpendale not sell any yams
ActionBuilder.SUCK.withModifier(Modifier.SLOPPY)
.target(new Target(your.mother()))
.build
why would a gas station sell yam
UnsupportedOperationException
it's from The Office
season 2 episode 12 IIRC
Thats your fucking problem
Best series ever
I know the best of Michael Scott is pretty much EVERY SINGLE SCENE he's in, but we've had to narrow it down somehow.
If you feel like we've missed a vital scene out, PLEASE PLEASE comment and let us know. We love hearing from you...
Streaming now on Peacock: https://pck.tv/3mPrdWB
Watch The Office US on Google Play: http://bit.ly/2xYQkLD & i...
too corny for me
fixing good
trying to be funny, making it unfunny
idk its hard to translate corny
cornΒ·y
/ΛkΓ΄rnΔ/
trite, banal, or mawkishly sentimental.
corny has like 10 german words lol
first one is like "cheesy"
ye that
second one is "overly weird"
third one is also cheesy
fourth means "deprecated" so ugh
and the sixth or so is "rich in grains" lol
@slender coral ign
shrimpzo is gay
who tf is shrimpzo
my friend
is he cute?
are you gonna fucking add me
but then I remember that you got ?ban perms
damn right i do
and then I pretend to be your friend
smart move
π§
should ClientboundAddEntityPacket be sent to players in a radius or can it just be sent globally and client will handle it?
send globally
the client controls rendering
actually tho
you will need to resend it if the player is not within a radius
ah yeah forgot about that one
Anyone happens to know how to add a day suffix to SimpleDateFormats? like 15th, 3rd, 2nd, etc
Am i dumb or does location#getChunk load the chunk?
It should load the chunk, yes
any quick way to get whether the chunk is loaded through location
or do i have to manually get the chunk coord and check through world
Yeah you'd have to check World#isChunkLoaded(x, z)
I'm currently trying to make some experience with streams, would this be a good replacement for the method?
public Warp getWarpByName(String name) {
for (Warp warp : this.warpStorage) {
if (warp.getName().equals(name)) {
return warp;
}
}
return null;
}```
```java
public Warp getWarpByName(String name) {
return this.warpStorage.stream()
.filter(warp -> warp.getName().equals(name))
.findAny()
.orElse(null);
}```
I'm currently making a simple VillagerTradeEvent (for spigot) and this works, but I want to know how to detect the count of the output they got from the trade by shift clicking, since this only works if you click once, and get one item. (I know how to detect ShiftClick, i'm just wondering how can I find how much items they got and how can i call event for each one)
public final class VillagerTradeListener implements Listener {
@EventHandler
public void onVillagerTrade(InventoryClickEvent event) {
if (event.getClickedInventory() instanceof MerchantInventory villagerMerchantInventory) {
Integer slotClick = event.getSlot();
ItemStack slotItem = villagerMerchantInventory.getItem(slotClick);
MerchantRecipe villagerMerchantRecipe = villagerMerchantInventory.getSelectedRecipe();
if (slotClick != 2){return;}
if (slotItem != null || slotItem.getType() != Material.AIR){
Merchant entity = villagerMerchantInventory.getMerchant();
TradeEvent villagerTradeEvent = new TradeEvent(
(Player) entity.getTrader(),
entity,
villagerMerchantInventory,
villagerMerchantRecipe,
slotItem,
slotClick,
villagerMerchantRecipe.getAdjustedIngredient1(),
villagerMerchantRecipe.getMaxUses(),
villagerMerchantRecipe.getVillagerExperience()
);
Bukkit.getServer().getPluginManager().callEvent(villagerTradeEvent);
if (villagerTradeEvent.isCancelled()){ event.setCancelled(true); }
}
}
}
}```
Yes
But also no
You should just use a HashMap π₯²
Map<String, Warp>
Couldn't you divide the number of items on the left hand side by the price of the trade and multiply by the output item count?
So for example if they have 64 emeralds in the slot and it costs 5 emeralds for 8 sticks, it's (64 / 5) * 8
= 96
(Integer division)
You know how you can shift click to get multiple items from the trade? I kinda want to find the output item count and call the event for every single one
I know what you're asking
Did you even read my reply
Because I told you the solution and you then just restated the question
I'm not sure how advisable it is to call potentially hundreds of events for a single click, you should consider a different approach
Hey, so I'm looking for a way to make it when an anvil falls then it gets removed. I've tried
@EventHandler
void onDamage(EntityDamageEvent event) {
if (event.getEntityType() == EntityType.FALLING_BLOCK && event.getCause() == DamageCause.FALLING_BLOCK)
event.getEntity().remove();
}
but it only works when an anvil is damaged so most of the time it does nothing. And I've tried
@EventHandler
public void onBlockChange(EntityChangeBlockEvent event){
if(event.getBlock() == Material.ANVIL.createBlockData()) {
Location l = event.getBlock().getLocation();
World w = event.getBlock().getWorld();
w.setBlockData(l, Material.AIR.createBlockData());
}
}
which I didn't except to work but yea. Anyone know how to do this?
You're doing == on BlockData
Wait no
You're doing Block == BlockData
Which will always be false
Wait for the second one right?
Do e.getBlock().getType().toString().contains("ANVIL");
Yes
Ah
So
@EventHandler
public void onBlockChange(EntityChangeBlockEvent event){
if(event.getBlock() == event.getBlock().getType().toString().contains("ANVIL")()) {
Location l = event.getBlock().getLocation();
World w = event.getBlock().getWorld();
w.setBlockData(l, Material.AIR.createBlockData());
}
}
Right?
Hello. I have a question. Normaly how long is going to take to approve a premium resoure?
3 years
No
xD DAM
Get rid of the == and everything before it except the if
Oh right ok
Alright
You also have an extra () you don't need at the end
Very noob question here:
List<Player> players = new ArrayList<>(world.getPlayers());
Player hunter = players.remove(new Random().nextInt(players.size()));
Player hunter1 = players.remove(new Random().nextInt(players.size()));
Does that guarantee that hunter and hunter1 will never be the same player?
Yeah, but how do I get the output item count?
yes but re-use the Random
Hi im having an issues on compile
for(var player : e.getPlayer().getServer().getOnlinePlayers()) {
e.getPlayer().hidePlayer(player);
player.hidePlayer(e.getPlayer());
}
The line is the first one and the error is "cannot find symbol"
yes but they are correct
Player will be fine
Im using intelliJ idea
wont usually impact javac
not fixed
are you sure your event is called e and not event or smth
i switched from java 11 to 8
yes im sure
for(Player player : e.getPlayer().getServer().getOnlinePlayers()) this would be finally fixed?
and working?
yea but try it
for (Player hunter : world.getPlayers()) {
//hunter.Do a thing
}
Will that execute on all the players in that world? Or should I use Bukkit.getOnlinePlayers?
thats all in world
online is all on server
Oh yea, forgot about that thanks!
But this is weird:
for (Player hunter : Dinohunters) {
hunter.sendMessage(ChatColor.RED + "You Are A Hunter!\nTry to shoot the runners dead before they make it!");
Dinohunters always has 2 entries. But the two hunters both receive two messages instead of one?
What is "Dinohunters"
that doesn't look to be how you make an enhanced loop
Dinohunters is the variable that contains this
List<Player> players = new ArrayList<>(world.getPlayers());
Player hunter = players.remove(new Random().nextInt(players.size()));
Player hunter1 = players.remove(new Random().nextInt(players.size()));
So it picks 2 "hunters" that cannot be the same
Don't name a class "Methods"
I know its bad practice
Also what is the issue?
then dont do it
What do you guys think would be a good visual indicator that a text is hoverable?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
sure
Also rename ur setHunter method
having the name of the world is very misleading
it sounds like it should set a player as the hunter
^^^
Also use lombok for setters / getters
oh
^ but still saves like 1000 lines when you want to make one for like 10 vars
The for loop executes twice for each player
oh sorry
yea but I dont see why
I need to code a plugin where I get items broken by water, how can I listen to that event?
ThreadLocalRandom π
I'd say use a scheduler
I mean is it caused by this?
Methods obj = new Methods();
Methods obj = new Methods();``` you're calling this in the event, which means it's called as often as this event occurs
Why a scheduler?
yea...
oh, its in the worldChange event
doesnt that mean that it will execute the numbers of players changed worlds?
like if there were three players, it would execute 3 times?
you're creating a new Methods every time that event occurs
If he teleports 2 players twice, etc
thats the issue, is there a way to like create the object only once?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
put the object into a class variable rather than a local method-scoped variable
wdym?
^instead of creating one more it every time you need it
one way to think about it is that variables are basically ropes or boxes that contain or hold objects
so when people talk about caching, usually it involves some type of variable that hold on to some object so the jvm doesnt garbage collect it
My friend also receives two
yea
ill do that main class thing
π€
ill test the onEnable one first
But how would I allow other classes to access thisvariable
without creating a new object to access the variable and starting it all over again
yea di seems complex but ill try it
private Method method;
@Override
public void onEnable() {
method = new Methods();
}
public Method getMethod() {
return this.method;
}```
something like that
is there a way to disable chat reporting ?
convert all messages to system ones
If that's not enough to get it working for him idk :D
thanks so much!
how do i do that
But you should really change the class' name (Methods)
yea, main class
oh no
"com.sinden.runnervshunter.RunnerVSHunter.getMethods()" because "this.plugin" is null
error code or code
public class StartGame implements Listener {
private final RunnerVSHunter plugin; //main class
public StartGame(RunnerVSHunter plugin) {
this.plugin = plugin;
}
@EventHandler
public void onChangeWorld(final PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (this.plugin.getMethods().isWorldType(player.getWorld().getName()) && !player.getWorld().getName().equals("RunnerVsHunterhub")) {
int count = this.plugin.getMethods().getPlayerCount(player.getWorld().getName());
}
}
wdym?
Show your main class
Why?
//Main class
private Methods method;
@Override
public void onEnable(){
getServer().getPluginManager().registerEvents(new StartGame(this), this);
method = new Methods();
}
public Methods getMethods() {
return this.method;
}
PlayerChangedWorldEvent is called after the player already changed the world
You forgot to compile and/or copy the jar. This code does not correlate to your exception
wait i have some other stuff that i think is really bad
public class StartGame implements Listener {
private final RunnerVSHunter plugin; //main class
public StartGame(RunnerVSHunter plugin) {
this.plugin = plugin;
}
@EventHandler
public void onChangeWorld(final PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (this.plugin etc.){
//stuff
if(this.plugin){ //I can't use this.plugin here, how do I fix that
}
}
}
You can. Again: I think you didnt compile and/or copy the jar.
Its says cannot resolve symbol plugin
no missing
checked
if it matters: this is in a runnable
Show the full class then. The actual code.
Because what youve sent wont compile for several reasons
mightve missed that
runnable isnt for delay
yea
And if its inside an anonymous class scope then you need to use
StartGame.this.plugin
wow
This should work
7smile7
you got any basic prometheus integration tutorial or code?
I'd like to setup some graphs π but I'm low-iq
Prometheus? You mean Graphana?
graphana graphs the output of prometheus so yeah
prometheus is the actual database / gathering program
Thats quite specifc XD nope i dont have a tutorial for that.
But you can do either polling or webhooks. Shouldnt be too hard.
Isnt there a plugin that exposes metric endpoints or something.
I swear ive seen it in the last few weeks.
life saver
π€ this is great
^ anyone can help pls?
why are you trying to set legacy data on a new plugin
wym?
not really no
alsoo can I use PLAYER_HEAD instead of SKULL_ITEM
?
Yeah
thanks brother
The SpigotApi uses the GPL license. As far as I know the GPL license forces me to use GPL im my project. Does it apply to plugins using the SpigotApi as well?
Edit: sentence structure
in theory yes but in practice no
So in theory every plugin has to be open source?
in theory
And why only in theory? Do I run into any danger if I publish a library with the SpigotApi and license it under MIT?
But someone could enforce it?
Never going to happen, unless you do somethign shady
What is the remapped packet for destroying an entity?
Oh it might just be ClientboundRemoveEntitiesPacket
Okay thanks. π
Sounds like I am safe.
after i send the packet
player skin got updated but he cant interact with the world
until /kill
can i redo class deletion in ij? π
you can;t simply change teh skin
I wonder if we can make an npc that mimics player movement
so we can fuck with it
and change skin without bugging
Anyone know how I can change a players Minecraft name internally through packets?
setdisplayname ?
I think it's a bit more complicated than that
You can;t change their name. Theres setDisplayName but changing the name above their head, look at teh paste above
Ah okay. Thanks
they will still chat with their proper name, but it will show the altered name
Is it worth using packets for a sidebar? Or should I just use bukkit scoreboards
import com.palmergames.multiversion.utils.NMSUtils;
What does this import come from?
Thanks
didnt help at all
bukkit scoreboards use packets iirc
There can only be one scoreboard at a time
If I start a bukkit runnable, with a value being true, but while the runnable is counting down, the value changes to false, how would I instantly cancel the runnable?
because I think cancel(); only checks once or something?
the enforceability of it is questionable ever since the DMCA
Would making my CommandManager a singleton be frowned upon?
I'm not going to, I'm just wondering
what sort of runnable?
you say counting down, do you mean a runTaskLater?
yea
when exactly would the runnable cancel if i did
run(){
if(this){
cancel();
}
}//runtasklater
What is the difference between scope compile and provided?
but the other code only executes when the runnable has counted down?
provided doesnt get shaded
just check the boolean when it executes
ffs, I said in my documentation you provide the lib and now anyone who tried it probably got an error
the problem is, what if the boolean changes while the runnable counts down
im trying to check if there are enough players in a world
what if there is, the runnable counts down, but as the runnable is counting down the player leaves
So the only use for the shade plugin is relocation?
or does that shade plugin handle the compile scope?
if the requirements are met, just start the game or whatever, and in your runnable if the game is already started, ignore it
wdym?
all shade does it move the dependency into your runtime jar
but the compile scope shades it?
compile scope just means it available throughout the compilation stage
so it shows the shade plugin that it needs to be shaded?
maven doesn't shade it automatically?
it does
all you need to know for shade is, provided doesnt shade
compile is the default scope
one final question for the minute, do I shade lombok?
its included in spigot?
oh yea, thanks!
right, so provided?
You use the main scoreboard
yeah
thanks
Now use that scoreboard for tablist as well
Wdym?
You can't do anything about that
what about commons-io?
Because when I didn't shade it I got a no class def
yeah probably then
A player can only be in one team at a time. Make sure you don't have two teams
maybe I need the apache dependency tho? are they different?
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<scope>compile</scope>
</dependency>```
thats what I'm using
You dont need to define compile scope, itβs default
Yeah I'm aware
Again make sure you don't have two teams
I see no check for the player team
That's not checking if a player is in a team
Setting the player team or player scoreboard will override the existing ones
A player can only be in one team at a time
Use the same team
And same scoreboard
hi, in my plugin I want it so that players cannot drop items in a specific world so I came up with this:
@EventHandler
public void ItemDropEvent (PlayerDropItemEvent event) {
Player p = event.getPlayer();
if (p.getWorld().equals("world")) {
event.setCancelled(true);
}
}
but players can still drop items in this world. to confirm that the event is actually getting cancelled, I did this:
@EventHandler
public void ItemDropEvent (PlayerDropItemEvent event) { event.setCancelled(true);
}
and indeed it does prevent players from dropping items. why can't the first method work though?
yea World is not a String
Hi, looking for help on creating a big shop plugin (Will explain more in DMS, if someone is willing to help out) (Payment is included)
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/
aha! thank you!
if I want to clear an array, do I just set it to null?
didnt think it mattered, but its a list
is there a difference for clearing them?
no way
bruh
XD i am blind thanks so much
na, is a runnable fine?
ok thanks
I really don't get how people never notice this
like the IDE would mark this yellow saying "world can never equal a string"
no idea why everyone ignores this warning

Mye daddy
im dead bored
Does anyone know any half-decent XML parsers that are kinda like the org.json:json artifact but for XML? Java's built-in one sucks ass
is SpawnReason.NATURAL in CreatureSpawnEvent triggered whenever the "world" spawns an entity when it likes to?
What's wrong with the builtin one?
Found this; https://dom4j.github.io/
Basically I am forced to do things such as
Element versioning = (Element) metadata.getElementsByTagName("versioning").item(0);
Element versions = null;
for (Node node : new IterableNodeList(versioning.getChildNodes())) {
if (node instanceof Element element) {
if (element.getTagName().toLowerCase(Locale.ROOT).equals("versions")) {
versions = element;
Which uhm could be semantically be improved by a bit
It's especially stupid that .getElementsByTagName walks the entire tree - so it will even return elements that have the given tag name that are children of children of the element
However this does seem to do what I want thanks.
Hi, where can you create a post on spigotmc?
forums
?domagicyouwizard
Assuming its development related
?howtomakeathread
?howtopostathread
ofc it's post
Ok, so I needa create 20 ports to get access to here, which is super weird: https://www.spigotmc.org/forums/services-recruitment-v2.54/
It's to prevent bots
Am I allowed to create spam ports to get access?
Yep mostlikely
To shade or not to shade. How do I figure that out when building plugins?
When it's a library you probably have to shade it
When you're depending on a plugin not
Atleast when that plugin is on the server
If its included with Spigot = no shade
Oo, what if the dependency has spigot api as a dependency?
β
Or if itβs another plugin whoβs api you are using
Does it count as a library or a plugin?
(assuming the library is only using spigot api for implementing things, without plugin.yml and whatnot)
Uhh spigot API is provided as the server
Mhm okay, that means I wouldn't need to shade it right
What if the dependency has other* dependent libraries apart from the spigot-api and it needs them to function?
You don;t worry about other plugins/libs dependencies
thats for them to take care of
or the server owner
Yeah, well, I'm trying to make a utility/commons package to use across my plugins, and I suppose that part is what I'm trying to figure out
You only worry about what you specifically rely on
So this is my situation:
Some Plugin - spigot 1.19_R1
- utilityPkg 1.0_SNAPSHOT
utilityPkg - spigot-api 1.19_R1
- collection_commons
- lombok
- reflections
I reckon I don't need to shade in spigot 1.19_R1 because its provided as the server, but I'll have to shade in utilityPkg right? It's not a maven dependency, it's just a jar I made.
But do i need to rely on an urber jar of utilityPkg or the normal jar will be fine?
You can always exclude dependencies from maven artifacts
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>0.98.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- We don't want to harm our dependency tree with transitive dependencies-->
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Would be an example for that
With the provided scope right?
how to get banned from spigot within a day