🆙 Gamecenter

This commit is contained in:
duckietm 2024-05-29 11:38:23 +02:00
parent 2d528aaaac
commit 32383e7cc4
12 changed files with 151 additions and 14 deletions

View File

@ -266,7 +266,8 @@ public class Bot implements Runnable {
if(PLACEMENT_MESSAGES.length > 0) { if(PLACEMENT_MESSAGES.length > 0) {
String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]; String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)];
if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) { if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) {
this.talk(message); if(!habbo.roomBypass) this.talk(message);
else this.talk("Deliver the drink here, " + habbo.getHabboInfo().getUsername() + "!");
} }
} }
} }

View File

@ -109,18 +109,20 @@ public class BotManager {
return; return;
if (room != null && bot != null && habbo != null) { if (room != null && bot != null && habbo != null) {
if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_PLACEFURNI)) { if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_PLACEFURNI) || habbo.roomBypass) {
if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS)) { if(!habbo.roomBypass){
habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS)) {
return; habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
} return;
}
if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY)) if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY))
return; return;
if (room.hasBotsAt(location.x, location.y)) { if (room.hasBotsAt(location.x, location.y)) {
habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE));
return; return;
}
} }
RoomUnit roomUnit = new RoomUnit(); RoomUnit roomUnit = new RoomUnit();

View File

@ -518,6 +518,20 @@ public class ItemManager {
} }
} }
public HabboItem createItemNoSql(int habboId, Item item, int limitedStack, int limitedSells, String extraData) {
Class<? extends HabboItem> itemClass = item.getInteractionType().getType();
int id = new Random().nextInt(10000000) + 1000000000;
if (itemClass != null) {
try {
return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(id, habboId, item, extraData, limitedStack, limitedSells);
} catch (Exception e) {
LOGGER.error("Caught exception", e);
return new InteractionDefault(id, habboId, item, extraData, limitedStack, limitedSells);
}
}
return null;
}
public void addNewUserGift(NewUserGift gift) { public void addNewUserGift(NewUserGift gift) {
this.newuserGifts.put(gift.getId(), gift); this.newuserGifts.put(gift.getId(), gift);
} }

View File

@ -1643,8 +1643,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return true; return true;
} }
} else { } else {
if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.animateWalk) { if ((unit.hasStatus(RoomUnitStatus.MOVE) || unit.hasStatus(RoomUnitStatus.SNOWWAR_RUN)) && !unit.animateWalk) {
unit.removeStatus(RoomUnitStatus.MOVE); unit.removeStatus(RoomUnitStatus.MOVE);
unit.removeStatus(RoomUnitStatus.SNOWWAR_RUN);
update = true; update = true;
} }
@ -1670,7 +1671,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
if (!unit.isWalking() && !unit.cmdLay) { if (!unit.isWalking() && !unit.cmdLay && !unit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK)) {
HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY()); HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY());
if (topItem == null || !topItem.getBaseItem().allowLay()) { if (topItem == null || !topItem.getBaseItem().allowLay()) {

View File

@ -531,6 +531,7 @@ public class RoomManager {
} }
if (overrideChecks || if (overrideChecks ||
habbo.roomBypass ||
room.isOwner(habbo) || room.isOwner(habbo) ||
room.getState() == RoomState.OPEN || room.getState() == RoomState.OPEN ||
habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) ||

View File

@ -79,6 +79,7 @@ public class RoomUnit {
private Room room; private Room room;
private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private RoomRightLevels rightsLevel = RoomRightLevels.NONE;
private THashSet<Integer> overridableTiles; private THashSet<Integer> overridableTiles;
private boolean isGameSnow;
public RoomUnit() { public RoomUnit() {
this.id = 0; this.id = 0;
@ -95,6 +96,7 @@ public class RoomUnit {
this.isKicked = false; this.isKicked = false;
this.overridableTiles = new THashSet<>(); this.overridableTiles = new THashSet<>();
this.timeInRoom = 0; this.timeInRoom = 0;
this.isGameSnow = false;
} }
public void clearWalking() { public void clearWalking() {
@ -155,8 +157,13 @@ public class RoomUnit {
if (this.status.remove(RoomUnitStatus.SIT) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.SIT) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.SNOWWAR_RUN) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.SNOWWAR_PICK) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.SNOWWAR_DIE_BACK) != null) this.statusUpdate = true;
if (this.status.remove(RoomUnitStatus.SNOWWAR_DIE_FRONT) != null) this.statusUpdate = true;
for (Map.Entry<RoomUnitStatus, String> set : this.status.entrySet()) { for (Map.Entry<RoomUnitStatus, String> set : this.status.entrySet()) {
if (set.getKey().removeWhenWalking) { if (set.getKey().removeWhenWalking) {
this.status.remove(set.getKey()); this.status.remove(set.getKey());
@ -334,7 +341,18 @@ public class RoomUnit {
this.setPreviousLocation(this.getCurrentLocation()); this.setPreviousLocation(this.getCurrentLocation());
if(this.getIsGameSnow()){
this.setStatus(RoomUnitStatus.SNOWWAR_RUN, next.x + "," + next.y + "," + zHeight);
}
this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight); this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight);
if(this.getStatusMap().containsKey(RoomUnitStatus.SNOWWAR_RUN)){
this.removeStatus(RoomUnitStatus.MOVE);
this.removeStatus(RoomUnitStatus.SNOWWAR_RUN);
this.setStatus(RoomUnitStatus.SNOWWAR_RUN, next.x + "," + next.y + "," + zHeight);
}
if (habbo != null) { if (habbo != null) {
if (habbo.getHabboInfo().getRiding() != null) { if (habbo.getHabboInfo().getRiding() != null) {
RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit(); RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit();
@ -694,6 +712,14 @@ public class RoomUnit {
return; return;
} }
if (this.status.containsKey(RoomUnitStatus.SNOWWAR_DIE_BACK) || this.status.containsKey(RoomUnitStatus.SNOWWAR_DIE_FRONT)) {
return;
}
if (this.status.containsKey(RoomUnitStatus.SNOWWAR_PICK)) {
return;
}
if (!this.status.containsKey(RoomUnitStatus.SIT)) { if (!this.status.containsKey(RoomUnitStatus.SIT)) {
this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]);
} }
@ -820,4 +846,11 @@ public class RoomUnit {
public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) { public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
this.moveBlockingTask = moveBlockingTask; this.moveBlockingTask = moveBlockingTask;
} }
public boolean getIsGameSnow() {
return isGameSnow;
}
public void setGameSnow(boolean gameSnow) {
isGameSnow = gameSnow;
}
} }

View File

@ -52,6 +52,12 @@ public enum RoomUnitStatus {
GROW_6("grw6"), GROW_6("grw6"),
GROW_7("grw7"), GROW_7("grw7"),
SNOWWAR_DIE_BACK("swdieback", true),
SNOWWAR_DIE_FRONT("swdiefront", true),
SNOWWAR_PICK("swpick", true),
SNOWWAR_RUN("swrun", true),
SNOWWAR_THROW("swthrow", true),
KICK("kck"), KICK("kck"),
WAG_TAIL("wag"), WAG_TAIL("wag"),
DANCE("dan"), DANCE("dan"),

View File

@ -45,6 +45,7 @@ public class Habbo implements Runnable {
private volatile boolean update; private volatile boolean update;
private volatile boolean disconnected = false; private volatile boolean disconnected = false;
private volatile boolean disconnecting = false; private volatile boolean disconnecting = false;
public boolean roomBypass = false;
public Habbo(ResultSet set) { public Habbo(ResultSet set) {
this.client = null; this.client = null;

View File

@ -32,12 +32,21 @@ public class RoomUserLookAtPoint extends MessageHandler {
if (!roomUnit.canWalk()) if (!roomUnit.canWalk())
return; return;
if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_RUN))
return;
if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE))
return; return;
if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY)) if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY))
return; return;
if (roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK) || roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_FRONT))
return;
if (roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_PICK))
return;
if (roomUnit.isIdle()) if (roomUnit.isIdle())
return; return;

View File

@ -98,7 +98,7 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
// Don't care // Don't care
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_PICK) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_DIE_FRONT) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK)) {
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
return; return;
} }

View File

@ -285,6 +285,70 @@ public class PluginManager {
} }
} }
public void updatePluginByName(String name) {
File loc = new File("plugins");
HabboPlugin pluginReload = null;
for(HabboPlugin p : this.plugins){
if(p.configuration.name.equalsIgnoreCase(name)){
pluginReload = p;
}
}
if (!loc.exists()) {
if (loc.mkdirs()) {
LOGGER.info("Created plugins directory!");
}
}
for (File file : Objects.requireNonNull(loc.listFiles(file -> file.getPath().toLowerCase().endsWith(".jar")))) {
URLClassLoader urlClassLoader;
InputStream stream;
try {
urlClassLoader = URLClassLoader.newInstance(new URL[]{file.toURI().toURL()});
stream = urlClassLoader.getResourceAsStream("plugin.json");
if (stream == null) {
throw new RuntimeException("Invalid Jar! Missing plugin.json in: " + file.getName());
}
byte[] content = new byte[stream.available()];
if (stream.read(content) > 0) {
String body = new String(content);
Gson gson = new GsonBuilder().create();
HabboPluginConfiguration pluginConfigurtion = gson.fromJson(body, HabboPluginConfiguration.class);
try {
Class<?> clazz = urlClassLoader.loadClass(pluginConfigurtion.main);
Class<? extends HabboPlugin> stackClazz = clazz.asSubclass(HabboPlugin.class);
Constructor<? extends HabboPlugin> constructor = stackClazz.getConstructor();
HabboPlugin plugin = constructor.newInstance();
plugin.configuration = pluginConfigurtion;
plugin.classLoader = urlClassLoader;
plugin.stream = stream;
if(plugin.configuration.name.equalsIgnoreCase(name) && pluginReload != null){
if(this.plugins.contains(pluginReload) && this.plugins.remove(pluginReload)){
this.plugins.add(plugin);
plugin.onEnable();
LOGGER.info("Plugin: " + plugin.configuration.name + " updated!");
}
}
} catch (Exception e) {
LOGGER.error("Could not load plugin {}!", pluginConfigurtion.name);
LOGGER.error("Caught exception", e);
}
}
} catch (Exception e) {
LOGGER.error("Caught exception", e);
}
}
}
public void registerEvents(HabboPlugin plugin, EventListener listener) { public void registerEvents(HabboPlugin plugin, EventListener listener) {
synchronized (plugin.registeredEvents) { synchronized (plugin.registeredEvents) {
Method[] methods = listener.getClass().getMethods(); Method[] methods = listener.getClass().getMethods();

View File

@ -53,6 +53,11 @@ public class RoomUnitWalkToLocation implements Runnable {
return; return;
} }
if (!this.walker.getGoal().equals(this.goalTile) || (this.walker.getPath().size() == 0 && (!this.walker.hasStatus(RoomUnitStatus.MOVE) || !this.walker.hasStatus(RoomUnitStatus.SNOWWAR_RUN)))) {
onFail();
return;
}
Emulator.getThreading().run(this, 250); Emulator.getThreading().run(this, 250);
} }