mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Update ServerStatisticsPacket
This commit is contained in:
parent
8a29f2ff5e
commit
9f169b6365
12 changed files with 201 additions and 161 deletions
|
@ -43,6 +43,7 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
|||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.StatisticCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ClickItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CraftingBookDataType;
|
||||
|
@ -572,57 +573,66 @@ public class MagicValues {
|
|||
register(EnterCreditsValue.SEEN_BEFORE, 0);
|
||||
register(EnterCreditsValue.FIRST_TIME, 1);
|
||||
|
||||
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.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_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.TIMES_LEFT_GAME, 0);
|
||||
register(GenericStatistic.TICKS_PLAYED, 1);
|
||||
register(GenericStatistic.TICKS_SINCE_DEATH, 2);
|
||||
register(GenericStatistic.TICKS_SNEAKED, 3);
|
||||
register(GenericStatistic.CENTIMETERS_WALKED, 4);
|
||||
register(GenericStatistic.CENTIMETERS_CROUCHED, 5);
|
||||
register(GenericStatistic.CENTIMETERS_SPRINTED, 6);
|
||||
register(GenericStatistic.CENTIMETERS_SWAM, 7);
|
||||
register(GenericStatistic.CENTIMETERS_FALLEN, 8);
|
||||
register(GenericStatistic.CENTIMETERS_CLIMBED, 9);
|
||||
register(GenericStatistic.CENTIMETERS_FLOWN, 10);
|
||||
register(GenericStatistic.CENTIMETERS_DOVE, 11);
|
||||
register(GenericStatistic.CENTIMETERS_TRAVELLED_IN_MINECART, 12);
|
||||
register(GenericStatistic.CENTIMETERS_TRAVELLED_IN_BOAT, 13);
|
||||
register(GenericStatistic.CENTIMETERS_RODE_ON_PIG, 14);
|
||||
register(GenericStatistic.CENTIMETERS_RODE_ON_HORSE, 15);
|
||||
register(GenericStatistic.CENTIMETERS_FLOWN_WITH_ELYTRA, 16);
|
||||
register(GenericStatistic.TIMES_JUMPED, 17);
|
||||
register(GenericStatistic.TIMES_DROPPED_ITEMS, 18);
|
||||
register(GenericStatistic.DAMAGE_DEALT, 19);
|
||||
register(GenericStatistic.DAMAGE_TAKEN, 20);
|
||||
register(GenericStatistic.DEATHS, 21);
|
||||
register(GenericStatistic.MOB_KILLS, 22);
|
||||
register(GenericStatistic.ANIMALS_BRED, 23);
|
||||
register(GenericStatistic.PLAYERS_KILLED, 24);
|
||||
register(GenericStatistic.FISH_CAUGHT, 25);
|
||||
register(GenericStatistic.TIMES_TALKED_TO_VILLAGERS, 26);
|
||||
register(GenericStatistic.TIMES_TRADED_WITH_VILLAGERS, 27);
|
||||
register(GenericStatistic.CAKE_SLICES_EATEN, 28);
|
||||
register(GenericStatistic.TIMES_CAULDRON_FILLED, 29);
|
||||
register(GenericStatistic.TIMES_CAULDRON_USED, 30);
|
||||
register(GenericStatistic.TIMES_ARMOR_CLEANED, 31);
|
||||
register(GenericStatistic.TIMES_BANNER_CLEANED, 32);
|
||||
register(GenericStatistic.TIMES_BREWING_STAND_GUI_OPENED, 33);
|
||||
register(GenericStatistic.TIMES_BEACON_GUI_OPENED, 34);
|
||||
register(GenericStatistic.TIMES_DROPPER_GUI_OPENED, 35);
|
||||
register(GenericStatistic.TIMES_HOPPER_GUI_OPENED, 36);
|
||||
register(GenericStatistic.TIMES_DISPENSER_GUI_OPENED, 37);
|
||||
register(GenericStatistic.TIMES_NOTEBLOCK_PLAYED, 38);
|
||||
register(GenericStatistic.TIMES_NOTEBLOCK_TUNED, 39);
|
||||
register(GenericStatistic.TIMES_PLANT_POTTED, 40);
|
||||
register(GenericStatistic.TIMES_TRAPPED_CHEST_GUI_OPENED, 41);
|
||||
register(GenericStatistic.TIMES_ENDER_CHEST_GUI_OPENED, 42);
|
||||
register(GenericStatistic.TIMES_ENCHANTED_ITEMS, 43);
|
||||
register(GenericStatistic.TIMES_RECORD_PLAYED, 44);
|
||||
register(GenericStatistic.TIMES_FURNACE_GUI_OPENED, 45);
|
||||
register(GenericStatistic.TIMES_CRAFTING_TABLE_GUI_OPENED, 46);
|
||||
register(GenericStatistic.TIMES_CHEST_GUI_OPENED, 47);
|
||||
register(GenericStatistic.TIMES_BED_ENTERED, 48);
|
||||
register(GenericStatistic.TIMES_SHULKER_BOX_GUI_OPENED, 49);
|
||||
|
||||
register(StatisticCategory.BREAK_BLOCK, 0);
|
||||
register(StatisticCategory.CRAFT_ITEM, 1);
|
||||
register(StatisticCategory.USE_ITEM, 2);
|
||||
register(StatisticCategory.BREAK_ITEM, 3);
|
||||
register(StatisticCategory.PICKED_UP_ITEM, 4);
|
||||
register(StatisticCategory.DROP_ITEM, 5);
|
||||
register(StatisticCategory.KILL_ENTITY, 6);
|
||||
register(StatisticCategory.KILLED_BY_ENTITY, 7);
|
||||
register(StatisticCategory.GENERIC, 8);
|
||||
|
||||
register(ParticleType.AMBIENT_ENTITY_EFFECT, 0);
|
||||
register(ParticleType.ANGRY_VILLAGER, 1);
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BreakBlockStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public BreakBlockStatistic(String id) {
|
||||
public BreakBlockStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class BreakBlockStatistic implements Statistic {
|
|||
if(!(o instanceof BreakBlockStatistic)) return false;
|
||||
|
||||
BreakBlockStatistic that = (BreakBlockStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BreakItemStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public BreakItemStatistic(String id) {
|
||||
public BreakItemStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class BreakItemStatistic implements Statistic {
|
|||
if(!(o instanceof BreakItemStatistic)) return false;
|
||||
|
||||
BreakItemStatistic that = (BreakItemStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CraftItemStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public CraftItemStatistic(String id) {
|
||||
public CraftItemStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class CraftItemStatistic implements Statistic {
|
|||
if(!(o instanceof CraftItemStatistic)) return false;
|
||||
|
||||
CraftItemStatistic that = (CraftItemStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CustomStatistic implements Statistic {
|
||||
private String name;
|
||||
private int category;
|
||||
private int id;
|
||||
|
||||
public CustomStatistic(String name) {
|
||||
this.name = name;
|
||||
public CustomStatistic(int id) {
|
||||
this(MagicValues.value(Integer.class, StatisticCategory.GENERIC), id);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
public CustomStatistic(int category, int id) {
|
||||
this.category = category;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,12 +30,13 @@ public class CustomStatistic implements Statistic {
|
|||
if(!(o instanceof CustomStatistic)) return false;
|
||||
|
||||
CustomStatistic that = (CustomStatistic) o;
|
||||
return Objects.equals(this.name, that.name);
|
||||
return this.category == that.category
|
||||
&& this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtil.hashCode(this.name);
|
||||
return ObjectUtil.hashCode(this.id, this.category);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DropItemStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public DropItemStatistic(String id) {
|
||||
public DropItemStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class DropItemStatistic implements Statistic {
|
|||
if(!(o instanceof DropItemStatistic)) return false;
|
||||
|
||||
DropItemStatistic that = (DropItemStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KillEntityStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public KillEntityStatistic(String id) {
|
||||
public KillEntityStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class KillEntityStatistic implements Statistic {
|
|||
if(!(o instanceof KillEntityStatistic)) return false;
|
||||
|
||||
KillEntityStatistic that = (KillEntityStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class KilledByEntityStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public KilledByEntityStatistic(String id) {
|
||||
public KilledByEntityStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class KilledByEntityStatistic implements Statistic {
|
|||
if(!(o instanceof KilledByEntityStatistic)) return false;
|
||||
|
||||
KilledByEntityStatistic that = (KilledByEntityStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PickupItemStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public PickupItemStatistic(String id) {
|
||||
public PickupItemStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class PickupItemStatistic implements Statistic {
|
|||
if(!(o instanceof PickupItemStatistic)) return false;
|
||||
|
||||
PickupItemStatistic that = (PickupItemStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public enum StatisticCategory {
|
||||
BREAK_BLOCK,
|
||||
CRAFT_ITEM,
|
||||
USE_ITEM,
|
||||
BREAK_ITEM,
|
||||
PICKED_UP_ITEM,
|
||||
DROP_ITEM,
|
||||
KILL_ENTITY,
|
||||
KILLED_BY_ENTITY,
|
||||
GENERIC;
|
||||
}
|
|
@ -2,16 +2,14 @@ package com.github.steveice10.mc.protocol.data.game.statistic;
|
|||
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class UseItemStatistic implements Statistic {
|
||||
private String id;
|
||||
private int id;
|
||||
|
||||
public UseItemStatistic(String id) {
|
||||
public UseItemStatistic(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -21,7 +19,7 @@ public class UseItemStatistic implements Statistic {
|
|||
if(!(o instanceof UseItemStatistic)) return false;
|
||||
|
||||
UseItemStatistic that = (UseItemStatistic) o;
|
||||
return Objects.equals(this.id, that.id);
|
||||
return this.id == that.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ 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.StatisticCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.UseItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
|
@ -21,15 +22,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class ServerStatisticsPacket extends MinecraftPacket {
|
||||
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>();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -48,32 +40,44 @@ public class ServerStatisticsPacket extends MinecraftPacket {
|
|||
public void read(NetInput in) throws IOException {
|
||||
int length = in.readVarInt();
|
||||
for(int index = 0; index < length; index++) {
|
||||
String value = in.readString();
|
||||
Statistic statistic = null;
|
||||
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(value.substring(BREAK_BLOCK_PREFIX.length()));
|
||||
} else if(value.startsWith(USE_ITEM_PREFIX)) {
|
||||
statistic = new UseItemStatistic(value.substring(USE_ITEM_PREFIX.length()));
|
||||
} else if(value.startsWith(BREAK_ITEM_PREFIX)) {
|
||||
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 {
|
||||
try {
|
||||
statistic = MagicValues.key(GenericStatistic.class, value);
|
||||
} catch(IllegalArgumentException e) {
|
||||
statistic = new CustomStatistic(value);
|
||||
int categoryId = in.readVarInt();
|
||||
int statisticId = in.readVarInt();
|
||||
Statistic statistic;
|
||||
try {
|
||||
switch (MagicValues.key(StatisticCategory.class, categoryId)) {
|
||||
case BREAK_BLOCK:
|
||||
statistic = new BreakBlockStatistic(statisticId);
|
||||
break;
|
||||
case CRAFT_ITEM:
|
||||
statistic = new CraftItemStatistic(statisticId);
|
||||
break;
|
||||
case USE_ITEM:
|
||||
statistic = new UseItemStatistic(statisticId);
|
||||
break;
|
||||
case BREAK_ITEM:
|
||||
statistic = new BreakItemStatistic(statisticId);
|
||||
break;
|
||||
case PICKED_UP_ITEM:
|
||||
statistic = new PickupItemStatistic(statisticId);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
statistic = new DropItemStatistic(statisticId);
|
||||
break;
|
||||
case KILL_ENTITY:
|
||||
statistic = new KillEntityStatistic(statisticId);
|
||||
break;
|
||||
case KILLED_BY_ENTITY:
|
||||
statistic = new KilledByEntityStatistic(statisticId);
|
||||
break;
|
||||
case GENERIC:
|
||||
statistic = MagicValues.key(GenericStatistic.class, statisticId);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
statistic = new CustomStatistic(categoryId, statisticId);
|
||||
}
|
||||
|
||||
this.statistics.put(statistic, in.readVarInt());
|
||||
}
|
||||
}
|
||||
|
@ -82,28 +86,47 @@ public class ServerStatisticsPacket extends MinecraftPacket {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.statistics.size());
|
||||
for(Statistic statistic : this.statistics.keySet()) {
|
||||
String value = "";
|
||||
if(statistic instanceof CraftItemStatistic) {
|
||||
value = CRAFT_ITEM_PREFIX + ((CraftItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakBlockStatistic) {
|
||||
value = BREAK_BLOCK_PREFIX + ((BreakBlockStatistic) statistic).getId();
|
||||
} else if(statistic instanceof UseItemStatistic) {
|
||||
value = USE_ITEM_PREFIX + ((UseItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakItemStatistic) {
|
||||
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);
|
||||
int categoryId;
|
||||
int statisticId;
|
||||
if(statistic instanceof CustomStatistic) {
|
||||
categoryId = ((CustomStatistic) statistic).getCategory();
|
||||
statisticId = ((CustomStatistic) statistic).getId();
|
||||
} else {
|
||||
StatisticCategory category;
|
||||
if(statistic instanceof CraftItemStatistic) {
|
||||
category = StatisticCategory.CRAFT_ITEM;
|
||||
statisticId = ((CraftItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakBlockStatistic) {
|
||||
category = StatisticCategory.BREAK_BLOCK;
|
||||
statisticId = ((BreakBlockStatistic) statistic).getId();
|
||||
} else if(statistic instanceof UseItemStatistic) {
|
||||
category = StatisticCategory.USE_ITEM;
|
||||
statisticId = ((UseItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof BreakItemStatistic) {
|
||||
category = StatisticCategory.BREAK_ITEM;
|
||||
statisticId = ((BreakItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof KillEntityStatistic) {
|
||||
category = StatisticCategory.KILL_ENTITY;
|
||||
statisticId = ((KillEntityStatistic) statistic).getId();
|
||||
} else if(statistic instanceof KilledByEntityStatistic) {
|
||||
category = StatisticCategory.KILLED_BY_ENTITY;
|
||||
statisticId = ((KilledByEntityStatistic) statistic).getId();
|
||||
} else if(statistic instanceof DropItemStatistic) {
|
||||
category = StatisticCategory.DROP_ITEM;
|
||||
statisticId = ((DropItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof PickupItemStatistic) {
|
||||
category = StatisticCategory.PICKED_UP_ITEM;
|
||||
statisticId = ((PickupItemStatistic) statistic).getId();
|
||||
} else if(statistic instanceof GenericStatistic) {
|
||||
category = StatisticCategory.GENERIC;
|
||||
statisticId = MagicValues.value(Integer.class, statistic);
|
||||
} else {
|
||||
throw new IllegalArgumentException(statistic.getClass().getName());
|
||||
}
|
||||
categoryId = MagicValues.value(Integer.class, category);
|
||||
}
|
||||
|
||||
out.writeString(value);
|
||||
out.writeVarInt(categoryId);
|
||||
out.writeVarInt(statisticId);
|
||||
out.writeVarInt(this.statistics.get(statistic));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue