#help-development
1 messages ยท Page 2295 of 1
and then provide your plugins instance
i just prefer to check for my own class subclass because my plugin extends BurchAPI
if you want just rip that whole class
and replace invokeClass with your DI needs
I cannot use DI
Because i dont know if people will use Di with which class
That the main issue
๐ฌ
I wont know if people ill use constructors on command class for example, maybe yes maybe not
So you can have a setInjection(T) (Generic) object settier for DI
and store theyre JavaPlugin class instance as a generic
More things lmao
thats why you check
look at my code
constructors are ALWAYS in java
unless privated/protected
thats why you catch invocation errors
and then tell the API user that theyre methods need to be public
but by default java provides a public constructor with no args
yeah i know
But what if they add some randoms args that i dont know then i cannot initialize
But if i ignore them they will get NPE exceptions
๐
just dont register the command?
and it never gets called
throw a error message into console
"CommandXYZ will not be loaded due to a invalid command constructor"
then continue in your loading loop
typically you wont need more than your plugins instance in a command
most people who know java make getters in the main class like instance.getPlayerDataService()
passing any other args to a command constructor doesnt rly make sense
Since @Command sets everything about the command you need
too much things for a simple deal
well overall this kind of thing isnt simple, but not overly complex either
I ill just do them to save a Map<Command, Class>
So them i force to pass the class instance ith args already
saves a lot of overhead when getting classes and stuff
how about something better
if your annotations are set at runtime retention
make users extend a Command class, and then make them pass a instance to registerCommand() in your command class handler
and you dont need to handle anything besides annotations
all object in java have getClass()
use that to get the annotations
and you wont need to worry about the constructor then
So them just do something like:
CommandAPi#register(class implementing CommandData)
tbf?
oh ok
i just use it so its easier to store in a list
cause theylle all be instances of each other
My user extend ApiCommand
I also want something diff
that way i can shove theyre command class into the command map
without any special processing
Because i want to each class contains many commands (each boolean method + annotated with @Command = new command)
- Burch
ohhh
interesting okay
so like each method is a boolean annotated with @Command
in that case u dont need the extension
I'm modifying the vanilla knockback and damage, but I'm having issues with calculating the damage of armor and whatnot. The final damage doesn't seem to calculate for armor, so how can I work around this and calculate it properly?
// Works, but doesn't account for armor
double damageFinal = event.getFinalDamage();
Bukkit.getScheduler().runTask(app, () -> {
double health = player.getHealth() - damageFinal;
if (health < 0.0) {
health = 0.1;
}
player.setHealth(health);
});
// Everything below works properly
Combat.sendDamageAnim(event.getDamager(), player); // Sends the animation packet
Combat.applyKnockback(player, damager, 0); // Applies custom knockback
just scan theyre JavaObject.getClass() methods for the annotated methods and your chillin
and it can be any class that way
But i want them to register like this:
new CommandClass(arguments)
yep it will work like that
registerCommand(new MyCommandDoesntMatterWhatItExtends(arg1, arg2, arg2));
public void registerCommand(Object obj) {
obj.getClass(); // run through its methods here to search for annotated methods
}
Oh okkk
just make sure you annotations have runtime retention or you wont be able to use them
I think IDE already warns you for that tho
uhmm hmm
Burch do you have kotlin experience?
Use Damagable @last swift
absolutely none :c
Oh sorry for being ass-hole but i having some more issues :/
your not xD
I have a protection plugin with next modules: core, 1.19 and 1.12
And im thinking i will face flags issue
๐ฌ
I have 0 idea how to do maven modules
Might be a question for smile or conclure
No no
oh okay
There no isue with that
wym by flag issues then?
Because some flags are version dependent i think, something like animas protection flag and mobs
I call flags to special atribbutes that allow/disallow something
ohh
do they not have like a getSomething(String) method?
like with Material.getMaterial?
I keep a track of a List<Flag> on my core claim object
Whats the import for that class
Flag
But i dont know how to that flags i mention before (animals and mobs protection) because they are version dependent
or is it FLags
Flag is an enum
I dont see any bukkit Flag classes
What does it store?
My bad i didnt explain you
better yet, how do you get the anims and stuff?
WHats the code for that
i need need the object names of how you get the animation ids and stuff
Yeah that my question, because the flags that are not version dependent like command protections are created inside the core module
Like is there AnimationSomething.SWING_ARM?
cause idk how your getitng all this stuff
I explain you more or less here
I just need the class name
is all
like a code snippet of how you play animations etc
As animals and mobs are diff in 1.12 and 1.19 what do i need to do? Listen to special flag on each plugin module or in the core?
i just wanna see the methods of the class
Do i explain?
Oh let me use translator so its better
like the code your using
i just need the code your using that enum class in cause idk what your doing
Something like this
are these stored into PDT?
So if this is your plugin why would it be version dependent?
And then on the core i listen to block place, delete and command, check if flag is enabled and allow/disallow the action
Because of flags and mobs animals?
Because on 1.19 are not the same mobs that 1.12
Yes
That why
Im asking if need to listen to flags on the core or each plugin module
๐
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html#valueOf(java.lang.String)
You can use this method if you like if you want to keep it the same accross the field, youll need to catch those exceptions thrown so wrap it in a method where when you catch the exceptions it returns null
A friend told me to code the full project on 1 module but using spigot api 1.13 but im not sure. So them i created 3 modules core (common things), plugin 1.12 and plugin 1.19
I would personally never develop 3 seperate code bases
But would work what my friend said?
Because let say if i code the plugin in that way then some mobs and animals doesnt exists so i will have issues related to flags
๐ค
no because your plugin compiles to one jar and it can only depend on one version
That way just sounds like youll be making 3 forks of your plugin, and youll need to release a new resource page for each one
Thats why you never want to hard code in any bukkit enums
always try to use string getters
So how are you getting entity types then? valueOf?
your Flag class wont be an issue its the entity types that will
I still didnt code the mobs and animals flags
yes i know
then in that case
what u suggest
follow this
it will be version safe
for any version that has EntityType class + that method (valueOf is a default java enum method)
i would wrap it tho
how do i make a custom ban message so it doesnt be the default message
package no;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
public class BanListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerLoginEvent e) {
Player player = e.getPlayer();
if(player.isBanned()) {
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', "&cno"));
}
}
}
public EntityType getType(String type) {
try {
return EntityType.valuedOf(type);
} catch (IllegalArgumentException | NullPointerException ignored) {
return null;
}
}
if (getType("HUSK") == null) {
Bukkit.getLogger().info("Please use a version that supports husks!");
}
Ohh ok
I know what you mean
:))
e
hmm
Does that not already change the kick message?
If not, use AsyncPlayerPreLoginEvent
(You should use that anyways)
it doesnt
k now i am gonna go to the docs
this
kicking in this event should set the message
or disallowing cause thats how that events used
ik
ok and i dont know how to use AsyncPlayerPreLoginEvent
e yes
uh
how do i get players name
cuz
i am stupid
;-;
Use UUID for checking bans
just get slot 0 and check its meta data
Player names change, UUID's dont
yea nvm
?paste use this
?paste
Put it in a paste
my brain isnt working
hmmm is the player an item now?
don't store info using player names
use their uuid instead Player#getUniquieID
if (player instanceof ItemStack stack) {}
hmmm They might want to use reflection here
yes but how do i check if they are banned
yep
and bugs and stuff
IIRC BanList has a method for it
sec
spare him don't do it ๐ญ
Better idea:
-
Learn more java
-
Take the UUID, pass it to OfflinePlayer then getName() of that player
BanList seems to be handlred horribly
declaration: package: org.bukkit, interface: BanList
like excuse me?
we ban off names spigot?
spigot?
what the hell
i wish I could PR to change that xD
Okay well
yes I gotch you gimme a second
it does support IP's
if you get the IP list you can search via ip
but no uuid tf
prolly because bans.json is so aids
@EventHandler
// I was just spoonfed like a baby :)
public void onSpoonFeed(SpoonfeedEvent event){
event.setCancelled(true);
}
you forgot @EventHandler
mb
pooog
it should work
its on line 1 therefore it cancels the item in the first item slot
SpoonfeedEvent is an alternative
did i do it right man
UUID uuid = e.getUniqueId();
Player player = Bukkit.getPlayer(uuid);
I think Conclure could help him
well think is
@ivory sleet wanna help this guy for us :)
Player is only available after the player actually joins
so you need to use OfflinePlayer
Any idea i can add to leeroy?
i need ideas on some dickhead things he can do
if you get to far from leeroy he goes to your spawnpoint and blows it up than returns to chasing you
not sure if this is possible but a fine idea
add actual leeroy voice
where he teleports offset 20 blocks then darts at you 5x speed
@quaint mantle
pls help
i wish
i could make a tecture pack ngl
omg
thank you jacek
?ban @pastel copper
Done. That felt good.
Whats an un-used sound in MC anyone know?
pog
big pog
you dont need to override voice
no you just replace a sound in the game
in the texture pack
and then play that sound to client
but you can add brand new sound in texturepack
ok i;ve sended it
alright codes added now to just find leeroy jenkins audio
perfect
time to test 
Creative variable names
indeed, he does do that too
only issue it that youtube vid didnt covnert to ogg properly
oh my god
this gonna be hilarious
bwahahahahahaha
pathfinding fucked up at the start but still funny
button click ๐
can you imagine hearing that ever time you clicked a button
"LEEROOOYYY JENKIINNS"
@gleaming grove hahaha
goes to change settings
speeds through menus
LEEEEROOOYYYY- LEEEROOOYYYY- LEERROOOOOOYYY JENNKKKIIINNNNSSS

im gonna have waaay to much fun with these sounds
im gonna make leeroy a fucking menace
i;m waiting for better skin
Need to create something better to make him not go all batshit crazy lmfao
this one is perfect
i need a little bit of help figure out OutputStreams
try (FileOutputStream fos = new FileOutputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos)) {
room.serialize(oos, getWorld());
oos.flush();
byte[] bytes = bos.toByteArray();
bos.flush();
}```
what would be the purpose of flushing the ByteArrayOutputStream
actually it seems to be nothing
because flush doesn't do anything in the superclass
and ByteArray... doesnt override flush
so my question has been answered
the purpose of flush() is to remove everything in the current buffer
its good if your re-using a output stream and want to make sure nothings on the buffer before doing your next thing
but if your using it once you can just close it iirc
i like to flush then close tho
uhmm not sure about that one
i just re-initialize it ngl
prolly not the best way, i assume reset() is propor but i dont use streams long enough for that
i just open them for file writing and then close, or for a quick rest request
yea its just that rn it's in a try-clause thing
(forgot the right name for it)
so theyre effectively final
lambda?
cause you can have nonfinals on try/catch
but in lambdas, when setting variables using = they need to be effectively final, or an AtomicReferance
i try to avoid situations like this where i can
cause i dont like either options
sometimes you cant though
How would i create a pagination command using this method though
i have a couple questions ima just wait for 7smile7
damn 7smile has a whole ass command
also if an offline player needs to be accessed, would it be proper if I loaded the offline player and then eventually unload it later when all the data gets flushed
he has multiple
what a show off
He's better than you stay mad
Question this is gonna be VERY stupid but I'm desperate because my workaround is total aids
My IDE alerts me "task" might not have been initialized, however it will 100% will always be initialized by then as this timer has ran multiple times by now
How can i mark this as unsafe, or override this method somehow?
im joking calm down
yall can just block me ik most stupid question
any reason to not use bukkitrunnables in this case?
yeah was just gonna say
BukkitRunnables allow that?
you can call cancel() directly
yeah you can cancel internally
I have a scheduler utility that's just a fancy wrapper to bukkit's scheduler
it's stupid as shit
yeah i might do the same thing
i have a runTask(Runnable, delay) method in my main inherited class
but thats it lmfao
the code internally just calls the bukkit method after wrapping it around like 8 different classes
oh thats a smart one though ngl
i would prefer an empty constructor cause im too lazy to get my plugins instance xD
I can then do stuff like
task.onCancel(() -> {
...
});
ohhh functional intefaces
can .run also take lambda?
mmmm
also if you call every(...) it returns a modiified ScheduledTask thing that allows me to set a duration
yes
callbacks in java fun
new ScheduleBuilder(plugin)
.every(1).seconds()
.run(() -> {
Bukkit.broadcastMessage("tick");
})
.during(5).minutes()
.async()
.onCancel(() -> {
Bukkit.broadcastMessage("cancelled");
})
.start();
placeBlockasNpc(loc, Material.DIRT, () -> { // executes after completions });
im working on a wrapper class rn actually to build my callback functions like that
cause rn my code be looking like
completablefuture poor man edition
nono
cries in callbacks
it IS a completable future
well kinda
the function executes async
call back to main thread for callback function
my man
efficient asf too
that's small
not much I can do about it
someTask()
.andThen(anotherTask()
.andThen(() -> {
}));
im going to make a builder similar to this
that's the method for pasting a house / island
๐คก
I only had to rewrite it like 4 times
thats not bad though for schematic pasting
oh it doesn't paste the schematic
oh
ahh
it then calls one of the two methods (one for pasting handlers that want a loaded world, the other for unloaded world)
illusion have you met leeroy yet?
I saw it on a video
is that for a skyblock plugin?
but did you see him with the added sound effects 
yeah
yes
Which then pastes the island :)
I've done bigger blobs of code for fake blocks
and pasting fake blocks from schematics
using multi-block-change packets (one per chunk section)
and making a shitty WE api for fake blocks
that just has a set method
The code for saving islands is actually like a third of the size
but 2x as janky
because paper decided to be a special little snowflake and save worlds async with no way to know when the worlds are actually saved
WorldSaveEvent triggers at the start of the save instead of once the buffers are all flushed
so I made an intentional configurable delay
๐คก
But if I unload the world as soon as the buffers are all flushed the world may still corrupt
so there's another delay on top
why are fake blocks needed?
Fake blocks are for another project
where I run like 25 minigame instances at once in a single world
because the map doesn't change much
The fake blocks are just doors that you can unlock to access other areas of the map
So I just set those blocks to air and send fake blocks for the doors
unlocking will just sent a premade empty area packet
:)
But my stupid ass decided to optimize the shit out of it to only use one packet per chunk section, regardless of how many doors or blocks were there
And then make it all load out of a schematic
I mean it's like 400 lines total
And another 100 lines to make sure you can click on those blocks
and not just break and bug them out
I also made sure to optimize the heck out of it by hashing every single aspect of the block's location
AKA making a chunk system
For quicker lookup times
I made a plugin that when a player right clicks a sculk shrieker with a nether star it summons the wither, but when the warden is summoned, the console gets spammed with errors.
Here is my code:
package me.guedosha.summonwarden;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public final class Summonwarden extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onDemandSummon(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block b = event.getClickedBlock();
Action action = event.getAction();
ItemStack item = event.getItem();
if (action == Action.RIGHT_CLICK_BLOCK && b.getType() == Material.SCULK_SHRIEKER && item.getType() == Material.NETHER_STAR) {
player.getWorld().spawnEntity(b.getLocation(), EntityType.WARDEN);
}
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
and here is the console error:
oh wtf
ahh i see i always wondered uses for fake blocks
always seen ppl using em
sorry for slow responses working on leeroy
i cant send the console error as an image. give me a moment
They're nice for per-player effects
like a cave entrance you can blow up in an rpg
without making a whole world for that
I made a whole client-sided tutorial with fake blocks and entities
where you had fake menus you could click on
ERROR Could not pass event PlayerInteractEvent to Summonwarden v0.1
20.07 22:25:19 [Server] INFO java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null
20.07 22:25:19 [Server] INFO at me.guedosha.summonwarden.Summonwarden.onDemandSummon(Summonwarden.java:30) ~[summonwarden-0.1.jar:?]
20.07 22:25:19 [Server] INFO at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1.execute(Unknown Source) ~[?:?]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:git-Purpur-1662]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:666) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
20.07 22:25:19 [Server] INFO at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:544) ~[purpur-1.19.jar:git-Purpur-1662]
Hello, how can i send a action bar for the player 15 times for 15 seconds
but i need to the actionbar update
what if the item is null
or the block is null
add null checks
You need to handle that type of stuff instead of just pasting a block of text and expecting us to spoonfeed you
the cursed method comment should say 40 tho
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
target = Bukkit.getPlayer(UUID.fromString(args[0]));
if (target == null) {// Handle null target}
}
Is there a better way of handling this?
I could just not do the second check, but you never know lol
?paste
oommmfffgggg
i hate pasting code man
so FUCKING annoying
@vagrant stratus
UUID throws that exception if invalid one is provided
i prolly fucked the ternary up maybe
i did
reverse the last 2 parts of ut
uuid first then string
I keep forgetting ?: is a thing ๐
i did too and i was looking at that like hmm
and it popped into my mind
i 100% never use them in my own code
Anyone versed in ProtocolLib? I used to have this working before updating and such (and decompiling my src from before, might have screwed it)
I'll most likely use them within my Anti-Malware more when I rewrite lol
โจ windows corrupted and i didnt have a backup anywhere โจ
github ๐
^^
well yeah i know that now.
your decompiled source is likely fucked to shit with the variable names and other things
unless you compiled with the original jar
that one has your pom and stuff still in it
so if you can manage to find that jar ๐
I already fixed all of it except this part
ive spent the past week unfucking it
now im to this point
I'm good with protocollib
What you need?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
getting this error
this.protocolManager.addPacketListener(new PacketAdapter(this.cadiaBees, ListenerPriority.NORMAL, PacketType.Play.Client.CHAT){
public void onPacketReceiving(PacketEvent event) {
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
CustomHive customHive = cadiaBees.hiveGUI.getPlayerInteractingHive(player);
PersistentDataContainer container = cadiaBees.hiveManager.getBlockForHive(customHive);
if (container != null && cadiaBees.hiveManager.getPlayerNamingHiveTask(player) != null) {
event.setCancelled(true);
String newName = packet.getStrings().read(0);
if (newName.equalsIgnoreCase("cancel")) {
player.sendTitle(ChatColor.YELLOW + "Hive-Naming Cancelled", "", 20, 40, 40);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
cadiaBees.hiveManager.getPlayerNamingHiveTask(player).cancel();
cadiaBees.hiveManager.removePlayerNamingHiveTask(player);
return;
}
if (newName.length() > 35) {
player.sendMessage(ChatColor.RED + "The max length for a hive name is " + ChatColor.GRAY + "25" + ChatColor.RED + " characters!");
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
return;
}
cadiaBees.hivePDCManager.setHiveName(container, ChatColor.translateAlternateColorCodes('&', newName));
player.sendTitle(ChatColor.translateAlternateColorCodes('&', newName), ChatColor.GRAY + "Hive successfully renamed!.", 20, 40, 40);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_YES, 1.0f, 1.0f);
cadiaBees.hiveHoloManager.getHolosForHive(customHive).get(0).getHoloLines().set(0, ChatColor.translateAlternateColorCodes('&', newName));
for (Player allPlayers : Bukkit.getOnlinePlayers()) {
cadiaBees.cadiaCore.hologramManager.refreshHolo(allPlayers, cadiaBees.hiveHoloManager.getHolosForHive(customHive).get(0));
}
cadiaBees.hiveManager.getPlayerNamingHiveTask(player).cancel();
cadiaBees.hiveManager.removePlayerNamingHiveTask(player);
cadiaBees.hiveGUI.removePlayerInteractingHive(player);
}
}
});
listener
How to trigger command in server for a player?
pass them as the CommandSender in Bukkit.dispatchCommand
CommandSender inherits Player iirc
or visa versa
Packets are being read async
what's HivePDCManager#93
blockIsPlayerHive
thx
public boolean blockIsPlayerHive(Block hiveBlock) {
Beehive playerHive = (Beehive) hiveBlock.getState();
if(playerHive.getPersistentDataContainer() == null) return false;
NamespacedKey hiveCustomKey = new NamespacedKey(cadiaBees, "custom-hive");
if(playerHive.getPersistentDataContainer().has(hiveCustomKey, PersistentDataType.INTEGER)) {
return true;
}
return false;
}
BukkitScheduler#runTask
I thought there was a lambda thing
regardless why aren't you using a chat event for this kind of stuff?
they dont need to be cancelled so its fine
you literally cancel the packet event
pass in a lambda in the runTask
well if I cant cancel it from sending the message thats an issue
idk why i have this in a packet listener tbh..
Well I also cant do this on chat...because the chat even is also async..
holy shit i got it
well..cant cancel i need to
fun fact if your doing something async and need to shove it back to main thread the BukkitSchedular/BukkitTask#runTask will throw the code inside the runnable on the main thread
(if thats your issue)
i see yada mentioned that too
here
Anyone knows how to detonate a firework instantly?
hmm
sec
You have a Projectile instance right?
declaration: package: org.bukkit.entity, interface: Firework
detonate()
wait
sorry
sec
i assume you tried that?
or not yet
yeah figured
now it stopped for some reason
yeah i cant find any methods for actually setting the fuse time hmmm
PrimedTNT has setFuseTicks
maybe theres another type for firework or something
lemme find
damn
why is that so complicated lmfao
yea xD
https://www.spigotmc.org/threads/instant-fireworks.198746/
This poor guy waited 2 years
Ive looked up in some forums and they said i need to delay the fuse in a few ticks so it will do, I delayed in 10 ticks and it still didn't work
Sounds like its gonna need some seriously tricky packet trickery, or fake fireworks
Or we need 7smile7 or choco
7smile offline rn tho
Does somebody know if resoucepack could be download from public FTP with this code?
event.getPlayer().setTexturePack(settings.getFtpTexturesURL());
just as long as the url returns the direct file
eg with dropbox, you have to change the end of the link to dl=1 that way the url returns the file
not sure how exactly it needs to be returned tho
sounds promising
anyone have a link to the namespacekey of vanilla recipes? including smelting recipes
i done this
does this look like instant ?
?
look at the last reply
HAHAHA
to give credit on the guy i sent
that is a rather weird thing to do cause you cant edit the fuse time
I never understand why people just randomly close their threads
someone might have an answer and now people just find a closed thread on google without any answer and no way to reply
so useless
โi copied this multiversion setUnbreakable from spigot forums, will this work ?
ItemMeta already has a setUnbreakable tho, or?
not on older versions iirc
Found that itemmeta.spigot().setUnbreakable() exists on lower versions, probably wont exists on newer, maybe set the durability to Integer.MAX_VALUE
not sure if that code sent would work, best thing is to try it ๐
man maven is the most
stupidest fucking shit ever
god why do people use this pile of shit
the repos are literally harded as https
Yep maven bad (:
like you cant even access these urls with http
and mavens saying theyre http...
invalidated caches... added a mirror to settings.xml...
none of it worked 
Is there any fix for this?
is there a way to allow players from a certain server (not a proxy) to join another server?
for example, players can join server1 through server2, but they cannot directly join server1
context: i have a waiting lobby which is a bungee instance. the waiting lobby is not a proxy (again). they should go from the proxy to server1, and the from there to server2
lmfao wow found it
if it used a older version from the repo it redirected as http.... so you need the LATEST....
but to send the data (that a player has joined) from the proxy to server1 would require me to make a plugin for server1 too
wouldnt that be sketchy
someone could manipulate or abuse the response
Is there any way of putting Multiple Locations into world.dropItem(); Because every Time I fire the Command, the Server Crashes when it gets to the point of dropping items
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
java.lang.ExceptionInInitializerError: null
at MultyBot.SQLUtils.<clinit>(SQLUtils.java:14) ~[?:?]
b[0] = false;
``` is not valid java code
line 14 is URL
because plugin is null at that point
why is it null
because it hasnt been initialized first?
how to initialize it first?
you cant in this context. you will have to set your variable afterwards
your constructor only gets called if you create a new instance of that class. your static variables are initialized once the class has been loaded. because of that it doesn't know the plugin var yet
it is not wrong
that is correct
because it is static
you use ClassName.b = false
i wonder how is it supposed to run if the runnable part is outside of any method/constructor/initializer?
yea how does that even work
.runTaskLater(plugin, 20 * 5);
at the end of the runnable initialize
its the same as doing BukkitScheduler.runTaskLater(runnable)
no
i mean
thats what you should be using
if you have a class named TestClass and it has a public static boolean b you use TestClass.b to access it
u should learn java
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
you don't have a good enough understanding to be programming with spigot
not a good idea
well in this server we help with spigot
not java
i just had to explain a very basic concept to you
i cant understand what are you saying exactly can you edit my code instead? please
its expected that you have atleast a basic understanding of java's syntax
Hello
Given this event, how can I get the name of the advancement? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerAdvancementDoneEvent.html
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
#getAdvancement().getAdvancementDisplay().getTitle() ?
(Not sure it's the thing you are looking bu found it Quickly on the doc on my phone)
Sorry, I sent a wrong version of API I am working with
Lemme sec
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
Here
Idk about that, I need the name of the advancement, not just the key
Two options :
- create a namespace id converter (so you have to save all the name and put them next to a key)
- maybe there is a translation file containing all of this
how to hide a C418 - mellohi lore on disc?
Update : i found that
"you can get the advancementdisplay from the nms advancement. cast bukkit advancement to craftadvancement, get its handle, and then get the display. theres a public getter method for the display in nms advancement"
Hmm, okay, thank you
Quite old actually so test it before https://www.spigotmc.org/threads/need-help-with-items-lore.82696/#post-911275
thanks

Set it in the constructor
Why making a field static if you set it in the constructor tho
because if i dont i cant use getdatafolder in url
Set the URL field in the constructot
Hey hey, does anybody know what meta to use for changing the sound of a goat horn? Or in general how to change the instrument of a goat horn
hey
help
plugin is null when using it in a static reference like that
But how do I implement that in a plugin?
initialize url in the constructor
set the nbt of the item
is it possible with the spigot api?
yeah lol
what's the method called ๐ ๐
wdym how
what do you call "initialize"
there is ItemMeta but it doesn't include smth like "setInstrument()". And I didn't find a fitting ItemMeta class for a GoatHorn
How does the nether work? I have multiple world folders for the plugin I'm making. Each one has it's own nether right?
There's the event 'PlayerChangeWorldEvent', which triggers on a change between any world. I'd like to detect when a player changes between world folders
how would I do that?
lol what youre right
theres no goat horn meta
how could md_5 forget the goat horn
it's initialized statically
bruh
june
how is it so hard to add this
there are some wip pr's already
it's initialized when class is loaded but plugin isn't yet initialized
if you really want to use the spigot api you could build spigot yourself from those pr's
otherwise just use nms
or a library
how to fix it then?
set url's value in constructor
Whats the problem?
Ah i see. You cant mix static and instance variables like that.
Static is called before any instance is created of the class.
How can I check if item is named?
ItemMeta -> hasDisplayName
how to use plugin.getDataFolder() in my url variable?
Ok thanks
initialize url in the constructor
You cant
there is no "plugin" variable
replace everything
with an ; after url
and then in your constructor
initialize it
Make it not static.
Just write your plugin without the static keyword.
This will help your understand what static does.
What happens if you unload a world when a player is in it?
NEVER use static, unless someone who knows how to write Java tells you to
The player gets sent to the default world iirc
mk
The blank final field plugin may not have been initialized
I thought it just failed to unload the world, but I may be wrong
remove final from plugin?
Yes. Variable initializers are called before the constructor.
if i dont make it static then i cant use it in other classes
You need to create a getter and pass the instance to other classes
Did you master saving data into files first?
Using a database before understanding java is just bound to cause problems and increases your development time immensely.
I made an economy plugin and I require some data from thata database in another plugin. What is the best way to make an api? Are there any guides or docs you can recommend for that? Because I need a BalanceChange event which I can access from the other plugin and I have to be able to read the balance of a player.
Using event notifications is usually not something databases are designed for.
I only need the event whenever the balance of a player changes, because I have to update that in another plugin
but is there a doc or smth you could recommend? I think I'll be able to figure it out from there
So you are keeping two local representations in two different memory spaces?
Sorry, had to go for a sec. Uh no. Same server, meaning I could just add the economy plugin as a dependency, but Not sure how make the event. I think thats the actual problem
So your problem is just to create a custom event?
I mean you simply extend Event,
class BalanceChangeEvent extends Event
And after that you fire it.
Bukkit.getPluginManager().callEvent(new BalanceChangeEvent(playerId, changed ...));
- Dont forget the static handler list
Appreciate it, I'll take a look at that
Don't forget to implement cancellable ig
Thanks for the help! Makes sense so yeah, gonna try that
You good?
7-8 years ago I wrote that code ๐
o.O
facts, why do people use eclipse?
Always forget how long elgarl is around here already
I use Eclipse. I love it amd thats why I use it
hm
I mean I have the privilege of using IntelliJ Ultimate because my college gave me a license for it, so there's that
Oh well. It's just convenient to be able to look into databases that easily
Only two issues I have with Eclipse.
- You can;t resize the toolbar, so icons are really small on large monitors.
- Nested Modules are treated as separate projects.
my eyes dont want to work today :(
Returns true
I ment like how do I check if item is named with an anvil or if it just has its vanilla name
boolean isVanillaName = meta.getDisplayName().equals("");
That works but is it a good way tho?
Advantages/Disadvantages of these approaches?
no need for a click method ig
they both have click methods don't they?
actually the constructor way looks cleaner to me
Weird theme
no u
this theme looks hot but its only for vscode :(
just use the mario plugin
whas that
super mario theme in intellij
only downside is that you can't play as Luigi yet
with sounds
Is there a better way of iterating through all players in a world to get the closest one to a particular position, other than using Bukkit.getOnlinePlayers()?
World#getOnlinePlayers
sounds horrible
sounds great
Either getNearbyEntities() or iteration through all players (in this exact world) and checking for distance squared
maybe?
huh
there is apparently also a getNearbyPlayers
but is that better than manually iterating?
thanks for all the answers btw, wow
wdym, i got that for intellij i think
This sounds like a paper method
is a thing
except yellow variables
declaration: package: org.bukkit, interface: World
no clue, im using spigot
I only have spigot as a dependency
Iteration with distance squared is pretty fast. All you do is N multiplications.
nobody listening to me smh
Ive already suggested that
wait so where the heck do these methods come from?
everything looks blurred
I would always prefer api methods over self written ones and then
hope that the underlying implementation is decent.
spigot api lol
oo
can someone verify if am still alive?
not really
I see
it looks cleaner
so ill use that
But there is no method to get the nearest player to a point, so...
there is tho
Which one?
o wait
I might have misphrased a bit
I just wanted to get the nearby players within a certain radius to a point
I can just use
Oh. Thats a completely different task. Then def use this method.
oh thats a method too
I mean not completely different
This is not a spigot method btw
paper
how
You have it on your classpath
Are you using maven or gradle?
And you didnt add any jars manually?
I see
if its available i might as well use it
otherwise I would manually iterate through the players
Here is a replication
public List<Player> getNearbyPlayers(Location location, double radius) {
return location.getWorld()
.getNearbyEntities(location, radius, radius, radius, entity -> entity instanceof Player)
.stream()
.map(Player.class::cast)
.toList();
}
I think it depends on how many entities are nearby too
if the nearby entities is more than the total amount of players it would be better to iterate through all players instead right?
Player.class.isInstance :(((
no way isInstance is a thing
method references :((((
are leaves transparent
it is tho
not needed
Oh you mean for the Predicate
yep
Yes you could also use Player.class::isInstance

fastest way to check if block is leave
Tag.LEAVES.isTagged(material)
not sure if thats the fastest but its one line ๐
ij just crashed by looking at that method smh
Any maven wizards?
How can i take an entire package from my plugin, and treat it as provided? Eg not compiling the files into my jar file, but still allow compiling
wdym, you want to expose certain "APIs" from your plugin?
me?
no that chicken crossing the road
if it's me, I need to do it because when importing citizensapi NMS methods they're remapped oddly, but in their source code they're not
So i take their classes and manually hard fork them into my jar only copying classes I need
These classes shouldn't be hard compiled in, they should be as provided but I'm unable to do it via maven repo due to the remappings
Hence why i want the files removed and treated as "provided"
doubt its possible
but worth asking
no its not you
i think there is this maven-jar-plugin
try play around it and see jar contents
hello, so i have3 servers (in theory) and on one server is my minigame and the other is lobby, 3rd is bungee, how do I make that players user /play in lobby and it joins them to the game
oh nvm
? I masking how to program it?
pluginmessaging stuff?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Can you tell me, I use the default config file, I add a few things and use reloadConfig. But no data is changed.
How can create a Item which has a translatable name? For instance I'm creating a potion with an effect, but I want it's name to be "Potion of Strength" (-> translatable). Because I create it via plugin it's name is "uncraftable potion".
adding via code or directly to the file
Adding via code works fine. Directly not.
You must be saving before you reload which overwrites the manual edits
you need translations
yes, I know, but how do I put these translations on the item?
should each player have their own translation?
you want to animate teh chest opening? or you actually want to open it for someone?
yes, it should be like a default item name
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
o my bad
replied to the wrong message
and the String is for instance: "item.minecraft.potion.effect.night_vision"
I have this: "item.minecraft.potion.effect.night_vision" and I want this : "Potion of Night Vision" (for every language)
o wait
localized name is not what youre looking for
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
translatable components is what youre looking for I believe
I believe so too
but how do I put this component ON the item?
that's what I'm looking for
I believe NMS is the way to go, but I'm clueless how to start
Directly add and reload, no new data I add will be loaded. I don't understand.
you can;t just be reloading
I do this often in many of my plugins so I know it works exactly as it should
Save instead of reloading
Just save?
why should he save if he wants his manual changes to apply?
,?
He's trying to load in manual changes he made to teh config.yml
Because heโs making changes by code
Reloading just gets data from the file again
yes
Which wouldnโt work becuase the manual changes havenโt been saved yet
Which is why I'm telling him he must be doing something else as well as reload
No his MANUAL changes are with a text editor, NOT via code
Yeah bad wording there mb
I get it wrong often too ๐
Why is vanilla minecraft easier than spigot in terms of custom items / names
Add via code no problem. I just add (by command), save and then reload new data added. But I added directly to the config file and reloaded, nothing changed.
can you send us the code you run on the reload command?
Speak for yourself. Custom items in spigot are easy if you know how to program and use your IDE
custom items in vanilla are even easier lol
Yeah, but nbt is sooo easy with vanilla commands
Sure but you have to look up every single attribute and you have no type safety.
And proper custom items are straight up impossible in vanilla.
My bet you are using an in memory cached object for the config not the actual read file.
good idea
Just that
why do you save the config before you reload it?
This is why FileConfiguration config = this.getConfig();
you are caching the config
I don't think so
saveConfig or not when I reloadConfig gives the same result.
yes
ok then maybe ElgarL is right
all of your reference is to your local config variable
there are a few things
if you reload and want it in your config you need to (after reload) config = this.getConfig();
for instance " List<String> msg = config.getStringList("msg");" is only updated on the beginning. If you reload the config this list won't change
case "reload":
if (!sender.hasPermission("be.reload")) return true;
reloadConfig();
for (String s : this.getConfig().getStringList("msg")) System.out.println(s);
break;
try this
just start writing raw json ๐ ๐ค
Ok. Thanks.
Will try it. If works.
For reloads you should always have a single reload method that makes sure all of your components are reloaded properly.
And your command only calls this method.
For configs: Always load your configs when the server starts.
Dont use FileConfigurations for configs on runtime.
When you reload you simply load all configs into your data classes again and call all needed component initializer.
Can't get it to work :/
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = nmsItemStack.v();
tag.a("translate", new TranslatableComponent(potionType.getNameLocation() + potionEffectType.getKey().getKey()).getTranslate());
nmsItemStack.b(tag);
itemStack = CraftItemStack.asBukkitCopy(nmsItemStack);
meta = (PotionMeta) itemStack.getItemMeta();
that TranslatableComponent doesn't even make sense LMAO
You are aware that you need to either use vanilla-only names or provide a resourcepack for the client to be able to translate components?