#help-development
1 messages ยท Page 211 of 1
love how Unsafe.getUnsafe() just throws a securityexception
oh wow I got a new error I didn't even notice
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown error 1146
what the heck is this
lmfao
dafuq? ๐คฃ
only java internals are supposed to call it :)
bruuuuuuuuuuuuuuuuuuh
then lets make everything a Java external
and so no one will call it
kek
and make it be depressed
so spoof a java internal
spoof classloader
ah fuck i dont think its possible to spoof the platform classloader ๐คก
Looks like I fucked up my whole fucking code
be the platform
the plugin... basically...
- can't detect the fucking driver
- can't create a table, because it doesn't exists... meanwhile its coded to create the fucking table when it doesn't exists...
i wanna learn some hacks in java lol
Runtime.getRuntime().halt()
๐คฃ
hacks in what way
Unsafe::throwException is a fun one too
idk i was looking at the advanced stuff and i felt like god
lmao
is Unsafe safe to use tho?
lmfao
lmao
hehe
lol
Unsafe.getSafe
been trying to figure out brigadier with spigot as I wanted to use it, but
final CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();
on github it wants you using CommandSourceStack it doesn't seem like that is visible at all do I need to use nms?
I'm aware of commadore but I'm fine using the brigadier command api
does someone know to what targetSelector got changed? (NMS)
a
How can i add all nearby players to a gui?
how might I create an explosion 2 blocks from where the player is facing?>
hello?
I'm trying to do this in the 1.19 version
Have you considered using Mojmaps so you don't have to deal with obfudcated names
nope
Highly recommend using them. You can find a guide on the 1.19 release post
Asumming you're using maven
yep I'm using maven
But do you got a idea what is wrong?
Yeah
Nms
And then you can use getSource().getBukkitEntity() or sth iirc
To get the bukkit sender
๐ข ok
Destroyed my whole code now
https://nms.screamingsandals.org/ here you go partner
look up the spigot mapping names you have than switch them out for mojang ^
๐ฅณ then party and enjoy your easy development in the future
sometimes pain in the now will provide you with longterm benefit
Thanks
Can someone tell me why am I getting false sometime from checkThiefGUI method? Or better way how to sync player inventory with GUI? GUI is displaying only few slots (ex. 10) from player inventory. Reaming slots are covered by barrier or some fill item. https://pastebin.com/kBSLY8Ej
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I hope someone can understand what I mean ๐
But I can't really find in the Goat Class the targetSelector or goalSelector
ok good luck
how can i improve this config? yaml arena-selection: size: 27 title: "-" items: background: material: "BLACK_STAINED_GLASS_PANE" display-name: "" lore: [] previous-page: slot: 21 material: "ARROW" display-name: "&b&lPrevious Page" lore: [] close: slot: 22 material: "RED_DYE" display-name: "&c&lClose" next-page: slot: 23 material: "ARROW" display-name: "&b&lNext Page" lore: []
alright, thanks
Damn I hate this Obfuscated shit
good thing mojang maps aren't obfuscated
also why bother asking here just dig through the server code yourself
its in your .m2 file
just decompile the server jar with the mojang mappings in it
hell you could even decompile the obfuscated jar and then just use screaming sandles
then you look around for what u want
On the playeradvancement event, how do I check if the advancement is rare or normal?
?jd-s
declaration: package: org.bukkit.advancement, interface: Advancement
if there is nothing like this on javadocs
I don't think that is the event that runs when a player gets an achivement is it?
type?
declaration: package: org.bukkit.advancement, enum: AdvancementDisplayType
icon is itemstack
What does that mean
ye what does that change
idk
if there is not RARE thing in javadocs
manually create a list with rare advancements
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
this is it :)
if your advancement is not rare then goodbye
oh shit i sent advancement class
can i not use these?
instead of event
i don't know if this types represent RARE or non-rare
try it
ill check mc to see which one means what
@grand flint I think it would work
how do you even build a command with brigadier
LiteralArgumentBuilder<CommandSourceStack> builder = literal("test").executes(new BukCom() {
@Override
public int run(CommandContext<CommandSourceStack> arg0) throws CommandSyntaxException {
return 0;
}
});
public interface BukCom extends Command<CommandSourceStack> {
}```
I tried making my own interface to force type CommandSourceStack, but executes only takes in Command<Object> which then changes the type LiteralArgumentBuilder<CommandSourceStack> to LiteralArgumentBuilder<Object> which than can nolonger be registered by my dispatcher I'm honestly confused as hell how I'm supposed to get this work if all of the generics in the LiteralArgumentBuilder only take in Objects versus my CommandSource
is it possible to migrate from fileconfiguration to file?
advancement.type or something?
๐ I guess you could in a very very convoluted manner yes
now this might get pretty tricky so hang in there
oik
public void onPlayerAdvancement(PlayerAdvancementDoneEvent e) {
Advancement advancement = e.getAdvancement();
With this code, how do I check if advancement is a challenge type, how do I get it from advancement?
bukkit conifg api ๐
I cant find it
๐คฆ๐ฝโโ๏ธ its what your using lol
wait so did I do it right?
yea I'm just making a joke lol
if its not inside it will be enabled
That is not what you have done
You did if(replay is in list) enable reply
oh shoot
public Reply(Main plugin) {
this.plugin = plugin;
if (!(this.plugin.getConfig().getStringList("DisabledCommands").contains("reply"))){
Objects.requireNonNull(this.plugin.getCommand("reply")).setExecutor(this);
}
}
okie but now its just doing this
plugin.yml is doing this
What
well it doesnt return anything which I want it to return unknown command
no he reloaded his server ๐
so other plugins can take priority over it
I didnt reload the server
how can I made sure other plugins can take priority?
like remove it from plugin.yml once the command is disabled
eh I never use the plugin.yml I just edit the command map directly
though you shouldn't be getting into that this early I don't think so I don't have a direct answer on how you'd do that
you'd have to use reflection don't worry about it
You can't get it that way as its inside of jar, you can get JarEntry of it but I'm not sure if you can edit it like that, you would have to Google
Yeah, also there are better ways to accomplish what you want
i tried ?google but it made no help, what i'm trying to do is disable a command from my plugin and remove all traces until the command is removed from the config file
I need to access plugin.yml to remove the command
You would have to use reflection to add it directly to commandmap without plugin.yml,there are probably other ways but as I never worked with any, I would not be able to help
My intellij says build complete but the jar file is not there
How are you building and what dep management system
Nevermind, I fixed that issue, but now I get an error saying access denied
Can you screenshot
Lol looks like you are running intellij as other non admin user
Nope
Or your dir is read only for some reason
Can you try just to manually create some text file in that dir?
I can
It works
Visual studio doesn't have this issue
Roblox Studio has an issue if I don't run it as admin, it will say permission denied and not launch
So it's not readonly, your intellij is probably running as different user, idk how trough
Can you run ij as admin?
Any other solution?
try to Google or ask at some forum ยฏ_(ใ)_/ยฏ
When using tabcomplete, how do i make it filter the results as the user types in the command
tyy
Hello, I have a plugin called ranksystem with only one command called rank and when I type the command, the tab proposes to type /ranksystem:rank or /rank. How can I disable that ?
I just want the tab to propose /rank but not /ransystem:rank because that's really not beautiful
there's a possibility of a java version difference
sometimes when the dependency is on a higher version of java intellij guesses it's not accessable
so does maven
lmao does anyone use vscode for java?
๐ข I thought I was needed for some specific form of help this hurt me inside
why
wdym why
because it makes running servers easy locally
2 much
i see
I've always used vscode for every lang web dev etc. It has a nicer UI and can be just as usable and efficent given you give the time to customize it
I use a script for this though if you have the redhat java support right click on the file bar or ctrl+shift+p maven create maven project should pop up
I use eclipse hotkeys so the hotkey might be different for you
also a lot of people have an issue with vsc having slow autocomplete see that complained a lot here I'd advise upping the ram you give by default its like 500mb to 1gig but I just set it to 2gb as I have 32 at my disposal
thank you i noticed that
what is your path set to, I can't get maven to find my java home even though its set
@EventHandler
@Deprecated
public void onPlayerChat(PlayerChatEvent event) {
//Check if event is enabled:
if(!(this.plugin.getConfig().getBoolean("ColorchatSupport"))) {
}
//Done :D
else {
Player player = event.getPlayer();
if(player.hasPermission("betterserver.permissions.chat.chatcolor")) {
event.setMessage(event.getMessage().replace('&', 'ยง'));
}
}
}
Can someone help me debug it? It's doing a bunch of random stuff but it's pretty obvious what it's supposed to do.
it worked before I added the config checker
No that works i'm trying to make the config thing work
ill restart it
okie
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
//Check if event is enabled:
if(!(this.plugin.getConfig().getBoolean("ColorchatSupport"))) {
}
//Done :D
else {
Player player = event.getPlayer();
if(player.hasPermission("betterserver.permissions.chat.chatcolor")) {
event.setMessage(colorize(event.getMessage()));
}
}
i added the string above
the thing that is not working is the config
omg
thank you i feel so stupid
Also that if/else looks a bit messed up
my final question is how do I detect if the config.yml is null (has errors)
thanks ๐
events for when a bow is shot by a player? or when arrow lands on a block
What
thanks if i will use the first one i should do something like EntityShootBowEvent instanceof Player?
thats an env variable thing
Why does it have to be type parameter if it will only accept class
https://github.com/EthanGarey/BetterServer
Yall should review my plugin ๐
im not giving the link to the spigot thing cause thats advertising
I had that problom too, you just have to cancel the message event and send a message to all players
Is that not going to mess up my essentials chat
idfk
Idk if this was intentionall but from what I looked at (Gamemode and Give) you do not check if the player is opped OR has a permission node
its in plugin.yml
ah
if (pie.getBow().getItemMeta().equals(ItemManager.shock_powder.getItemMeta() && pie.getEntityType().equals(Player)){
//
}
}
}``` how do I check if the entity that shot the bow is a playER?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
someone help my brain remember. what was the class holding all the item sets named
sobs
like a bunch of listt of item sets
a set of items
that are like eachother
like WOOL
yeaaas
thanks
How do I change my intellij java version?
How do I check my javaversion
cmd.exe -> java -version
you need jetbrains toolbox to update intellij
I have
well it maches
should i change the one in pom.xml too?
what should i make it my java version is 17
Thank you
Also what would this be for 1.19.2
1.19.2-R0.1-SNAPSHOT
<version>1.19.2-R0.1-SNAPSHOT</version>
it doesn't work, here is my updated code;
he didnt use @EventHandler or onPlayerInteract would be yellow
No where do I run it
Where should I run it
anywhjere
oh you have to make a batch
[20:52:58 INFO]: [BetterServer] There is a new update available.
It's been a hour and it still hasnt updated, anyone knows why?
new UpdateChecker(this, 105989).getVersion(version -> {
if(this.getDescription().getVersion().equals(version)) {
getLogger().info("There is not a new update available.");
} else {
getLogger().info("There is a new update available.
");
}
});
well we can't smell whats inside UpdateChecker. so you would need to share that
i guess its using Spiget api
package BetterServer.Commands.AdminEssentials;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
public class UpdateChecker {
private final JavaPlugin plugin;
private final int resourceId;
public UpdateChecker(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(final Consumer<String> consumer) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scanner = new Scanner(inputStream)) {
if (scanner.hasNext()) consumer.accept(scanner.next());
} catch (IOException exception) {
plugin.getLogger().info("Unable to check for updates: " + exception.getMessage());
}
});
}
}
is 0.0.2.7 not latest version?
0.0.2.7 is the latest
well whats the problem then
api returns correct version
any way I can do updatechecker.equals(0.0.2.7)?
The 2.6 update was corrupted so I had to delete it
ok i ran buildtools what do i do now
oh wait I dfigured out why my thing doesnt work thanks guys
so my next problom is in my config.yml file I whave a version which is set every time I update my plugin. if the jar file changes how can I make it so the version changes when the jar file reloads to its correct version but everything else stays the same?
why wont this work, ```@EventHandler
public void onPlayerInteract(EntityShootBowEvent pie) {
Entity entity = pie.getEntity();
if (entity instanceof Player){
if(pie.getBow().getItemMeta().equals(ItemManager.shock_powder.getItemMeta())) {
if (pie.getProjectile().getVelocity().equals(0)){
entity.teleport(pie.getProjectile().getLocation());}
}
}
}
}``` I want the player to be TPED to the arrow when they shoot from the bow, to check if the bow is not midair i added an if condition that checked if the velocity was 0 if it was then it tped the player to the arrow, for some reason when i use the item in minecraftit does nothing the arrow lands and it doesn't tp me
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
lol thats temporary ._.
I run buildtools with the bat file and put latest as the version, I still get the error
ik it was a joke
getVelocity returns a vector I believe, so check it's length
anyone know?
this seems right, thanks! I'll try it out and tell you how it goes
๐ฆ
https://paste.md-5.net/ranijoxumu.java
here is my main
changed it
i'm having some trouble becuase i'm getting the same problem the arrow does nothing it does not tp me at all
no i fixed it added event handler and i implemented listener the first thing
um, you are using a player interact event?
Is there a way I can change the Minimum/Maximum world height on my 1.19 server so players on 1.8 will not bug out when they get lower in the world? I use ViaRewind, ViaBackwords, and ViaVersion.
what's the different between getDefaultsSection and getDefaults
watch the projectileHitEvent
also how do I access the config in the jar file (not edit just get info)
oh, makes sense because the event doesn't include the part where the arrow lands on the floor, so then what can i do
ProjectileHitEvent
Why would you do that, arent you the one that set that up?
I want to get the version thats built into the jar and add it to the config file
this is called when a projectile like arrow snowball egg etc hits the block
?
yes
ok so i dont have to mess with velocity
Ig you can get jarfile and JarEntry and after that return inputstream, but you are just overcomplicating
Just make version class with constant or smth
when my plugin gets updated I want it to automatically change the version: in config.yml without deleting the file
but idk hw to check for the version
But.. Plugin will not be updated then
If file is not delwted
Just make version class or smthing like that
ill get a pic for you of my plugins theme
Alr, thanks
but that doesnt show what one you are using
should this work? ``` @EventHandler
public void onPlayerInteract(ProjectileHitEvent pie) {
Entity entity = pie.getEntity();
if (entity instanceof Player) {
if (((Player) entity).getItemInUse().getItemMeta().equals(ItemManager.shock_powder.getItemMeta())) {
entity.teleport(pie.getEntity().getLocation());
}
}
}```
What does NBT support do? I seen it but didn't download it
no
probably because the player will tp to itsself?
if you only want to tp when you shoot a Block use event.getHitBlock()
but check it's not null, as it can be if you shot another entity like a Player or a mob
like this ? ```
if (((Player) entity).getItemInUse().getItemMeta().equals(ItemManager.shock_powder.getItemMeta()) && pie.getHitBlock() != null ) {
entity.teleport(pie.getHitBlock().getLocation());
}```
@eternal oxide
how might I detect an explosion when the player is facing a wall
this what I have rn
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
Player player = event.getPlayer();
Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(2));
if (event.getItem() != null) {
double x = event.getPlayer().getAttackCooldown();
int y = (int) x;
if (x == y) {
if (event.getItem().getItemMeta().equals(ItemManager.GravHammer.getItemMeta())) {
player.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 5f);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3, 255, false, false, false));
System.out.println("I work");
}
}
}
}```

https://api.spigotmc.org/legacy/update.php?resource=105989
Why is it returning 0.0.2.4 when the latest version is 0.0.2.7
thats simply a if(true)
i mean it returns true yea lol
sometimes when I hit a player, the explosion event never gets created
whats with that
probably this
?pmc
bump
wdym
when did you update it
spigot api can take up to 3 hours until it updates
also for me its 0.0.2.7
its been 6 hours since 0.0.2.5
clear your brower cache
it returns the correct version.
for me its 0.0.2.5
what does this mean? java event.getAction() == Action.PHYSICAL
tf
stepping on pressureplates for example
is a physical action
k, how might I make it so, if they hit a player, an explosion is created?
using EntityDamageByEntityEvent i would probably
is there anything faster than spigot api
already tried lol ```java
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
Player attacker = (Player) event.getDamager();
if (attacker.getInventory().getItemInMainHand().equals(ItemManager.GravHammer)) {
Player victim = (Player) event.getEntity();
attacker.getWorld().createExplosion(attacker.getLocation().getX(), attacker.getLocation().getX(), attacker.getLocation().getX(), 5f);
Bukkit.broadcastMessage("[CrystalBall] " + attacker.getName() + " hit " + victim.getName() + " with a netherite axe!");
}
}
}```
the first one is the subchannel you want to reach, the second is the argument you later read on the other channel
the if statement is probably just failing
its all descripted in there
which one
the item in main hand equals thingy
^
k, so what should i do
try using #isSimilar
and you dont create arguments. they are like "commands". if the argument is what you are looking for, you react to it
k
Also you should debug your code, since you donโt know which part is failing
k
ok*
also, would this work for detecting a position 2 blocks from the player is facing? ```java
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
Player player = event.getPlayer();
Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(2));
if (event.getItem() != null) {
double x = event.getPlayer().getAttackCooldown();
int y = (int) x;
if (x == y) {
if (event.getItem().getItemMeta().equals(ItemManager.GravHammer.getItemMeta())) {
player.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 5f);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3, 255, false, false, false));
System.out.println("I work");
}
}
}
}
}```
Ok.*
no, just ok*
forget the x and y shit
public void onPlayerInteract(ProjectileHitEvent pie) {
Entity entity = pie.getEntity();
if (entity instanceof Player) {
if (((Player) entity).getItemInUse().getItemMeta().equals(ItemManager.shock_powder.getItemMeta()) ) {
entity.teleport(pie.getHitBlock().getLocation());
}
}
}``` why wont this work i want the player to teleport whereever the arrow landed yet it doesn't do that
debug
or use arrow instaed of pie
idk
haven't used projectile hit event
would this get the players direction 2 blocks ahead?
Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(2));
the event is registered, though whats wrong with the meta check
you are checking if the arrow is the player
halp me
thats unnecessary. you send the data my #sendPluginMessage
no considering you are multiplying by 2
while checking for the meta? because it checks for the ItemInUse for the player when checking the meta
Isnt the direction a vector doe
no. your entity instanceof Player basically checks if the projectile, รก the arrow, is of type Player
bro
?pmc
even if it was a vector, you wouldn't multiply it by 2 either
look that link up
oh ok
the player or any other entity
so would I add by 2?
too many convos to follow
so in theory i have to remove the condidtion cehckking if the player is an arrow/
yes you would need to add
Location direction = player.getLocation().getDirection();
Location front = player.getLocation().add(direction);```
I think
And just multiply by the amount of blocks you want infront of the player
I did that on my phone so idk
Yeah
I tried it out, but it only triggers the explosion in 1 direction
@raw prairie
because the location of the player only has one direction
Yeah
get the eye location
It says that location direction has to be a vector
Then do direction.toVector()
Or whatever you need
This would be so much easier on my pc
no like, location needs to be replaced with vecotr
Vector playersDirection = player.getEyeLocation().getDirection();
multiply this then by 2
where
nvm
lol
Location front = player.getLocation().add(playersDirection).multiply(2);?
what should I put in my create explosion thing
what might I add in my create explosion thing
player.getWorld().createExplosion(?, ?, ?, 5f);
Yes, then add the previous location to the location parameter
If that's what your after
yes?
what
so front
Front it
Is
Location loc = player.getLocation().clone().add(direction); // this should be 1 block in front of the player```
what does the clone do
this could be also his side or back
if he turns
Teue
since the direction doesnt update in his normal location
therefor:
so what might I put in here player.getWorld().createExplosion(front.add(), front, front, 5f);
@hybrid spoke
im so confused
tryn to create an explosion in 2 blocks in the direction of the player
so then get the players direction
Vector playersDirection = player.getEyeLocation().getDirection();
multiply it by 2
playersDirection.multiply(2)
and add it to the explosions location what would be the players
?front.add(playersDirection).getX()
maybe/
Herobrine
i think because NPCs can click inventories too
bump
?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.
brehg
it says it needs an coords
@hybrid spoke would this work?
player.getWorld().createExplosion(front.getX(), front.getY(), front.getZ(), 5f);```
he has. legit given you the exact code needed to make work what u wanted..
Im aware
I added it
so wut da problem
have you tried doing some research yourself?
Vector playersDirection = player.getEyeLocation().getDirection();
Location front = player.getLocation().add(playersDirection).multiply(2);```
try and see if it works
ya
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
you literally just merged the spoonfeeds which you received
you missed the chance to
https://tryitands.ee/
Wtf
yeaaa i coulnt be bothered haha
Discord game?
its a mc mod
they are quite well made
especially the drawing one is fun
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
If it isn't out putting any error it not loading or if it's working you are doing something wrong if isn't what it surpose to
I am
Sleep deprivation sry
lost my motivation in actually coding long ago
and still i have somehow 1k+ contributions on github
like before it breaks
then it would act like bedrock
btw it explicit says Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
oh well nvm thats the default descr
a very handy event for explosions
isnt it the break animation?
break animation as far as I know is client side, not aware of being able to cancel that
should be a new feature iirc
Apparently it's old
wasnt it 1.18 or smth
I found a bukkit.org post from 2013 with it
Blockdamageabort is new tho
It's not in 1.16.5 jd

I think if you're reusing a world, i.e. hypixel bedwars maps, the better thing would be to just delete and replace, gg
Iirc that's the ideal route ppl say
@ancient plank ohw my gosh ur a daddy ornn enjoyer??!!
yes you can
it would just block the disabling in this case
and if you finished it finish disabling
just dont do anything async in there
that would be too late then
Can the client break if server isn't registering it?
didn't realize it
Like fake breaking
well cool I guess
On client side
there is always ways to dysnc client and server
just never save the world
when such things happen weird things do indeed happen on the client lol
like seeing a block that the server isn't tracking but the client believes it is real
on load you can tell it to not save the world in any case
could do that in the worldinitevent

I need to go through and move a lot of things off the main thread in my most recent plugin, but I'll do it later...
๐ค
procrastinating
I rewrote the whole project in one sitting with no errors (a miracle), shut up
how can I perform the return operation with my two cfs? java public CompletableFuture<Integer> getMasteryTillLevelUp(Player p, String skill) { final CompletableFuture<Integer> future = new CompletableFuture<>(); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { UUID uuid = p.getUniqueId(); CompletableFuture<Integer> futureCEXP = sqlGetter.getDataInt(uuid, skill, "CEXP"); CompletableFuture<Integer> futureEXP = sqlGetter.getDataInt(uuid, skill, "EXP"); try { future.complete(futureEXP.get() - futureCEXP.get()); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }); return future; }
something like that
how can I make that less shit
How do yall structure your command method? Making a complex command with branching args makes my code look so messy with all those conditionals.
You want to return both of your CompletableFuture<Integer>'s?
I want to return a future that performs a substraction operation on the return of two other cfs
use a command framework
I made my own a while ago, this is what to expect https://github.com/KyTDK/NeoUtils/wiki/Using-the-command-manager
Utils for spigot development. Contribute to KyTDK/NeoUtils development by creating an account on GitHub.
Doesnt this require the server to also have the dependency?
Isnt that what the code current is doing?
not if you shade it
like this maven <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.3.0</version> <configuration> <minimizeJar>true</minimizeJar> <!--If you do minimize the jar, you must apply the filter otherwise essential classes will be excluded from the final jar--> <relocations> <relocation> <pattern>com.neomechanical.neoutils</pattern> <shadedPattern>YOUR.PACKAGE.neoutils</shadedPattern> </relocation> </relocations> <filters> <filter> <artifact>*:*</artifact> <excludeDefaults>false</excludeDefaults> <includes> <include>com/neomechanical/neoutils/**</include> </includes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin>
Il take a look into that, thanks
is it possible to add something like this?
there we go!
the NBT: 3 Tag(s)
so I will need nms?
wondering with something like this ^?
I was thinking about making a 'quick reset' for villager trades, but I'm not sure what should be:
- the activation method given that keypresses are client side
- how to actually set the villager trades to one of the vanilla defaults
I'm dumb so what's the best way to handle an optional method, but not everything needs deactivate
e.g.
public abstract class Effect {
public abstract void activate();
}
some effects may be only activatable, however some may be able to be deactivated yet it would be weird for all of them to have to use both
perhaps defaults?
ehh, defaults would be useless I believe, given the effect would have different code for the required activate and optional deactivate
something like this maybe?
abstract class test {
public void activate() {
}
public void deactivate() {
}
public static class implementation extends test{
@Override
public void activate() {
//do something if you want
}
//no deactivation
}
}```
not entirely sure what ur doing tbh
That is a possibility, yea
then default code could be something as well, depending on what happens with the absence of activation or deactivation
im trying to use the bungeecord plugin messaging channel in my bukkit plugin but im getting this error: https://imgur.com/eDUCf2j
im pretty sure that i set up everything correctly so i have no idea why its throwing that error
I hate to be that guy that isn't magical but we need code
you may also want to consider using a plugin messaging framework
My util has one if you're interested in using it/stealing code
my bad
my onenable ondisable and my actual code to send the plugin message is https://imgur.com/a/0VMq8wx
(commented out because of the errors it was throwing)
NBT tags just mean that it has unique NBT data on it. You can easily recreate that item using just the spigot api
its hard to figure out whats happening with images of code, perhaps upload it to ?paste
?paste
could I have an example?
not sure, just copy my plugin channeling code lol
its a lot more elegant
@shadow zinc I see you lol
it doesn't work ๐ฆ i'm having to reconstruct the entire thing so its works standalone
should have checked before, my bad
Is player livingentity?
yes
@EventHandler
public void onServerPing(ServerListPingEvent e)
Is there any way to check if the ping request came from BungeeCord by comparing the player's addresses? (On BungeeCord I do player.getServer().getInfo().ping();)
Sending data through the serverping is impossible
I'm making an api, how do I use JavaPlugin.getPlugin to get the instance of the plugin that initialized my plugin?
what class do I pass into getPlugin(?)?
when I do ```java
private static JavaPlugin plugin;
public static JavaPlugin getInstance() {
if (plugin == null) {
try {
plugin = JavaPlugin.getPlugin(NeoUtils.class);
init();
} catch (final IllegalArgumentException | IllegalStateException exception) {
throw new IllegalStateException();
}
}
return plugin;
}```
NeoUtils.class is my main class
Why you're doing JavaPlugin.getPlugin()
You can just make an instance variable
after that assign it onEnable
And make a getter for it
Also no need to catch all theee exceptions
Bruh why?
so it can either be standalone or shaded
Yea I understand you
any ideas how getPlugin works?
Pass your main class
ah yes before my computer crashed I was going to mention something
private static JavaPlugin plugin;
public static JavaPlugin getInstance() {
if (plugin == null) {
try {
plugin = JavaPlugin.getPlugin(NeoUtils.class);
init();
} catch (final IllegalArgumentException | IllegalStateException exception) {
throw new IllegalStateException();
}
}
return plugin;
}```
code
but
I get an error
let me find it real quick
What is the error?
its basically NeoConfig can't be cast to NeoUtils
NeoConfig is my plugin using the library
That's cast exception
yeah but its the line plugin = JavaPlugin.getPlugin(NeoUtils.class);
I'm not casting plugin
You can try to get the plugin then print some value of it
To see if you're getting the instance
The class cast exception should be from something you are casting
It means it cannot be casted
[20:14:55 ERROR]: Error occurred while enabling NeoConfig v1.5.4 (Is it up to date?)
java.lang.ClassCastException: Cannot cast com.neomechanical.neoconfig.NeoConfig to com.neomechanical.neoconfig.neoutils.NeoUtils
at java.lang.Class.cast(Class.java:3889) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.getPlugin(JavaPlugin.java:408) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at com.neomechanical.neoconfig.neoutils.NeoUtils.getInstance(NeoUtils.java:16) ~[NeoConfig-1.5.4.jar:?]
at com.neomechanical.neoconfig.neoutils.NeoUtils.init(NeoUtils.java:34) ~[NeoConfig-1.5.4.jar:?]
at com.neomechanical.neoconfig.neoutils.NeoUtils.getNeoUtilities(NeoUtils.java:28) ~[NeoConfig-1.5.4.jar:?]
at com.neomechanical.neoconfig.NeoConfig.onEnable(NeoConfig.java:69) ~[NeoConfig-1.5.4.jar:?]```
Why you're casting NeoConfig with NeoUtils?
im not
Can you send the code when you're running the getInstance method
but onEnable isn't called when I use it in another plugin shaded right?
For shading yes
so I can't do that
I think the error is coming from where you're using the getInstance
Then your NeoUtils should be fine
how if I'm getting errors?
very unlikely
As I said try to get the instance then print one value from the plugin
If you can't print any value
Then your plugin is not started
Someone know how to get the player how trigger the mo spawner activation ??
print something about the plugin instance when I can't get it without a cast exception?
not sure I follow sorry
Try to do directly NeoUtils.getInstance().getDataFolder().toString()
get player in area of CreatureSpawner
nothing happens because I still get the exception
That's strange
gonna try getProvidingPlugin because why not
Hi! I have a question about thread safety and passing large amounts of information back to the main thread.
I have a class called LoadCostumeFileRunnable that extends BukkitRunnable. I use this class to asynchronously load in and process a large and complex file. I want to pass all of this information back to to my main thread as a HashMap<String, Costume>, where Costume is a class that contains two enum types(CostumeHead and CostumeBody), an int and an int[].
The copy-constructor for Costume looks like this:
public Costume(Costume costume) {
this.head = costume.getHead();
this.body = costume.getBody();
this.tempo = costume.getTempo();
int i = 0;
while (i < Costume.MOVEMENT_SPEED_ARRAY_SIZE) {
this.movementSpeeds[i] = costume.getMovementSpeeds()[i];
i += 1;
}
}
To start the async runnable I do:
new LoadCostumeFileRunnable(plugin, fileName).runTaskAsynchronously(plugin);.
In the LoadCostumeFileRunnable I have:
@Override
public void run() {
final HashMap<String, Costume> callbackCostumeMap = new HashMap<>();
// Load stuff
Bukkit.getScheduler().runTask(this.plugin, () -> { plugin.callBackMethod(callbackCostumeMap) });
}
Where callbackMethod() is:
public void callbackMethod(@Nullable HashMap<String, Costume> costumeMap) {
this.costumeMap.clear();
for (HashMap.Entry<String, Costume> entry : costumeMap.entrySet()) {
this.costumeMap.put(new String(entry.getKey()), new Costume(entry.getValue()));
}
}
Can anyone see any glaring problems with this? Particularly with how the data is copied back to the main thread?
(I fully intend to add to, remove from and edit the HashMap once it has been copied.)
stackoverflow with getProvidingPlugin
so it doesn't even get an instance
help how to export plugin with maven pls
I try to use javacord with my plugin using maven but when export plugin javacord not with in
shade
shade???
shade
what is shade?
thank you so much it worked
glad to hear
I keep getting java [21:11:45 ERROR]: Error occurred while enabling NeoConfig v1.5.4 (Is it up to date?) java.lang.IllegalStateException: null at com.neomechanical.neoconfig.neoutils.NeoUtils.getInstance(NeoUtils.java:23) ~[NeoConfig-1.5.4.jar:?] at com.neomechanical.neoconfig.NeoConfig.onEnable(NeoConfig.java:70) ~[NeoConfig-1.5.4.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
when I try to do ```java
public static JavaPlugin getInstance() {
if (plugin == null) {
try {
plugin = JavaPlugin.getProvidingPlugin(Class.forName(Thread.currentThread().getStackTrace()[3].getClassName()));
if (plugin == null) {
throw new IllegalStateException("Cannot find plugin instance");
}
init();
} catch (final IllegalArgumentException | IllegalStateException exception) {
exception.printStackTrace();
throw new IllegalStateException();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
return plugin;
}```
im making a library that will be standalone and shaded
I want it to just get it automatically tho
if I could make it work that would be great
Definitely not a fan of that... Use DI
No need to over-engineer the code
Relying on where things are called is a bad idea
alright, but can we at least discuss why it doesn't work?
No idea it doesn't look like you sent the entire error
Also have you tried printing out the class name in the stackstace so you have the right index
Yeah you have the wrong index in the stacktrace
as I said earlier that code is very much dependent on where you call getInstance
@shadow zinc you can try NeoUtils.getPlugin(NeoUtils.class)
our favourite error java.lang.ClassCastException: Cannot cast com.neomechanical.neoconfig.NeoConfig to com.neomechanical.neoconfig.neoutils.NeoUtils
Does anyone here have an idea for a Bazaar plugin? There's quite a lot of mathematics behind it and maybe one of you knows an open source project?
I need help finding the source of recursion
java.lang.StackOverflowError: null
at java.text.DecimalFormat.getPositivePrefixFieldPositions(DecimalFormat.java:2590) ~[?:?]
at java.text.DecimalFormat.subformat(DecimalFormat.java:1743) ~[?:?]
at java.text.DecimalFormat.format(DecimalFormat.java:780) ~[?:?]
at java.text.DecimalFormat.format(DecimalFormat.java:714) ~[?:?]
at java.text.SimpleDateFormat.zeroPaddingNumber(SimpleDateFormat.java:1428) ~[?:?]
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1367) ~[?:?]
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:1001) ~[?:?]
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:971) ~[?:?]
at java.text.DateFormat.format(DateFormat.java:378) ~[?:?]
at com.neomechanical.neoutils.ServerMetrics.<init>(ServerMetrics.java:17) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtilities.<init>(NeoUtilities.java:64) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.init(NeoUtils.java:111) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.getNeoUtilities(NeoUtils.java:101) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.version.Versioning.register(Versioning.java:40) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtilities.<init>(NeoUtilities.java:71) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.init(NeoUtils.java:111) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.getNeoUtilities(NeoUtils.java:101) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.version.Versioning.register(Versioning.java:40) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtilities.<init>(NeoUtilities.java:71) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.init(NeoUtils.java:111) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.getNeoUtilities(NeoUtils.java:101) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.version.Versioning.register(Versioning.java:40) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtilities.<init>(NeoUtilities.java:71) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.init(NeoUtils.java:111) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtils.getNeoUtilities(NeoUtils.java:101) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.version.Versioning.register(Versioning.java:40) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]
at com.neomechanical.neoutils.NeoUtilities.<init>(NeoUtilities.java:71) ~[NeoUtils-2.0.0-SNAPSHOT.jar:?]```
Yes something like that
I have absolutely no idea how to do this
chuck on some rock and chug a coke for inspiration
found recursion
I reckon time travel isnโt possible because it would throw a stack overflow
or a null pointer exception
Finally it works
best feeling
hey there, what is the difference from normal advancements to recipe advancements?
I need to only register normal advancements and get completely spamed of the others.
goofy thing
you can bypass the stack by just having a List<Runnable> and looping it
where the runnable internally adds to the list
So I want there to be different points as rewards for each different mob. Is there a better way than doing it this way?
points. + entityType.name().toLowerCase() ?
Can XP entities or minecarts not be detected in the EntityDeathEvent?
yeah you can just add checks for those
name().endsWIth("MINECART")
or startsWith idk
Nvm figured out: The Event only deals with LivingEntities
for (int i = cube.getX1(); i <= cube.getX2();i++) {
for (int j = cube.getY1(); j <= cube.getY2(); j++) {
for (int k = cube.getZ1(); k <= cube.getZ2();k++) {
Block block = world.getBlockAt(i,j,k);
block.setType(material);
}
}
}``` should i store the values in a list and then loop through the list so it doesnt eat that much cpu?
cause its in a bukkitrunnable and it can do it every second
Blockphysics event or some shit oike that
Im having trouble with this code
player.getWorld().createExplosion(loc.getX(), loc., front.getZ(), 5f);
Trying to get 2 blocks from where the player is placing, but It doesn't seem to work.. Heres my code:
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
Player player = event.getPlayer();
Vector playersDirection = player.getLocation().getDirection();
Location loc = player.getLocation().add(playersDirection).multiply(2);
if (event.getItem() != null) {
double x = event.getPlayer().getAttackCooldown();
int y = (int) x;
if (x == y) {
if (event.getItem().getItemMeta().equals(ItemManager.GravHammer.getItemMeta())) {
player.getWorld().createExplosion(loc.getX(), loc., front.getZ(), 5f);
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3, 255, false, false, false));
System.out.println("I work");
}
}
}
}
}```
Any ideas?
NvM i got it, thank you
??:D
I figured it out
I thought too hard about the loc part
Kinda dumb for not realizing lol
I don't even understand the question. ๐
this is me forgetting to add important stuff lol
What does he really want, I don't understand the question.
he already figured out what he wanted
ItemMeta = item.getItemMeta(); //where is the name :D?
what kind of name do I need to write?
ItemMeta meta =
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.
tf
sorry im begginer ๐
ItemMeta ItemMeta = Item.getItemMeta()
also watch some youtube tutorials for this basic stuff
there is alot of (Spigot / Bukkit ) api coding tuts out there
or sources
quick google
plus your I-D-E tells what right!
Why your i always uppercase.
thats how you write if you dont have a variable
it the class
Nice
you write item.getItemMeta(); and item is the class Item
so you write Item.getItemMeta();
tru
dunno how to explain
XD
declaration: package: org.bukkit.inventory, class: ItemStack
For what ๐ฟ. I understand it.
I have two plugins A and B. Plugin B depends on A. I can add custom "handlers" to A from my plugin B, but the problem is that these handlers are called when the server is shutting down, and when the server is shutting down B is always going to disable before A and when it disables all it's classes are unloaded. So I will just get errors that the class doesn't exist from plugin A. How can I fix this?
java-naming-conventions
?conventions
'ItemMeta meta = ItemMeta meta' would make more sense
๐
Sus moment
better having it more clear
getting Instance of other Plugins?
?paste
having trouble with calling the entitydamageby entity event
it only seems to run 1 time
then stops calling the code within
any ideas?
no, plugin B simply just registered a class to plugin A and A tries to use it when the server is shutting down
bump
?paste ๐
im feeling like an idiot having everything mutable with setters, why cant mongo just use reflections
meh
what meh
Is there a simpler way
its too stupid to search for constructors too smh
pdc is simple
problem is, it recognizes the weapon and broadcasts the message tho
so it does
work
it only runs one time for sum reason
oh wait
๐คฆโโ๏ธ
i didnt check durablility
So if B != null and A != null
B excute function send to A?
A register function
A use.. your class
Seems over do
why not just use the instances
Does someone know what the Pathfinder is when a goat is attacking?
do you mean as Server log or in game player chat stuff?
i'm pretty sure every message will be there
idk what you're trying to?
Is there something to check when a totem of undying is used?
if i wanted to use mongodb on my plugin and the server not running on my pc, do i have to set the connection to some running mongodb server or run the server myself on that pc?
EntityPotionEffectEvent
declaration: package: org.bukkit.event.entity, class: EntityPotionEffectEvent, enum: Cause
most things you can easily just find in spigot doc
This is a lil stupid
but how might I iniatlize the runnable I am using
cause this
doesnt work
Im using runTaskTimer
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
anyone know why it is not including LWJGL?
it does show in the compile classpath
but not in the external libraries
dependencies {
api 'it.unimi.dsi:fastutil:8.5.8'
api 'net.orbyfied.j8:j8-registry:0.1.0'
api 'net.orbyfied.j8:j8-util:0.2.1.1_hotfix2'
api 'net.orbyfied.j8:j8-event:0.1.0_hotfix1'
// platforms
compileOnlyApi "org.lwjgl:lwjgl"
compileOnlyApi "org.lwjgl:lwjgl-glfw"
compileOnlyApi "org.lwjgl:lwjgl-jawt"
compileOnlyApi "org.lwjgl:lwjgl-jemalloc"
}
i think the simple way is to use the message channel..
on reciving
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
}
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
the Bungeecord does the global stuff
why not just send it via bungeecord?
I don't know if this applies to you, but one major drawback of plugin messages is that both spigot servers sending/receiving messages must have atleast 1 player online.
FakePlayer <-- this a joke
yeah it sucks
tru
Does someone know what the Pathfinder is when a goat is attacking?
I got tired of dealing with plugin messaging weirdness and wrote my own socket stuff to use. Much more work but more reliable
Server log to Bungeecord?
and more insecure
Depends on the use-case, if it's bound to loopback it's fine
would rather use a webservice or some third party stuff
Unless I'm wrong then I'd love to learn
what you trying to do?
this refers to the object you're currently in. runTaskTimer wants the instance of your plugin. If you schedule it from within your plugin's main class, you can use this, otherwise you need to pass an instance of the plugin to the other class to use there.
Or get the instance some other way, but passing it's the easiest
trying to replenish a totem of undying in the offhand
every 10 seconds
I worked it out
but I haave trouble putting the totem in the offhand
there is a event? bruh
Apart from lambda scopes, where this is inherited from the surrounding scope
public OtherThing(MyPlugin plugin) {
this.plugin = plugin;
}
...{
new BukkitRunnable() {...}.runTaskTimer(plugin, number, number);
}```
I already have that worked out
but how do I put the totem in the offhand
i mean for the totem
hmm wondering if plugin uses mongodb, the end user has to run the mongodb server themselves or connect to a public hosted one or what
player.getInventory().setItemInOffHand(item);
lemme guess you want to check if there is a totem every 10 sec?
Yeah
@raw prairie
be aware from inner attacks then
I wanna put a totem in offhand every 10 seconds
repeating task
yea
you probably need
I already have it
lol
I have a bukkit runnable
public void onEntityDamage(EntityPotionEffectEvent e){
if(e.getCause().equals(EntityPotionEffectEvent.Cause.TOTEM)){
Player player = (Player) e.getEntity();
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
player.sendMessage(ChatColor.RED + "[CrystalBall] " + ChatColor.GREEN + "Your shield is down! Wait 10 seconds for it to replenish!");
player.getInventory().setItemInOffHand(Item);
Bukkit.getScheduler().runTaskTimer(plugin, () -> {}, 2, 10);
}, 0, 200);
}
}```
You're scheduling a new timer (repeating task) every time that happens?
Tf is that
yep
just have one task for the user, store it in a map somewhere or whatever
