org.bukkit.Statistic.Type Java Examples

The following examples show how to use org.bukkit.Statistic.Type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example #2
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #3
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #4
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #5
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #6
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void resetTitle() {
    if (getHandle().connection == null) {
        return;
    }
    SPacketTitle packetReset = new SPacketTitle(SPacketTitle.Type.RESET, null);
    getHandle().connection.sendPacket(packetReset);
}
 
Example #9
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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());
    }
}
 
Example #10
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #12
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
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;
}
 
Example #17
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isBanned() {
    return server.getBanList(BanList.Type.NAME).isBanned(getName());
}
 
Example #18
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@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));
}
 
Example #19
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
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;
}
 
Example #20
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@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);
    }
}
 
Example #21
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isBanned() {
    return server.getBanList(BanList.Type.NAME).isBanned(getName());
}
 
Example #22
Source File: CraftPlayer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@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));
}