EjectAll for Comet Server

Results 1 to 12 of 12
  1. #1
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,375Posts

    EjectAll for Comet Server

    Hi

    Comet does not have an ejectall command, and the pickall does not take into account items owned by other players.

    To fix this, first open PickAllCommand.java and replace it with this:

    Code:
    package com.cometproject.server.game.commands.user.room;
    
    
    import com.cometproject.server.config.Locale;
    import com.cometproject.server.game.commands.ChatCommand;
    import com.cometproject.server.game.rooms.objects.items.RoomItem;
    import com.cometproject.server.game.rooms.objects.items.RoomItemFloor;
    import com.cometproject.server.game.rooms.objects.items.RoomItemWall;
    import com.cometproject.server.game.rooms.types.Room;
    import com.cometproject.server.network.sessions.Session;
    
    
    import java.util.ArrayList;
    import java.util.List;
    
    
    
    
    public class PickAllCommand extends ChatCommand {
        @Override
        public void execute(Session client, String message[]) {
            Room room = client.getPlayer().getEntity().getRoom();
    
    
            if (room == null || !room.getData().getOwner().equals(client.getPlayer().getData().getUsername())) {
                return;
            }
    
    
            List<RoomItem> itemsToRemove = new ArrayList<>();
    
    
            itemsToRemove.addAll(room.getItems().getFloorItems().values());
            itemsToRemove.addAll(room.getItems().getWallItems().values());
    
    
            for (RoomItem item : itemsToRemove) {
                if (item instanceof RoomItemFloor) {
                    if(item.getOwner() == room.getData().getOwnerId()) {
                        room.getItems().removeItem((RoomItemFloor) item, client);
                    }
                } else if (item instanceof RoomItemWall) {
                    if(item.getOwner() == room.getData().getOwnerId()) {
                        room.getItems().removeItem((RoomItemWall) item, client, true);
                    }
                }
            }
    
    
            itemsToRemove.clear();
        }
    
    
        @Override
        public String getPermission() {
            return "pickall_command";
        }
    
    
        @Override
        public String getDescription() {
            return Locale.get("command.pickall.description");
        }
    }
    Then navigate to ItemsComponent.java and add these 2 voids:

    Code:
        public void removeNonOwnedItem(RoomItemFloor item, int ownerId) {
            RoomItemDao.removeItemFromRoom(item.getItemId(), ownerId);
    
    
            Session client = NetworkManager.getInstance().getSessions().getByPlayerId(ownerId);
    
    
            room.getEntities().broadcastMessage(new RemoveFloorItemMessageComposer(ItemManager.getInstance().getItemVirtualId(item.getId()), ownerId));
            this.getFloorItems().remove(item.getId());
    
    
            if(client != null && client.getPlayer() != null) {
                client.getPlayer().getInventory().add(item.getId(), item.getItemId(), item.getExtraData(), item.getLimitedEditionItemData());
                client.send(new UpdateInventoryMessageComposer());
            }
        }
    
    
        public void removeNonOwnedItem(RoomItemWall item, int ownerId) {
            RoomItemDao.removeItemFromRoom(item.getItemId(), ownerId);
    
    
            room.getEntities().broadcastMessage(new RemoveWallItemMessageComposer(ItemManager.getInstance().getItemVirtualId(item.getId()), ownerId));
            this.getWallItems().remove(item.getId());
    
    
            Session client = NetworkManager.getInstance().getSessions().getByPlayerId(ownerId);
            if(client != null && client.getPlayer() != null) {
                client.getPlayer().getInventory().add(item.getId(), item.getItemId(), item.getExtraData(), item.getLimitedEditionItemData());
                client.send(new UpdateInventoryMessageComposer());
            }
        }
    Then create a new file in commands/user/room named EjectAllCommand.java and populate it with this:

    Code:
    package com.cometproject.server.game.commands.user.room;
    
    
    import com.cometproject.server.config.Locale;
    import com.cometproject.server.game.commands.ChatCommand;
    import com.cometproject.server.game.rooms.objects.items.RoomItem;
    import com.cometproject.server.game.rooms.objects.items.RoomItemFloor;
    import com.cometproject.server.game.rooms.objects.items.RoomItemWall;
    import com.cometproject.server.game.rooms.types.Room;
    import com.cometproject.server.network.sessions.Session;
    
    
    import java.util.ArrayList;
    import java.util.List;
    
    
    
    
    public class EjectAllCommand extends ChatCommand {
        @Override
        public void execute(Session client, String message[]) {
            Room room = client.getPlayer().getEntity().getRoom();
    
    
            if (room == null || !room.getData().getOwner().equals(client.getPlayer().getData().getUsername())) {
                return;
            }
    
    
            List<RoomItem> itemsToRemove = new ArrayList<>();
    
    
            itemsToRemove.addAll(room.getItems().getFloorItems().values());
            itemsToRemove.addAll(room.getItems().getWallItems().values());
    
    
            for (RoomItem item : itemsToRemove) {
                final int ownerId = item.getOwner();
                if(ownerId != room.getData().getOwnerId()) {
                    if (item instanceof RoomItemFloor) {
                        room.getItems().removeNonOwnedItem((RoomItemFloor) item, ownerId);
                    } else if (item instanceof RoomItemWall) {
                        room.getItems().removeNonOwnedItem((RoomItemWall) item, ownerId);
                    }
                }
            }
    
    
            itemsToRemove.clear();
        }
    
    
        @Override
        public String getPermission() {
            return "ejectall_command";
        }
    
    
        @Override
        public String getDescription() {
            return Locale.get("command.ejectall.description");
        }
    }
    Then simply open CommandManager.java and add a new command binding like so:

    Code:
    this.addCommand("ejectall", new EjectAllCommand());
    Was requested by someone I work for however I figured everyone should be able to have this command as it should have been in there by default.
    Last edited by Jonteh; 14-10-16 at 05:19 AM.


  2. #2
    Developer Quackster is online now
    DeveloperRank
    Dec 2010 Join Date
    AustraliaLocation
    3,474Posts

    Re: EjectAll for Comet Server

    Sorry, but can you explain what ejectall does? I seem to be a bit out of touch, never heard of such command before

  3. #3
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,375Posts

    Re: EjectAll for Comet Server

    Quote Originally Posted by Quackster View Post
    Sorry, but can you explain what ejectall does? I seem to be a bit out of touch, never heard of such command before
    "Comet does not have an ejectall command, and the pickall does not take into account items owned by other players."

    :ejectall removes all items not owned by the room owner and returns them to the correct owners inventory.

  4. #4
    iiiiiiiiiii Brought is offline
    MemberRank
    Aug 2013 Join Date
    469Posts

    Re: EjectAll for Comet Server

    Good release. If you build rooms it's definitely annoying having to individually pickup other people's furniture they've dropped if you can't use :ejectall!

  5. #5
    Alpha Member Moogly is offline
    MemberRank
    Feb 2008 Join Date
    Pool LidoLocation
    2,322Posts

    Re: EjectAll for Comet Server

    I thought the reason it didn't have such functionality had to do with not supporting groups because Leon thought they were pointless? Isn't it still a groups feature to have other people's furniture in your room or has that changed since? A bit out of the loop these days on the specifics. Thanks for the release either way.

  6. #6
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,375Posts

    Re: EjectAll for Comet Server

    Quote Originally Posted by Moogly View Post
    I thought the reason it didn't have such functionality had to do with not supporting groups because Leon thought they were pointless? Isn't it still a groups feature to have other people's furniture in your room or has that changed since? A bit out of the loop these days on the specifics. Thanks for the release either way.
    Groups aren't exactly pointless. And they are fully supported in Comet (Badge editor, member management, gates, forums, etc) so I was confused as to why it didn't support eject all, because it's helpful where multiple people are contributing to a room and don't want to lose their rares, especially on economy based hotels.

  7. #7
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,607Posts

    Re: EjectAll for Comet Server

    And groups are amazing. They allow people to build rooms together without having to donate or trade furniture.
    Last edited by Taiga; 13-10-16 at 03:22 PM. Reason: Removed off-topic content

  8. #8
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: EjectAll for Comet Server

    Agree with @Jonteh explanation and @The General point. Using /pickall isn't great. Also a lot of emulator i doesn't see this feature. It's really bad picking all furniture to yourself and don't give back to their respective owners.
    @Jonteh only one question, did you changed also :pickall to don't remove the furnitures of other owners? In Habbo :pickall removes only yours furnitures. And :ejectall remove yours and the others furnitures delivering it to the owners. (When has a Group in the Room). Since in non-group rooms other users can't place furniture, only trade it to the owner. They can control the furnitures placed in the room (position and rotation). Also only in group rooms members with rights can edit interaction stuff of furniture and bots. It's coded in this way in Comet?

    Also how the command will be handled if are triggered by staff members? If a staff does :pickall all the furniture goes to him? And :ejectall will return to respective owners too?

    Anyway, great command release.

  9. #9
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,607Posts

    Re: EjectAll for Comet Server

    Quote Originally Posted by ovflowd View Post
    Also a lot of emulator i doesn't see this feature. It's really bad picking all furniture to yourself and don't give back to their respective owners.
    @Jonteh only one question, did you changed also :pickall to don't remove the furnitures of other owners? In Habbo :pickall removes only yours furnitures. And :ejectall remove yours and the others furnitures delivering it to the owners. (When has a Group in the Room). Since in non-group rooms other users can't place furniture, only trade it to the owner. They can control the furnitures placed in the room (position and rotation). Also only in group rooms members with rights can edit interaction stuff of furniture and bots. It's coded in this way in Comet?

    Also how the command will be handled if are triggered by staff members? If a staff does :pickall all the furniture goes to him? And :ejectall will return to respective owners too?

    Anyway, great command release.
    This is how I did it for Arcturus which has this feature for half a year or so already. Its in the details what makes an emulator great.

  10. #10
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,375Posts

    Re: EjectAll for Comet Server

    Quote Originally Posted by ovflowd View Post
    Agree with @Jonteh explanation and @The General point. Using /pickall isn't great. Also a lot of emulator i doesn't see this feature. It's really bad picking all furniture to yourself and don't give back to their respective owners.
    @Jonteh only one question, did you changed also :pickall to don't remove the furnitures of other owners? In Habbo :pickall removes only yours furnitures. And :ejectall remove yours and the others furnitures delivering it to the owners. (When has a Group in the Room). Since in non-group rooms other users can't place furniture, only trade it to the owner. They can control the furnitures placed in the room (position and rotation). Also only in group rooms members with rights can edit interaction stuff of furniture and bots. It's coded in this way in Comet?

    Also how the command will be handled if are triggered by staff members? If a staff does :pickall all the furniture goes to him? And :ejectall will return to respective owners too?

    Anyway, great command release.
    Yes, pickall only removes the owners furniture now, and ejectall removes the leftover furni that belongs to other players.

    If a staff member does pickall, it reacts the same way as if a normal member was to use it.

    - - - Updated - - -

    Quote Originally Posted by The General View Post
    This is how I did it for Arcturus which has this feature for half a year or so already. Its in the details what makes an emulator great.
    I was really surprised that Comet did not have the command. It was sitting at the bottom of my todo list for about 2 months now :p

    - - - Updated - - -

    Dungoof'd, fixed the snippets.

  11. #11
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: EjectAll for Comet Server

    @Jonteh, but how staff would remove all furnitures from the room if isn't a room group. (Like the furniture of the room is banned/prohibited) and a staff need remove the entirely contents of the room. How he will proceed?

    - - - Updated - - -

    So the :pickall if triggered by a staff will remove all furniture from the room and deliver it to the room owner? and if it's a room group :ejectall will remove all furniture from the room?

  12. #12
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,375Posts

    Re: EjectAll for Comet Server

    Quote Originally Posted by ovflowd View Post
    @Jonteh, but how staff would remove all furnitures from the room if isn't a room group. (Like the furniture of the room is banned/prohibited) and a staff need remove the entirely contents of the room. How he will proceed?

    - - - Updated - - -

    So the :pickall if triggered by a staff will remove all furniture from the room and deliver it to the room owner? and if it's a room group :ejectall will remove all furniture from the room?
    I don't see how any furniture can be banned or prohibited, in all my years of developing and maintaining hotels I've never come across a situation like that.

    If :pickall is triggered by staff, it will not pick any furni. It is like this to prevent abuse, though it would be simple to make it permissions based. :ejectall will always only remove items that don't belong to the room owner and return them to the rightful owners inventory, regardless of who is using the command (staff or room owner.)

    - - - Updated - - -

    Oh also, it applies to _all_ rooms, not just group rooms. So you can build a room with your friends, even if they do not have a group.



Advertisement