use of net.minecraft.server.MinecraftServer in project SecurityCraft by Geforce132.
the class GuiRetinalScannerSetup method actionPerformed.
protected void actionPerformed(GuiButton guibutton) {
switch(guibutton.id) {
case 0:
String players = this.textboxAllowedPlayers.getText();
World W = Minecraft.getMinecraft().theWorld;
MinecraftServer minecraftserver = MinecraftServer.getServer();
try {
if (this.mc.isSingleplayer()) {
//String string = "saves/" + BlockRetinalScanner.worldObj.getSaveHandler().getWorldDirectoryName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ;
//File file = new File(string);
//file.mkdirs();
//file.createNewFile();
//PrintWriter out = new PrintWriter("saves/" + BlockRetinalScanner.worldObj.getSaveHandler().getWorldDirectoryName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ + "/players.txt");
//out.println(players);
//out.close();
} else {
//String string = minecraftserver.getWorldName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ;
//File file = new File(string);
//file.mkdirs();
//file.createNewFile();
//PrintWriter out = new PrintWriter(minecraftserver.getWorldName() + "/SecurityCraft/retScanner/players/" + BlockRetinalScanner.lastScannerX + "-" + BlockRetinalScanner.lastScannerY + "-" + BlockRetinalScanner.lastScannerZ + "/players.txt");
//out.println(players);
//out.close();
}
if (this.mc.isSingleplayer()) {
EntityClientPlayerMP P = Minecraft.getMinecraft().thePlayer;
P.closeScreen();
P.openGui(mod_SecurityCraft.instance, 3, W, (int) P.posX, (int) P.posY, (int) P.posZ);
} else {
//HelpfulMethods.closePlayerScreen(BlockRetinalScanner.playerObj);
//BlockRetinalScanner.playerObj.openGui(mod_SecurityCraft.instance, 3, W, (int) BlockRetinalScanner.playerObj.posX, (int) BlockRetinalScanner.playerObj.posY, (int) BlockRetinalScanner.playerObj.posZ);
}
} catch (Exception e) {
e.printStackTrace();
}
break;
}
}
use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.
the class CommandContaining method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
BlockExpression matcher = parameters.rc().expression(new BlockExpression(RecurrentComplex.specialRegistry)).require();
CommandSearchStructure.postResultMessage(commandSender, RCTextStyle::structure, CommandSearchStructure.search(StructureRegistry.INSTANCE.ids(), name -> containedBlocks(StructureRegistry.INSTANCE.get(name), matcher)));
}
use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.
the class CommandPreview method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
EntityPlayer player = getCommandSenderAsPlayer(commandSender);
RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
Operation.PreviewType previewType = parameters.get().first().map(Operation.PreviewType::find, s -> ServerTranslations.commandException("commands.rcpreview.invalid")).require();
RCEntityInfo.setPreviewType(previewType);
RCEntityInfo.sendPreviewTypeToClients(player);
commandSender.sendMessage(ServerTranslations.format("commands.rcpreview.success", previewType.key));
}
use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.
the class CommandWriteAll method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
String adapterID = parameters.get().first().require();
if (!RecurrentComplex.saver.has(adapterID))
throw ServerTranslations.commandException("commands.rcsaveall.noregistry");
ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
Optional<FileSaverAdapter<?>> adapterOptional = Optional.ofNullable(RecurrentComplex.saver.get(adapterID));
Set<String> ids = adapterOptional.map(a -> a.getRegistry().ids()).orElse(Collections.emptySet());
ResourceExpression resourceExpression = ExpressionCache.of(new ResourceExpression(id -> adapterOptional.map(a -> a.getRegistry().has(id)).orElse(false)), parameters.get().at(1).require());
int saved = 0, failed = 0;
for (String id : ids) {
if (!resourceExpression.test(new RawResourceLocation(adapterOptional.map(a -> a.getRegistry().status(id).getDomain()).orElseThrow(IllegalStateException::new), id)))
continue;
boolean success = RecurrentComplex.saver.trySave(directory.toPath(), adapterID, id);
if (success)
saved++;
else
failed++;
}
commandSender.sendMessage(ServerTranslations.format("commands.rcsaveall.result", saved, directory, failed));
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.CUSTOM);
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.SERVER);
}
use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomFuelsCommand method canCommandSenderUseCommand.
@Override
public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) {
if (pCommandSender instanceof EntityPlayerMP) {
EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender;
boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile());
// && tIncreative;
return tPlayerOpped;
} else if (pCommandSender instanceof MinecraftServer)
return true;
else
return false;
}
Aggregations