Where is my fault in the house system?

To
14

I'm currently programming a house system in Minecraft.

I imagined that a shield in the radius of 3 blocks (from the door) must be a shield and the name of the player should be there.

So far so good, so I did that. But despite the shield other players can open the doors.

I thank you in advance for the answers.

_________________________________________

@EventHandler
public void onOpenDoor (PlayerInteractEvent e) {
if (e.getAction () == Action.LEFT_CLICK_BLOCK || e.getAction () == Action.RIGHT_CLICK_BLOCK) {
Block b = e.getClickedBlock ();
Player p = e.getPlayer ();

if (b.getType () == material.WOODEN_DOOR) {
Door d = (Door) b.getState (). GetData ();
int radius = 3;
Block middle = b;

for (int x = radius; x> = -radius; x--) {
for (int y = radius; y> = -radius; y--) {
for (int z = radius; z> = -radius; z--) {
if (middle.getRelative (x, y, z) .getType () == Material.WALL_SIGN) {
Sign s = (Sign) middle.getRelative (x, y, z) .getState ();

if (! (s.getLine (1) .equals ("" + p.getName () + "" {
if (! D.isOpen ()) {
d.setOpen (true);

if (d.isTopHalf ())
((Door) b.getRelative (BlockFace.DOWN, 1) .getState (). GetData ()). SetOpen (true);
else
((Door) b.getRelative (BlockFace.UP, 1) .getState (). GetData ()). SetOpen (true);

if (e.isCancelled ()) {
e.setCancelled (false);
}

b.getState () Update ().
}
else {
d.setOpen (false);

if (d.isTopHalf ())
((Door) b.getRelative (BlockFace.DOWN, 1) .getState (). GetData ()). SetOpen (false);
else
((Door) b.getRelative (BlockFace.UP, 1) .getState (). GetData ()). SetOpen (false);

if (e.isCancelled ()) {
e.setCancelled (false);
}

b.getState () Update ().
}
}
}
}
}
}
}
}
}
}

Ma

Please, please use https://hastebin.com… Or any other code-correct-einrück-side…

To
To

Would you know the error @Nirthog?

Ma

So, to give you an answer in advance, I think it's not a good idea to put 3 for loops right behind each other, because, if I guess it right, the innermost loop of research runs through, checking only the z coordinates, but without changing the x or y coordinate. Aka first runs through the z, then the y (since z is already through and x is not) and then x. In the end, you only control a few coords, but only the z coordinate changes, because only there's looked up. At least that's noticed on my first look. I'll take a look

Ma

Maybe I do not see it, but is it possible that you have not declared anywhere that if the sign line does not match the name that the event has been canceled? Because you canceld apparently it only checks if isCanceled anyway… That's very confusing.

If you need more help => Avankziar # 7545 (My Discord) and Teamviewer are your friend.

Then I can look straight at it.

To

Thanks first time you took the time, I'll gladly accept their help but unfortunately I do not own a discord. Could you write a script for me like you think it could work?

Ma

Goes also Ts3 => ts3.visia.at. The script I have to look, because the last time with the doors is already something ago.

To

I'll stop by, unfortunately I have to go to work (late shift)

Ma

Something took a while, but hopefully it should go => https://hastebin.com/...ehupi.java

To

Thanks for your work.

To

It is somewhere else still a mistake, it still does not work

Ma

This is written from a script for the 1.12.2 in 1.13.1, I think there you still have to adapt to your version.

To

Oh well, I'm currently programming on the 1.10 what exactly do I have to adjust there at the "programming level" I'm out xD because I know me not at all

Ma

Well, I always program for the current, so a dilemma…