#help-development
1 messages · Page 1621 of 1
You can be my friend instead
i quit like a year ago
i have never seen you in my life before
literally this
|||||||||
tab
||
||
bump
?scheduling
just save it as a variable
Feel like you should read that
i already read that
i did (int)
Then you should be a pro (:
alright i now am a pro
Still what exactly are you trying to accomplish in the big run?
its complicated
You intrigued me
when someone clicks an item in a gui, it closes the inv and prompts to enter something in chat, and using the bukkittask, retrieve what the player wrote (on playerchatevent, run the task "get chat message")
to retrieve what the player wrote
Uh you probably don’t need it then
Oo!
i tried using conversation API or anvilGUI and its pain in ass
You might wanna use my lib for this
You start to sound like redempt
im going to
Boring parts but crucial for it to grow
But yeah @manic bison maybe imaginedev got a good example, see if you can find something there by any chance?
actually i did understand chatresponsemanager.java
Epic dev moment (:
what is lombok.RequiredArgsConstructor?
it just automatically generates the constructor
i reccommend it 
makes everything easier to type
although java 14+, lombok loses half of its usefulness
records 😠
less lines of code
IDE minimizes
You’re a lost cause in this case I’m afraid
just change requiredargsconstructor to an actual constructor
i deleted it
well you need to make a constructor for it
it put errors everywhere
well you need to make a constructor for it
what the name of the constructor ? so i can build it mayB
?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.
of the one you put on your classes
constructor should have the name of the class you are creating here...
oh lombok
okay this is mind fucking
and also how would I call the class to register the message ?
I've been trying to fix this for more than 24 hours
and now my editor wont start
Editor could not be initialized. nice
public class ResponseHandler extends ChatResponseHandler {
private final ChatResponseManager manager = new ChatResponseManager(this);
}
okay i'm switching to intellij idea
?
Not sure what you mean by this
you've solved your own question here
gamePlayer.setData(new PlayerData());
public class Events implements Listener {
@EventHandler
public void BlockPlaceEvent(BlockPlaceEvent e) {
if (e.getBlock().getType().equals(Material.DIAMOND_BLOCK)) {
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Location b = e.getBlock().getLocation();
e.getPlayer().getWorld().dropItemNaturally(b, new ItemStack(Material.DIAMOND));
}
}, 0L, 20L);
}
}
}``` confused on bukkit schedulers, what do i replace this with at `scheduler.scheduleSyncRepeatingTask(this, new Runnable()` line?
replace it with lambda
scheduler.scheduleSyncRepeatingTask(this, () -> {
//code here
}, 0L, 20L);
how could I detect if players successfully landed in water? I dont fall fall damage enabled. rn im basically checking if the player is in liquid on the move event but its highly inaccurate when falling from a great height
I've debugged pretty much everything and can't find this issue
but when I click a kit the other kits get added to database
they seem to be already in the map even when a kit is not clicked https://imgur.com/a/erKXiiY
So im making a plugin which is supposed to be platform agnostic. At the moment im doing events, should I create my own event objects and use Guava eventbus? So both fabric and spigot will just hook into their platforms event system and will just call a platform agnostic event by pushing one of my events to the eventbus
Good idea?
I'm a bit confused by BungeeCord's permissions system as, as far as I can tell, you don't need to register the permission, you just check for it either by defining the permission node in a Command's constructor or using Player.hasPermission(String node). Is there nothing else to it like the ability to have all players have a permission by default or automatically allowing console access, like in the Spigot API?
how to make player execute command if they are within certain coords
i have this when i try to start my server Error occurred while enabling (Is it up to date?) with this big error someone can help me?
Error occurred while enabling Duel v2.1 (Is it up to date?)
java.lang.NullPointerException
at fr.anubizyt.duel.Duels.onEnable(Duels.java:55) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.reload(Bukkit.java:535) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [serveur.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [serveur.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [serveur.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [serveur.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [serveur.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [serveur.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks
The permission system by default uses the groups in the configs of bungee, most people dont use it though
What you can do though is install Luckperms on bungee
It will hook into the permission system and you can all point them to the same database to sync your spigot/bungee perms
Although bungeecord knowing of the permissions isnt that useful when it comes to anything but custom networks with custom plugins
how to check fi player at specific coord
i follow what they said but all my variable is initialled in the line ...
i restart it 5 time
you reloaded on that error
yea
its the same error
if the error is still the same, send us your Duels.class without taking anything out of it
?paste
PlayerMoveEvent, or run a timer and check every few seconds.
i did already
What yaw and pitch do you want?
how i send it after
i send the link?
yes
the NPE is on line https://paste.md-5.net/ezunasibik.java#L55 so that means the var it uses on it is arenaSection is null, which means that section in your config doesn't exist
how i can resolve it
how can i get as soon as a player touches the ground? because rn it waits for them to move a tiny bit or has a little delay then runs the code i want it to
the player falls from a big height
Are you using EntityDamageEvent?
there is no falldamage
What do you mean there is no falldamage?
can u resolve it for me plssss i dont know how pls you can save my project
check for Action physical in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html
it shoudl trigger on a player landing
burmp
then you have bad logic. falling though a switch possibly?
I ain't using a switch case though?
or something like
somewhere you are adding cooldowns when you shoudl not
so falling through a switch, looping all cooldowns instead of just the one you want
something like
Im leaning towards this ```java
public long getTime(IPlayer iPlayer, String cooldown) {
PlayerData data = playerMap.get(iPlayer.getUuid());
if (data.cooldownMap.get(cooldown) == null) {
data.addCooldown(cooldown, 0L);
}
return data.cooldownMap.get(cooldown);
}
the things that add up to it seems like its this
can u do it for me pls or not?
well, yes. If there is no cooldown that is setting zero
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.
Long value = data.cooldownMap.get(cooldown);
return (value != null)? value: 0L;```
that prob works too
so i need to put under arenaSection != null?
Elgar you think I should save it to the db when the player gets the cooldown or just save it when they disconnect or just both?
so long as you save async you can save it when teh cooldown happens
I just have a feeling it's gonna get spammed
Not really aaking for ‘help’ but curious on good ways to get feedback on code. While I’m pretty comfortable with the Spigot and Bungeecord APIs now, I know there’s probably loads I need to improve on when it comes to formatting my code (since I’ve usually ended up sticking to just one file until more recently) and keeping it generally performant. I haven’t done a ton with these APIs yet so there’s probably many shortcuts to some of the things I’ve tried to do that I’m missing out on. While my plugins mostly perform fine, I think it’s still a good idea to keep it as performant as possible to avoid my future self having to deal with it all
It generally just comes down to experience, or if you want a second new asshole, ask in here for code criticism when its busier.
I understand that, but most of my experience comes from me sharing snoppets of code somewhere and getting small bits of critisism on that, so I’d imagine it would be easier to get it all done in one and then it stops me getting experience over a long period of time then ending up lookin through all my past projects and trying to improve all my pretty messy code hah
pls use code blocks
how
at fr.anubizyt.duel.Duels.onEnable(Duels.java:55) ~[?:?]```
```
test
```
Use code blocks or put your error into a paste too
Also remember that if you share small snippets of code using this, you can specify the language used on the first line too
@cerulean estuary r u following a tutorial
yeah but they were sharing an error so
Yep, just wanted to let them know for future
ah
i try to follow this
https://www.spigotmc.org/wiki/stacktraces/ but i cant find the error
line 55 of onEnable, so quite high up. I'm going to guess a missing command from the plugin.yml
I think they meant a tutorial on how to make the plugin in the first place as, if you were, kt is likely that the tutorial is outdated
at this line i dont create a command
@cerulean estuary before working with spigot, or probably any libraries, try to learn the basics, or even more, of java
We can't guess. What is line 55?
for (String string : arenaSection.getKeys(true)){
then arenaSection is null
i learn the base
how i can change that
Just define it?
it either your yaml thats wrong or how you are reading it
Unless arenaSection is supposed to come from a library or another plugin
teh getKeys(true) tends to indicate its a ConfigurationSection
is there any way I can target all sign types simply? im trying to see if a player right clicks a sign but I dont want to have to check type against all of the sign types
however, if you want just the keys you shoudl getKeys(false) else they will be objects and not strings
normally it's false but i try to change it
if (Tag.SIGN.isTagged(block.getType()))
ConfigurationSection arenaSection = arenaConfig.getConfigurationSection("arenas"); like that?
btw, I hate saying this, but if you’re having to read a tutorial on stacktraces and not sure how to make something not null, I don’t think you know enough of the basics yet
ah thsts rlly helpful thx
?paste @cerulean estuary Show us your yml
yeah thats what I was trying to get to but I didnt wanna seem mean
i know sorry...
there is no arenas in that. Thats yoru plugin.yml
yeah ur fine, its something a lot of people do at the start of coding. you want to just rush into the fun stuff but you have to make sure you have a solid understanding of everything else before you go there otherwise youll just end up very confused
i know sorry
well I am running into new issues now apparently the user can only have one cooldown the other ones will cancel themselves
so i need to add arenas: description
you get teh vector from a location, or you create a new one.
I would be interested in seeing a quiz that runs yu through all the Java basics you should know before using APIs like Spigot and Bungee to make it easier to find oit if you’re ready yet and what you might want to learn, because I made the mistake of learning the APIs first an I know from experience it’s annoying to be told you might not know enough (and from people have a bit less of a postive response from being told that here) and it’s also annoying to have to re-learn all of Java because you’re missing a few key details. Having a quiz tell you would both mean having to read a lot less tutorials as you can more easily skip everything you’re already fine with
so if you want it to go the direction the player is looking, spawnLoc.setDirection(player.getLocation().getDirection())
a location set?
Not sure what you are asking
yep I did that aswell, I think w3 has stuff like that but they arent very advanced
It’s the pitch and yaw
See there is a problem with this. No one really knows what the "Java Basics" are actually because everyone has their own opinion and its different for everyone.
so you have a spawn location for yoru Arrow. are you tryign to send to to another location?
I suppose the features could be ranked by their imprtance and if you miss a few things that some people wouldn’t say are as importan, instead of saying “You need to learn this first” it could just be marked as a suggestion
final Vector directionVector = targetLoc.toVector().subtract(projectile.getLocation().toVector());
loc.setDirection(directionVector);```
Define suggests you are trying to set the pitch and yaw, I thought you were trying to get it? For getting, iirc it’s judt loc.getPitch() and loc.getYaw(). For setting it’s loc.setYaw(yaw) and loc.setPitch(pitch) then Player.setLocation(loc)
What is the target?
Oh right, I thought you were trying to get the direction an entity is looking at. I’d imagine the player is the target and the arrow is what they want to point towards the player
The thing you want it to go in the direction of
Is it possible for a map to reset to a default value?
then just set that yaw and pitch on teh arrows location
Then just set the pitch and yaw and apply the new loc to the arrow
Also, I have a feeling you weren’t intending for the 2 degrees off on the pitch and yaw you set; to go spdirectly west, you’ll be wanting yaw 90 and pitch 0
Is the pitch and yaw set the pitch & yaw you want it to use? If not, you need to change it using the functions I gave yoy before
-2 pitch wouls be a slightly upwards elevation
If I remember correctly -90 is upwards
???
What could be a reason why when 2 or more cooldowns are added into a map and when a player leaves and rejoins one of them are replaced with the first cooldown and now are duplicated?
Sorry I was meaning ??? to him saying “just the pitch and yaw” to me asking what he wants to do with the pitch & aw
ah
not saving before loading, and not checkign the map for existing cooldowns
In this code, you aren’t setting the pitch and yaw, so I’m a but confused; are you trying to say that yoy can’t set the pitch and yaw because they already have a pitch and yaw by default ans you don’t realise you can still change it?
Just thinking about this
public class RemoveLocation implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public RemoveLocation(Main plugin) {
this.plugin = plugin;
plugin.getCommand("RemoveLocation").setExecutor(this);
}
}
and do i really have to declare plugin as a variable when i don't use it elsewhere in the file? can't i just keep the plugin.getCommand("listlocations").setExecutor(this); and it'd still work fine?
If you have the pitch and yaw set, just getDirection().normalize().multiply(speed) and apply that as a velocity
Just keep it a variable in the RemoveLocation() and don’t define it in the class
I should clear their map when they disconnect
yep
We can’t see your full code and I assume these are line numbers but they mean nothing to us
hmm okay, i was confused when i saw it in a tutorial video since it seemed kind of pointless
None of those numbers are 92 and 2 or 90 and 0 though...
So you’re not setting them to the values you want
Alright, so you’ve set the pitch and yaw... then what’s your auestion? I thought yuo were asking how to set it but you’re saying you’ve already set it elsewhere in your code?
Oh wait, are you asking how to apply the location you got from the constructor to the arrow? I was looking for a getYaw() or getPitch()
Should just be .setLocation(Location loc)
Im doing both of those this is how im adding their data / loading their data when they join```java
if (res.next()) {
playerMap.put(UUID.fromString(res.getString("UUID")), new PlayerData(iPlayer.getUuid()));
PlayerData data = playerMap.get(iPlayer.getUuid());
data.addCooldown(res.getString("Cooldown"), res.getLong("Time"));
} else {
playerMap.put(iPlayer.getUuid(), new PlayerData(iPlayer.getUuid()));
}
Is it possible to control completely over what commands the player see immediately after typing a slash? I have tried TabCompleteEvent but it seems to fire only after a registered command has been typed in, when the first argument is meant to be typed.
how do i see if the player is looking at a block, what i wanted to do is cast a line from the player, and along that line check if theres any blocks but idk how to do it
This is to do with Minecrafts Brigadier parser
I'll look into that, thanks!
declaration: package: org.bukkit.entity, interface: LivingEntity
Have you tried player.getEyeLocation().getBlock()?
Player.getTargetBlock()
Oh, that's probably it
That would only get the block in their face
There is an updateCommands method in CraftPlayer which is responsible for sending the packets to the client as to what commands the server has
Does that extend BukkitCommand?
Nope this is in CraftPlayer
Can anyone make me custom plugins? I will pay $20USD if you can dm me
?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/
You will get into a bit of NMS stuff
I see, thanks for the help!
No problem :)
Just Player#updateCommands() called at any time updates the clients command map
how do i make get target block not include air?
and how do i check if a point is inside of a blocks collider
getTargetBlockExact does take collision into account
And only returns air if it hits the max length
?paste
why is items null
its final
theres no fucking way
hey im wondering how i can get the blocks under the player
specifically, the glass
Do you have another items in ClickableGui?
get the block under the player location
its just a loop right
the 3x3
nope
the items are never accessed publicly
there is no way it could possibly be null
Then from that code its impossible for items to be null
use a raycast
i actually found something on the spigot site
Or just a loop
but thank you :D
yeah thats what i did
Loop down until you find a glass block, then loop nearby blocks
How can I remove those armor stands? I spawned them using packets.
Looks like spirits
I've done that, but the armor stands still there, I even tried to restart the server and the armor stands are still there.
whenever i do setPassenger, the passenger always gets hit how do i make it so they dont get hit
damn its so annoying that i can limit how much resource i give to a plugin...
i suppose i can code it to run stuff with delay in it
if only theres a feature like the set affinity in task manager :<
agreed
https://gyazo.com/a7c75e4dee1c8bdb188568319432acad
what is the MOST OPTIMIZED way to make something like this. I could do it with player move event but I feel that would cause server lag
well move event is probably the best way of doing it
unless you move them every tick
aight
why can't i teleport the enderdragon if it has someone riding it? heres my code
Location l = p.getLocation();
//Get the way the player is facing
float h = (float) Math.cos(-l.getPitch()*Math.PI / 180);
float dx = (float) Math.cos( (l.getYaw() + 90)*Math.PI / 180)*h;
float dz = (float) Math.sin( (l.getYaw() + 90)*Math.PI / 180)*h;
float dy = (float) Math.sin(-l.getPitch()*Math.PI / 180);
EnderDragon m = (EnderDragon) p.getWorld().spawnEntity(l, EntityType.ENDER_DRAGON);
m.setPassenger(p);
new BukkitRunnable() {
Location b = p.getLocation();
public void run() {
b = b.add(new Vector(dx, dy, dz));
m.teleport(b);
}
}.runTaskTimer(plugin, 0L, 0L);
it only works the moment i get off the ender dragon
I don't spawn the armor stand again. Here's my whole class https://paste.md-5.net/kulejobawo.java.
You can't teleport entity while the entity have a passenger.
any idea how to fix this
I don't think so, I've been reseraching that for a week full and no result.
I had the same problem as you
They taking damage when you set them as a passenger?
like say its a snowball, or an arrow, when i make them ride it it just hits them and then it dissapears
Your best bet is removing the passenger before teleport and add the passenger back to the ender dragon. It will be glitchy i guess.
Might have to have an invisible armour stand they ride that is riding the snowball to avoid collision
how does hypixel make rush pearls though
Mind showing me like a video or something?
Riding a pearl?
I've not tried it but I'd imagine the pearl could contact you
They add player as a passenger of the ender pearl.
if they were constantly teleporting you, you wouldn't be able to turn so fluidly
so i don't think its a constant teleporting
what do you mean turn so fluidly?
all they're teleporting is your x,y and z
not your yaw or pitch
i thought you aren't able to do that
You are
how d you do it
just make the yaw and pitch always equal to that of the players
so you're not taking control away from their head
no that would make your turning kinda buggy and teleporty
They're not teleporting the player each tick
They simply just make the player rides ender pearl
So the movement will follow the vehicle (ender pearl)
bcz client side minecraft updates your angle every frame, but the server only gets the angle every tick
what?
no?
The game loop is consistent on both sides
20 ticks be it server or single player
when you're turning in minecraft, it's updated to your fps
thats why it doesn't look like the game is running at 20 fps
and is smooth and all
no.... fps is just how fast the game can display updates. Whenever you move or turn your head, a packet is sent to the server about this
no it isn't, it's only sent 20 times a second
so the angle the server has isn't the same as where the player is looking
wrong
why don't you just try it
the x axis of headmovement has a minimum variance before the head wil actually move
thus, it will look choppy
Pretty sure if an entity is riding another, they won't collide
Otherwise boats would be glitchy
so r u saying you can't only teleport x y and z
since then it will be choppy if you try just setting it to what the server thinks the players pitch and yaw is
So the better way is to attach the player to a projectile and move the projectile by applying velocities on it
Where do I find api documentation on spigot? I found out I was using legacy api to get my plugin version.
hey, sorry for this terrible question...
i have an issue on the AsyncPlayerChatEvent
(im setting the format)
where if the message contains %, theres a parsing error
or formating error
im not sure how to fix that
do i replace that character with \%
Isnt this paper?
do i just replace the % character with two \ followed infront of it
Spigot
gave up with Paper 😳
Oh go to Paper about that
Well, it looks like paper to me
its not
That's adventure not spigot api
Error is from Paper
Ah ok
ahh
i dont really like the people at paper, so to avoid trying to actually have a conversation with them i'm going to try to replace the character first
it just sets hte chat format tbh
bukkit defaults it to <their_username> message
99% sure
e.setFormat(string);
I would make sure the server is up to date
If it is report error to Paper they shouldn't be too rude about it
Just make sure you're on 1.16 or 1.17
just linking the paste website ?
you didn't link the error, that is why you got that reaction 😂
Lmaoooo
lmfao
looking at it, your format is just plain wrong. The format string contains, well, only the format
you already pass the message and username in it
Don't ask to ask, just ask
Please help to help me to help you
xD
what
Does someone knows where Nexus is storing the artifacts when deployed through a docker container, because the documentation says there should be a folder named sonatype-work, but it's nowhere to be found in the container
in otherwords the class that extends JavaPlugin
If my main class was called Core inside of packages com and laeven
?kick @quaint mantle spamming
Done. That felt good.
Guy needs a chill pill Jesus
Thanks :)
This
;-;
?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.
I've told you what to put
why are you being mean
.
Then go learn Java
And stop spamming
I won't
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.
wat
@ivory sleet u see this man (he wrote "die" in a reply to the CafeBabe message)
we wont spoodneef him
so now hes mad
yes????
idk what to do in this situation
so many good opportunities, but i will try.
Stop pinging me ;/
pog vibes?
ok thats just pathetic sorry
im sorry
i cant not say something, please act like not a 7 year old on the Spigot discord
agreed
what
If you behave like this in other places get ready for the ban hammer
is that a threat?
This is going to be the end of me lmao
First plugin i make ends up being platform agnostic with fabric support too
Having to remake my own Plugin API
With my own eventbus and shit
Just use abstraction
Thats what im doing
Then why the eventbus
Platforms
I have a core package which contains my own event implementations and commandsender and stuff and I implement it in the Spigot plugin. I need my own eventbus because platforms
I need to be able to cancel events in more ways than just not sending a message because the guava bus will just continue sending to listeners
Guava event bus :I
🙏 also just gives more control
Aight
I used guava because its the only one i know of but i ended up just making my own
forgot no custom emotes
Better
Myeah it’s not as sophisticated you’d think it would be
Yeah i would have at least hoped for like, event cancellation
but it doesnt even have that
At the moment i kinda just do it by requiring all events to extend off of event
/**
* Base event interface
*/
public interface Event {
/**
* Get player who sent the message
*
* @return player
*/
PlatformPlayer getPlayer();
/**
* Cancel the event from firing, no other listeners will be fired after this is called
*/
void cancel();
/**
* Check if the event was cancelled
*
* @return cancelled
*/
boolean isCancelled();
}
which is this
🙏
I like buses
the one problem is i kinda have to use interface and I cant really store the cancelled variable inside the Event itself
so every implementation needs it
abstract class?
I could but i mean... hm maybe
^^
let me see if that would work for this
A base class seems way more suitable
aye
The thing is that https://i.kawaii.sh/7nI8Ico.png
all this would have to be abstract classes which would have to be extended further in spigot/fabric impls
but yeah i can prob do that
Why that?
Why not have your event bus completely decoupled from any platform
It is
All those events are purely up to implementation
But other platforms have implementations for those events
So when they get called its like a conversion event
public class SpigotChatEvent implements PlayerChatEvent {
private final AsyncPlayerChatEvent chatEvent;
private final PlatformPlayer player;
public SpigotChatEvent(AsyncPlayerChatEvent chatEvent) {
this.chatEvent = chatEvent;
this.player = new SpigotPlayer(chatEvent.getPlayer());
}
@Override
public PlatformPlayer getPlayer() {
return player;
}
@Override
public void cancel() {
chatEvent.setCancelled(true);
}
@Override
public String getMessage() {
return chatEvent.getMessage();
}
@Override
public void setMessage(String message) {
chatEvent.setMessage(message);
}
@Override
public void setFormat(String format) {
chatEvent.setFormat(format);
}
@Override
public Set<PlatformPlayer> getRecipients() {
return new RecipientSet<>(chatEvent.getRecipients());
}
}
example
RecipientSet is an adapter set implementation btw
so you can change recipients using platformplayers
Hmm I was thinking something else but I guess
What would you do for this?
PlayformIndependentChatEvent <- PlatformIndependentEvent
Then you got in spigot for instance
ChatEventListener
which listens to the APCE and then from there it publishes a new PlatformIndependentEvent() in this way the common/shared logic doesn’t need to know about any platform dependent shit. Then if it’s the right choice is another question.
That could work too actually you are correct
not for plugin/server configuring
Need to make a note to figure out which is better for this
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Go read the doc
There are not that many elements to plugin.yml
The main problem with this atm is stuff like recipients wouldnt work since you would have to have a different implementation from fabric/spigot due to the APIs being so different
Im building mine so its more spigot oriented on the agnostic side but recipient stuff is decently big
looks like this atm lmao
Did you read the doc
if you don't understand what a main class is, or what packages are, you have some homework to do
so learn java
Then go learn java
You could have an api interface Recipient and then an RecipientImpl then in each platform you have for instance a SpigotRecipient and a RecipientBridger which bridges between the SpigotRecipient and RecipientImpl or something
Maybe a bit over engineered
?ban @quaint mantle stop goofing around, come back later
Done. That felt good.
:o
I recommend this tutorial
MY UDEMY COURSES ARE 87.5% OFF TILL JULY 11th
►► New C++ Programming Bootcamp Series for $9.99 : https://bit.ly/C_Course_5 Over 20 Hrs + 52 Videos + Quizzes + Graded Assignments + New Videos Every Month
►► Python Programming Bootcamp Series for $9.99 : https://bit.ly/Master_Python_5 Highest Rated Python Udemy Course + 48 Hrs + 199 Videos + D...
Yeah this is probably the right way for it
Oh, he's gone
Yeah
Aight
He was literally talking about raiding before he deserved it lmao
He didn't even want to learn Java
:l
Hopefully we won’t see his alts either
alt joins

Tfw event in bus literally just has nothing implemented in it except extends to differentiate event
public abstract class PlayerMoveEvent extends Event {}
👁️ 👃🏽 👁️

More like i need to differentiate the type of event being sent in the bus
Event contains all the bases stuff like getting player and cancels
All i need to do in my plugin is cancel the move of the player maybe
Instanceof or an enum event type
instanceof
Yep
Alright
If a spigot event isnt cancellable the most that setting cancel will do is just not call anymore listeners on my eventbus
since its just one event in spigot to send it to the bus
Yeah sounds reasonable
oh?
Ok annotation and reflection time lets go
then how do you cancel an event like PlayerQuit :3
Keeps the player hostage on the server
well, it just wont call anymore subscribers for player quit
if there are any after the current one
they will still disconnect it just cancels the other listeners from calling
I see... I thought cancel just meant whatever was to be processed afterwords would not happen
well that happens for relevant events like chat
on top of not calling anymore subscribers
oh actually question is there a way to get a method as a function/consumer value
🙏
Yep, and call it
Method
in a map
With java im guessing yes since it just will keep the object above it alive while method ref is stored
or create a class with a method you intent to override on initialisation
Method just holds the name of the method to invoke and where it is in the program
Well unreflecting the reflect
the reflection class Method
what im essentially trying to do is anything in a listener with a handler annotation should be saved into a map as a value
Yeah
What i could do as well is just hold the object and the method handle in a pair tho
That would work right?
You can override a method on initialisation in a custom class
with the code you wish
and store it
or just use a runnable
or BukkitRunnable
Yeah just Arrays.stream(class.getDeclaredMethods())
.peek(m -> m.setAccessible(true))
.filter(m -> m.getAnnotation(EventAnnot.class) != null)
And then whatever u want
Alright
how can i "create" the light beam that heals the dragon and point it somewhere?
Ah gotcha
so you can perform multiple ops
even though you could just do
Arrays.stream(class.getDeclaredMethods()).forEach(v ->
{
// Stuff
});
That defeats the purpose of streaming it but yeah
ik ik xD
I've been awake for 27 hours, excuse my thought process
is there a way to return an exception from a stream above the calling function
kinda wanna make sure the param types are normal
Wanna make sure theres only one parameter and its of a certain instance
Yeah i mean like throwing an exception in a stream
and making it return to the above function
wrap it in a try catch?
Im not sure if that would work but afaik streams are fall up
No because i want the person using the bus to get the exception
As in im throwing it
Oh yeah Apache got something for it 1 sec
Altho no peek so you might wanna do the
.map(m -> {
m.setAccessible(true);
return m;
})
bye byeeee
?ban @quaint mantle ban evasion
Done. That felt good.
To be fair Idk lol
adding commons rq
Think sam is behind that
I see
Isn’t that added by default riku?
Else just create your own failable stream (:
Spigot already uses apache
remember im using it in core not spigot
you just need to call it
Oh right
Then create a helper class for it I guess
This man right here. Is a man of culture.
:D
So does he use lombok?
I do have lombok in some stuff but i avoid it for stuff more now
Because it depends on IDE a lot
I wish there was something like lombok as a language feature tho
imo
it makes code cleaner but lombok aint it
We got kotlin but yeah
Hey all, what is the best of making all tools in one plugin or split it
Elaborate
^
whats the usage of FailableStream btw
I think he means just tools for development. Designing an API
It’s basically a stream which takes throwing functional interfaces
In my personal opinion, I'd prefer small libraries dedicated to solving one problem or that provide utilities for one thing
less clutter
Like
interface Runnable {
void run() throws Exception;
}
Like StringUtils lib seperate from a PlayerUtils lib
Is there someone here with experience with the Nexus Repository Manager?
Then it has the throws declaration so no need to have a try catch inside the lambda later
instead of bundling everything if you only need to use a few functions from one lib
Yeah I know a guy, well some guys but they don’t surf in this discord
Maybe you can forward this question
Hmm sure, why not ask them yourself? 😮
Sure
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.
or better in #help-server 
tfw peak doesnt exist in FailableStream
I'm trying to backup Nexus so i can update the docker container, in the documentation it says there should be a folder named sonatype-work but it's nowhere to be found. I found that there are blob storages which are apparently used by some repositories in the Container. Can i just backup those and replace the default blob storage in the new docker container or am i missing something?
.
ah
.map(m -> {
if (m.getParameterTypes().length > 1) {
throw new ListenerRegisterException(String.format("Unable to register listener %s because method %s contained more than one parameter",
object.getClass().getName(), m.getName()));
}
return m;
});```
error check 👌
or just new BlahException().printStackTrace() maybe
Can I ask for Bungeecord help in this server?
Lol ye
ye
On what discord do i have to look for them
I did send ya a DM, shouldn’t be advertising here
If it’s bungeecord development then go for it here else #help-server is the place
Okay I am trying to make a plugin, that grabs the tps & playercount of every server every few minutes. My approach would be to get the playercount with the default message channel and the tps with "sub"-plugins on each server, that sends the tps back when they receive a specific message.
I would have a Main Plugin on the Main Server and smaller Plugins for the tps on all the other servers
Is this a good approach or should I do it differently?
sadly its private
Yeah that's the annoying thing with bungee
messages to a server sit in a queue until a player arrives on the server
oh
how do i check if a Class<?> is an instance of another class
Honestly a better solution might be sockets
that accepts an object altho would i pass a class into there?
Class#isAssignableFrom
Class<?>.isAssignableFrom(Class here);
This or backwards? method.getParameterTypes()[0].isAssignableFrom(Event.class)
So the same I would have done but with sockets or is there a better way?
Think that one
I think its the inverse lmao
Idk that one always confuses me
Not that I know of, there might be some bungee plugins that do the trick or even some plugins that just communicate via some custom bridge
Well because it has to be possible for the argument to be an instance of event
Redis :0
so if you can assign the argument to Event its right
Ye
Any recommendations?
👌 I always use plugin messaging when all it needs is a simple UDP message from or to bungee
for me i use plugin messaging for sending server specific data like how many players are on the network and the name of the server to the spigot server so it can display on scoreboard
You can do it with something like mysql but it’s a hacky solution
but yeah redis is better usually
This is one example
But you'd need ChatControl
😮
:/
It does however ignore players
if you google around you might find other solutions
Yeah I would need that anyways but isnt sending one query for each server at roughly the same time bad?
Wym?
I mean if you use redis pub/sub you’d do it async and then ofc it handles the synchronization for you between different pub subs
You could just perform a multicast
I want to store the tps/playercount in the sql database. Should I just make every server update an entry every few minutes?
probably cache it and then write it every so often
and then write it to the database
Is this the best way to do this
private final Map<Class<?>, Set<Pair<Object, Method>>> subscribers = new ConcurrentHashMap<>();
essentially just storing the class and then a set of subscribers which is the object and the method of the handler
Is set needed there?
well the first part of the map is the event being called, the set is the list of subscribers for that class
Also use a class rather than use something like a Pair
whyso
Because that’s damn nested lol
Ah
Nested type params are kinda yeah mh
ill make a CallableMethod which just calls a method
contains the object and the method
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.
Riku you might wanna have an ArrayList<CallableMethod>
ArrayLists are faster for iteration than HashSet or smtng like that
No idea
?ban @nova flame ban evasion
Done. That felt good.
Nested data structures -> Create new classes
public class CallableMethod {
private final Object object;
private final Method method;
public CallableMethod(Object object, Method method) {
this.object = object;
this.method = method;
}
public Object invoke(Object... args) throws InvocationTargetException, IllegalAccessException {
return method.invoke(object, args);
}
}
this works
🤷♂️
i should call it InstancedMethod instead
Map<Class<?>,CallableMethod[]> map = new IdentityHashMap<>();
Uh
CallableMethod sounds better
but you can dynamically register listeners so array isn't that good of an idea
Yeah that’s what the Bukkit event api uses tho I believe
as in at any point you can register two listener objects to one event
ah
whats an IdentityHashMap
True
It uses == to identify keys in short
So if two objects are different instances but have the hashCode they’re still considered different keys
ah and accessing .class is comparing static refs
Yeah
gotcha
(:
i come from c++ and stuff like that so i understand the mechanics of that a lot more i think
I wish we had reflection there too but we do not
It becomes nice when you use it for a while, using anything below C++17 is a bit meh
You can just point at stuff. What do you need reflections for.
dynamic stuff
if I do smtng like
std::cin << "t" it would shout or whatever
like this type of eventbus thing
Or yeah having the bitwise operator in the wrong direction
you can even overload []
Lol nice
thats why the Vector impl in C++ is accessed like array
Vector is the C++ arraylist
i do not mean unreal engine that is horrible with C++
After all it allows you to be more agile and conservative about memory I guess
Yeah the game i was writing had some cool systems. The whole thing was half written in lua because i wrote the main systems in C++ and wanted it to be moddable so the main game content/items were defined in Lua and loaded through a content.pak
and you could like expand on it with others but i never got far enough for it to be super cool
Lua was compile time turned into JIT bytecode too when it became a .pak
So it was even fast there too
Oo
I needa pick up that project but i guarantee my first order of business would be a whole scale rewrite because i was less conventional back then lmao
🤡
^
I wish there was like a eslint type thing for Java/C++ but it not only enforced syntax but ways you should do things like iteration
Like "use streams here instead to follow lint file"
Same on my third rewrite of my mod ;(
Lol
i forgot .computeIfAbsent was a thing and im wowed by it for the 3rd time lmao
wdym?
like rewrite ppl code or yours
I make bad code into good code
o
People’s and my own lol
hmm
Conclure code review my mod
i think i dont do any bad practice in my code but idk what ppl think
Let's go DMs
Sure link lmao
Good code is actually subjective to a certain extent but we could have a look
tfw tech companies still pay by lines of code sometimes
e can someone send me git official website
i lost it
its this https://git-scm.com/
right
Let’s use spring
Good?
public <T extends Event> void post(T event) {
Set<InstancedMethod> methods = subscribers.get(event.getClass());
if (methods == null) return;
for (InstancedMethod method : methods) {
if (event.isCancelled()) return;
try {
method.invoke(event);
} catch (InvocationTargetException | IllegalAccessException e) {
logger.severe(String.format("Unable to call handler %s on %s",
method.getMethod().getName(),
method.getObject().getClass().getName()));
logger.severe(ExceptionUtils.getStackTrace(e));
}
}
}
im asking
Nice riku
idk if it is some guy told me
oh ok
I dont know if its a good idea to pass a logger as the sole argument into EventBus tho but like
🤷♂️ why not
public void removeListener(Object listener) {
subscribers.values().forEach(m -> m.removeIf(method -> method.getObject().equals(listener)));
}
i love functional java lmao
😳
IDK
it told me to download this
I swear that might be the installer
which is really funny
but yeah do it a lot of apps need it
i alr have it installed bro
thats just the runtime, essentially a JVM
i installed like 3 times
Accessing config from other class throws me an NPE ?
different versions because yk... .net
Share code :0
git is worth it
im just doing it so i can share code or whatever
You should use git so you can store your code in iterations
instead of storing it in a zip file on google drive lmao
u can ctrl z if u do an oopsie
and i hate using my terminal
im not gonna bother explaining it, pros use it for a reason so if you wanna become a dev you are gonna have to learn it at some point
no avoiding it
no jobs will accept you if you dont know git lmao
backwards compatible pretty sure
JVM 16 can run Java 8
same shit
more specifically bytecode version 60 runtime can run 55
i want to copy and paste a building through code, anyone an idea on how to go about that?
WorldEditAPI ia highly recommended
its about 300 blocks smh
LOOPS :D
oh?
/j btw
I use worldeditapi right now to hook into block changes to check if a sign is being replaced and check if that sign is a sign in my database
since yk, sign interactions
i hate the system but it works
🤡
when block break event doesnt trigger with wedit
you have a documentation?
a sec please
thanks
here is the javadoc specifically
make sure you have worldedit as a dependency in spigot btw
i recommend using FastAsyncWorldEdit
oh
basically faster worldedit implementation
mk
but regular worldedit docs apply yeah
If using try statements with FAWE make sure to call things async
I have too much code, I would have to throw all my classes as it's a big project
plus the code is a mess as I haven't finished it yet...
(I'm using the saveDefaultConfig() method, and an instance of my main class instead of a constructor)
private Main main = Main.getInstance();
int i = main.getConfig().getInt("int"); //NPE on this line
while it is not null on the config
I mean
!= 0
oh wait figured it out
I was creating a new instance of this class
in my main
(insert facepalm here)
goodbye
fking hell
i waited like 3 mins for that shitty git to restart my pc
legit wasted my time
[13:42:43] [Server thread/DEBUG]: Opening connection to https://api.mojang.com/profiles/minecraft
[13:42:43] [Server thread/DEBUG]: Writing POST data to https://api.mojang.com/profiles/minecraft: ["furkantr6676baba"]
[13:42:43] [Server thread/DEBUG]: Reading data from https://api.mojang.com/profiles/minecraft
[13:42:43] [Server thread/DEBUG]: Reading error page from https://api.mojang.com/profiles/minecraft
[13:42:43] [Server thread/DEBUG]: Successful read, server response was 403
[13:42:43] [Server thread/DEBUG]: Response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Request blocked.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: KQAQlpizbGgckB8fZ0LpRlDHYGv6jdCow41ktwA_8Ksc0v5bOjcIxw==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
So my server has lag, how do I fix it?
Stay in #help-server
🤔
You inbred baboon
Chill lmao
When coding a plugin for a bungeecord network, that doesnt need the bungee features tho, can I just use the spigot api?
if its a bungee plugin you obv cant use the spigot api
I'm so tired this made my day xD
You'd use the bungee api
how to add pdc to itemstack
persistent data container?
yea
stack.getItemMeta().getPersistentDataContainer()
