Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
WetABQ authored Jun 29, 2018
1 parent af81659 commit f9b02f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ private void addDummy() {
player.dataPacket(pk3);
player.dataPacket(pk4);*/
byte[] skin = image(AntiCheatAPI.getInstance().getMasterConfig().getSkinPath());
NPC npc = new NPC(new Position(player.getX(), player.getY() + 3, player.getZ(), player.getLevel()), skin, player);
npc.setNameTag("AntiCheat");
NPC npc = new NPC(new Position(player.getX(), player.getY() - 2, player.getZ(), player.getLevel()), skin, player);
npc.setNameTag("'");
npc.setScale(0.0001F);
this.npc = npc;
}

public void move(Player player) {
npc.teleport(new Location(player.x, player.y, player.z, player.yaw, player.pitch));
npc.teleport(new Location(player.x, player.y - 2, player.z, player.yaw, player.pitch));
}

public NPC getNpc() {
return npc;
}

private static byte[] image(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class NPC extends EntityHuman {

public NPC(Position pos, byte[] skin, Player player) {
super(pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4), getEntityNBT(pos, skin));
this.setDataFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_INVISIBLE, false);
this.setDataFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG, false);
this.setDataFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_CAN_SHOW_NAMETAG, false);
this.setHealth(999);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cn.nukkit.event.player.PlayerChatEvent;
import cn.nukkit.event.player.PlayerJoinEvent;
import cn.nukkit.event.player.PlayerMoveEvent;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.event.server.DataPacketReceiveEvent;
import cn.nukkit.level.Position;
import cn.nukkit.math.Vector3;
Expand Down Expand Up @@ -120,6 +121,13 @@ public void onMove(PlayerMoveEvent event) {
}
}

@EventHandler
public void onQuit(PlayerQuitEvent event) {
if (AntiCheatAPI.getInstance().getMasterConfig().getAntiAutoAim() && AntiAutoAim.containsKey(event.getPlayer().getName())) {
AntiAutoAim.get(event.getPlayer().getName()).getNpc().close();
}
}

@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
Reach reach = new Reach(event.getPlayer(), event.getBlock());
Expand Down Expand Up @@ -164,7 +172,7 @@ public void onEntitDamage(EntityDamageByEntityEvent event) {
}
event.setKnockBack(0.25F); // Nukkit KnockBack is so ‘long’
}
if (event.getEntity() instanceof NPC) {
if (event.getEntity() instanceof NPC || event.getEntity().getNameTag().equals("'")) {
event.setCancelled();
}
}
Expand Down

0 comments on commit f9b02f7

Please sign in to comment.