use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class ChangeFreeToInteractBlockMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final ChangeFreeToInteractBlockMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony != null) {
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.EDIT_PERMISSIONS)) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.item.permissionscepter.permission.deny");
return;
}
if (message.type == MessageType.ADD_BLOCK) {
switch(message.mode) {
case LOCATION:
colony.addFreePosition(message.pos);
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.item.permissionscepter.addposition.success", message.pos.getX(), message.pos.getY(), message.pos.getZ());
break;
case BLOCK:
colony.addFreeBlock(message.block);
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.item.permissionscepter.addblock.success", message.block.getRegistryName());
break;
default:
}
} else {
switch(message.mode) {
case LOCATION:
colony.removeFreePosition(message.pos);
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.item.permissionscepter.removelocation.success", message.pos.getX(), message.pos.getY(), message.pos.getZ());
break;
case BLOCK:
colony.removeFreeBlock(message.block);
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.item.permissionscepter.removeblock.success", message.block.getRegistryName());
break;
default:
}
}
}
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class GeneralEntityWalkToProxy method getWayPoints.
@Override
public Set<BlockPos> getWayPoints() {
final EntityLiving living = getEntity();
final Colony colony = ColonyManager.getClosestColony(living.getEntityWorld(), living.getPosition());
if (colony == null || !colony.isCoordInColony(living.getEntityWorld(), living.getPosition())) {
return Collections.emptySet();
}
return colony.getWayPoints().keySet();
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class AddRemoveRecipeMessage method messageOnServerThread.
/**
* Executes the message on the server thread.
* Only if the player has the permission, toggle message.
*
* @param message the original message.
* @param player the player associated.
*/
@Override
public void messageOnServerThread(final AddRemoveRecipeMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony == null || !colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final AbstractBuilding buildingWorker = colony.getBuildingManager().getBuilding(message.building);
if (buildingWorker instanceof AbstractBuildingWorker) {
final IToken token = ColonyManager.getRecipeManager().checkOrAddRecipe(message.storage);
if (message.remove) {
((AbstractBuildingWorker) buildingWorker).removeRecipe(token);
} else {
((AbstractBuildingWorker) buildingWorker).addRecipe(token);
}
buildingWorker.markDirty();
}
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class AssignUnassignMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final AssignUnassignMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony != null) {
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final AbstractBuilding building = colony.getBuildingManager().getBuilding(message.buildingId);
if (!(building instanceof BuildingHome)) {
return;
}
final CitizenData citizen = colony.getCitizenManager().getCitizen(message.citizenID);
if (message.assign && !((BuildingHome) building).isFull() && citizen.getHomeBuilding() == null) {
((BuildingHome) building).addResident(citizen);
} else if (((BuildingHome) building).hasResident(citizen)) {
building.removeCitizen(citizen);
}
}
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class GuardTaskMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final GuardTaskMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony != null) {
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
@Nullable final AbstractBuildingGuards building = colony.getBuildingManager().getBuilding(message.buildingId, AbstractBuildingGuards.class);
if (building != null) {
if (message.job != -1) {
building.setJob(AbstractBuildingGuards.GuardJob.values()[message.job]);
}
building.setAssignManually(message.assignmentMode);
building.setPatrolManually(message.patrollingMode);
building.setRetrieveOnLowHealth(message.retrieval);
building.setTask(AbstractBuildingGuards.Task.values()[message.task]);
if (building.getTask().equals(AbstractBuildingGuards.Task.FOLLOW)) {
building.setPlayerToFollow(player);
}
}
}
}
Aggregations