#help-development
1 messages · Page 2069 of 1
i've googled everywhere i cant find it
mainly because its different between versions
i need to know for 1.18.1
?jd-s
don't use google. Use the docs
i've checked the docs too
declaration: package: org.bukkit.scoreboard, interface: Objective
nothing about a character limit
Then just try it and see
that'll take forever tho lol
nevermind i just use the /scoreboard command
forgot that was a thing
theres no character limit to the point where it can take up the whole screen
Then there is no feasible character limit. Problem solved
iirc 32 for older versions, unlimited or 64 for newer versions
Can someone tell me pls what is the difference between fileconfiguration and file
yes, on enable just load them
Hey this may be a dumb question, but how come I cant access the data in a hashmap from another class? I want to get some data from a PlayerInteractEntityEvent to a InventoryClickEvent
The best way I thought to do this was by setting up a hash map in the PlayerInteractEntityEvent however when I try to access the hashmap from the InventoryClickEvent it doesn't show me any data
Anyone have an idea why
you should use a service or so called manager class to do so
you just then create a Singelton instance in your main and access the instance with you main plugin
Something like XYPlugin.getPlugin(XYPlugin.class).getPlayerManager().getGreatHashmap()
alright let me try something liek that
sick it worked, is there any particular reason why it didnt work in the event class?
okay yeah that makes sense now, I feel stupid lmao...
Someone tell me the difference between file and fileconfuguration
im trying to make a plugin that gives each player a ArrayList<Coordinate> where Coordinate is a class that has Location, and name of the location as a string
but i cant figure out how to save the data and retrieve the data everytime the server opens and closes
I basically used a Hashmap of arraylist<Coordinate>
use a database or files to save your data
Fileconfiguration and files
Make methods 'save , load' and call it from main
idk if i'm right but i think that a file its just a normal file, a file configuration it's a yaml thingy that you load in a file
a File is a Java object representation of a file on your storage device, a FileConfiguration is a Java object representation of a configuration based on the contents of a file, typically YAML in the context of spigot/bukkit
Mye it’s pretty much just file location vs file content
Cant we use same methods on this two?
Okay im having a very odd bug here, i am using Inventory#addItem(ItemStack) to add a item to a players inventory
Ive used isEmpty() on that hashmap returned from the method, its empty so its 100% added to the players inventory (I have a handler if the list is not empty the item im trying to add to a player's inventory, and each and every time my debug log is not fired and that method isnt called so i know 100% its being added somewhere)
My issue here, is the item simply is not being added to the players inventory (Ive tried calling p.updateInventory(), not difference here the item is not added)
Now: The item being added is a Main hand item, there is a system where
if player gets hit -> get the ItemStack in the items hand, and store it using a clone() method -> set main hand to AIR -> give player cloned ItemStack
The behavior here is the item is simply just banished to the shadow realm, never to be seen again
I can but give me a few as i need to change a few things from it
Hello guys,
The render method of a Renderer class gets called like every quarter second, right? How would I manually call and update a map instantly rather than wait for the next "bus" to pick my renderer changes up?
Call the render method yourself?
I try, but the method requires a MapCanvas parameter and idk where to get it
Cast if you can
Cast from what?
There's the map itemstack itself, mapmeta, and mapview. I dunno where to get canvas from
Got it, basically saved the canvas to a field var after the first render call, now I can use that whenever I want to call it myself. Kinda hacky lol
If any of you got a better solution, please share ! 😄
hm doesn't sound optimal but I'm not aware of another way
Maybe take a look at some other map plugins and see how they work
True, plus I still don't know what the drawbacks of doing this method is. I'll just use this until I find a better way
Make sure to store a weak reference so you don't start wasting memory
Okay i actually managed to figure out what was wrong, my bad i had my main hand set as the first slot like so, and when it did the steps i did above it was just re-adding it into that one singular slot with another method i try
I ended up adding a method that gets a empty AIR slot and it will instead add it to that specific slot, and makes sure that slot isnt the held item slot
i guess i just dont understand its implementation correctly but if i access the primary command map using this method
try
{
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
bukkitCmds = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
}
catch(Exception e)
{
e.printStackTrace();
}
i get a list of all commands
but can only unregister plugin added commands?
Elaborate
For example, I want to create a custom config file. Should I define it as File or File configuration?
Hello,
I am trying to run a function from another plugins main class that returns its instance but it keeps returning null.
public static JustAnimations INSTANCE;
private final Map<String, BlockAnimation> animations = new HashMap<>();
public JustAnimations() {
INSTANCE = this;
}```
^^^ the plugin main class
when i run `JustAnimations.INSTANCE` from my other plugin (the animation plugin is a dependency) it returns null
That means your other plugin is ran before JustAnimations
w o w n o w a y , h o w c o u l d t h a t b e ?
but my plugin has justanimations set as a dependency & starts after it in console?
how can i unregister vanilla commands? apparently the knownCommands field has been renamed and reflection is anoying to reverse engineer
so i hoped someone already knows what the field is named now
[10:59:22] [Server thread/WARN]: java.lang.NoSuchFieldException: knownCommands
``` using this ```java
try
{
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("knownCommands");
}
catch (NoSuchFieldException | SecurityException e)
{
e.printStackTrace();
}
so hows the field named now? i need it
oh
commandmap isnt nms
if u have the commandmap as a class just ctrl click it
like if u write CommandMap and import it
hello, how can i get the color of a terracotta block? I need a String variable with the color prefix
i dont really understand
i want to remove vanilla commands, so that they're unaccessable
and for that i need the knownCommands field
thing is that its name is deprecated as it seems to have been changed
you can listen for a playerchatasyncevent, check if a player runs a command and then cancel it
i need to get a prefix from the material, not to get the material from a string
but how can i just get the "RED_" prefix?
i already do that
and what's the problem?
the problem is
that i want to override the /op command
with my own logic
so i want to unregister the vanilla command
and register my custom one
nvm, i got it
yeah you can do an if statement
if it's a vanilla command you cancel it, otherwise you just return
i dont want to cancel it
those are redundant tasks which will eat away processing power which i already need for really resource intensive tasks
uh
just replace the "terracota"
part
oh u alr got t
what
sir machines are way faster than what you think
cancelling an event which occurs not that often
will not take any resources for the most part
a few nanoseconds wont matter
Premature optimization bad
mhm
fine ill reverse it myself
okay then how exactly do i override the /op command and replace it
using the PlayerCommandPreprocessEvent
and then execute it from the console?
or this
is there a better way to turn a byte[] into a String than using new String(char[]) ?
it is depended in plugin.yml & same issue when shaded
new String(bytes, StandardCharsets.UTF_8);
i think
that only works for bytes though? I have chars and not bytes
show your plugin.yml pls
ah
version: '${project.version}'
main: me.cyric.animationextras.Main
api-version: 1.18
depend:
- JustAnimations```
plugin.yml
why not use new String(chars) though
does the other plugin have any depends?
I thought maybe there's something else lol
isnt there a loadafter tag
it soft depends world edit?
no, that's what depend does
there's loadbefore
oh
yes
open your .jar with winrar or whatever and check if the included plugin.yml really contains the depend section
I know
but sometimes when you forget mvn clean I've had weird results of some changes not being added to the .jar
so can't hurt to check it
it is
like locally on my pc?
then all I can think of is one thing:
one of your plugins has cyclic dependencies. this causes the server to load all plugins in an arbitrary order
e.g. two plugins softdepend on each other
try with only your plugin and your dependency and no other plugins
same thing
it is
?paste your latest.log pls
^
<groupId>com.github.JustDoom</groupId>
<artifactId>JustAnimations</artifactId>
<version>d6e3227a0c</version>
</dependency>```
like this?
huh
what are you talking
wait
I mean
the loading order is correct
- JustAnimations gets loaded
- your plugin gets loaded
- JustAnimations gets enabled
- your plugin gets enabled
everything's fine
if he has the shade-plugin enabled, then yes
i dont think im shading it?
but they were talking about wrong loading order, which isn't true
do you have maven shade plugin in your <build><plugins>?
it makes 2 versions one normal one with -shaded at the end (i've been using the one without -shaded)
so you are shading it
add <scope>provided</scope> to the JustANimations dependency
also I am confused why you kept saying that your plugin gets enabled BEFORE JustAnimations, the log cleary shows that's not the case 😛
you are accessing the JustAnimations.INSTANCE of the version you have shaded into your plugin, obviously that never created any instance
so yeah just do this and it'll work ^
btw am I the only one who always keeps accidently typing into their IDE instead of discord lol
F
so it softdepends
why light theme
i type in discord instead of my ide :/
it's brighter
no way guys
lol okay that never happened to me
same
no
happens to me
always
you're never calling timer()
print al
well, this
rather than printing "b"
print al
it should display like
[something, something, something]
to see if there is data in it
if there is no data it will display as []
hm
try using a list
an array list
i wanna see if it works then
Also why are you doing this?
ohk
eeeeeeeeeh
can I somehow force YamlConfiguration to use quotes for strings?
right now it saves it without quotes unless absolutely needed
that'd confuse admins as they'll think they can just insert color codes and it'll work
I gave up when I tried with my translib and couldn't make it work. It only seems to do it when necessary
hm I see one dirty possible workaround
insert a weird string into every line before saving, after that remove it manually again lol
that'd at least work
like inserting &x_dirty_hack_&x in every line
Idk. Maybe it's time to open a PR lol
yeah that would be nice
I'll use my dirty hack
I'll prepend &x___&x to every string, then remove it during saving the file

free pr
my hack is so awesome
totally readable
very good for admins
it happens when you add some utf8 symbols e.g. the bell \u0007
does anyone know what characters are needed to make YamlConfiguration use double quotes?
I can only force it to use single quotes
is there an event for "player took damage"? i can't really find anything applicable for that
EntityDamageEvent
I don't see a way to get the player from that
@vocal cloud
I found out how to do it
private static void hackDumperOptions(YamlConfiguration savedFile) {
try {
Field field = YamlConfiguration.class.getDeclaredField("yamlDumperOptions");
field.setAccessible(true);
DumperOptions options = (DumperOptions) field.get(savedFile);
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
} catch (Exception e) {
e.printStackTrace();
}
}
where's the problem?
I think you must add the kotlin-gradle-plugin to your buildscript {}
but not sure
what does it mean [plugin name] attempted to register an invalid EventHandler method signature?
here is my code:
@EventHandler
public void onEntityDamage(Entity entity, EntityDamageEvent.DamageCause cause, double damage) {
if (entity instanceof Player p) {
System.out.println(String.format("%s took damage", p.getName()));
}
}
i just copy-pasted the signature from javadoc
double damage
@EventHandler methods take exactly one argument, which is an event
oh
you can't just randomly add new parameters and expect the event handler to know what to pass there
get the entity and damage and cause from the event param
lol i tried using the event constructor signature as the event handler signature. im dumb
it's just onWhatEver(Event event)
yea lol
nvm this only works on scalars, I am stupid
that would work ^
well partially
the problem is that the Yaml class internally copies that on constructor call
e.g. you are too late
another issue is the fact that the keys would be affected by this too
it'll only work for scalars
I need it to work for regular strings
I have now decided to use my dirty hack that just adds something like {{&x__&x}} to the beginning of every string, then remove it again when saving it
although that way I only get single quotes
but I guess that's fine
it's extremely dirty but I haven't found any better way
https://github.com/JEFF-Media-GbR/MessageAPI/blob/614f6436c625569c55567c920b8185d78043ce5d/src/main/java/com/jeff_media/messageapi/utils/LanguageFileUtils.java#L63
https://github.com/JEFF-Media-GbR/MessageAPI/blob/614f6436c625569c55567c920b8185d78043ce5d/src/main/java/com/jeff_media/messageapi/utils/LanguageFileUtils.java#L113
at least it works lol
what are you trying to do
force a yaml file to quote all strings
it's for translations and messages
so admins would break the config all the time by adding color codes at the beginning if it wouldn't be quoted in the default config
final var yamlConfiguration = new YamlConfiguration();
try {
final Field yamlField = YamlConfiguration.class.getDeclaredField("yaml");
yamlField.setAccessible(true);
final Yaml innerYaml = (Yaml) yamlField.get(yamlConfiguration);
final Field representerField = Yaml.class.getDeclaredField("representer");
representerField.setAccessible(true);
final Representer representer = (Representer) representerField.get(innerYaml);
representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
} catch (final ReflectiveOperationException exception) {
throw new RuntimeException("Something bad happened", exception);
}
this works
however that enforces quotes on keys as well
really? thanks, I'll try
hmm on keys too
well I could manually remove them again 😄 as long as it'd allow me to use double quotes
Yea you could just switch to double quoted
I can be 100% sure that all my saved files will always either be in the format
"key": "string"
or
- "string"
so I could just manually remove the quotes from keys
yea you should be able to just match ".*":
Can i open the player's crafting inventory with armor, shield and 4(5) slots for craft?
that'd also match something like this though:
- "my text: whatever"
I think this should do
^\s*"(.+?)":
oh ye
line = line.replaceFirst("^\\s*\"(.+?)\":","$1");
jesus wish me luck
yaaay it works, I only forgot the colon 🙂
Thanks @eternal night !
nice 🙏
@vocal cloud The solution is to combine this with some regex during saving the file
yes, but I'm not sure if that requires reflection right now
im already working with reflection
that aint no problem
i just need to know the field names
lol
it's just to test my message library 😄
and thank got I used the "ß"
it still has troubles with UTF8
otherwise I wouldn't have noticed
WHATß
any ideas ?
try
{
final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
CommandMap bukkitCmds = (CommandMap) f.get(Bukkit.getServer());
Command cmd = bukkitCmds.getCommand("op");
if (cmd != null)
{
Bukkit.getServer().getPlayer("TheTimeee").sendMessage("Command found");
cmd.unregister(bukkitCmds);
f.set(org.bukkit.craftbukkit.v1_18_R1.command.VanillaCommandWrapper, cmd);
}
else
{
Bukkit.getServer().getPlayer("TheTimeee").sendMessage("Command not found");
}
}
catch(Exception e)
{
e.printStackTrace();
}
``` kinda here but that obv doesnt apply the change
that's the error
basically I'm creating an item with a custom craft and it's giving me the error and idk what's wrong
public class ItemManager {
public static ItemStack heart;
public static void init(){
createHeart();
}
public static void createHeart(){
// Heart Iem
ItemStack heartItem = new ItemStack(Material.RED_DYE);
ItemMeta heartItemMeta = heartItem.getItemMeta();
heartItemMeta.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Heart");
ArrayList<String> heartItemLore = new ArrayList<>();
heartItemMeta.addEnchant(Enchantment.DURABILITY, 255, true);
heartItemLore.add("+1 Heart");
heartItemLore.add(ChatColor.GREEN + "Right click to redeem heart!");
heartItemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
heartItemMeta.setLore(heartItemLore);
heartItem.setItemMeta(heartItemMeta);
heart = heartItem;
// Recipe
ShapedRecipe shapedRecipe = new ShapedRecipe(NamespacedKey.minecraft("heartitem"), heartItem);
shapedRecipe.shape("ABA",
"BCB",
"ABA");
shapedRecipe.setIngredient('A', Material.IRON_BLOCK);
shapedRecipe.setIngredient('B', Material.DIAMOND);
shapedRecipe.setIngredient('C', Material.REDSTONE_BLOCK);
Bukkit.getServer().addRecipe(shapedRecipe);
}
}```
you can't register two recipes using the same namespacedkey
wdym
I don't register two
will calling createHeart() create a different one?
oh yeah
everytime I call that it will create a new shape recipe
well I thought I have to create it every time the plugin starts
But your using the same namespaced key
yeah
The NamespacedKey is a Unique identifier
I fixed my UTF8 issue
fucking FileWriter doesnt take a Charset in java 8
so I replaced FileWriter with OutputStreamWriter(FileOutputStream)
Yes you create it every time your plugin starts
why are you using the minecraft namespace?
Someone correct me if wrong, but I though that you needed to register your recipes on enable every time because custom recipes were cleared from the recipe map on shutdown?
well what else do I use to create a recipe
your plugin new NamespacedKey(plugin, "heartitem")
Your own plugin.
ohh
but I need the result to be the item
do u want me to show u the parameters
oh wait
nvm
i'm doing it wrong lmfao
so something like this right?
new ShapedRecipe(new NamespacedKey(CreeperLS.getInstance(), "heartitem"), heartItem);
yes
I see, thanks
so any help on how to override vanilla command executors?
why do you actually want to do that?
the proper solution would be to simply not give permission to the vanilla commands
i want to modify the way the op command works
and deop
and i want the console to also be able
to use the modified version
so i want to redirect the execution onto my plugins method
oh okay. easiest solution is to use the PlayerCommandPreprocessEvent
simply get the first word, and if it contains a :, split it by the : and get the right part of it
if it's op or deop, replace it with your command
that's definitely the easiest way and doesn't require any NMS
thats what ive done
and where's the problem?
but that doesnt override vanilla behavior for console executed commands
that is true, but how is that a problem?
Is there a way to make Player#spigot()#respawn() not force open the pause menu, or is this just a bug on my end on my client?
someone with access to the console can basically do anything they like anyway
it shouldn't open that
I have my secondary client open on my pause menu, and it doesnt open until that method is called hmm
if theres a better
this is the answer ive found on google a thousand times
and it didnt satisfy
thats why i ask here
do it in a task
I indeed am
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Bukkit.getScheduler().runTask(this, () -> event.getEntity().spigot().respawn());
}
1 tick after the player is considered dead
this works for me without any escape menu
the first video is the one with runTask
the second video is calling it immediately
sec ill show my video
Sorry for background music lmfa and the lag on second client
yes but cache the key instead of creating it everytime
aah
that's because you don't have the window in focus
it's because your chat closes
when you die
Okay so with 2 actual players, i shouldnt need to worry about this?
nope
Thanks!
i run it in a BukkitRunnable
haven't tried that but should be the same
Yeah more or less basically same thing
ah good point ty
at least that worked for me 🙂
Yeah should basically be the same way, weird how bukkit has so many ways to handle runnables lmao, thanks for the help alex
@tender shard so u dunno?
as said, I think it's totally unneccessary
people with access to console can do anything anyway
they could also just edit ops.json
if they want to use minecraft:op, so be it
imho you shouldn't mess with that command at all
I understand it for other commands but not for op
hey, Player#setAllowFlight doesn't seem to be doing anything, I just have a join event that calls p.getPlayer().setAllowFlight(true);
is there something I'm missing?
throw new IllegalStateException("Could neither load the given language file, nor the saved default language file, nor the included default language file!");
is this more an illegalstate or an illegalargument exception?
since it always falls back to the included default file, I guess it's more an illegal state than an illegal argument right?
uhh, when an item is stacked the server thinks they're 2 different items cuz they're 2 different item stacks, how can I make it do the same thing even if it's stacked
You could try to execute it a tick later.
ItemStack#isSimilar will still return true if only the amount changed
isSimilar is basically equals() while ignoring the amount
i'm new to plugin dev, is there a builtin function for execute something on next tick?
hmm okay
yes
?scheduling
^, runTask will run 1 tick later
basically this:
Bukkit.getScheduler().runTask(myPlugin, () -> {
// your code
});
however it should work fine without delaying it
are you sure your event handler is even called?
yes, other stuff before the setAllowFlight works correctly
i'm going to try to move the setAllowFlight before the other stuff and see if it still gets called
@quaint mantle
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().setAllowFlight(true);
}
this works 100%
you're doing sth wrong
i just tried it
🤔
that should work absolutely fine
here is my code
@EventHandler
fun onJoin(p: PlayerJoinEvent) {
p.getPlayer().setAllowFlight(true);
var addr = p.getPlayer().getAddress().toString().substring(1).split(":")[0];
p.setJoinMessage(String.format("%s%s has joined, welcome!", ChatColor.ITALIC, addr));
p.getPlayer().setInvulnerable(true);
}
ignore the uh
but the chat message gets sent correctly
you're looking at the wrong line
i set as invulnerable at the beginning of the function
you call your event "p"?
uh i just copy pasted some example code
ouch
that's a funny name for an event
yeah setALlowFLight still requires them to double-tap space
then you have other pugins that disallow flying on join
^^
neuron activation happened
what is PlayerCommandPreprocessEvent used for?
is there also a command suggestion event and/or command execution event
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
there's a tab complete event, yes
ah
is there a way to set the caption above the text box
like what brigadier does
in an event like that
(tab complete)
when you hate code inspection
how can i create a craftbukkit shaded jar?
why do you need one
to access vanilla methods to write to the field
why don't you just use spigot instead of craftbukkit?
but to get craftbukkit:
java17 -jar BuildTools.jar --rev 1.18.2 --compile craftbukkit
then you're using the wrong one
yea i did that
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
the mentioned shaded .jar only has the API, you should take the one from the spigot folder use maven instead
just use maven and everything will magically work
"vanilla" methods would be NMS
yes, they are all included in the spigot artifact from the local maven repo
yes you can
of course you can
maven plugin is included in Eclipse
just start a Maven project or convert to Maven
it's just a pain in the ass to get it working when you already have a non-maven project in eclipse
eclipse always starts breaking when it founds both, eclipse files and a pom.xml
so be sure to delete your eclipse project files when you convert to maven
eclipse sucks anyway
Could not load spigot.yml, please correct your syntax errors
org.bukkit.configuration.InvalidConfigurationException: unacceptable code point ' ' (0x0) special characters are not allowed
in "'string'", position 0
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:59) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:128) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.spigotmc.SpigotConfig.init(SpigotConfig.java:59) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:187) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
Caused by: org.yaml.snakeyaml.reader.ReaderException: special characters are not allowed
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:211) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
im so stuck with this error and i dont know what it its?
you messed up your spigot.yml. #help-server
because you try to use the bootstrapped .jar
instead of the one in your local maven repo
which is wrong
the proper .jar is at C:\Users\mfnal\.m2\repository\org\spigotmc\spigot\1.18.2-R0.1-SNAPSHOT
and you should also use the remapped-mojang jar fie
omg intellij shut up
how is that a problem
Hey folks, I'm in the land of JNI again, but running into this: Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/bouncycastle/crypto/AsymmetricCipherKeyPair (wrong name: META-INF/versions/9/org/bouncycastle/crypto/AsymmetricCipherKeyPair), when loading a class, what does this mean? besides that the class couldnt be found, obviously
specificially the second part
@tender shard whats the best maven template to use if i want as little other dependencies as possible?
start from scratch
you don't need any templates
Solution is surprisingly simple: Just ignore it 😂 :
if class_name.ends_with("module-info") || class_name.starts_with("META-INF") {
return Ok(None)
}
Since you also use NMS, check this after that too:
https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/
@granite owl
ugh
what is that, PHP?
Rust 😄
I wouldn't touch imperial units with a 3.33m pole 😛
:true:
you mean... !Boolean.FALSE
I'll take a JValue::Bool(0) today :"D
!Boolean.FALSE.equals(Boolean.FALSE)
YamlConfiguration yaml = new YamlConfiguration().load("{}");
boolean bool = !yaml.getBoolean("asd");
well that would be false
corrected
function count(tbl, v)
table.sort(tbl)
local count = 0
for i = 1, table.getn(tbl) do
if tbl[i] == v then
count = count+1
elseif tbl[i] > v then
break
end
end
return count
end
lua is way cooler
Kappa
Wait, does that return a Boolean or boolean?
boolean
it's equals(), it's a primitive boolean
but my favorite way of getting true is still
Double.NaN != Double.NaN
does the negation auto-unbox a Boolean btw?
Then thisll hold JValue::Bool(0) 😂 otherwhise it'd be Object::new_boolean_object(env, false)?.into_inner().into(), which is uglier
:pepechrist:
let's try it
it seems like it
Condition '!Boolean.TRUE' is always 'false'
but I couldn't really check since this all returns java.lang.Boolean
Object Bool = Boolean.TRUE;
Object bool = true;
Object negatedBool = !Boolean.TRUE;
System.out.println(Bool.getClass());
System.out.println(bool.getClass());
System.out.println(negatedBool.getClass());
which makes sense, I put it into an Object
so no idea
lol
new Boolean(new Boolean(new Boolean(new Boolean(new Boolean(false)))))
huh, would be a nice to know
i need to take care of the performance 
so no negation on a Boolean anymore
not if it's nullable
ohh, maybe because of that sonarlint always wants me to do Boolean.FALSE.equals(myBool)
public static void main(String... args) {
Boolean bool = null;
System.out.println(!bool);
}
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "bool" is null
at GlobalGson.main(GlobalGson.java:11)
@tender shard so ive setup a simple maven project it compiled the server accepted the implementations and it executes
but ive got a warning that my JRE compiliance does not match
where do i set this now because i couldnt set it at the start
xD
what java version do you want to compile for?
do you have <java.version> set to 17?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
<configuration>
<target>${java.version}</target>
<source>${java.version}</source>
</configuration>
</plugin>
this belongs into <build><plugins>
no ive set it in the project properties
under build path
was able to change it there
you should also set it in the pom
in case you compile it without intellij from command line etc
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SystemControl</groupId>
<artifactId>SystemControl</artifactId>
<version>1.0.0</version>
<name>SystemControl</name>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
sorry to bother but i really didnt wanna use it
i only rush trough it because im apparently forced to use it now xD
yes that's correct but you should also at least set the java version for the compiler plugin
k
also setting the project encoding to UTF8 is always advised
:3
and now i have full access to all methods?
no no no
you did only add spigot-api
you need spigot to access NMS methods
I sent you a blog post
one sec I'll send it again
found it
yes it's a bit long because it uses remapped mappings
but you want to use them
that way your NMS fields aren't called "a" "b" "c" but "playerConnection" etc
so you have the proper names and not just random garbage
sure
you then just have to add everything you need yourself
e.g. if you want to shade dependencies, you have to add the maven-shade-plugin
but yeah I always write the pom manually
darkmode where
https://de.wikipedia.org/wiki/Gesetz_von_Demeter what a shitty example
Das Gesetz von Demeter (englisch Law of Demeter, kurz LoD) ist eine Entwurfs-Richtlinie in der objektorientierten Softwareentwicklung. Sie besagt im Wesentlichen, dass Objekte nur mit Objekten in ihrer unmittelbaren Umgebung kommunizieren sollen. Dadurch soll die Kopplung (das heißt die Anzahl von Abhängigkeiten) in einem Softwaresystem verringe...
they forgot to add the Motor class in the second example
Guys
I am making a plugin
i have a command that should open a gui, but when running the command, there are no errors, and no gui opening
Did you register it? Plugin.yaml etc etc
I did
I forgot to put p.openinventory infron tof it
Dumb mistake xd
But
Another error
I changed the command
In the command class itself, and in the plugin.yml
and now it says
'org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.whiood.mubblemcislands.Main''
it is the right main path tho
🤷♂️ you sure otherwise it wouldn't say that
yes
and it used to work
but now i just changes the command name
and it doesnt
guys are there some elegant ways to get the final result(i.e. the item stack in the clicked slot after the event happens) of an InventoryClickEvent?
what is an elegant way to you?
<=10 lines code i think?
you can get the item with a oneliner or what do you mean
i almost mean that
so is there a one-line solution?
🤔let me try
unfortunately it doesn't work
it returns the item in the clicked slot before the event really happens
what are you trying to do
so delay it by one tick?
Why would you need to do that just get the item they grabbed
hmm i may need to cancel this event after that, so delaying doesn't seem to be a good solution
why cant i build artifacts
i didn't get it. could you please explain a bit?
explain a bit what u trying to do lol
#getCurrentItem
It should work fine what's wrong with it
i'm trying to get what will be in the clicked slot if the event really happens, but i still need to be able to cancel this event after that
it simply returns the current item in the slot instead of what i need
e.getCurrentItem
Logic
e.setCancelled
Your probably way over thinking this
the problem is that e.getCurrentItem doesn't return what i need
for example, if i put one stack of dirt blocks in an empty slot, e.getCurrentItem will return AIR currently in the slot instead of a stack of dirt
it acts just like this
Then add a slight delay
@tender shard the websites xml format seems incorrect
as it's better to keep the ability of cancelling the event i wonder if there's a solution without delaying
You probably want InventoryClickEvent#getCursor instead.
It will return whatever items is in player cursor, or what items that the player trying to store on the inventory.
i guess it's only suitable when the action is PLACE_ALL?
For some reason when I try to teleport an armor stand, the teleport fails (it returns false). Could this be because the armorstand is being ridden or is it something else?
LEFT and RIGHT also, for shift click I think you want to use getCurrentItem
Wait, I don't even know what is PLACE_ALL
PLACE_ALL means you place the whole itemstack into a slot
PLACE_ONE e.g. is right clicking a slot while having items on your cursor
PLACE_ALL is leftclicking an empty slot with items on your cursor
What's the name of the enum?
InventoryAction
Ah, I thought you meant ClickType
i cant import this
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
what's the error message?
did you simply forget to click the maven reload button?
missing parent node
also i still have to use these names? new org.bukkit.craftbukkit.v1_18_R2.command.VanillaCommandWrapper(null, null)
means that plugins still break across versions i dont really get the benefit of remapping
It gives you the unobfuscated names.
If you're not working with NMS then you don't need remapped.
that obviously belongs into <build><plugins>
kk ty
in 99% of cases, plugins belong into <build><plugins>
So I would like to stop people from being able to destroy boats as well as make them stop pushing them.
How would this be possible like what event do i need?
hey i made a stats system but i think i have something not working
Try EntityDamageEvent
Tried doesn't work
as it is a vechile I am now testing out the VehicleDamageEvent
But I want to disable the push event as well
how do I do that?
Only issue now is that I want to get the player from that event as I am only disabeling this event at spawn
I searched the javadocs and found this although I never heard of this lmao
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.html
But than the question how do I get the VehicleEntityDamage event and than the player location?
never mind I will just use the location of the located Vechile
How to get the damager of the VehicleDamageEvent?
declaration: package: org.bukkit.event.vehicle, class: VehicleDamageEvent
ninja'd
Yea I checked the spigot docs but that only shows how to get the attacker but how do I than get the player
Hey who do I dm to report mistakes on the spiggot website
oke thank you
what mistake did you find?
just wanted to notify someone that on the buildtools/#latest part they still say 1.18.1 is the latest stable one and you shouldnt use higher for servers but its 1.18.2 by now
not big thing just thought could write a small dm to someone
That's a Wiki page, anyone can edit it.
lol BestTools + Drop2Inv + InvUnload on Oneblock is like cheating
How can I use packets to make the client think that a particular player is no longer there, i.e. offline, and how can I undo this?
why would you need packets for that
The Sheep lMFAO
Player#hidePlayer
yeeet
an internal error occurred while attempting to perform this command
If a player tries to place a block at the position where a hidden player is, it will not work.
you can hide players from other players using Player#hidePlayer. No packets needed for that
noone knows since you didnt send the error message
that's true, but you can't fix that with packets anyway
But there are servers that have it that way.
I didn't say it's not possible
Dud it’s there
listen to PlayerInteractEvent and set the block manually
Dud it's not
it's just like one line
you completely ignored the stacktrace
Thats it
Look in your console Blobsky
?paste
this is how an error looks like
the error message you sent is about as useful as this
Okay, using Paper has fixed the problem lol
don't you wanna support spigot too?
spigot still has like 45% "market" share 😄
just listen to PlayerInteractEvent
check if it's right click bloc kwith a block in main hand
then check if there's a player at the clicked block's relative blockface
then set the block manually
it's maybe 5 lines of code
I would use Spigot either way, since Paper is pretty buggy in 1.8.8.
why is this code wrong
@EventHandler
public void onSnowballHit(EntityDamageByEntityEvent e) {
if ((e.getDamager() instanceof Snowball))
if ((e.getEntity() instanceof Player)) {
double damage = 0.01;
e.setDamage(damage);
Projectile projectile = (Projectile) e.getEntity();
Player attacked = (Player) e.getEntity();
ProjectileSource ps = ((Snowball) e.getDamager()).getShooter();
if (!(ps instanceof Player)) {
return;
}
Player shooter = (Player) ps;
{
ArrayList<java.lang.String> lore = new ArrayList<>();
lore.add("This balls can freeze a player");
if (projectile instanceof Snowball) {
if (shooter.getInventory().getItemInMainHand().getItemMeta().getLore().equals(lore)) {
attacked.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 20, true));
attacked.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, 100, true));
}
}
}
}
}
?notworking
"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.
Thank you very much. I might need a little help with BlockFace.
so i would like to that if the player is hitted by a custom snowball the player should get jump effect and slowness effect
and it doesnt work i cant freeze somebody
tokay imagine the following:
you click the upper face of the block at 0 100 0
now you get the clicked block, it returns the block at 0 100 0
now you get the clicked blockface, it returns BlockFace.UP
then you do clickedBlock.getRelative(clickedBlockFace)
this will the the block at 0 101 0
the one where you have to have to place the block
whew
Ohhhh okay now i know what you mean
so you can always find out where the block "would have been" placed, then manually place it
are you alright?
this was funny
lol
yeah I really don't get how some people can code plugins but don't understand that sending the actual error is important to get help
because they probably don't actually know how to code plugins
How can I use things like event.getBlockAgainst()?
or java
oh ok should i sent the error
true
getBlockAgainst is the block that was clicked
check this
the dirt block is the "blockPlaceAgainst"
erm I mean
getBlockAgainst
the BlockFace is UP since I clicked the TOP part of the dirt
so you do getBlockAgainst.getRelative(BlockFace.UP), that's where the wood would end up
Okay thanks
np
pls help
[15:38:31 ERROR]: Could not pass event ProjectileHitEvent to Main v${1.0}
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor9.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:git-Paper-259]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:629) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callProjectileHitEvent(CraftEventFactory.java:1421) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.world.entity.projectile.Projectile.preOnHit(Projectile.java:169) ~[?:?]
at net.minecraft.world.entity.projectile.ThrowableProjectile.tick(ThrowableProjectile.java:79) ~[?:?]
at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:1134) ~[?:?]
at net.minecraft.world.level.Level.guardEntityTick(Level.java:936) ~[?:?]
at net.minecraft.server.level.ServerLevel.lambda$tick$5(ServerLevel.java:673) ~[?:?]
at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:43) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:653) ~[?:?]
at
net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1591) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:483) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1455) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1225) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-259]
at java.lang.Thread.run(Thread.java:833) ~[?:?] thats the error
you are trying to get the ItemMeta of an "empty" slot
show SwapEvent line 39
why the swap event is perfectly fine i tried it
if (player.getInventory().getItemInMainHand().getItemMeta().getLore().equals(lore)) {
look closely at your error
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]
lemme dumb it down a lil, here's the key things you need to look for:
Cannot invoke ItemMeta.getLore() because the return value of ItemStack.getItemMeta() is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]
but i definied it
noo
but it works at the other items perfectly fine
how i also can give an item a tag so i can definy which item it has to be
There is no sound :((
how to a make event apply to custom items
Arraylist in listener doesn't update
you have to play that manually
pls help
patience young padawan
HI! How can i check if a player is between two locations?
how do i do something like this?
i want to check if a normal book is a custom book from a class that i made
idk how to explain it well
use math, check if the player location is higher than the first location and lower than the second
that won't work
ik
you have to identify your custom book by PDC tags or similar
np
? pdc yourself
i used BoundingBox
u can do that too
still need to override vanilla commands yet xD
I pdc myself all the time
I've written libraries to PDC myself
for example with MorePersistentDataTypes, you can PDC a player
https://hub.jeff-media.com/javadocs/morepersistentdatatypes/com/jeff_media/morepersistentdatatypes/DataType.html#PLAYER See? I can easily PDC myself with that
declaration: package: com.jeff_media.morepersistentdatatypes, interface: DataType
i have an event listener that does some funny requests stuff when a mob is killed
but the mob doesnt die until the funny requests stuff is done
is there a way to kill the mob
then do the funny requests stuff?
delay or wait until the event is done
that is one way
that would do whatever your funny stuff is off the main thread, which may or may not be what you want
Have the events for left and right clicks been merged into the interact event?
you have two hands, you need to find out which hand you want
mb low res pic
public void entityKill(EntityDeathEvent event){
Player player = event.getEntity().getKiller();
new BukkitRunnable() {
@Override
public void run() {
instance.getCoinsManager().addCoins(player, 10);
this.cancel();
}
}.runTaskAsynchronously(instance);```
havent tried this method yet
Primary and secondary hands are not related to wether it is a left or right click
wonders what happend when a mob kills something, do they get money?
its an example to see whether the thing works
why do i get this error? Could not initialize class willocore.willocore.world.Regions
if you never swap, i guess that is true
That is not what I need regardless
I need a consistent way to do a thing when a player left or rightclicks
Regardless of entity in front of them, item in hand or whatever
ok so my way for the asynchronous loop works
ty espresso guy for making me realise
yeah, in kill and death events the entity is still alive until the event exit
i realised
what's ActionBarLoop line 57
can you try to call that from the main thread to get a more useful error msg?
looks like you're doing some bad stuff in a static initializer block
yes
line 12
in your Regions class
what's that?
it's either a static field or a static { } block
there's your error
is that an enum?
yes
what's ServerLocationManager line 40?
It seems like you access your enum from the class that's needed to init your enum class in the first place
you kinda "self reference" your enum class before it could be initialized
I guess
this is the actual error, before i was just trying to access a null location but this is the actual problem
yes
show your server location manager line 40 pls
I bet you access your Regions enum there
exactly
so what's eventhandlers line 178
just calling the method
I see
is that really the full stacktrace? 😮
yes
i think there is some problem with class compiling (?)
is your code o ngithub or sth?
nope
nah
the error says it couldn't create the instance of Regions
.
can you paste your whole regions class?
am i understanding it right that to accesss the maven repository i still need to run buildtools?
with the corrisponding version i want to build for
does ServerLocationsManager access Regions enum?
no, ServerLocationsManager is just for getting Locations based on keys from the plugin configs
hm then I also don't know
your enum looks suspicous anyway, you shouldn't have to call any stuff in the constructor to get stuff from elsewhere
enums are supposed to be like static final constant fields
sussy
but if we look at the error it says something related to class initializing. NoClassDefFoundError
yes, the class can't be found because it couldn't be initialized
so it doesn't exist for the classloader
it tried to init it, but couldn't
so it's not present an runtime
that's normal
doesnt have anything to do with compilation
I guess you could easily fix that by not using an enum
but instead use public static final fields
well, i'll try to recode the whole region system from the start, without enum
Wouldn’t it be better to just make that enum it’s own class? It would be a lot more flexible if it was. Probably my wouldn’t be running into the current issue as well.
for example, check out this: https://github.com/JEFF-Media-GbR/MessageAPI/blob/0d4c9372f21b0caf7f177b1af918512496ceac6a/src/main/java/com/jeff_media/messageapi/formatters/standalone/ColorCodeFormatter.java
one would think this should be an enum
but if it was, I couldn't access BY_CHAR in the enum constructor
your problems seems to be similar
well, tysm i'll try
can somebody just help me
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
no, you didnt ask any question
prolly referring to this
not sure
how can i get a Field without having to hard code for each possible value? Like valueOf() of an Enum?
to this
i asked this question
what do you mean?
put your stuff into a map
https://github.com/JEFF-Media-GbR/MessageAPI/blob/0d4c9372f21b0caf7f177b1af918512496ceac6a/src/main/java/com/jeff_media/messageapi/formatters/standalone/ColorCodeFormatter.java as said, check my LegacyColor class and it's BY_CHAR map
this is basically just a workaround because enums are weird sometimes
well they aren't really weird, it's just that you and me were trying to abuse them
if you ever have to call any other methods in your enum constructor, it probably shouldn't be an enum
hello
how would i define the stuff in the hashmap?
What do you mean exactly?
what are you trying to get?
add your stuff in the constructor
this is basically exactly how the builtin chat colors work. also the other things like Enchantment class etc
they look like enums from the outside, but actually it's just a normal class with many public static final fields
okay!
So is the player interact event not firing on right clicks?
i mean how can i add in the event the specific item which can only do the event
it depends what you right click and with what item
clickHandler = Events.listen(PlayerInteractEvent.class, EventPriority.MONITOR, e -> {
sessions.forEach(s -> {
if(s.getPlayer().equals(e.getPlayer()) && s.getSelection() != null) {
System.out.println("Yes");
if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK)
s.getSelection().executePrimary();
else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)
s.getSelection().executeSecondary();
}
});
});```
Doesn't matter
But the if block never gets executed on a right click
Only a leftclick
it does matter
So then how can I get a consistent event fired whenever the player either presses left click or right click
for certain items, some events are simply not called
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). For the purpose of avoiding doubt, this means that the event will only be in the cancelled state if it is fired as a result of some prediction made by the server where no subsequent code will run, rather than when the subsequent interaction activity (e.g. placing a block in an illegal position (BlockCanBuildEvent) will fail. ```
there's a jira report about that but md_5 closed it because he said it can't be fixed without causing much further trouble
So if i understand correctly you have a PlayerInteractEvent and you want to do something if the clicked item is equal to something?
yeah
So you're saying there is no way for me to detect a right click
well it depends
