diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java index c30fe59e..e89d04fb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java @@ -1,13 +1,22 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.icetag; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.Achievement; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.games.tag.IceTagGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; public class InteractionIceTagField extends InteractionTagField { + private final HashMap stepTimes = new HashMap<>(); + public InteractionIceTagField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, IceTagGame.class); } @@ -15,4 +24,24 @@ public class InteractionIceTagField extends InteractionTagField { public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, IceTagGame.class); } + + @Override + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null) + this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); + } + + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null && this.stepTimes.containsKey(habbo)) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); + this.stepTimes.remove(habbo); + } + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java index b00750d1..29e4f8ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java @@ -1,13 +1,21 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate; +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.games.tag.RollerskateGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; public class InteractionRollerskateField extends InteractionTagField { + private final HashMap stepTimes = new HashMap<>(); + public InteractionRollerskateField(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem, RollerskateGame.class); } @@ -15,4 +23,24 @@ public class InteractionRollerskateField extends InteractionTagField { public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells, RollerskateGame.class); } + + @Override + public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOn(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null) + this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp()); + } + + @Override + public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { + super.onWalkOff(roomUnit, room, objects); + + Habbo habbo = room.getHabbo(roomUnit); + if (habbo != null && this.stepTimes.containsKey(habbo)) { + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60); + this.stepTimes.remove(habbo); + } + } } \ No newline at end of file