类org.bukkit.Statistic.Type源码实例Demo

下面列出了怎么用org.bukkit.Statistic.Type的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Kettle   文件: CraftPlayer.java
@Override
public void sendMap(MapView map) {
    if (getHandle().connection == null) return;

    RenderData data = ((CraftMapView) map).render(this);
    Collection<MapDecoration> icons = new ArrayList<>();
    for (MapCursor cursor : data.cursors) {
        if (cursor.isVisible()) {
            icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection()));
        }
    }

    SPacketMaps packet = new SPacketMaps(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 128, 128);
    getHandle().connection.sendPacket(packet);
}
 
源代码2 项目: Kettle   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
    getHandle().getStatFile().unlockAchievement(getHandle(), nmsStatistic, newValue);
}
 
源代码3 项目: Kettle   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic, Material material) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
    Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
    return getHandle().getStatFile().readStat(nmsStatistic);
}
 
源代码4 项目: Kettle   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, Material material, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
    Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
    getHandle().getStatFile().unlockAchievement(getHandle(), nmsStatistic, newValue);
}
 
源代码5 项目: Kettle   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic, EntityType entityType) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(entityType, "EntityType cannot be null");
    Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
    Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
    return getHandle().getStatFile().readStat(nmsStatistic);
}
 
源代码6 项目: Kettle   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(entityType, "EntityType cannot be null");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
    Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
    getHandle().getStatFile().unlockAchievement(getHandle(), nmsStatistic, newValue);
}
 
源代码7 项目: Kettle   文件: CraftPlayer.java
@Override
public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) {
    SPacketTitle times = new SPacketTitle(fadeIn, stay, fadeOut);
    getHandle().connection.sendPacket(times);

    if (title != null) {
        SPacketTitle packetTitle = new SPacketTitle(SPacketTitle.Type.TITLE, CraftChatMessage.fromString(title)[0]);
        getHandle().connection.sendPacket(packetTitle);
    }

    if (subtitle != null) {
        SPacketTitle packetSubtitle = new SPacketTitle(SPacketTitle.Type.SUBTITLE, CraftChatMessage.fromString(subtitle)[0]);
        getHandle().connection.sendPacket(packetSubtitle);
    }
}
 
源代码8 项目: Kettle   文件: CraftPlayer.java
@Override
public void resetTitle() {
    if (getHandle().connection == null) {
        return;
    }
    SPacketTitle packetReset = new SPacketTitle(SPacketTitle.Type.RESET, null);
    getHandle().connection.sendPacket(packetReset);
}
 
源代码9 项目: Kettle   文件: CraftEventFactory.java
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, RayTraceResult position) {
    Block hitBlock = null;
    if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos blockposition = position.getBlockPos();
        hitBlock = entity.getBukkitEntity().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    }

    ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entityHit == null ? null : position.entityHit.getBukkitEntity(), hitBlock);
    entity.world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
源代码10 项目: Thermos   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
    getHandle().func_147099_x().func_150873_a(getHandle(), nmsStatistic, newValue);
}
 
源代码11 项目: Thermos   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic, Material material) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
    Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
    return getHandle().func_147099_x().writeStat(nmsStatistic);
}
 
源代码12 项目: Thermos   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, Material material, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
    Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
    getHandle().func_147099_x().func_150873_a(getHandle(), nmsStatistic, newValue);
}
 
源代码13 项目: Thermos   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic, EntityType entityType) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(entityType, "EntityType cannot be null");
    Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
    Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
    return getHandle().func_147099_x().writeStat(nmsStatistic);
}
 
源代码14 项目: Thermos   文件: CraftPlayer.java
@Override
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.notNull(entityType, "EntityType cannot be null");
    Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
    Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
    net.minecraft.stats.StatBase nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
    Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
    getHandle().func_147099_x().func_150873_a(getHandle(), nmsStatistic, newValue);
}
 
源代码15 项目: Thermos   文件: CraftPlayer.java
@Override
public void setBanned(boolean value) {
    if (value) {
        server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null);
    } else {
        server.getBanList(BanList.Type.NAME).pardon(getName());
    }
}
 
源代码16 项目: Kettle   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
    return getHandle().getStatFile().readStat(CraftStatistic.getNMSStatistic(statistic));
}
 
源代码17 项目: Kettle   文件: CraftPlayer.java
@Override
public boolean isBanned() {
    return server.getBanList(BanList.Type.NAME).isBanned(getName());
}
 
源代码18 项目: Kettle   文件: CraftPlayer.java
@Override
public void playEffect(Location location, Effect effect, int id, int data, float offsetX, float offsetY, float offsetZ, float speed, int particleCount, int radius) {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(effect, "Effect cannot be null");
    Validate.notNull(location.getWorld(), "World cannot be null");
    Packet packet;
    if (effect.getType() != Effect.Type.PARTICLE) {
        int packetData = effect.getId();
        packet = new SPacketEffect(packetData, new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), id, false);
    } else {
        net.minecraft.util.EnumParticleTypes particle = null;
        int[] extra = null;
        for (net.minecraft.util.EnumParticleTypes p : net.minecraft.util.EnumParticleTypes.values()) {
            if (effect.getName().startsWith(p.getParticleName().replace("_", ""))) {
                particle = p;
                if (effect.getData() != null) {
                    if (effect.getData().equals(Material.class)) {
                        extra = new int[]{id};
                    } else {
                        extra = new int[]{(data << 12) | (id & 0xFFF)};
                    }
                }
                break;
            }
        }
        if (extra == null) {
            extra = new int[0];
        }
        packet = new SPacketParticles(particle, true, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount, extra);
    }
    int distance;
    radius *= radius;
    if (getHandle().connection == null) {
        return;
    }
    if (!location.getWorld().equals(getWorld())) {
        return;
    }

    distance = (int) getLocation().distanceSquared(location);
    if (distance <= radius) {
        getHandle().connection.sendPacket(packet);
    }
}
 
源代码19 项目: Kettle   文件: CraftEventFactory.java
public static Cancellable handleStatisticsIncrease(EntityPlayer entityHuman, net.minecraft.stats.StatBase statistic, int current, int incrementation) {
    Player player = ((EntityPlayerMP) entityHuman).getBukkitEntity();
    Event event;
    if (true) {
        org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
        if (stat == null) {
            // System.err.println("Unhandled statistic: " + statistic);
            return null;
        }
        switch (stat) {
            case FALL_ONE_CM:
            case BOAT_ONE_CM:
            case CLIMB_ONE_CM:
            case DIVE_ONE_CM:
            case FLY_ONE_CM:
            case HORSE_ONE_CM:
            case MINECART_ONE_CM:
            case PIG_ONE_CM:
            case PLAY_ONE_TICK:
            case SWIM_ONE_CM:
            case WALK_ONE_CM:
            case SPRINT_ONE_CM:
            case CROUCH_ONE_CM:
            case TIME_SINCE_DEATH:
            case SNEAK_TIME:
                // Do not process event for these - too spammy
                return null;
            default:
        }
        if (stat.getType() == Type.UNTYPED) {
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation);
        } else if (stat.getType() == Type.ENTITY) {
            EntityType entityType = CraftStatistic.getEntityTypeFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType);
        } else {
            Material material = CraftStatistic.getMaterialFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, material);
        }
    }
    entityHuman.world.getServer().getPluginManager().callEvent(event);
    return (Cancellable) event;
}
 
源代码20 项目: Thermos   文件: CraftPlayer.java
@Override
public int getStatistic(Statistic statistic) {
    Validate.notNull(statistic, "Statistic cannot be null");
    Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
    return getHandle().func_147099_x().writeStat(CraftStatistic.getNMSStatistic(statistic));
}
 
源代码21 项目: Thermos   文件: CraftPlayer.java
@Override
public boolean isBanned() {
    return server.getBanList(BanList.Type.NAME).isBanned(getName());
}
 
源代码22 项目: Thermos   文件: CraftEventFactory.java
public static Cancellable handleStatisticsIncrease(EntityPlayer entityHuman, net.minecraft.stats.StatBase statistic, int current, int incrementation) {
    Player player = ((EntityPlayerMP) entityHuman).getBukkitEntity();
    Event event;
    if (statistic instanceof net.minecraft.stats.Achievement) {
        if (current != 0) {
            return null;
        }
        event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.stats.Achievement) statistic));
    } else {
        org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
        if (stat == null)
        {
            return null;
        }
        switch (stat) {
            case FALL_ONE_CM:
            case BOAT_ONE_CM:
            case CLIMB_ONE_CM:
            case DIVE_ONE_CM:
            case FLY_ONE_CM:
            case HORSE_ONE_CM:
            case MINECART_ONE_CM:
            case PIG_ONE_CM:
            case PLAY_ONE_TICK:
            case SWIM_ONE_CM:
            case WALK_ONE_CM:
                // Do not process event for these - too spammy
                return null;
            default:
        }
        if (stat.getType() == Type.UNTYPED) {
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation);
        } else if (stat.getType() == Type.ENTITY) {
            EntityType entityType = CraftStatistic.getEntityTypeFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType);
        } else {
            Material material = CraftStatistic.getMaterialFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, material);
        }
    }
    entityHuman.worldObj.getServer().getPluginManager().callEvent(event);
    return (Cancellable) event;
}
 
 类所在包
 类方法
 同包方法