mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
Statistics
This commit is contained in:
parent
3630aecf5f
commit
c328c274d4
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.game.datatypes;
|
||||||
|
|
||||||
|
public enum Statistics {
|
||||||
|
ACHIEVEMENT_OPEN_INVENTORY(new Identifier("achievement.openInventory")),
|
||||||
|
ACHIEVEMENT_MINE_WOOD(new Identifier("achievement.mineWood")),
|
||||||
|
ACHIEVEMENT_BUILD_WORKBENCH(new Identifier("achievement.buildWorkBench")),
|
||||||
|
ACHIEVEMENT_BUILD_PICKAXE(new Identifier("achievement.buildPickaxe")),
|
||||||
|
ACHIEVEMENT_BUILD_FURNACE(new Identifier("achievement.buildFurnace")),
|
||||||
|
ACHIEVEMENT_ACQUIRE_IRON(new Identifier("achievement.acquireIron")),
|
||||||
|
ACHIEVEMENT_BUILD_HOE(new Identifier("achievement.buildHoe")),
|
||||||
|
ACHIEVEMENT_MAKE_BREAD(new Identifier("achievement.makeBread")),
|
||||||
|
ACHIEVEMENT_BAKE_CAKE(new Identifier("achievement.bakeCake")),
|
||||||
|
ACHIEVEMENT_BUILD_BETTER_PICKAXE(new Identifier("achievement.buildBetterPickaxe")),
|
||||||
|
ACHIEVEMENT_COOK_FISH(new Identifier("achievement.cookFish")),
|
||||||
|
ACHIEVEMENT_ON_A_RAIL(new Identifier("achievement.onARail")),
|
||||||
|
ACHIEVEMENT_BUILD_SWORD(new Identifier("achievement.buildSword")),
|
||||||
|
ACHIEVEMENT_KILL_ENEMY(new Identifier("achievement.killEnemy")),
|
||||||
|
ACHIEVEMENT_KILL_COW(new Identifier("achievement.killCow")),
|
||||||
|
ACHIEVEMENT_FLY_PIG(new Identifier("achievement.flyPig")),
|
||||||
|
ACHIEVEMENT_SNIPE_SKELETON(new Identifier("achievement.snipeSkeleton")),
|
||||||
|
ACHIEVEMENT_DIAMONDS(new Identifier("achievement.diamonds")),
|
||||||
|
ACHIEVEMENT_DIAMONDS_TO_YOU(new Identifier("achievement.diamondsToYou")),
|
||||||
|
ACHIEVEMENT_PORTAL(new Identifier("achievement.portal")),
|
||||||
|
ACHIEVEMENT_GHAST(new Identifier("achievement.ghast")),
|
||||||
|
ACHIEVEMENT_BLAZE_ROD(new Identifier("achievement.blazeRod")),
|
||||||
|
ACHIEVEMENT_POTION(new Identifier("achievement.potion")),
|
||||||
|
ACHIEVEMENT_THE_END(new Identifier("achievement.theEnd")),
|
||||||
|
ACHIEVEMENT_THE_END2(new Identifier("achievement.theEnd2")),
|
||||||
|
ACHIEVEMENT_ENCHANTMENTS(new Identifier("achievement.enchantments")),
|
||||||
|
ACHIEVEMENT_OVERKILL(new Identifier("achievement.overkill")),
|
||||||
|
ACHIEVEMENT_BOOKCASE(new Identifier("achievement.bookcase")),
|
||||||
|
ACHIEVEMENT_BREED_COW(new Identifier("achievement.breedCow")),
|
||||||
|
ACHIEVEMENT_SPAWN_WITHER(new Identifier("achievement.spawnWither")),
|
||||||
|
ACHIEVEMENT_KILL_WITHER(new Identifier("achievement.killWither")),
|
||||||
|
ACHIEVEMENT_FULL_BEACON(new Identifier("achievement.fullBeacon")),
|
||||||
|
ACHIEVEMENT_EXPLORE_ALL_BIOMES(new Identifier("achievement.exploreAllBiomes")),
|
||||||
|
|
||||||
|
STAT_LEAVE_GAME(new Identifier("stat.leaveGame")),
|
||||||
|
STAT_PLAY_ONE_MINUTE(new Identifier("stat.playOneMinute")),
|
||||||
|
STAT_WALK_ONE_CM(new Identifier("stat.walkOneCm")),
|
||||||
|
STAT_SWIM_ONE_CM(new Identifier("stat.swimOneCm")),
|
||||||
|
STAT_FALL_ONE_CM(new Identifier("stat.fallOneCm")),
|
||||||
|
STAT_CLIMB_ONE_CM(new Identifier("stat.climbOneCm")),
|
||||||
|
STAT_FLY_ONE_CM(new Identifier("stat.flyOneCm")),
|
||||||
|
STAT_DIVE_ONE_CM(new Identifier("stat.diveOneCm")),
|
||||||
|
STAT_MINECART__ONE__CM(new Identifier("stat.minecartOneCm")),
|
||||||
|
STAT_BOAT__ONE__CM(new Identifier("stat.boatOneCm")),
|
||||||
|
STAT_PIG__ONE__CM(new Identifier("stat.pigOneCm")),
|
||||||
|
STAT_HORSE__ONE__CM(new Identifier("stat.horseOneCm")),
|
||||||
|
STAT_JUMP(new Identifier("stat.jump")),
|
||||||
|
STAT_DROP(new Identifier("stat.drop")),
|
||||||
|
STAT_DAMAGE_DEALT(new Identifier("stat.damageDealt")),
|
||||||
|
STAT_DAMAGE_TAKEN(new Identifier("stat.damageTaken")),
|
||||||
|
STAT_DEATHS(new Identifier("stat.deaths")),
|
||||||
|
STAT_MOB_KILLS(new Identifier("stat.mobKills")),
|
||||||
|
STAT_ANIMALS_BRED(new Identifier("stat.animalsBred")),
|
||||||
|
STAT_PLAYER_KILLS(new Identifier("stat.playerKills")),
|
||||||
|
STAT_FISH_CAUGHT(new Identifier("stat.fishCaught")),
|
||||||
|
STAT_JUN_KFISHED(new Identifier("stat.junkFished")),
|
||||||
|
STAT_TREASURE_FISHED(new Identifier("stat.treasureFished")),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
final Identifier identifier;
|
||||||
|
|
||||||
|
Statistics(Identifier identifier) {
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Statistics byIdentifier(Identifier identifier) {
|
||||||
|
for (Statistics s : values()) {
|
||||||
|
if (s.getIdentifier().equals(identifier)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.game.datatypes.Identifier;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.Statistics;
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class PacketStatistics implements ClientboundPacket {
|
||||||
|
HashMap<Statistics, Integer> statistics = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(InPacketBuffer buffer, ProtocolVersion v) {
|
||||||
|
switch (v) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
int length = buffer.readVarInt();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
statistics.put(Statistics.byIdentifier(new Identifier(buffer.readString())), buffer.readVarInt());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Received player statistics (count=%d)", statistics.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PacketHandler h) {
|
||||||
|
h.handle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Statistics, Integer> getStatistics() {
|
||||||
|
return statistics;
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
|||||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
public class WindowProperty implements ClientboundPacket {
|
public class PacketWindowProperty implements ClientboundPacket {
|
||||||
byte windowId;
|
byte windowId;
|
||||||
short property;
|
short property;
|
||||||
short value;
|
short value;
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
|
public class PacketClientStatus implements ServerboundPacket {
|
||||||
|
|
||||||
|
private final ClientStatus status;
|
||||||
|
|
||||||
|
public PacketClientStatus(ClientStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutPacketBuffer write(ProtocolVersion v) {
|
||||||
|
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLIENT_STATUS));
|
||||||
|
switch (v) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
buffer.writeByte((byte) status.getId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Sending client status packet (status=%s)", status.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ClientStatus {
|
||||||
|
PERFORM_RESPAWN(0),
|
||||||
|
REQUEST_STATISTICS(1),
|
||||||
|
OPEN_INVENTORY_ACHIEVEMENT(2);
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
ClientStatus(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClientStatus byId(int id) {
|
||||||
|
for (ClientStatus s : values()) {
|
||||||
|
if (s.getId() == id) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -328,11 +328,15 @@ public class PacketHandler {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(WindowProperty pkg) {
|
public void handle(PacketWindowProperty pkg) {
|
||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketConfirmTransactionReceiving pkg) {
|
public void handle(PacketConfirmTransactionReceiving pkg) {
|
||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle(PacketStatistics pkg) {
|
||||||
|
//ToDo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ public interface Protocol {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SET_SLOT, PacketSetSlot.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SET_SLOT, PacketSetSlot.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_WINDOW_CONFIRMATION, PacketConfirmTransactionReceiving.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_WINDOW_CONFIRMATION, PacketConfirmTransactionReceiving.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_PLAYER_ABILITIES, PacketPlayerAbilitiesReceiving.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_PLAYER_ABILITIES, PacketPlayerAbilitiesReceiving.class);
|
||||||
|
packetClassMapping.put(Packets.Clientbound.PLAY_STATISTICS, PacketStatistics.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getProtocolVersion();
|
int getProtocolVersion();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user