Search in sources :

Example 1 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project Crazy-Crates by Crazy-Crew.

the class StructureService method createSingleStructure.

/**
 * Creates a single structure of maximum 32x32x32 blocks. If you need a larger area, use {@link #createStructuresArray(Location[], String)}
 * @param corners - The edges of the area (order doesn't matter)
 * @param author - The listed author of the structure
 * @return DefinedStructure - The new structure instance
 */
public static DefinedStructure createSingleStructure(Location[] corners, String author) {
    if (corners.length != 2)
        throw new IllegalArgumentException("An area needs to be set up by exactly 2 opposite edges!");
    Location[] normalized = normalizeEdges(corners[0], corners[1]);
    WorldServer world = ((CraftWorld) normalized[0].getWorld()).getHandle();
    int[] dimensions = getDimensions(normalized);
    if (dimensions[0] > 32 || dimensions[1] > 32 || dimensions[2] > 32)
        throw new IllegalArgumentException("A single structure can only be 32x32x32! If you need more, use #createStructuresArea.");
    DefinedStructure structure = new DefinedStructure();
    structure.a(world, new BlockPosition(normalized[0].getBlockX(), normalized[0].getBlockY(), normalized[0].getBlockZ()), new BlockPosition(dimensions[0], dimensions[1], dimensions[2]), true, Blocks.jb);
    structure.a(author);
    return structure;
}
Also used : DefinedStructure(net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructure) BlockPosition(net.minecraft.core.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) Location(org.bukkit.Location)

Example 2 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project DragonsOnline by UniverseCraft.

the class AntiCheatCommand method onCommand.

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (label.equalsIgnoreCase("acping")) {
        if (!requirePermission(sender, PermissionLevel.MODERATOR))
            return true;
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acping <player>");
            return true;
        }
        Player target = lookupPlayer(sender, args[0]);
        if (target == null)
            return true;
        sender.sendMessage(ChatColor.GREEN + "Ping of " + target.getName() + " is " + plugin.getCombatRewinder().getInstantaneousPing(target) + "ms (Bukkit: " + plugin.getDragonsInstance().getBridge().getPing(target) + "ms)");
        return true;
    } else if (label.equalsIgnoreCase("acpps")) {
        if (!requirePermission(sender, PermissionLevel.MODERATOR))
            return true;
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acpps <player>");
            return true;
        }
        Player target = lookupPlayer(sender, args[0]);
        FastPackets check = plugin.getCheckRegistry().getCheckByClass(FastPackets.class);
        sender.sendMessage(ChatColor.GREEN + "Current PPS of " + target.getName() + " is " + MathUtil.round(check.getPPS(target)) + " (" + plugin.getCombatRewinder().getInstantaneousPing(target) + "ms i, " + plugin.getDragonsInstance().getBridge().getPing(target) + "ms b)");
        return true;
    }
    if (!requirePermission(sender, PermissionLevel.DEVELOPER))
        return true;
    Player player = player(sender);
    if (label.equalsIgnoreCase("acdebug")) {
        plugin.setDebug(!plugin.isDebug());
        if (plugin.isDebug()) {
            sender.sendMessage(ChatColor.GREEN + "Now debugging anticheat");
        } else {
            sender.sendMessage(ChatColor.GREEN + "No longer debugging anticheat");
        }
        return true;
    } else if (label.equalsIgnoreCase("acdump")) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acdump <Player>");
            return true;
        }
        User target = lookupUser(sender, args[0]);
        sender.sendMessage("CHECK - CATEGORY - VL");
        for (Check check : plugin.getCheckRegistry().getChecks()) {
            ViolationData violationData = ViolationData.of(check, target);
            sender.sendMessage(check.getName() + " - " + check.getType() + " - " + MathUtil.round(violationData.vl));
        }
    } else if (label.equalsIgnoreCase("acresetplayer")) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acresetplayer <Player>");
            return true;
        }
        User target = lookupUser(sender, args[0]);
        for (Check check : plugin.getCheckRegistry().getChecks()) {
            ViolationData violationData = ViolationData.of(check, target);
            violationData.vl = 0;
        }
        MoveData moveData = MoveData.of(target);
        moveData.lastRubberband = 0L;
        moveData.lastValidLocation = target.getPlayer().getLocation();
        moveData.validMoves = MoveData.MIN_VALID_MOVES_TO_SET_VALID_LOCATION;
        sender.sendMessage("Reset check data for " + target.getName());
    } else if (label.equalsIgnoreCase("acflushlog")) {
        plugin.getTestingMoveListener().dumpLog();
        plugin.getTestingMoveListener().disableLog();
        sender.sendMessage(ChatColor.GREEN + "Dumped log to console and cleared");
        return true;
    } else if (label.equalsIgnoreCase("acstartlog")) {
        plugin.getTestingMoveListener().clearLog();
        plugin.getTestingMoveListener().enableLog();
        return true;
    } else if (label.equalsIgnoreCase("acblockdata")) {
        IBlockData blockData = ((CraftWorld) player.getWorld()).getHandle().getType(new BlockPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
        Block nmsBlock = blockData.getBlock();
        sender.sendMessage("nmsBlock=" + nmsBlock);
        float ff = nmsBlock.getFrictionFactor();
        sender.sendMessage("frictionFactor=" + ff);
        // ?
        ff *= 0.91;
        sender.sendMessage("*multiplier=" + 0.1 * (0.1627714 / (ff * ff * ff)));
        sender.sendMessage("*a=" + ff);
        sender.sendMessage("calculated onGround=" + ACUtil.isOnGround(player));
        return true;
    } else if (label.equalsIgnoreCase("acban")) {
        if (!requirePermission(sender, SystemProfileFlag.MODERATION))
            return true;
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acban <player> [internal info]");
            return true;
        }
        User target = lookupUser(sender, args[0]);
        String info = StringUtil.concatArgs(args, 1);
        if (target == null)
            return true;
        Report report = reportLoader.fileInternalReport(target, new Document("type", "ac_ban").append("info", info));
        report.addNote("Action automatically taken on this report");
        report.setStatus(ReportStatus.ACTION_TAKEN);
        WrappedUser.of(target).punish(PunishmentType.BAN, PunishmentCode.AC_BAN, PunishmentCode.AC_BAN.getStandingLevel(), "ID " + report.getId(), user(sender));
        sender.sendMessage(ChatColor.GREEN + "Anticheat ban executed successfully. Correlated Report ID: " + report.getId());
    } else if (label.equalsIgnoreCase("ackick")) {
        if (!requirePermission(sender, SystemProfileFlag.MODERATION))
            return true;
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/ackick <player>");
            return true;
        }
        User target = lookupUser(sender, args[0]);
        if (target == null)
            return true;
        WrappedUser.of(target).punish(PunishmentType.KICK, PunishmentCode.CHEATING_WARNING, 0, null, null);
        sender.sendMessage(ChatColor.GREEN + "Kicked " + target.getName() + " for illegal client modifications");
    } else if (label.equalsIgnoreCase("acspoofping")) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acspoofping <value|off>");
            return true;
        }
        if (args[0].equalsIgnoreCase("off")) {
            plugin.getCombatRewinder().debug_pingSpoof.remove(player);
            sender.sendMessage(ChatColor.GREEN + "Stopped spoofing your ping.");
        } else {
            plugin.getCombatRewinder().debug_pingSpoof.put(player, (long) parseInt(player, args[0]));
            sender.sendMessage(ChatColor.GREEN + "Began spoofing your anticheat ping to " + args[0] + "ms");
        }
    } else if (label.equalsIgnoreCase("acraytol")) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/acraytol <tolerance>");
            return true;
        }
        Double tol = parseDouble(sender, args[0]);
        if (tol == null)
            return true;
        plugin.getCombatRewinder().rayTraceTolerance = tol;
        sender.sendMessage(ChatColor.GREEN + "Set combat rewind ray tracing tolerance to +/- " + args[0] + " blocks");
    } else if (label.equalsIgnoreCase("acstatus")) {
        for (Check check : plugin.getCheckRegistry().getChecks()) {
            sender.sendMessage((check.isEnabled() ? ChatColor.DARK_GREEN : ChatColor.RED) + check.getName() + (check.isEnabled() ? "(Enabled)" : "(Disabled)"));
        }
    } else if (label.equalsIgnoreCase("actoggle")) {
        // If all checks are inactive, make them all active
        if (args.length == 0) {
            if (plugin.getCheckRegistry().getChecks().stream().filter(c -> c.isEnabled()).count() > 0) {
                plugin.getCheckRegistry().getChecks().forEach(c -> c.setEnabled(false));
                sender.sendMessage(ChatColor.GREEN + "Disabled all checks.");
            } else {
                plugin.getCheckRegistry().getChecks().forEach(c -> c.setEnabled(true));
                sender.sendMessage(ChatColor.GREEN + "Enabled all checks.");
            }
        } else {
            Check check = plugin.getCheckRegistry().getCheckByName(args[0]);
            if (check == null) {
                sender.sendMessage(ChatColor.RED + "No check by that name exists! /acstatus");
                return true;
            }
            check.setEnabled(!check.isEnabled());
            sender.sendMessage(ChatColor.GREEN + (check.isEnabled() ? "Enabled" : "Disabled") + " check " + check.getName());
        }
    } else if (label.equalsIgnoreCase("achitstats")) {
        Map<Player, Boolean> toggle = plugin.getCombatRewinder().debug_hitStats;
        toggle.put(player, !toggle.getOrDefault(player, false));
        sender.sendMessage(ChatColor.GREEN + "Toggled hit rejection stats in action bar");
    } else if (label.equalsIgnoreCase("acresethitstats")) {
        plugin.getCombatRewinder().debug_hitCount.remove(player);
        plugin.getCombatRewinder().debug_rejectedCount.remove(player);
        sender.sendMessage(ChatColor.GREEN + "Reset your hit rejection stats");
    } else {
        sender.sendMessage(ChatColor.GREEN + "Dragons Online custom anti-cheat (ALPHA)");
    }
    return true;
}
Also used : Document(org.bson.Document) ReportLoader(mc.dragons.tools.moderation.report.ReportLoader) Block(net.minecraft.server.v1_16_R3.Block) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) FastPackets(mc.dragons.anticheat.check.move.FastPackets) User(mc.dragons.core.gameobject.user.User) Player(org.bukkit.entity.Player) DragonsAntiCheat(mc.dragons.anticheat.DragonsAntiCheat) Report(mc.dragons.tools.moderation.report.ReportLoader.Report) DragonsCommandExecutor(mc.dragons.core.commands.DragonsCommandExecutor) PermissionLevel(mc.dragons.core.gameobject.user.permission.PermissionLevel) ReportStatus(mc.dragons.tools.moderation.report.ReportLoader.ReportStatus) MoveData(mc.dragons.anticheat.check.move.MoveData) Map(java.util.Map) WrappedUser(mc.dragons.tools.moderation.WrappedUser) PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType) StringUtil(mc.dragons.core.util.StringUtil) CommandSender(org.bukkit.command.CommandSender) ViolationData(mc.dragons.anticheat.check.ViolationData) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) SystemProfileFlag(mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Check(mc.dragons.anticheat.check.Check) ChatColor(org.bukkit.ChatColor) Command(org.bukkit.command.Command) ACUtil(mc.dragons.anticheat.util.ACUtil) MathUtil(mc.dragons.core.util.MathUtil) PunishmentCode(mc.dragons.tools.moderation.punishment.PunishmentCode) Player(org.bukkit.entity.Player) MoveData(mc.dragons.anticheat.check.move.MoveData) User(mc.dragons.core.gameobject.user.User) WrappedUser(mc.dragons.tools.moderation.WrappedUser) Report(mc.dragons.tools.moderation.report.ReportLoader.Report) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Check(mc.dragons.anticheat.check.Check) ViolationData(mc.dragons.anticheat.check.ViolationData) Document(org.bson.Document) FastPackets(mc.dragons.anticheat.check.move.FastPackets) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) Block(net.minecraft.server.v1_16_R3.Block) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 3 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method spawn.

public void spawn() {
    registry.unregister(this);
    uuid = UUID.randomUUID();
    this.isDestroyed = false;
    DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
    // displayName);
    GameProfile gameProfile = new GameProfile(uuid, "");
    gameProfile.getProperties().clear();
    gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
    this.handle = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
    handle.persist = true;
    handle.collides = false;
    handle.setCustomNameVisible(false);
    handle.setInvulnerable(npc.isImmortal());
    handle.playerConnection = new PlayerConnection(((CraftServer) Bukkit.getServer()).getServer(), new NetworkManager(EnumProtocolDirection.SERVERBOUND), handle);
    ((CraftWorld) location.getWorld()).addEntity(handle, CreatureSpawnEvent.SpawnReason.CUSTOM);
    handle.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    registry.register(this);
    for (Entity e : getEntity().getNearbyEntities(SPAWN_RADIUS, SPAWN_RADIUS, SPAWN_RADIUS)) {
        if (e instanceof Player) {
            registry.updateSpawns((Player) e, true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) PacketPlayOutEntity(net.minecraft.server.v1_16_R3.PacketPlayOutEntity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) GameProfile(com.mojang.authlib.GameProfile) PlayerInteractManager(net.minecraft.server.v1_16_R3.PlayerInteractManager) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) DedicatedServer(net.minecraft.server.v1_16_R3.DedicatedServer) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) NetworkManager(net.minecraft.server.v1_16_R3.NetworkManager) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Property(com.mojang.authlib.properties.Property) PlayerConnection(net.minecraft.server.v1_16_R3.PlayerConnection)

Example 4 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method removeLoader.

@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
    Location loaderLoc = chunkLoader.getLocation();
    assert loaderLoc.getWorld() != null;
    WorldServer world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
    long tileEntityLong = ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
    TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
    if (tileEntityChunkLoader != null) {
        tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_16_R3::removeHologram);
        tileEntityChunkLoader.removed = true;
        world.tileEntityListTick.remove(tileEntityChunkLoader);
    }
    if (spawnParticle)
        world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
    for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
        Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
        chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
        world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
    }
}
Also used : NBTTagLong(net.minecraft.server.v1_16_R3.NBTTagLong) ChunkLoader(com.bgsoftware.wildloaders.api.loaders.ChunkLoader) Block(net.minecraft.server.v1_16_R3.Block) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) TileEntityMobSpawner(net.minecraft.server.v1_16_R3.TileEntityMobSpawner) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WChunkLoader(com.bgsoftware.wildloaders.loaders.WChunkLoader) Location(org.bukkit.Location) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) Map(java.util.Map) WildLoadersPlugin(com.bgsoftware.wildloaders.WildLoadersPlugin) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) Hologram(com.bgsoftware.wildloaders.api.holograms.Hologram) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntity(net.minecraft.server.v1_16_R3.TileEntity) World(net.minecraft.server.v1_16_R3.World) NBTTagString(net.minecraft.server.v1_16_R3.NBTTagString) TileEntityTypes(net.minecraft.server.v1_16_R3.TileEntityTypes) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Collection(java.util.Collection) UUID(java.util.UUID) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ChunkCoordIntPair(net.minecraft.server.v1_16_R3.ChunkCoordIntPair) ITickable(net.minecraft.server.v1_16_R3.ITickable) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) List(java.util.List) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) ChunkLoaderNPC(com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC) Collections(java.util.Collections) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) ITileEntityChunkLoader(com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader) TileEntityMobSpawner(net.minecraft.server.v1_16_R3.TileEntityMobSpawner) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Location(org.bukkit.Location)

Example 5 with CraftWorld

use of org.bukkit.craftbukkit.v1_19_R1.CraftWorld in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method updateSpawner.

@Override
public void updateSpawner(Location location, boolean reset) {
    assert location.getWorld() != null;
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    IBlockData blockData = world.getType(blockPosition);
    TileEntityMobSpawner mobSpawner = (TileEntityMobSpawner) world.getTileEntity(blockPosition);
    if (mobSpawner == null)
        return;
    mobSpawner.getSpawner().requiredPlayerRange = reset ? 16 : -1;
}
Also used : IBlockData(net.minecraft.server.v1_16_R3.IBlockData) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) TileEntityMobSpawner(net.minecraft.server.v1_16_R3.TileEntityMobSpawner) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)147 Location (org.bukkit.Location)131 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)111 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)103 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)95 BlockPos (net.minecraft.core.BlockPos)83 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)74 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)66 ItemStack (org.bukkit.inventory.ItemStack)61 Block (org.bukkit.block.Block)57 LivingEntity (org.bukkit.entity.LivingEntity)54 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)53 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)47 ArrayList (java.util.ArrayList)43 World (org.bukkit.World)41 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)39 Entity (org.bukkit.entity.Entity)39 Level (net.minecraft.world.level.Level)38 List (java.util.List)34 GameProfile (com.mojang.authlib.GameProfile)32