/** * Set the behavior of the component to display information about a parameterless statistic when the client hovers over the text. * * @param statistic The statistic to display. * @param material The sole material parameter to the statistic. * @return This message component instance. * @exception IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. */ public MessageComponent statisticTooltip(Statistic statistic, Material material) throws IllegalArgumentException { Type type = statistic.getType(); if (type == Type.UNTYPED) throw new IllegalArgumentException("That statistic needs no additional parameter!"); if ((type == Type.BLOCK && material.isBlock()) || type == Type.ENTITY) throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); try { return onHover(MessageHoverEvent.HoverEventAction.SHOW_ACHIEVEMENT, (String) FIELD_STATISTIC_NAME.get(GET_MATERIAL_STATISTIC.invoke(null, statistic, material))); } catch (Exception e) { e.printStackTrace(); } return this; }
/** * Set the behavior of the component to display information about a parameterless statistic when the client hovers over the text. * * @param statistic The statistic to display. * @param entity The sole entity type parameter to the statistic. * @return This message component instance. * @exception IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. */ public MessageComponent statisticTooltip(Statistic statistic, EntityType entity) throws IllegalArgumentException { Type type = statistic.getType(); if (type == Type.UNTYPED) throw new IllegalArgumentException("That statistic needs no additional parameter!"); if (type != Type.ENTITY) throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); try { return onHover(MessageHoverEvent.HoverEventAction.SHOW_ACHIEVEMENT, (String) FIELD_STATISTIC_NAME.get(GET_ENTITY_STATISTIC.invoke(null, statistic, entity))); } catch (Exception e) { e.printStackTrace(); } return this; }
/** * Set the behavior of the current editing component to display information about a statistic parametered with a material when the client hovers over the text. * <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p> * @param which The statistic to display. * @param item The sole material parameter to the statistic. * @return This builder instance. * @exception IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. */ public FancyMessage statisticTooltip(final Statistic which, Material item) { Type type = which.getType(); if (type == Type.UNTYPED) { throw new IllegalArgumentException("That statistic needs no additional parameter!"); } if ((type == Type.BLOCK && item.isBlock()) || type == Type.ENTITY) { throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); } try { Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item); return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); } catch (Exception e) { e.printStackTrace(); return this; } }
/** * Set the behavior of the current editing component to display information about a statistic parametered with an entity type when the client hovers over the text. * <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p> * @param which The statistic to display. * @param entity The sole entity type parameter to the statistic. * @return This builder instance. * @exception IllegalArgumentException If the statistic requires a parameter which was not supplied, or was supplied a parameter that was not required. */ public FancyMessage statisticTooltip(final Statistic which, EntityType entity) { Type type = which.getType(); if (type == Type.UNTYPED) { throw new IllegalArgumentException("That statistic needs no additional parameter!"); } if (type != Type.ENTITY) { throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); } try { Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity); return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); } catch (Exception e) { e.printStackTrace(); return this; } }
@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); }
@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); }
@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); }
@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); }
@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); }
@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()); } }
@Override public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { if (title != null) { S45PacketTitle packetTitle = new S45PacketTitle(S45PacketTitle.Type.TITLE, CraftChatMessage.fromString(title)[0]); UraniumPlusCommon.getChancel().sendTo(packetTitle,getHandle()); } if (subtitle != null) { S45PacketTitle packetSubtitle = new S45PacketTitle(S45PacketTitle.Type.SUBTITLE, CraftChatMessage.fromString(subtitle)[0]); UraniumPlusCommon.getChancel().sendTo(packetSubtitle,getHandle()); } S45PacketTitle times = new S45PacketTitle(fadeIn, stay, fadeOut); UraniumPlusCommon.getChancel().sendTo(times,getHandle()); }
/** * Set the behavior of the component to display information about a parameterless statistic when the client hovers over the text. * * @param statistic The statistic to display. * @return This message component instance. * @exception IllegalArgumentException If the statistic requires a parameter which was not supplied. */ public MessageComponent statisticTooltip(Statistic statistic) throws IllegalArgumentException { Type type = statistic.getType(); if (type != Type.UNTYPED) throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!"); try { return onHover(MessageHoverEvent.HoverEventAction.SHOW_ACHIEVEMENT, (String) FIELD_STATISTIC_NAME.get(GET_NMS_STATISTIC.invoke(null, statistic))); } catch (Exception e) { e.printStackTrace(); } return this; }
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); 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; }