Dawson Hessler 0692b2f1b9 Implemented fix for unregister commands. | 5 роки тому | |
---|---|---|
Atlas | 5 роки тому | |
AtlasBungee | 5 роки тому | |
Example | 5 роки тому | |
.gitattributes | 5 роки тому | |
.gitignore | 5 роки тому | |
README.md | 5 роки тому |
Atlas is an all-in-one and cohesive API for developers who want to improve their Bukkit plugins or anti-cheats.
package cc.funkemunky.anticheat.api.event;
import cc.funkemunky.api.events.AtlasEvent;
import cc.funkemunky.api.events.Cancellable;
import lombok.AllArgsConstructor;
import lombok.Getter;
public class TickEvent extends AtlasEvent implements Cancellable {
private int currentTick;
public TickEvent(int currentTick) {
this.currentTick = currentTick;
}
public int getCurrentTick() {
return currentTick;
}
@Override
public boolean isCancelled() {
return false;
}
@Override
public void setCancelled(boolean b) {
}
}
new BukkitRunnable() {
public void run() {
TickEvent tickEvent = new TickEvent(currentTicks++);
Atlas.getInstance().getEventManager().callEvent(tickEvent);
}
}.runTaskTimerAsynchronously(this, 1L, 1L);
package cc.funkemunky.anticheat.impl.listeners;
import cc.funkemunky.anticheat.Rock;
import cc.funkemunky.anticheat.api.data.PlayerData;
import cc.funkemunky.anticheat.api.event.TickEvent;
import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.events.AtlasListener;
import cc.funkemunky.api.events.Listen;
import cc.funkemunky.api.utils.Init;
@Init
public class FunkeListeners implements AtlasListener {
@Listen
public void onTickEvent(TickEvent event) {
Atlas.getInstance().executeTask(() -> Rock.getInstance().getDataManager().getDataObjects().keySet().forEach(key -> {
PlayerData data = Rock.getInstance().getDataManager().getDataObjects().get(key);
data.getActionProcessor().update(data);
}));
}
}
public void onEnable() {
Atlas.getInstance().getEventManager().registerListeners(new FunkeListeners(), this);
}
TinyProtocolHandler.sendPacket(e.getPlayer(), new WrappedOutKeepAlivePacket(233 + e.getPlayer().getEntityId() + 935));
@Listen
public void onEvent(PacketRecieveEvent e) {
if(e.getType().equals(Packet.Client.ENTITY_ACTION)) {
WrappedInEntityActionPacket packet = new WrappedInEntityActionPacket(e.getPacket(), e.getPlayer());
switch(packet.getAction()) {
case START_SNEAKING:
data.skiderino.sneak = true;
break;
case STOP_SNEAKING:
data.skiderino.sneak = false;
break;
case START_SPRINTING:
data.skiderino.sprint = true;
break;
case STOP_SPRINTING:
data.skiderino.sprint = false;
break;
}
}
}
@Listen
public void onPacketSend(PacketSendEvent e) {
PlayerData data = Fiona.getInstance().getDataManager().getPlayerData(e.getPlayer());
if (data != null) {
switch (e.getType()) {
case Packet.Server.KEEP_ALIVE:
data.lastServerKeepAlive = System.currentTimeMillis();
break;
case Packet.Server.ENTITY_METADATA:
WrappedOutEntityMetadata wrapper = new WrappedOutEntityMetadata(e.getPacket(), e.getPlayer());
if(wrapper.getObjects().size() > 0) {
if(wrapper.getObjects().get(0).getObject() instanceof Byte && (data.isUsingItem = ((Byte) wrapper.getObjects().get(0).getObject()) % 0x5 == 1)) {
data.lastUseItem.reset();
}
}
break;
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onEvent(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getItem() != null
&& event.getItem().getType().equals(Material.BLAZE_ROD)
&& event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase(Color.Red + "Magic Box Wand")) {
Block block = event.getClickedBlock();
event.getPlayer().sendMessage(block.getType().name() + "'s Data: " + block.getData());
for (BoundingBox box : Atlas.getInstance().getBlockBoxManager().getBlockBox().getSpecificBox(block.getLocation())) {
for (float x = box.minX; x < box.maxX; x += 0.2f) {
for (float y = box.minY; y < box.maxY; y += 0.2f) {
for (float z = box.minZ; z < box.maxZ; z += 0.2f) {
WrappedPacketPlayOutWorldParticle packet = new WrappedPacketPlayOutWorldParticle(WrappedEnumParticle.FLAME, true, x, y, z, 0f, 0f, 0f, 0f, 1, null);
packet.sendPacket(event.getPlayer());
}
}
}
event.getPlayer().sendMessage(ReflectionsUtil.getVanillaBlock(event.getClickedBlock()).getClass().getSimpleName() + ": " + box.toString());
}
}
}
}
List<BoundingBox> box = Atlas.getInstance().getBlockBoxManager().getBlockBox().getCollidingBoxes(to.getWorld(), data.boundingBox.grow(0.5f, 0.1f, 0.5f).subtract(0, 0.5f, 0, 0, 0, 0));
CollisionAssessment assessment = new CollisionAssessment(data.boundingBox, data);
box.forEach(bb -> assessment.assessBox(bb, to.getWorld()));
MiscUtils.getEntityBoundingBox(e.getPlayer());