mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Merge pull request #258 from ReplayMod/statistics
ServerStatisticsPacket
This commit is contained in:
commit
9d7f06c3b7
12 changed files with 285 additions and 141 deletions
|
@ -29,7 +29,6 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition
|
|||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Achievement;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ClickItemParam;
|
||||
|
@ -571,64 +570,56 @@ public class MagicValues {
|
|||
register(EnterCreditsValue.SEEN_BEFORE, 0);
|
||||
register(EnterCreditsValue.FIRST_TIME, 1);
|
||||
|
||||
register(Achievement.TAKING_INVENTORY, "achievement.openInventory");
|
||||
register(Achievement.GETTING_WOOD, "achievement.mineWood");
|
||||
register(Achievement.BENCHMARKING, "achievement.buildWorkBench");
|
||||
register(Achievement.TIME_TO_MINE, "achievement.buildPickaxe");
|
||||
register(Achievement.HOT_TOPIC, "achievement.buildFurnace");
|
||||
register(Achievement.ACQUIRE_HARDWARE, "achievement.acquireIron");
|
||||
register(Achievement.TIME_TO_FARM, "achievement.buildHoe");
|
||||
register(Achievement.BAKE_BREAD, "achievement.makeBread");
|
||||
register(Achievement.THE_LIE, "achievement.bakeCake");
|
||||
register(Achievement.GETTING_AN_UPGRADE, "achievement.buildBetterPickaxe");
|
||||
register(Achievement.DELICIOUS_FISH, "achievement.cookFish");
|
||||
register(Achievement.ON_A_RAIL, "achievement.onARail");
|
||||
register(Achievement.TIME_TO_STRIKE, "achievement.buildSword");
|
||||
register(Achievement.MONSTER_HUNTER, "achievement.killEnemy");
|
||||
register(Achievement.COW_TIPPER, "achievement.killCow");
|
||||
register(Achievement.WHEN_PIGS_FLY, "achievement.flyPig");
|
||||
register(Achievement.SNIPER_DUEL, "achievement.snipeSkeleton");
|
||||
register(Achievement.DIAMONDS, "achievement.diamonds");
|
||||
register(Achievement.WE_NEED_TO_GO_DEEPER, "achievement.portal");
|
||||
register(Achievement.RETURN_TO_SENDER, "achievement.ghast");
|
||||
register(Achievement.INTO_FIRE, "achievement.blazeRod");
|
||||
register(Achievement.LOCAL_BREWERY, "achievement.potion");
|
||||
register(Achievement.THE_END_1, "achievement.theEnd");
|
||||
register(Achievement.THE_END_2, "achievement.theEnd2");
|
||||
register(Achievement.ENCHANTER, "achievement.enchantments");
|
||||
register(Achievement.OVERKILL, "achievement.overkill");
|
||||
register(Achievement.LIBRARIAN, "achievement.bookcase");
|
||||
register(Achievement.ADVENTURING_TIME, "achievement.exploreAllBiomes");
|
||||
register(Achievement.THE_BEGINNING_1, "achievement.spawnWither");
|
||||
register(Achievement.THE_BEGINNING_2, "achievement.killWither");
|
||||
register(Achievement.BEACONATOR, "achievement.fullBeacon");
|
||||
register(Achievement.REPOPULATION, "achievement.breedCow");
|
||||
register(Achievement.DIAMONDS_TO_YOU, "achievement.diamondsToYou");
|
||||
register(Achievement.OVERPOWERED, "achievement.overpowered");
|
||||
|
||||
register(GenericStatistic.CAKE_SLICES_EATEN, "stat.cakeSlicesEaten");
|
||||
register(GenericStatistic.TIMES_CAULDRON_FILLED, "stat.cauldronFilled");
|
||||
register(GenericStatistic.TIMES_CAULDRON_USED, "stat.cauldronUsed");
|
||||
register(GenericStatistic.TIMES_ARMOR_CLEANED, "stat.armorCleaned");
|
||||
register(GenericStatistic.TIMES_BANNER_CLEANED, "stat.bannerCleaned");
|
||||
register(GenericStatistic.TIMES_BREWING_STAND_GUI_OPENED, "stat.brewingstandInteraction");
|
||||
register(GenericStatistic.TIMES_BEACON_GUI_OPENED, "stat.beaconInteraction");
|
||||
register(GenericStatistic.TIMES_CRAFTING_TABLE_GUI_OPENED, "stat.craftingTableInteraction");
|
||||
register(GenericStatistic.TIMES_FURNACE_GUI_OPENED, "stat.furnaceInteraction");
|
||||
register(GenericStatistic.TIMES_DISPENSER_GUI_OPENED, "stat.dispenserInteraction");
|
||||
register(GenericStatistic.TIMES_DROPPER_GUI_OPENED, "stat.dropperInteraction");
|
||||
register(GenericStatistic.TIMES_HOPPER_GUI_OPENED, "stat.hopperInteraction");
|
||||
register(GenericStatistic.TIMES_CHEST_GUI_OPENED, "stat.chestInteraction");
|
||||
register(GenericStatistic.TIMES_SHULKER_BOX_GUI_OPENED, "stat.shulkerBoxOpened");
|
||||
register(GenericStatistic.TIMES_TRAPPED_CHEST_GUI_OPENED, "stat.trappedChestInteraction");
|
||||
register(GenericStatistic.TIMES_ENDER_CHEST_GUI_OPENED, "stat.enderchestInteraction");
|
||||
register(GenericStatistic.TIMES_NOTEBLOCK_PLAYED, "stat.noteblockPlayed");
|
||||
register(GenericStatistic.TIMES_NOTEBLOCK_TUNED, "stat.noteblockTuned");
|
||||
register(GenericStatistic.TIMES_PLANT_POTTED, "stat.flowerPotted");
|
||||
register(GenericStatistic.TIMES_RECORD_PLAYED, "stat.recordPlayed");
|
||||
register(GenericStatistic.TIMES_BED_ENTERED, "stat.sleepInBed");
|
||||
register(GenericStatistic.TIMES_LEFT_GAME, "stat.leaveGame");
|
||||
register(GenericStatistic.MINUTES_PLAYED, "stat.playOneMinute");
|
||||
register(GenericStatistic.BLOCKS_WALKED, "stat.walkOneCm");
|
||||
register(GenericStatistic.BLOCKS_SWAM, "stat.swimOneCm");
|
||||
register(GenericStatistic.BLOCKS_FALLEN, "stat.fallOneCm");
|
||||
register(GenericStatistic.BLOCKS_CLIMBED, "stat.climbOneCm");
|
||||
register(GenericStatistic.BLOCKS_FLOWN, "stat.flyOneCm");
|
||||
register(GenericStatistic.BLOCKS_DOVE, "stat.diveOneCm");
|
||||
register(GenericStatistic.BLOCKS_TRAVELLED_IN_MINECART, "stat.minecartOneCm");
|
||||
register(GenericStatistic.BLOCKS_TRAVELLED_IN_BOAT, "stat.boatOneCm");
|
||||
register(GenericStatistic.BLOCKS_RODE_ON_PIG, "stat.pigOneCm");
|
||||
register(GenericStatistic.BLOCKS_RODE_ON_HORSE, "stat.horseOneCm");
|
||||
register(GenericStatistic.TICKS_PLAYED, "stat.playOneMinute");
|
||||
register(GenericStatistic.TICKS_SINCE_DEATH, "stat.timeSinceDeath");
|
||||
register(GenericStatistic.TICKS_SNEAKED, "stat.sneakTime");
|
||||
register(GenericStatistic.CENTIMETERS_WALKED, "stat.walkOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_CROUCHED, "stat.crouchOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_SPRINTED, "stat.sprintOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_SWAM, "stat.swimOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_FALLEN, "stat.fallOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_CLIMBED, "stat.climbOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_FLOWN, "stat.flyOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_FLOWN_WITH_ELYTRA, "stat.aviateOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_DOVE, "stat.diveOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_TRAVELLED_IN_MINECART, "stat.minecartOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_TRAVELLED_IN_BOAT, "stat.boatOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_RODE_ON_PIG, "stat.pigOneCm");
|
||||
register(GenericStatistic.CENTIMETERS_RODE_ON_HORSE, "stat.horseOneCm");
|
||||
register(GenericStatistic.TIMES_JUMPED, "stat.jump");
|
||||
register(GenericStatistic.TIMES_DROPPED_ITEMS, "stat.drop");
|
||||
register(GenericStatistic.TIMES_DEALT_DAMAGE, "stat.damageDealt");
|
||||
register(GenericStatistic.TIMES_ENCHANTED_ITEMS, "stat.itemEnchanted");
|
||||
register(GenericStatistic.TIMES_TALKED_TO_VILLAGERS, "stat.talkedToVillager");
|
||||
register(GenericStatistic.TIMES_TRADED_WITH_VILLAGERS, "stat.tradedWithVillager");
|
||||
register(GenericStatistic.DAMAGE_DEALT, "stat.damageDealt");
|
||||
register(GenericStatistic.DAMAGE_TAKEN, "stat.damageTaken");
|
||||
register(GenericStatistic.DEATHS, "stat.deaths");
|
||||
register(GenericStatistic.MOB_KILLS, "stat.mobKills");
|
||||
register(GenericStatistic.ANIMALS_BRED, "stat.animalsBred");
|
||||
register(GenericStatistic.PLAYERS_KILLED, "stat.playerKills");
|
||||
register(GenericStatistic.FISH_CAUGHT, "stat.fishCaught");
|
||||
register(GenericStatistic.JUNK_FISHED, "stat.junkFished");
|
||||
register(GenericStatistic.TREASURE_FISHED, "stat.treasureFished");
|
||||
|
||||
register(Particle.EXPLOSION_NORMAL, 0);
|
||||
register(Particle.EXPLOSION_LARGE, 1);
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public enum Achievement implements Statistic {
|
||||
TAKING_INVENTORY,
|
||||
GETTING_WOOD,
|
||||
BENCHMARKING,
|
||||
TIME_TO_MINE,
|
||||
HOT_TOPIC,
|
||||
ACQUIRE_HARDWARE,
|
||||
TIME_TO_FARM,
|
||||
BAKE_BREAD,
|
||||
THE_LIE,
|
||||
GETTING_AN_UPGRADE,
|
||||
DELICIOUS_FISH,
|
||||
ON_A_RAIL,
|
||||
TIME_TO_STRIKE,
|
||||
MONSTER_HUNTER,
|
||||
COW_TIPPER,
|
||||
WHEN_PIGS_FLY,
|
||||
SNIPER_DUEL,
|
||||
DIAMONDS,
|
||||
WE_NEED_TO_GO_DEEPER,
|
||||
RETURN_TO_SENDER,
|
||||
INTO_FIRE,
|
||||
LOCAL_BREWERY,
|
||||
THE_END_1,
|
||||
THE_END_2,
|
||||
ENCHANTER,
|
||||
OVERKILL,
|
||||
LIBRARIAN,
|
||||
ADVENTURING_TIME,
|
||||
THE_BEGINNING_1,
|
||||
THE_BEGINNING_2,
|
||||
BEACONATOR,
|
||||
REPOPULATION,
|
||||
DIAMONDS_TO_YOU,
|
||||
OVERPOWERED
|
||||
}
|
|
@ -2,14 +2,31 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
public class BreakBlockStatistic implements Statistic {
|
||||
|
||||
private int id;
|
||||
private String id;
|
||||
|
||||
public BreakBlockStatistic(int id) {
|
||||
public BreakBlockStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BreakBlockStatistic that = (BreakBlockStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
public class BreakItemStatistic implements Statistic {
|
||||
|
||||
private int id;
|
||||
private String id;
|
||||
|
||||
public BreakItemStatistic(int id) {
|
||||
public BreakItemStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ public class BreakItemStatistic implements Statistic {
|
|||
|
||||
BreakItemStatistic that = (BreakItemStatistic) o;
|
||||
|
||||
if(id != that.id) return false;
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
public class CraftItemStatistic implements Statistic {
|
||||
|
||||
private int id;
|
||||
private String id;
|
||||
|
||||
public CraftItemStatistic(int id) {
|
||||
public CraftItemStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ public class CraftItemStatistic implements Statistic {
|
|||
|
||||
CraftItemStatistic that = (CraftItemStatistic) o;
|
||||
|
||||
if(id != that.id) return false;
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class DropItemStatistic implements Statistic {
|
||||
|
||||
private String id;
|
||||
|
||||
public DropItemStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
DropItemStatistic that = (DropItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,28 +2,55 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
public enum GenericStatistic implements Statistic {
|
||||
|
||||
CAKE_SLICES_EATEN,
|
||||
TIMES_CAULDRON_FILLED,
|
||||
TIMES_CAULDRON_USED,
|
||||
TIMES_ARMOR_CLEANED,
|
||||
TIMES_BANNER_CLEANED,
|
||||
TIMES_BREWING_STAND_GUI_OPENED,
|
||||
TIMES_BEACON_GUI_OPENED,
|
||||
TIMES_CRAFTING_TABLE_GUI_OPENED,
|
||||
TIMES_FURNACE_GUI_OPENED,
|
||||
TIMES_DISPENSER_GUI_OPENED,
|
||||
TIMES_DROPPER_GUI_OPENED,
|
||||
TIMES_HOPPER_GUI_OPENED,
|
||||
TIMES_CHEST_GUI_OPENED,
|
||||
TIMES_TRAPPED_CHEST_GUI_OPENED,
|
||||
TIMES_ENDER_CHEST_GUI_OPENED,
|
||||
TIMES_SHULKER_BOX_GUI_OPENED,
|
||||
TIMES_NOTEBLOCK_PLAYED,
|
||||
TIMES_NOTEBLOCK_TUNED,
|
||||
TIMES_PLANT_POTTED,
|
||||
TIMES_RECORD_PLAYED,
|
||||
TIMES_BED_ENTERED,
|
||||
TIMES_LEFT_GAME,
|
||||
MINUTES_PLAYED,
|
||||
BLOCKS_WALKED,
|
||||
BLOCKS_SWAM,
|
||||
BLOCKS_FALLEN,
|
||||
BLOCKS_CLIMBED,
|
||||
BLOCKS_FLOWN,
|
||||
BLOCKS_DOVE,
|
||||
BLOCKS_TRAVELLED_IN_MINECART,
|
||||
BLOCKS_TRAVELLED_IN_BOAT,
|
||||
BLOCKS_RODE_ON_PIG,
|
||||
BLOCKS_RODE_ON_HORSE,
|
||||
TICKS_PLAYED,
|
||||
TICKS_SINCE_DEATH,
|
||||
TICKS_SNEAKED,
|
||||
CENTIMETERS_WALKED,
|
||||
CENTIMETERS_CROUCHED,
|
||||
CENTIMETERS_SPRINTED,
|
||||
CENTIMETERS_SWAM,
|
||||
CENTIMETERS_FALLEN,
|
||||
CENTIMETERS_CLIMBED,
|
||||
CENTIMETERS_FLOWN,
|
||||
CENTIMETERS_FLOWN_WITH_ELYTRA,
|
||||
CENTIMETERS_DOVE,
|
||||
CENTIMETERS_TRAVELLED_IN_MINECART,
|
||||
CENTIMETERS_TRAVELLED_IN_BOAT,
|
||||
CENTIMETERS_RODE_ON_PIG,
|
||||
CENTIMETERS_RODE_ON_HORSE,
|
||||
TIMES_JUMPED,
|
||||
TIMES_DROPPED_ITEMS,
|
||||
TIMES_DEALT_DAMAGE,
|
||||
TIMES_ENCHANTED_ITEMS,
|
||||
TIMES_TALKED_TO_VILLAGERS,
|
||||
TIMES_TRADED_WITH_VILLAGERS,
|
||||
DAMAGE_DEALT,
|
||||
DAMAGE_TAKEN,
|
||||
DEATHS,
|
||||
MOB_KILLS,
|
||||
ANIMALS_BRED,
|
||||
PLAYERS_KILLED,
|
||||
FISH_CAUGHT,
|
||||
JUNK_FISHED,
|
||||
TREASURE_FISHED;
|
||||
FISH_CAUGHT;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class KillEntityStatistic implements Statistic {
|
||||
|
||||
private String id;
|
||||
|
||||
public KillEntityStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
KillEntityStatistic that = (KillEntityStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class KilledByEntityStatistic implements Statistic {
|
||||
|
||||
private String id;
|
||||
|
||||
public KilledByEntityStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
KilledByEntityStatistic that = (KilledByEntityStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public class PickupItemStatistic implements Statistic {
|
||||
|
||||
private String id;
|
||||
|
||||
public PickupItemStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PickupItemStatistic that = (PickupItemStatistic) o;
|
||||
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,13 +2,13 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
public class UseItemStatistic implements Statistic {
|
||||
|
||||
private int id;
|
||||
private String id;
|
||||
|
||||
public UseItemStatistic(int id) {
|
||||
public UseItemStatistic(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ public class UseItemStatistic implements Statistic {
|
|||
|
||||
UseItemStatistic that = (UseItemStatistic) o;
|
||||
|
||||
if(id != that.id) return false;
|
||||
if(!id.equals(that.id)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Statistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.UseItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Achievement;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.BreakBlockStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.BreakItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.CraftItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.DropItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.KillEntityStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.KilledByEntityStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.PickupItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Statistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.UseItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
@ -19,10 +22,14 @@ import java.util.Map;
|
|||
|
||||
public class ServerStatisticsPacket implements Packet {
|
||||
|
||||
private static final String CRAFT_ITEM_PREFIX = "stats.craftItem.";
|
||||
private static final String BREAK_BLOCK_PREFIX = "stats.mineBlock.";
|
||||
private static final String USE_ITEM_PREFIX = "stats.useItem.";
|
||||
private static final String BREAK_ITEM_PREFIX = "stats.breakItem.";
|
||||
private static final String CRAFT_ITEM_PREFIX = "stat.craftItem.";
|
||||
private static final String BREAK_BLOCK_PREFIX = "stat.mineBlock.";
|
||||
private static final String USE_ITEM_PREFIX = "stat.useItem.";
|
||||
private static final String BREAK_ITEM_PREFIX = "stat.breakItem.";
|
||||
private static final String KILL_ENTITY_PREFIX = "stat.killEntity.";
|
||||
private static final String KILLED_BY_ENTITY_PREFIX = "stat.entityKilledBy.";
|
||||
private static final String DROP_ITEM_PREFIX = "stat.drop.";
|
||||
private static final String PICKUP_ITEM_PREFIX = "stat.pickup.";
|
||||
|
||||
private Map<Statistic, Integer> statistics = new HashMap<Statistic, Integer>();
|
||||
|
||||
|
@ -44,16 +51,22 @@ public class ServerStatisticsPacket implements Packet {
|
|||
for(int index = 0; index < length; index++) {
|
||||
String value = in.readString();
|
||||
Statistic statistic = null;
|
||||
if(value.startsWith("achievement.")) {
|
||||
statistic = MagicValues.key(Achievement.class, value);
|
||||
} else if(value.startsWith(CRAFT_ITEM_PREFIX)) {
|
||||
statistic = new CraftItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1)));
|
||||
if(value.startsWith(CRAFT_ITEM_PREFIX)) {
|
||||
statistic = new CraftItemStatistic(value.substring(CRAFT_ITEM_PREFIX.length()));
|
||||
} else if(value.startsWith(BREAK_BLOCK_PREFIX)) {
|
||||
statistic = new BreakBlockStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1)));
|
||||
statistic = new BreakBlockStatistic(value.substring(BREAK_BLOCK_PREFIX.length()));
|
||||
} else if(value.startsWith(USE_ITEM_PREFIX)) {
|
||||
statistic = new UseItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1)));
|
||||
statistic = new UseItemStatistic(value.substring(USE_ITEM_PREFIX.length()));
|
||||
} else if(value.startsWith(BREAK_ITEM_PREFIX)) {
|
||||
statistic = new BreakItemStatistic(Integer.parseInt(value.substring(value.lastIndexOf(".") + 1)));
|
||||
statistic = new BreakItemStatistic(value.substring(BREAK_ITEM_PREFIX.length()));
|
||||
} else if(value.startsWith(KILL_ENTITY_PREFIX)) {
|
||||
statistic = new KillEntityStatistic(value.substring(KILL_ENTITY_PREFIX.length()));
|
||||
} else if(value.startsWith(KILLED_BY_ENTITY_PREFIX)) {
|
||||
statistic = new KilledByEntityStatistic(value.substring(KILLED_BY_ENTITY_PREFIX.length()));
|
||||
} else if(value.startsWith(DROP_ITEM_PREFIX)) {
|
||||
statistic = new DropItemStatistic(value.substring(DROP_ITEM_PREFIX.length()));
|
||||
} else if(value.startsWith(PICKUP_ITEM_PREFIX)) {
|
||||
statistic = new PickupItemStatistic(value.substring(PICKUP_ITEM_PREFIX.length()));
|
||||
} else {
|
||||
statistic = MagicValues.key(GenericStatistic.class, value);
|
||||
}
|
||||
|
@ -67,16 +80,22 @@ public class ServerStatisticsPacket implements Packet {
|
|||
out.writeVarInt(this.statistics.size());
|
||||
for(Statistic statistic : this.statistics.keySet()) {
|
||||
String value = "";
|
||||
if(statistic instanceof Achievement) {
|
||||
value = MagicValues.value(String.class, (Achievement) statistic);
|
||||
} else if(statistic instanceof CraftItemStatistic) {
|
||||
if(statistic instanceof CraftItemStatistic) {
|
||||
value = CRAFT_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakBlockStatistic) {
|
||||
value = BREAK_BLOCK_PREFIX + ((CraftItemStatistic) statistic).getId();
|
||||
value = BREAK_BLOCK_PREFIX + ((BreakBlockStatistic) statistic).getId();
|
||||
} else if(statistic instanceof UseItemStatistic) {
|
||||
value = USE_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId();
|
||||
value = USE_ITEM_PREFIX + ((UseItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakItemStatistic) {
|
||||
value = BREAK_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId();
|
||||
value = BREAK_ITEM_PREFIX + ((BreakItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof KillEntityStatistic) {
|
||||
value = KILL_ENTITY_PREFIX + ((KillEntityStatistic) statistic).getId();
|
||||
} else if(statistic instanceof KilledByEntityStatistic) {
|
||||
value = KILLED_BY_ENTITY_PREFIX + ((KilledByEntityStatistic) statistic).getId();
|
||||
} else if(statistic instanceof DropItemStatistic) {
|
||||
value = DROP_ITEM_PREFIX + ((DropItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof PickupItemStatistic) {
|
||||
value = PICKUP_ITEM_PREFIX + ((PickupItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof GenericStatistic) {
|
||||
value = MagicValues.value(String.class, (GenericStatistic) statistic);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue