use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class WhoAmICommand method executeShared.
private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender) throws CommandException {
if (!(sender instanceof EntityPlayer)) {
Log.getLogger().info("Very funny, you're a console!");
return;
}
final IColony colony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), ((EntityPlayer) sender).getUniqueID());
final BlockPos pos = colony.getCenter();
final String colonyName = colony.getName();
final String playerName = sender.getDisplayName().getFormattedText();
final String posString = "x: " + pos.getX() + " y: " + pos.getY() + " z: " + pos.getZ();
sender.sendMessage(new TextComponentString(String.format(TELL_HIM, playerName, colonyName, posString)));
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class AbstractKillCommand method executeShared.
private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender) throws CommandException {
if (sender instanceof EntityPlayer && !isPlayerOpped(sender)) {
sender.sendMessage(new TextComponentString("Must be OP to use command"));
return;
}
int entitiesKilled = 0;
for (final Entity entity : server.getEntityWorld().getEntities(getEntityClass(), entity -> true)) {
entity.setDead();
entitiesKilled++;
}
sender.sendMessage(new TextComponentString(entitiesKilled + " entities killed"));
}
use of net.minecraft.util.text.TextComponentString in project Minestuck by mraof.
the class ServerEditHandler method newServerEditor.
public static void newServerEditor(EntityPlayerMP player, PlayerIdentifier computerOwner, PlayerIdentifier computerTarget) {
if (player.isRiding())
// Don't want to bother making the decoy able to ride anything right now.
return;
SburbConnection c = SkaianetHandler.getClientConnection(computerTarget);
if (c != null && c.getServerIdentifier().equals(computerOwner) && getData(c) == null && getData(player) == null) {
Debug.info("Activating edit mode on player \"" + player.getName() + "\", target player: \"" + computerTarget + "\".");
EntityDecoy decoy = new EntityDecoy((WorldServer) player.world, player);
EditData data = new EditData(decoy, player, c);
if (!c.enteredGame()) {
c.centerX = c.getClientData().getX();
c.centerZ = c.getClientData().getZ();
}
if (!setPlayerStats(player, c)) {
player.sendMessage(new TextComponentString(TextFormatting.RED + "Failed to activate edit mode."));
return;
}
if (c.inventory != null)
player.inventory.readFromNBT(c.inventory);
decoy.world.spawnEntity(decoy);
list.add(data);
MinestuckPacket packet = MinestuckPacket.makePacket(Type.SERVER_EDIT, computerTarget, c.centerX, c.centerZ, c.givenItems());
MinestuckChannelHandler.sendToPlayer(packet, player);
MinestuckPlayerTracker.updateGristCache(c.getClientIdentifier());
}
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class BuildToolPasteMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final BuildToolPasteMessage message, final EntityPlayerMP player) {
final StructureName sn = new StructureName(message.structureName);
if (!Structures.hasMD5(sn)) {
player.sendMessage(new TextComponentString("Can not build " + message.workOrderName + ": schematic missing!"));
return;
}
if (player.capabilities.isCreativeMode) {
if (message.isHut) {
handleHut(CompatibilityUtils.getWorld(player), player, sn, message.rotation, message.pos, message.mirror);
}
StructureWrapper.loadAndPlaceStructureWithRotation(player.world, message.structureName, message.pos, message.rotation, message.mirror ? Mirror.FRONT_BACK : Mirror.NONE, message.complete);
if (message.isHut) {
@Nullable final AbstractBuilding building = ColonyManager.getBuilding(CompatibilityUtils.getWorld(player), message.pos);
if (building != null) {
final WorkOrderBuild workOrder = new WorkOrderBuild(building, 1);
ConstructionTapeHelper.removeConstructionTape(workOrder, CompatibilityUtils.getWorld(player));
}
}
} else if (message.freeMode != null) {
if (player.getStatFile().readStat(StatList.getObjectUseStats(ModItems.supplyChest)) > 0) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.error.supplyChestAlreadyPlaced");
return;
}
final List<ItemStack> stacks = new ArrayList<>();
final int chestHeight;
if (message.freeMode == WindowBuildTool.FreeMode.SUPPLYSHIP) {
stacks.add(new ItemStack(ModItems.supplyChest));
chestHeight = SUPPLY_SHIP_CHEST_HEIGHT;
} else if (message.freeMode == WindowBuildTool.FreeMode.SUPPLYCAMP) {
stacks.add(new ItemStack(ModItems.supplyCamp));
chestHeight = 1;
} else {
chestHeight = 0;
}
player.addStat(StatList.getObjectUseStats(ModItems.supplyChest));
if (InventoryUtils.removeStacksFromItemHandler(new InvWrapper(player.inventory), stacks)) {
StructureWrapper.loadAndPlaceStructureWithRotation(player.world, message.structureName, message.pos, message.rotation, message.mirror ? Mirror.FRONT_BACK : Mirror.NONE, message.complete);
player.getServerWorld().setBlockState(message.pos.up(chestHeight), Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, player.getHorizontalFacing()));
fillChest((TileEntityChest) player.getServerWorld().getTileEntity(message.pos.up(chestHeight)));
} else {
LanguageHandler.sendPlayerMessage(player, "item.supplyChestDeployer.missing");
}
}
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class SchematicSaveMessage method messageOnServerThread.
@Override
public void messageOnServerThread(final SchematicSaveMessage message, final EntityPlayerMP player) {
if (!MineColonies.isClient() && !Configurations.gameplay.allowPlayerSchematics) {
Log.getLogger().info("SchematicSaveMessage: custom schematic is not allowed on this server.");
player.sendMessage(new TextComponentString("The server does not allow custom schematic!"));
return;
}
if (message.pieces > MAX_AMOUNT_OF_PIECES) {
Log.getLogger().error("Schematic has more than 10 pieces, discarding.");
player.sendMessage(new TextComponentString("Schematic has more than 10 pieces, that's too big!"));
return;
}
final boolean schematicSent;
if (message.data == null) {
Log.getLogger().error("Received empty schematic file");
schematicSent = false;
} else {
schematicSent = Structures.handleSaveSchematicMessage(message.data, message.id, message.pieces, message.piece);
}
if (schematicSent) {
player.sendMessage(new TextComponentString("Schematic successfully sent!"));
} else {
player.sendMessage(new TextComponentString("Failed to send the Schematic!"));
}
}
Aggregations