#help-development
1 messages · Page 2235 of 1
?reflection
fully server side
can someone link me something that explains reflection
what does grass look like?
Accessing a library without importing it
how'd that be an issue?
reflection is really used to access either inaccesible stuff or stuff u dont wanna depend on at compile time
like a private field in a class
useful for nms where the package name used to change as well as field names
yea hence why i said use remapped
so u dont need to import every version of spigot into ur ide
remapped reflection should not change on other versions
and even if you use remapped and build for one version only, sometimes, you wanna change a variable, but there is no method to do so and the variable in not public. so u use reflection, make the field accesible and set it
this is without using remapped, correct?
remapped leads to having a multimodule project with a module for every version that had a change
for sure it's useful
but sometimes, u cant avoid reflection/its just easier to go the way of reflection
ill just think about it once im told i can only do x with nms
What's the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent?
declaration: package: org.bukkit.event.player, class: PlayerInteractEntityEvent
declaration: package: org.bukkit.event.player, class: PlayerInteractAtEntityEvent
showed this dude the water and leaf color
freaked out
https://cdn.discordapp.com/attachments/902581430268362752/989628982645391451/unknown.png
lemme just
how does grass look?
not changed grass color
but isnt grass color determined by biome color?
mc is weird man
ah makes sense
so why tf are trees purple
they use biome color
oh wait
grass uses grass color iirc
there
close enough
what site is that?
mc wiki
can you dm me the whole class
Making it a nms free implementation
Using reflection
thats the code
the whole class, idk the imports n stuff
you just need a player object
and a location
yes and its in a cmd class
import net.minecraft.world.level.biome.BiomeFog;
what abt craft world
import lombok.SneakyThrows;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Optional;
idk
if (!(entity instanceof EnderDragonPart) && !(entity instanceof Player) && !(entity instanceof Wither)){
Random random = new Random();
int chance = random.nextInt(1,4);
if (chance == 1){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.COD);
} else if (chance == 2){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SALMON);
} else if (chance == 3){
entity.getWorld().spawnEntity(entity.getLocation(), EntityType.TROPICAL_FISH);
}
entity.remove();
}
}
@EventHandler
public void set(EntityShootBowEvent event){
if (event.getProjectile() instanceof Arrow && event.getEntity() instanceof Player){
if (event.getConsumable().getItemMeta().getCustomModelData() == 500){
event.getProjectile().setMetadata("fish", new FixedMetadataValue(plugin, true));
}
}
}
@EventHandler
public void hit(ProjectileHitEvent event){
if (event.getEntity() instanceof Arrow && event.getHitEntity() != null && event.getHitEntity() instanceof LivingEntity){
Arrow arrow = (Arrow) event.getEntity();
Entity entity = event.getHitEntity();
if (entity != null){
if (arrow.hasMetadata("fish") && entity.getType() != EntityType.COD && entity.getType() != EntityType.SALMON && entity.getType() != EntityType.TROPICAL_FISH){
event.getEntity().remove();
turn(event.getHitEntity());
}
}
}
}```
ty
I have this code which is supposed to turn mobs to fish if they're shot by an arrow with customModelData of 500. when I shoot at an unliving entity the entity disappears with the arrow and no errors are being sent in console. I checked and the first if statement in hit() is false which means that no lines like entity.remove() are being read by the plugin when I shoot at an unliving entity so I really don't know what can cause it. any ideas?
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/ So using this can i edit a plugin while the server is running?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
does anyone have any idea?
But i would have to keep transferring the plugin from the build output to the server folder
ok serious question: how can i whitelist players in bulk. i aint typing /whitelist add player 15725325 times
fair enough, but then reloading the plugin wont help right? reloading it only reload the config
mine doesnt lmao
when i run the reload command its just programmed to reload the config
how tho :(
there is no plugin.reload() function
lol im not gonna use plugman
i hear that it can break mechanics on your server
^ this is true
I deleted this entire code and it still happens
;-;
this
Hi, what is more performant?
- Having a repeating task running every second, checking if something is expired (would include a loop with multiple if statements each second)
or - Having (maybe a lot) active delayed tasks, that just wait a amount of time and then just run one operation?
wait around
actually it depends
I unregistered each event one by one and it still happens.
I removed the plugin and it still happens
wtf?
there are no other plugins in the server
yes
@quaint mantle I deleted all of the plugins in the server
and the boat disappears when I shoot at it
every unliving entity
ohhhhhhhhhhhhhhhhhhhhh
i got it
it was disappearing because i was in creative.
if im in survival the boat/whatever drops on the floor
its a game mechanic
nothing is wrong
@quaint mantle you meant something like that?
okay thanks :)
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/ So using this can i edit a plugin while the server is running?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
you have to set a "mysql_native_password" on mysql 8
If you just want to get rid of the error, at the cost of risking the security of the project (e.g. it's just a personal project or dev environment), go with @Pras's answer --
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
and then
flush privileges
Have u tried ^^
It's clearly a problem with mysql not your code
I think that's ur fix tbh
getSlot gets the slot of the clicked inv
Getrawslot pretends the top and bottom inv is one
I'm not smart enf to know
Did u flush privileges?
Same error?
Yea
root@localhost
Wait what were u using
Try running the plugin on 1.18
They error is that the client is outdated
Maybe 1.8 had an older driver or sumn idk
Buildtools and ur plugin
Shouldn't be hard
Mc server?
Or client
Check forge ig
Maybe u can fork forge
Never worked with client
you dont create a new inventory I presume
yes but involves some packet trickery (i borrowed this feature from deluxe menus actually)
ah okay
This event will fire when a player is finishing consuming an item (food, potion, milk bucket).
because you never use the super user on any system/application for anything other than management
and you're also sharing the super user with other applications that don't need such permissions
Doesn't matter to u tho since it's to test
To which packet and what field should I write to when opening a sign gui? I'm kinda lost here
what version?
ClientboundOpenSignEditorPacket
takes a BlockPos as constructor parameter
keep me updated on this one
What happens if the blockpos is not a sign?
probably crashes the client or doesn't let you sign
Or if it is is there a regular sign event?
likely doesn't let you sign
hey can someone help i have source files as a zip but i need them put as a jar
can anyone do it for me
Unzip?
And import to intellij
yes but what method do i use?
setVelocity with such speed
it takes in an x, y, z vector
that's the new velocity in blocks/second iirc
For lists
Collections.singletonList for a single element list
or Arrays.asList
not sure about map, I usually just call put methods
Either through guava or by creating an anonymous class
something like
Map<String, Integer> whatever = new HashMap<>() {{
put("potato", 123);
}};
I remember you could do something like that
not sure about semicolon positioning
yeah
but worky
*But dont overdo it. Creating constants like this is ok but dont use it if it gets instantiated too often.
probably makes an anonymous class or something stupid
But usually classes that contain data structures shouldnt be instantiated too often anyways.
can be any object
Sure
But that should either be a multimap or the list should be encapsulated in a new class.
Nesting raw collections is bad practice.
I'm currently designing a new file structure that I'm wanting to use for my language system. A sort of "language pack" if you would. I'd appreciate some feedback on it.
Here's an example of the directory structure.
.
├── locale_en
│ ├── default_messages
│ │ ├── default_guis_en.yml
│ │ └── default_locale_en.yml
│ ├── holiday_overrides
│ │ └── christmas_override_en.yml
│ ├── locale_en.yml
│ └── locale_guis_en.yml
└── locale_pl
├── default_messages
│ ├── default_guis_pl.yml
│ └── default_locale_pl.yml
├── holiday_overrides
│ └── christmas_override_pl.yml
├── locale_guis_pl.yml
└── locale_pl.yml
In this example, I have taken a different approach to the standard one language file most plugins use. There is still a general language file, but it only contains the general messages and error messages. Everything else that can be categorized would be put in a new file. In this case, language options for GUI items are put into a separate file.
Now, I believe that this will offer more benefits than drawbacks.
Benefits
+ Modularity
If a server owner disables a part of the plugin's functionality, lets say the GUIs for instance, the GUI locale files wouldn't need to be loaded, saving some memory. Compared to the standard language file, all of those extra sections would just be taking up unnecessary ram. (I know it probably isn't much, but hey, just because you have an abundance of RAM lying around is no excuse to use it unnecessarily!)
+ Expandability
If I wanted to add any future subdirectories, it would be extremely easy.
+ You don't have to delete files to get an updated version from a plugin update. (At least not as often)
In this case, the only files that would are the ones in the default_messages folder because this folder would be used to grab default/backup values incase of mismatched files.
Unless something new is added to an existing file, you can set it and forget it. Say for instance, you are using development builds of a plugin and the dev is changing GUIs pretty often. You wouldn't want to have to delete your language file every single time just to get some new sections. Not to mention all of the work you would have to do to re-update every section with the proper colors and messages.
Drawbacks
- Makes it a little more time consuming to setup.
Files like the holiday overrides section would likely have different color formatting and different holiday themed messages. Adding more work for the initial setup.
- Sacrifices some User Friendliness for Functionality.
it would be a little daunting to look at for the first time. As developers, this probably seems pretty straightforward, however, for normal server owners, they are used to the convenience of things being in one file. It wouldn't cause plugin functionality to break if they only modified one file, but would look incomplete if a server owner thought that they only needed to modify the general file.
- Harder to implement into code.
With an infinite expandable system like this, some hard coded methods would need to be made. As this system is intended for translations, sections need to be mapped to proper message values. Things like the plugin prefix which is located in the general language file would need to be used in every other file. Essentially coupling the general language file to every other one.
Also, dealing with multiple files could be a little problematic if they aren't managed properly.
These drawbacks aren't the biggest thing in the world, but Ease of Use and Ease of Understanding is nothing but a benefit to the end user. It would be nice if this system could be made a little friendlier, but with the way the files are laid out and labeled, it should hopefully be as straightforward as possible.
That's what I think at least, but what do you guys think?
Holy
How can I make the custom name of an entity always appear? (and not only when the player gets close enough)
Isn't that Client Side?
Why?
I'm making irongolems in a bedwars plugin and I want them to always show the name so the player will know what team they belong to
It has to be client side, no?
I don't know? 😅
Maybe something to do with spigot.yml
Entity#setCustomNameVisible(Boolean)
Pretty sure that's if it is visible at all 🤔
yes
they mean it will show when you aren't hovering over them
like how a player's would
i think by default the functionality is like name tagging a zombie where u have to be looking at them for the name to appear
Oh yea, this works with items and armorstands only i guess, sorry
But you may spawn an invisible armorstand and set the name of the armorstand
actually maybe it might default it to always visible
Can someone help me figure this issue out? : https://youtu.be/f5Yr_tqvvYE
?jd
So I have an old project that I made a while back. And I wanna redo all the insides. What’s the best way to decide what to remove?
Should I remove it all at once
And redo
Or take it one section at a time
Maybe make a separate branch in GitHub to mess with?
Maybe I’m overthinking
It is 2 am
How big is it?
Hello guys, Quick question. How do I register 2 events from 2 different classes?
one class is the main one
The same way u register one event
and the second is a different one imploments listener
Create an instance of your Listener classes and register them in your onEnable()
Wut?
First of all: You should not let your JavaPlugin class implement Listener.
why?(just curious)
Doesn't this work?
Its just dirty coding. There are clean code principles like separation of concerns and single responsibility principle that
define how to properly structure code. And creating new classes for new purposes is much cleaner than clumping everything together.
yea I started this plugin when I was a complete beginner but now I feel like most of my code is a mess, I never divided my code into classes. I just used the main class
yep doesn't work
"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.
xDDDD
anyways
basically, if I do both of them it cancels the manager.registerEvents(this ,this);
Nope. Add a sysout in both your listener methods (at the beginning) that print out "A" and "B" and you will see that both are still fired.
wdym?
What part specifically do you not understand?
Console log. You can use the logger or for quick debugging purpuses you can just call std::out
System.out.prinln("")
Well. Did you make sure both listeners are called by adding a debug message?
so I just go and take one random event from the main class and put it in there
like System.out blabla
and then I also do the same in the event in the other class
just making sure I understood
Sure. This will show you that both listener methods are fired regardless of other registered listeners.
I run the program and.. nothing happens it shows me a lot of messages but I dont see A or B
Which means nothing works at all? Well is your plugin even enabled?
Is it listed (and green) if you type in /pl
oh wait u mean in minecraft im an idiot
yes. to see which plugins are enabled
wait
my build messed up just a second
When i try to build it now gives me an erro for no reason
Errors have a reason 99% of the time
What is it?
Sounds like your project has no jdk to build on.
What IDE are you using? And are you using maven/gradle?
You cant "run" a plugin obviously...
yea ok I fixed it
I had to redebug it because I messed the maven thing up because me be stupid
Alright. Btw how do you compile?
This completely ignores your pom.xml and you could as well not use maven at all.
You can use this tab to build projects with maven.
The "all in one" cycle is just install.
Also if you are using maven then you should never add external jars or other dependencies to your project
because thats what maven is for.
oh ok
wdym?
Alright so I reloaded
it doesn't do the enable because it says there is an error
because I did the register events twice idk
We need to see the error to help
is there a method to make a completable future throw an eventual caught exception without doing it myself?
Uh wym?
The problem is that you dont know if there are other appendixes being added later on until you finalize the chain
Like CF wraps any runtime exception with a CompletionException and determines the stage as a failed stage iirc
not sure if i understand it correctly, but as an example whenComplete takes a biconsumer as an argument with a throwable
and i guess the throwable object is an eventual exception that was caught while completing the future or similar
Yes
But you also have CompletionStage::exceptionally
And fyi using get/join will throw the eventual exception that was caught during computation
aight thanks
assuming a player has a shield in each hand, how can i check which shield is raised? Normally it'd be the left one but theres that left hand option
What you can do is create a method in a utility class ("ExceptionUtils" for example)
public static <T extends Throwable> T delegatePrint(T throwable) {
throwable.printStackTrace();
return throwable;
}
This allows a shorter form
CompletableFuture.failedFuture(new RuntimeException("Test")).exceptionally(ExceptionUtils::delegatePrint);
oke thanks
check both hands and see which one is raised.
btw i've just noticed that vault uses doubles to represent player's balances
weak
isn't that bad because of floating point precision?
if your economy has so much inflation that you get precision errors you've got different problems
my economy doesn't exist yet but i'm wondering if the numbers are close to billions will you get noticeable precision errors
For currency you still have a decent precision of at least 6 decimal places after the dot if your number has 60 zeros
wow
hm?
i thought the precision was worse
its still got sixteen decimal numbers precision
eleven exponent bits and fifty two fraction bits
1.000000000000000000000023 will be more precise than
254,532,545,123.000000000000000000000023
i just need 2 numbers after the dot and i'm not making op prison economy so no 20 digit balance
so it should not be a problem
Then dont fret
Well it will be more accurate. Not precise.
also another issue with vault is that there are no separate methods to distinguish between removing money and transfering money
Do you use other plugins on your server which you didnt write?
most probably i won't
i was planning on implementing vault eco but i've already given up on the idea
Then why bother using vault. Just create your own economy.
also because of methods with player names as strings
oh and also because i need to retrieve data from a database for offline players
You can do all of that easily actually
Thats one of the biggest drawbacks of vault. No async integration.
Vault is getting pretty old right now
yep, what im doing now is i've taken most of the vault methods i think are useful for my eco and making sync and async ones
iirc it's been out since 2011/2012
yeah 2011
where? Player#isHandRaised just gives a boolean if it is
also
checking main and off hand doesnt tell me if the off hand is the right or left one
Right or left is relative because the player can change this in their own settings.
And you cant raise two shields. So if a shield is raised and the player has a shield
in his main hand, then this shield is the raised one.
im aware of that but i do need to know if the raised shield is in the right or left hand
im doing geometry with it
You can't
Or ask the player
nms it is
I don't know any packets that refers about it
I think it's juste client side design
But do you guys know someone that change the main hand?
Oh wait, does it change the apparence of other players ?
So just listen to that packet and save it
Then when the player use a shield you know which side
declaration: package: org.bukkit.entity, interface: HumanEntity
HumanEntity#getMainHand() -> LEFT | RIGHT
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Dont forget
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
unpopular opinion i hate rounded corner design boom
rounded corners are more harder to compute than square ones, also they seem not uniform to computer's screen, at least on computer screens we don't have rounded corners
Feels way smoother, squared corners bring hardness
Rounded corners help us to follow lines
So by user experience its a little bit more appealing
uh i cant find how to check if the player is blocking with the main hand or off hand
If blocking -> if main hand has shield : its the main heand -> if not : its the offhand
If blocking -> if main hand has shield : its the main heand -> if not : its the offhand
ah right
k
boolean swap = player.getMainHand() == MainHand.LEFT;
boolean shieldLeft = true;
if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD)
shieldLeft = false;
if(swap)
shieldLeft = !shieldLeft;
sounds about right?
welp i have a completely different issue now. I cant seem to find anything online for the shield hitbox except 'visually it's dependent on the texture pack', and a mention that its handled by the server. Does anyone know how i can get the hitbox the server uses for calculating if a projectile is blocked or not?
public enum Side {
LEFT, RIGHT, NONE
}
public static Side getRaisedSide(Player player) {
if(!player.isHandRaised()) {
return Side.NONE;
}
boolean invert = player.getMainHand() == MainHand.LEFT;
if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD) {
return invert ? Side.LEFT : Side.RIGHT;
} else {
return invert ? Side.RIGHT : Side.LEFT;
}
}
uh i guess... seems like it does about the same, i have a israised check before
You need to dig for that
urgh
see what im trying to do is fix the shield bug
but without access to that hitbox i can do squat
you recon it needs nms?
What is "the shield bug"?
if you block a projectile that was already shot
it does not get blocked
so if someone shoots you from fifty blocks away and you see that arrow flying at you and you block
you still get shot
No this sounds ridiculously stupid. Is this a thing in the newest version still?
is there a better way to do this?
private void setupListeners() {
final Listener[] listeners = new Listener[]{new PlayerBuild(), new PlayerChat(), new PlayerDamage(), new PlayerJoin(), new PlayerQuit(), new WeatherChange()};
Arrays.stream(listeners).forEach(listener -> getServer().getPluginManager().registerEvents(listener, this));
}```
Whats wrong with just doing one call per instance?
Anyways:
List.of(
new XListener(),
new YListener(),
new ZListener()
).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this));
I want to do it in one line
Why?
more clean

No its literally way dirtier.
You actual troll
List.of(new XListener(), new YListener(), new ZListener()).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this));
What ive posted is technically one line
Use a reflection library and it'll be 1 line 
You definitely beyond all programmers do not want to have it in one line
What is the best way to do it then?
As long as you can eliminate as many illusions as possible it’s pretty good
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new XListener(), this);
pluginManager.registerEvents(new YListener(), this);
pluginManager.registerEvents(new ZListener(), this);
There is nothing wrong with this one.
I've been staring at Projectile and Arrow in net.minecraft.world.entity.projectile for what feels the last half hour and cant seem to find where it deals with shields... can anyone give me a pointer?
void* p = malloc(16);
There you go. Dont forget to free it later
dig
maybe try look at where damage is done in the player
i doubt the shield has its own hitbox
you were damn close but the method i found is to handle stuff after the player blocked
unluckily i cant search for usages in the nms code
this will lead to a memory address being printed
you can make
Player p = Bukkit. get...
u cant print a list
its works to
wait he want send brod?
if its brodcast just make this
wtf is this java else if ("sonic_boom".equals(source.msgId)) { cause = DamageCause.SONIC_BOOM; }
that works?
bruh
are you understand javafx?
wait
you wanna check the player amount?
player and them are the same
yah
why make 2 variables the exact same
player and them are the exact same object
are you traying to send message on player join?
just use player
I got something. ProjectileUtil#getEntityHitResult(Level var0, Entity var1, Vec3 var2, Vec3 var3, AABB var4, Predicate<Entity> var5, float var6)
This is called by AbstractArrow on tick to determine if it did hit an entity
don't be like that
chatcolor. bold +" " +chatcolor.anycolor +""
help him learn
@viral hazel
dont make spam space
just one
no you need that
so any error you get?
nvm
yah i know he can make string color to &
but its usles
ok
lenght is work
the way you are doing it is fine
+1
also instead of hard coding theres a method to get the max players
yeah thats good
int numberOfOnlinePlayer = Bukkit.getOnlinePlayers().size();
int maxNumberOfPlayers = Bukkit.getMaxPlayers();
no need. Collection sizes are retrieved by calling .size() and not .length
Take a look at the two lines of code ive sent above pls.
smart way
look
just make this
yeah thats good
wait everyone
also u dont need to show us the imports
dont talk
cut down the message size
yourCodeGoesHere
look bro just make like this
Bukkit. getOnlinePlayer(). size() + Bukkit. getMaxPlayers();
just do this
im slow cuz im phone
@viral hazel
player.sendMessage(Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
dont forget the "/"
Finely
🎉 thanks bro
@viral hazel everythink ok?
ok
put space
and try
its will take time
but its the way
or
try put
=======
Centering a message is quite difficult because clients can have different settings for their chat width.
There are also a lot of resourcepacks that add different fonts.
Can I get the Drops count from a mined ore?
yah
and you can edit it
brb 10m
declaration: package: org.bukkit.event.block, class: BlockDropItemEvent
so hello I start in the code I try to create an lg to train me, my code is it good?
import org.bukkit.ChatColor;
@SuppressWarnings({"unused"})
public enum Aura {
LIGHT("werewolf.role.oracle.light", ChatColor.GREEN),
NEUTRAL("werewolf.role.oracle.neutral", ChatColor.GRAY),
DARK("werewolf.role.oracle.dark", ChatColor.DARK_RED);
private final String key;
private final ChatColor chatColor;
Aura(String key, ChatColor chatColor){
this.key = key;
this.chatColor = chatColor;
}
public ChatColor getChatColor() {
return chatColor;
}
public String getKey() {
return key;
}
}```
i only get a bunch of remapped files?
your code goes here
which is the correct one?
lowest one
ok ty
@SuppressWarnings({"unused"})
Why is that there?
it means for me I introduce and it is to use a single role
Makes no sense. Suppressions like that should be removed.
ok ty
Any way to make a fake hurt effect on an entity without damaging it?
damage it with damage set to 0
Damage it with a value of 0.0
CraftBukkit wrapps nms. Usually you get the wrapped nms object by calling getHandle()
nms version of livingentity i think
you cannot cast a bukkit entity to NMS entity
CraftEntity.getHandle() returns the NMS entity
ah ok
can you call super class externally
like i have overriden the method
inside second method
but i need to execute baseclass method
ik this is possible with cpp due to virtual functions
but i dont know about java
nvm
what I hypothetically thought would work, not gonna
the only part where you can call super is if its the first instruction in the constructor
so apparantly this is intended behaviour
why
You can create a new method
public void exposedStuff() {
super.internalStuff();
}
wat
isBlocking() is a condition for deflecting an arrow
however
there is a delay between isRising and isBlocking returning true (start of raising shield to having the shield up)
the idiotic part is that the animation is only about 30% of the delay
so you think you raised your shield
but actually its still 'being readied'
thats intentional... the game is coded to work like that
the vertical component of that 'related' bug with the upwards facing shield is there too
they remove y from the vector representing view direction
as a result you get hit
under what category do plugins fall that change game mechanics
wait the project to load
how do I get the two added arrows in EntityShootBowEvent when the bow is a crossbow with multishot?
File -> Project structure -> Modules -> press on + -> add the root as a module
See if the ProjectileLaunchEvent is fired for each arrow
?jd-s
EntityLoadCrossbowEvent
Might be fork-only
it doesn't show up
it doesn't exist
then its paper only
its paper only
😢
is there a work around it in spigot?
fix your xml syntax
what's the problem
they are closing <proejct> before the actual content
<project xlmns = blablabama and other stuff >
is there any way to detect crossbow load?
you could listen to playerinteractevent, then schedule a repeating runnable to check whether Player#getItemInUse is not null and once it's null again, check if their main hand item has an arrow loaded
dirty workaround though lol
hmm
i have another idea.
it there a way to make the event EntityShootBowEvent execute only once when the bow is a multishot crossbow?
you could create a Set<UUID> with the player's UUID once an arrow is shot, and then clear that entry in the next tick, and ignore every event called for a shooter that's in the set
you forgot dot
missing a . in between dev and tobys
dev.tobys.aqualand.Aqualand
Again: Read the exception. Your path is wrong
in your plugin.yml
not devtobys.aqualand.Aqualand

How can i easly double the drop amount from ores like diamonds
BlockDropItemEvent
I have a question, how do you select one string out of a list from a config.yml? is there a place I can learn how to do that?
randomly select one string out of a list
You basically read the entire list into memory and then select a string out of there.
You should not read configs often in general. Load everything into classes and fields when the server starts and use this data instead of configs.
hmmm ok
public CompletableFuture<Void> transferBalance(UUID from, UUID to, double amount) {
CompletableFuture<Void> future = new CompletableFuture<>();
playerRegistry.getOrLoadPlayer(from).whenComplete((cosmicFrom, throwable) -> {
playerRegistry.getOrLoadPlayer(to).whenComplete((cosmicTo, throwable1) -> {
transferBalance(cosmicFrom, cosmicTo, amount);
});
});
return future;
}
how can I make this cleaner?
ie making the two completable futures run at the same time and when both are completed, invoke transferBalance()
Why do you use "whenComplete" but ignoring the throwable?
Could also just use thenAccept
But other than that it looks ok. Just wondering when you are saving the data again.
And also what happens if this method is called too fast. Because this could lead to stale data if you dont use any locks.
currencies should always be done transaction based
useful to know
player profiles (named CosmicPlayer) are stored in a map and when i call getOrLoadPlayer, if the player profile is already loaded, it will be retrieved from the map, else it will be loaded from a database and put in the map
And you only access data from this single map? So there are no other minecraft instances interacting with playerdata?
i can use the packet, but what do i write to it or what do i need to set text?
oh i have noticed something bad
You can pass an executor to your CompletableFuture.
PersistentDataContainer data = player.getPersistentDataContainer();```
This used to work until I added vault as a maven dependency anyone knows why
Change the order of vault and spigot in your dependencies
wdym
as I already said, it takes a BlockPos as argument in the constructor. Which is the position of the sign that's to be edited
which event is caused when we click ender crystal, entitydeathevent or entityexplodeevent?
probably both
Whats wrong here?
https://paste.md-5.net/iluyicayux.java
i tried to cancel the death event but it didnt work
how can I do that? In the constructor?
But with this i cant check the broken block type.. This returns Air
Use getItems()
getBlock() is air because the block is already broken
But i can use the same methods like getitems in BlockBreakEvent where the gettype works
Well, no, because that wouldn't take into account stuff like fortune.
Oooof
Btw you can take a look at caffeine if you want
private final AsyncLoadingCache<UUID, CosmicPlayer> cache = Caffeine.newBuilder()
.expireAfterAccess(45, TimeUnit.MINUTES)
.removalListener(this::saveToDatabase)
.buildAsync(this::loadFromDatabase);
private CosmicPlayer loadFromDatabase(UUID key) {
// load data from DB
}
private void saveToDatabase(UUID key, CosmicPlayer player, RemovalCause cause) {
// Save data to DB
}
public CompletableFuture<CosmicPlayer> getOrLoad(UUID key) {
return this.cache.get(key);
}
Its a hashmap backed by a loader and writer
You need to get the broken BlockData. Not the current block. The items are dropped after the block was already broken. So its always air.
Might wanna pass an executor but myess caffeine is so yummy :3
Yeah specifying an executor and a Timer on top which is fed by the executor is better practice for this
interesting
By passing an executor i mean this:
private final ExecutorService executorService = Executors.newFixedThreadPool(4);
private CompletableFuture<CosmicPlayer> loadFromDBAsync(UUID key) {
return CompletableFuture.supplyAsync(() -> loadFromDBSync(key), executorService);
}
private CosmicPlayer loadFromDBSync(UUID key) {
// Access DB
}
That makes no sense...
Why is this dropping me 9 Redstone Dust when i just drop the same the same amount (4) again?
@EventHandler
public void onOreMine(BlockBreakEvent e) {
if (ores.contains(e.getBlock().getType())) {
e.getPlayer().sendMessage(e.getBlock().getDrops().toString());
e.getBlock().getDrops().forEach(item -> {
int amount = (item.getAmount());
e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(item.getType(), amount));
});
}
}
private static final Set<Material> ORES = Set.of(
Material.IRON_ORE,
Material.COAL_ORE,
Material.DIAMOND_ORE
);
@EventHandler
public void doubleMyDrops(BlockDropItemEvent event) {
Material type = event.getBlockState().getType();
if(!ORES.contains(type)) {
return;
}
event.getItems().forEach(item -> item.getWorld().dropItemNaturally(item.getLocation(), item.getItemStack().clone()));
}
If I execute the syncCommands method, could it freeze the server if it is done when shutting down?
what does it do
Where is that method even from?
I'm executing it via Reflections from the CraftServer class.
I'm using it to register my commands to tab completion.
(Which are registered dynamically)
Problem is that I want to clean up when my plugin is disabled, but sometimes the plugin disables because of a server shutdown
(Sometimes my plugin freezes the server when shutting down)
isnt that basically the same thing?
It should be, but I wasn't able to freeze the server with a reload or by disabling it, yet.
Only happens on shutdown
public CompletableFuture<Void> transferBalance(UUID from, UUID to, double amount) {
CompletableFuture<Void> future = new CompletableFuture<>();
playerRegistry.getOrLoadPlayer(from).thenAccept(cosmicFrom -> {
playerRegistry.getOrLoadPlayer(to).thenAccept(cosmicTo -> {
transferBalance(cosmicFrom, cosmicTo, amount);
});
});
return future;
}
``` Can I make both futures complete at once and then execute the code? right now when the first future is completed, the second one starts completing
do some log messages...
different topic, can i send particles to players async?
Yeah, should do that...
How do I get the vault colored prefix, because it is just "&4Owner Wihy" and I want it to be "(red)Owner Wihy"
String prefix = chat.getPlayerPrefix(player);
Sure. You can compose futures.
public CompletableFuture<Void> transfer(UUID from, UUID to, double amount) {
CompletableFuture<CosmicPlayer> fromStage = getPlayer(from);
CompletableFuture<CosmicPlayer> toStage = getPlayer(to);
return fromStage.thenAcceptBoth(toStage, (fromPlayer, toPlayer) -> transfer(fromPlayer, toPlayer, amount));
}
private void transfer(CosmicPlayer from, CosmicPlayer to, double amount) {
// transfer
}
private CompletableFuture<CosmicPlayer> getPlayer(UUID key) {
// fetch player
}
If it has an '&' color encoding then you could just call ChatColor.translateAlternateColorCodes()
so this will only run when both futures are completed won't it
kk thanks a lot
Can somebody help me
You can also have something returned. This is then a combination of those two futures to another future of a different type like a result
public CompletableFuture<TransactionResult> transfer(UUID from, UUID to, double amount) {
CompletableFuture<CosmicPlayer> fromStage = getPlayer(from);
CompletableFuture<CosmicPlayer> toStage = getPlayer(to);
return fromStage.thenCombine(toStage, (fromPlayer, toPlayer) -> transfer(fromPlayer, toPlayer, amount));
}
private TransactionResult transfer(CosmicPlayer from, CosmicPlayer to, double amount) {
// transfer
}
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Ah this one
was finna ask :p
thanks
I have to send an image but I can't send it here, can I send it to you privately?
link
Verify your spigot acc or upload it somewhere like imgur
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "wooo", someExecutor)
im an idiot who doesnt look at the messages above

so i can also do stuff like
public CompletableFuture<Boolean> has(UUID uuid, double amount) {
return playerRegistry.getOrLoadPlayer(uuid).thenApply(cosmicPlayer -> has(cosmicPlayer, amount));
}
primitive generics when :(
java 186
Cool
because it appears in the tab, my name should not be how do I solve it I also see other users
Show some code. How do you assemble your tablist? Do you use any apis?
uUse a plugin called tab
Did you read the name of this channel?
I didn't realize where I can get help with that?
Write the developer or #help-server
CraftServer
how u got 6 gb of errors?
¯_(ツ)_/¯
Wtf
I'm using JDA and it's printing the bot logs into console:
[17:36:23 INFO]: [net.dv8tion.jda.api.JDA] Login Successful!
[17:36:24 INFO]: [net.dv8tion.jda.internal.requests.WebSocketClient] Connected to WebSocket
[17:36:24 INFO]: [net.dv8tion.jda.api.JDA] Finished Loading!
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[17:36:24 WARN]: Nag author(s): '[PulseBeat02, itxfrosty]' of 'DeluxeMediaPlugin' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: Defaulting to no-operation (NOP) logger implementation
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Is there anyway to avoid this?
JDA seems to Sysout since no log4j configuration was specified
I know there's a way but I forget what it is
Wait no
It was a long time ago and it was jnativehook not jda
it seems that logback is the only way
i was adding my own handler to the logger
and the logger is just Logger.getLogger("my bot")
love digging thro my old code ;D
how to use Hex Colors?
1.18.1
This is my current code but it just returns the Hex Code
private static final Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
public static String getColor(String msg){
if(Bukkit.getVersion().contains("1.16")){
Matcher match = pattern.matcher(msg);
while(match.find()){
String color = msg.substring(match.start(),match.end());
msg = msg.replace(color, ChatColor.of(color) + "");
match = pattern.matcher(msg);
}
}
return ChatColor.translateAlternateColorCodes('&',msg);
}
Think u need chatcolr char before every char of the hex code
oh nooo
I could be wrong
Not sure
Mfnalex has something in his utils
U can check his github
thx
Why would that work?
https://www.spigotmc.org/threads/hex-color-code-translate.449748/
This works perfectly for HEX Colors
Use the last message
You didn't set it
Hey, anyone knows a way to display something on top of th head of a player BUT to only certain player.
Exemple :
player1 has written smth above their head
player2 sees it
player 3 doesnt
Share code
Ohh
Nvm
Ur using armorstands i assume?
quick question, how would you detect a player death that isnt a player? to detect player to player death im using
p instanceof Player && killer instanceof Player
but how would i do if the killer is not player? (this is just simple java i dont know i think lol)
i am not doing anything i am asking how to do it cuz honnestly i have no idea
So
you need to send packet to that player
whom you would like to display nametag
are you talking about nametags?
create an armor stand that will follow a player, and only show it to certain players
@mortal hare yeah that should work
lemme test
that's not easy, but I have something like this created but that is old and broken
it requires more than that since you need to handle all the cases
e.g moving to dimension
not spigot, but would this work?
Can i get the Name from the Dropped Item in the players language?
Hm why won't armorstands work
I dont think he's talking abt a prefix
armor stands and packets to hide it from certain players would be best solution
any clues why it adds 001 ?
int newLvl = (getRenownLevel(p))+1;
setRenownLevel(p,newLvl);
LvlAnnouncer.announceRenown(p,newLvl);
public static void announceRenown(Player p, int lvlTo){
p.sendTitle(ColorUtils.hex(Colors.RENOWN_UP.toString())+"Renown Level Up!",ColorUtils.hex(Colors.GOLD_COLOR.toString())+"You are now Renown Level " + lvlTo + "!");
}
+1
oh
it adding to a text
so ok i figured out a few things about earlier but i=now i m stuck : how can i make an armor stand invisible to certain players
(or the oposite)
like only show it to some players
its a int
so im just adding 1 to the int
Hi i have a question, how i can call the method PaginatedMenu#getPage(index) ? Knowing that im tracking players as Map<UUID, InventoryMenu>. Where InventoryMenu is the super class of PaginatedMenu.
Atm i have this method: InventoryMenu getMenu(UUID uuid);
And method getPage(index) is not in the super class
Can i get the LocalizedName with BlockDropItemEvent from the dropped ingot?
Sry don't wanted to ping
Only way is by using packets
bump lol
Spigot has hideEntity api now iirc
cant u use player.hideEntity?
deprecated iirc
Yeah but it maybe does the same packet trickery internally
I would be really thankfull if someone help
imma try to use packets
Which json library is this?
And you probably don't have to reupdate it on world change
Draft api might still work
any tutorials on how to do it? cuz i have no idea how
ProtocolLib. There might be some tutorials for this
json simple
7 smile won't player.hideEntity work?
com.googlecode
U can also use gson
"It should be PaginatedMenu extends InventoryMenu, not PaginatedMenu implements Menu" Do you remember you told me that? But now im stucked trying to call methods from the class that extends InventoryMenu
wait but to use PacketPlayOutEntityDestroy what do i need to implement?
?protocol
?jd-s
Let me check
Why won't player.hideEntity work?
Its deprecated
And?
You should not use depreated things
If someone use depretaed thing in most cases will not get help
It's draft api. You can give it a try
so to use PacketPlayOutEntityDestroy and CraftPlayer for instance what do i need to import?
Well you can't run a method from another class without casting no
Alternatively, you can make the singlepaged one always return the single page no matter the int requested
@sterile token i implemented ProtocolLib but still can't use PacketPlayOutEntityDestroy
nvm sorry
Maybe you find what you are looking
Oh sorry
so wait let me read it
And see if find what you need
So you need to give all privileges to root user right?
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password';
Allright
Let me stil lcheck
Link if you want to read https://www.yawintutor.com/access-denied-for-user-root-localhost/
level 4000 would be 3999 in code since its shifted by 1
Could you fix it?
will decimal values this small cause issues
if (isPlayerNearby) {
superiorHorse.comfortabilityStat().add(0.000000833333);
} else {
superiorHorse.comfortabilityStat().add(-0.000000138888889);
}
?tryandsee
bruh
yeah what more i can said
im saying like will it cause incomprehendable issues in the future
just test it
in the long run
yo ik that this is not related to spigot api really but i can't find the problem seriously so i've decided to ask here.
Im having problem with SQLite/MySQL commands which throws a SQLException
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "574144a0")
public static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS players (uuid CHAR(36) PRIMARY KEY,balance DOUBLE, deaths INT, kills INT, class STRING)";
public static String FIND = "SELECT EXISTS(SELECT * FROM players WHERE uuid =uid)";
public static String INSERT_INTO = "INSERT OR IGNORE INTO players(uuid,balance,deaths,kills,class) VALUES(?,?,?,?,?)";
public static String UPDATE = "UPDATE players SET balance =?,deaths =?,kills =?,class =? WHERE uuid =?";
this is all of my commands and it throws the error on finding a data...
any idea what should i do?
the code that throws me the error:
public DwarvRes getResultOf(UUID uuid) {
Statement statement = null;
String FIND_TABLE = "SELECT EXISTS(SELECT * FROM players WHERE uuid ="+uuid+")";
ResultSet res = null;
try {
statement = connection.createStatement();
assert statement != null;
res = statement.executeQuery(FIND_TABLE);
} catch (SQLException e) {
e.printStackTrace();
}
return new DwarvRes(res);
}
That why i prefer mongo
Its pretty much simply
And you dont get ilnesses caused of mysql shit commands
Hmn sintaxis is wrong
And that is why I do not use any database engines at all
You dont do: "SELECT EXISTS(SELECT * FROM players WHERE uuid ="+uuid+")"
You should use:
"SELECT * FROM players WHRE uuid="+uuid+""
Also is not okay using the uuid="+uuid+""
Its recommend to use:
PreparedStatement statement = new PreparedStatement("SELECT * FROM players WHERE uuid=?");
statement.setString(0, uuid);
If im not wrong
This is why I use nothing but raw server memory
Sometimes when I'm feeling bold, I just don't care about saving any data at all. Players can just re-apply their settings every time they log in or switch servers 
alr letme try these
btw i found that select exists prevents from sqlexception
That's pretty risky, memory could get its bits flipped by cosmic rays
Better to pause all server activity to prompt the player for their choice anytime a choice needs to be made
+1
Maybe "new PreparedStatement" is wrong, just search on google how to use prepared statement
Althought mongo has shits too
He get annoyed when im telling him to add a codec for Location, because the class doesnt have native types (String, int, double, boolean) instead the class have Boolean, Integer
Haha
Database in general are a problem
If you're wanting to create a PreparedStatement, use Connection#prepareStatement()
they are not a problem, just another thing to learn
that thing i couldnt remember if was "new PreparedStatement" or how you tell him
It had happen 1y since las time i touched Mysql
Any recommendations for building a menu api?
Im using custom resource pack which replaces some unicode characters for textures
And yet here I am wondering how to change the fonts programatically
aka can I have multiple .json files, multiple textures binded on same Unicode?
How would you do it, to being able to create normal menus and paginated menus?
i have a really simple math problem but its not really working in game-
this will run every tick right
new BukkitRunnable() {
@Override
public void run() {
for (SuperiorHorse horse : superiorHorses) {
ComfortabilityStat.tick(horse);
}
}
}.runTaskTimer(SuperiorSteed.getInstance(), 1, 1);
BukkitRunnable 😒
Oh please use ?di its not recommend to use singleton
Here
i was told to use this a long time ago lmao
im still getting that stupid error
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "97a2")
the only thing that ik from this error is that "97a2" is a part of my UUID
?status
whats wrong with it
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Oh not its active
i know what dependency injection is-
So why you dont use it?
what does that have to do with a bukkit runnable
Not bukkit runnable, use DI for java in general
Bukkit.getScheduler().runTaskTimer(plugin, () -> superiorHorses.forEach(ComfortabilityStat::tick), 1, 1);```
:)
i do..
but that doesnt have anything to do with the bukkit runnable stuff lmao
I know but we are giving advices
where in my code does it show that im not using dependency injection
ty 🙏
Redempt could know that im still ith the manu fact
oh fixed with a prepared statement nvm
What does this even mean
anyways
this runs every tick right
Yes
i'm trying to add 0.01 to the "comfortability" stat to the horse every minute if the player is standing next to it
Asking if you remember that 2 weeks ago you help me with my menu api, and im couldnt end it yet
That's not a good way to do it then
so I simply add .01 / 60 / 20 every tick
Loop over players, get nearby horses, and add the stat
it also needs to decrease
Rather than looping over every horse and checking for nearby players
if a player is not next to it
Oh
In that case you should store timestamps so you can calculate the stat on demand
the thing is that theres a ton of factors that is constantly altering the stat
it'll be a pain to set up timestamps like that
Tick is fine then I guess
Set the task timer to run every 20 * 60 ticks
Leave it as 20 * 60, not 1200
It's more explicit about intent
theres other things that needs to be done to the horse every tick tho
Ok then schedule another task for that
like every tick theres 5 functions that needs to be run on the horse every tick
thanks a lot btw.
that error was busying my mind for some days. and I had no idea why that's happening
Then schedule a task for those
Though 6 tasks wouldn't make much of a difference
Your welcome my dear if have more issues with Mysql just ask it here and ping me
Slightly more memory usage and slightly more overhead
anyways this isn't even adding 0.01 every minute somehow lmao
whatever ill create a new task for every 60 seconds
Could be floating point errors
doubles have 16 decimals places tho
the result is less than 16 digits
i guess floating point errors could still do something
Aren't your horses custom?
Override the tick method and make sure you call the super method then do ur custom stuff that ubwanna run each tick
Actually it depends
On what ur doing each tick
yeah but i also wanna minimize nms
What u wanna do each tick?
also i have a structured setup
many many things
I have a class called SuperiorHorse, which acts as a wrapper for both the bukkit entity and the nms entity
so I sometimes need to loop over the wrappers
its a whole bunch of stat updating and player interactions and stuff like that
Hey, so all I wanna do is when a command is run, flip a boolean.
public static boolean ctfstartBool;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
ctfstartBool = !ctfstartBool;
if (ctfstartBool = true) {
sender.sendMessage("CTFSTART = TRUE");
}
if (ctfstartBool = false) {
sender.sendMessage("CTFSTART = FALSE");
}
return true;
}
}```
The command works, but all it will give me is true, no matter how many times I run it. Obviously, i did something wrong lol. Any idea what?
the command works, but it just gives true no matter what
== to compare bool. you are setting it in your if check
Better to use java if (ctfstartBool) { sender.sendMessage("CTFSTART = TRUE"); } else { sender.sendMessage("CTFSTART = FALSE"); }
Hey
does anyone know how to place two portal blocks
with no frame next to eachother
How to set Inventory Title to BaseComponent?
pseudocode
1: get 2 locations where you want those portal to be
2: get Block from those locations
3: setType to portal
done that, portals seem to place 1 block apart
Adventure API (included in Paper) or NMS
not looking forward for using any API
soo should I get NMS version of the inventory and set the name to BaseComponent ?
Same with entities?
Location loc2 = new Location(Bukkit.getWorld("world"), 55, 68, 284);
loc1.getBlock().setType(Material.PORTAL);
loc2.getBlock().setType(Material.PORTAL);```
Yes
it works for other blocks
but not for portal
So what's this then?
when I use this code
they place 1 block apart
loc.add(0, 2, 0).getBlock().setType(Material.PORTAL);```
yes I know that
Then add 1 in the second line
If the y is 0 initially, you add 1 and set the block at y=1 to portal and then add 2 so y is now 3 and sets to portal
fucking hell my message keeps sending before i finish it
How to get NMS Entity from CraftEntity?
Check this
getHandle
Cqncel the blockphysics event that tries to break ur portal
How to convert BaseComponent into Component?
canncelled it
not working still
now only one block gets placed