Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

EjectAll for Comet Server

Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
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:
Developer
Developer
Joined
Dec 11, 2010
Messages
2,955
Reaction score
2,688
Sorry, but can you explain what ejectall does? I seem to be a bit out of touch, never heard of such command before :p:
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
Sorry, but can you explain what ejectall does? I seem to be a bit out of touch, never heard of such command before :p:

"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.
 
Elite Diviner
Joined
Aug 4, 2013
Messages
466
Reaction score
169
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!
 
Software Engineer
Loyal Member
Joined
Feb 19, 2008
Messages
1,055
Reaction score
492
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.
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
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.
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,171
Reaction score
916
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.
 
Joined
Aug 10, 2011
Messages
7,398
Reaction score
3,301
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.
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
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.



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



Dungoof'd, fixed the snippets.
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,171
Reaction score
916
@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?



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?
 
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
@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?



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.)



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.
 
Back
Top