I once again felt like programming a bit. But I came across something that seems impossible to me.
public void onGrab (PlayerInteractEntityEvent e) {
Player p = e.getPlayer ();
if (e.getRightClicked () instanceof Player) {
Player t = (Player) e.getRightClicked ();
if (liste1.contains (p)) {
System.out.println ("p in list 1");
}
if (list2.contains (p)) {
System.out.println ("p in list 2");
}
if (liste2.contains (t)) {
System.out.println ("t in list 2");
}
if (! Liste3.containsKey (t)) {
System.out.println ("t in list 3");
}
if (! Liste1.contains (p) &&! Liste2.contains (p) &&! Liste2.contains (t) && liste.containsKey (t)) {
p.setPassenger (t);
System.out.println ("t was grabbed by p");
liste2.add (p)
liste2.add (t)
}
}
For info: List 1 and 2 are empty (it was never reingedan before). In list 3, in turn, t is included.
Ingame looks like this: The Passenger is always set at any repeating. Even if list 2 contains p and t.
In the console comes at the first grabbing "t was grabbed by p". On the second and further painting, however, then "p in list 1", "p in list 2", "t in list 2" and "t was grabbed by p".
Where is the error please? I'm confused.
This is not a Minecraft code. That looks very much like Java.
Minecraft, however, does not offer a Java API.
No idea what exactly you have there and what you have in mind.
Which data types are available?
Probably the problem lies here:
"liste3" is not a list because a list has no method .containsKey ()
Better use "talking" variable names: Name the arrays for what they do. For example, "playerList" or "grabbedPlayers".
But you can write plugins for Minecraft in Java.
There are even tutorials for it:
https://bukkit.gamepedia.com/Plugin_Tutorial
Have you just copied the code or copied 1: 1.
Of the indents, it can be that the parentheses are not right around the last if statement.
In addition, the semicolons are missing in the list2.add method calls, but there you have mistyped you, because that would be a syntax error wenns in the code would be inside.
Bukkit is not Minecraft.
Bukkit is / was (?) An alternative software for Minecraftserver, which provides the Bukkit API for plugins. The Bukkit API is also supported by other server software. For this you probably try to write a plugin.
Minecraft is Java… Minecraftcodes = Javacodes… Liste3 is a HashMap. The names are only renamed here for eig. Better overview. Probably failed
That is written off, in the original these mistakes are not. There are no error messages. Neither in the programming environment, nor in the console
List3 is a hash map.
Why did you choose a HashMap? What is the value value associated with each key?
How does liste3 get its values? Or at least: Which key / value pairs are exactly in it?
the names are only renamed here for eig. Better overview. Probably failed
Yes, that has done exactly the opposite.
A code snippet (or even an entire class), including all variable declarations, where you just remove the non-relevant parts and leave the rest as it is, along with a description of what the goal is, would be far more helpful, because you have the Code then understand.
Minecraftcodes = Java codes…
Minecraft code! = Java code
Minecraft is not a programming language unlike Java.
Minecraft even has its own little script language (Datapacks) that does not look like Java.
If you forget the parentheses when the if does not lead to an error message. Check that out or let the code format automatically so you can quickly detect such errors.
Does not change anything, however, that you can write plugins for Minecraft in Java and that's exactly what the TE wants to do…
In addition, the code for me looks very much like a plugin for Bukkit.
That is written off, in the original these mistakes are not.
Try copy and paste instead of copying.
Then you do not build a typo.
It is always funny in both cases.
@ Franky12345678
The value t needs an assigned value. Player t has the value value of, for example 1. For this context, however, unimportant.
liste3 gets (for this experiment) its values from the onEnable () {} part to see if the code I used previously caused an error (that was not) → public void onEnable () {liste3. Put (t, 1)}
Much more than this code does not exist. It's all about which event is executed when.
For Minecraft plugins but is used in over 99% of cases Java.
What stolen xd I'm not a thief xD
Paste somehow does not work in the lines of code.