QOL: Add some java commands
Added many commands from Minecraft Java edition:
setblock
fill
seed
xp
gamemode spectator
summon
effect
difficulty
spawnpoint
setworldspawn
kick
enchant
All of the logic is contained inside of PlayerConnection.cpp along with the previous command handler, i also changed MobEffect.h to add a new helper for potion names -> ids.
And for spectator, a bunch of small changes inside server/client related file, along with the removal of the weird /spectator command which was added previously. I think it can still be refined because im not sure the invisibility thing is working.
This commit is contained in:
@@ -1987,8 +1987,11 @@ void ServerPlayer::restoreFrom(shared_ptr<Player> oldPlayer, bool restoreAll)
|
||||
|
||||
void ServerPlayer::onEffectAdded(MobEffectInstance *effect)
|
||||
{
|
||||
Player::onEffectAdded(effect);
|
||||
connection->send(std::make_shared<UpdateMobEffectPacket>(entityId, effect));
|
||||
if (this->connection != nullptr)
|
||||
{
|
||||
Player::onEffectAdded(effect);
|
||||
connection->send(std::make_shared<UpdateMobEffectPacket>(entityId, effect));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2001,8 +2004,11 @@ void ServerPlayer::onEffectUpdated(MobEffectInstance *effect, bool doRefreshAttr
|
||||
|
||||
void ServerPlayer::onEffectRemoved(MobEffectInstance *effect)
|
||||
{
|
||||
Player::onEffectRemoved(effect);
|
||||
connection->send(std::make_shared<RemoveMobEffectPacket>(entityId, effect));
|
||||
if (this->connection != nullptr)
|
||||
{
|
||||
Player::onEffectRemoved(effect);
|
||||
this->connection->send(std::make_shared<RemoveMobEffectPacket>(this->entityId, effect));
|
||||
}
|
||||
}
|
||||
|
||||
void ServerPlayer::teleportTo(double x, double y, double z)
|
||||
@@ -2151,4 +2157,4 @@ bool ServerPlayer::isSpectator()
|
||||
return false;
|
||||
}
|
||||
return gameMode->getGameType() == GameType::SPECTATOR;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user