mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Add saddle removing
This commit is contained in:
parent
fbdf56f22f
commit
a668cb9802
2
sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
Normal file
2
sqlupdates/2_3_0-RC-2_TO_2_3_0.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `users_pets`
|
||||||
|
ADD COLUMN `saddle_item_id` int(11) NULL;
|
@ -17,6 +17,7 @@ public class HorsePet extends RideablePet {
|
|||||||
this.hairStyle = set.getInt("hair_style");
|
this.hairStyle = set.getInt("hair_style");
|
||||||
this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1"));
|
this.hasSaddle(set.getString("saddle").equalsIgnoreCase("1"));
|
||||||
this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1"));
|
this.setAnyoneCanRide(set.getString("ride").equalsIgnoreCase("1"));
|
||||||
|
this.setSaddleItemId(set.getInt("saddle_item_id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HorsePet(int type, int race, String color, String name, int userId) {
|
public HorsePet(int type, int race, String color, String name, int userId) {
|
||||||
@ -30,12 +31,13 @@ public class HorsePet extends RideablePet {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (this.needsUpdate) {
|
if (this.needsUpdate) {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ? WHERE id = ?")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) {
|
||||||
statement.setInt(1, this.hairStyle);
|
statement.setInt(1, this.hairStyle);
|
||||||
statement.setInt(2, this.hairColor);
|
statement.setInt(2, this.hairColor);
|
||||||
statement.setString(3, this.hasSaddle() ? "1" : "0");
|
statement.setString(3, this.hasSaddle() ? "1" : "0");
|
||||||
statement.setString(4, this.anyoneCanRide() ? "1" : "0");
|
statement.setString(4, this.anyoneCanRide() ? "1" : "0");
|
||||||
statement.setInt(5, super.getId());
|
statement.setInt(5, this.getSaddleItemId());
|
||||||
|
statement.setInt(6, super.getId());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
@ -10,6 +10,7 @@ public class RideablePet extends Pet {
|
|||||||
private Habbo rider;
|
private Habbo rider;
|
||||||
private boolean hasSaddle;
|
private boolean hasSaddle;
|
||||||
private boolean anyoneCanRide;
|
private boolean anyoneCanRide;
|
||||||
|
private int saddleItemId;
|
||||||
|
|
||||||
public RideablePet(ResultSet set) throws SQLException {
|
public RideablePet(ResultSet set) throws SQLException {
|
||||||
super(set);
|
super(set);
|
||||||
@ -44,4 +45,12 @@ public class RideablePet extends Pet {
|
|||||||
public void setRider(Habbo rider) {
|
public void setRider(Habbo rider) {
|
||||||
this.rider = rider;
|
this.rider = rider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSaddleItemId() {
|
||||||
|
return saddleItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaddleItemId(int saddleItemId) {
|
||||||
|
this.saddleItemId = saddleItemId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,9 +542,10 @@ public class PacketManager {
|
|||||||
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
||||||
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
||||||
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
||||||
this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
|
this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
||||||
|
this.registerHandler(Incoming.HorseRemoveSaddleEvent, HorseRemoveSaddleEvent.class);
|
||||||
this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class);
|
this.registerHandler(Incoming.ToggleMonsterplantBreedableEvent, ToggleMonsterplantBreedableEvent.class);
|
||||||
this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class);
|
this.registerHandler(Incoming.CompostMonsterplantEvent, CompostMonsterplantEvent.class);
|
||||||
this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class);
|
this.registerHandler(Incoming.BreedMonsterplantsEvent, BreedMonsterplantsEvent.class);
|
||||||
|
@ -372,7 +372,7 @@ public class PacketManager_1006 {
|
|||||||
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
this.registerHandler(Incoming.PetPickupEvent, PetPickupEvent.class);
|
||||||
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
this.registerHandler(Incoming.ScratchPetEvent, ScratchPetEvent.class);
|
||||||
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
this.registerHandler(Incoming.RequestPetTrainingPanelEvent, RequestPetTrainingPanelEvent.class);
|
||||||
this.registerHandler(Incoming.HorseUseItemEvent, PetUseItemEvent.class);
|
this.registerHandler(Incoming.PetUseItemEvent, PetUseItemEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
this.registerHandler(Incoming.HorseRideSettingsEvent, PetRideSettingsEvent.class);
|
||||||
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
this.registerHandler(Incoming.HorseRideEvent, PetRideEvent.class);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ public class Incoming {
|
|||||||
public static final int SearchRoomsFriendsNowEvent = 1786;
|
public static final int SearchRoomsFriendsNowEvent = 1786;
|
||||||
public static final int SetStackHelperHeightEvent = 3839;
|
public static final int SetStackHelperHeightEvent = 3839;
|
||||||
public static final int RedeemVoucherEvent = 339;
|
public static final int RedeemVoucherEvent = 339;
|
||||||
public static final int HorseUseItemEvent = 1328;
|
public static final int PetUseItemEvent = 1328;
|
||||||
|
public static final int HorseRemoveSaddleEvent = 186;
|
||||||
public static final int BuyItemEvent = 1603;
|
public static final int BuyItemEvent = 1603;
|
||||||
public static final int AdvertisingSaveEvent = 3608;
|
public static final int AdvertisingSaveEvent = 3608;
|
||||||
public static final int RequestPetTrainingPanelEvent = 2161;
|
public static final int RequestPetTrainingPanelEvent = 2161;
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.eu.habbo.messages.incoming.rooms.pets;
|
||||||
|
|
||||||
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
|
import com.eu.habbo.habbohotel.pets.HorsePet;
|
||||||
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class HorseRemoveSaddleEvent extends MessageHandler {
|
||||||
|
@Override
|
||||||
|
public void handle() throws Exception {
|
||||||
|
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||||
|
Pet pet = room.getPet(this.packet.readInt());
|
||||||
|
|
||||||
|
if (pet == null || !(pet instanceof HorsePet)) return;
|
||||||
|
|
||||||
|
HorsePet horse = (HorsePet) pet;
|
||||||
|
|
||||||
|
if (!horse.hasSaddle()) return;
|
||||||
|
|
||||||
|
int saddleItemId = horse.getSaddleItemId();
|
||||||
|
|
||||||
|
if (saddleItemId == 0) { // backwards compatibility: horses could be missing the saddle item ID
|
||||||
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT id FROM items_base WHERE item_name LIKE 'horse_saddle%' LIMIT 1")) {
|
||||||
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
|
if (set.next()) {
|
||||||
|
saddleItemId = set.getInt("id");
|
||||||
|
} else {
|
||||||
|
Emulator.getLogging().logErrorLine("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Emulator.getLogging().logSQLException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item saddleItem = Emulator.getGameEnvironment().getItemManager().getItem(saddleItemId);
|
||||||
|
|
||||||
|
if (saddleItem == null) return;
|
||||||
|
|
||||||
|
horse.hasSaddle(false);
|
||||||
|
horse.needsUpdate = true;
|
||||||
|
Emulator.getThreading().run(pet);
|
||||||
|
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomPetHorseFigureComposer(horse).compose());
|
||||||
|
|
||||||
|
HabboItem saddle = Emulator.getGameEnvironment().getItemManager().createItem(this.client.getHabbo().getHabboInfo().getId(), saddleItem, 0, 0, "");
|
||||||
|
|
||||||
|
this.client.getHabbo().getInventory().getItemsComponent().addItem(saddle);
|
||||||
|
|
||||||
|
this.client.sendResponse(new AddHabboItemComposer(saddle));
|
||||||
|
this.client.sendResponse(new InventoryRefreshComposer());
|
||||||
|
}
|
||||||
|
}
|
@ -75,6 +75,7 @@ public class PetUseItemEvent extends MessageHandler {
|
|||||||
((HorsePet) pet).needsUpdate = true;
|
((HorsePet) pet).needsUpdate = true;
|
||||||
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) {
|
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) {
|
||||||
((HorsePet) pet).hasSaddle(true);
|
((HorsePet) pet).hasSaddle(true);
|
||||||
|
((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId());
|
||||||
((HorsePet) pet).needsUpdate = true;
|
((HorsePet) pet).needsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user