use of org.blockartistry.DynSurround.data.DimensionEffectData in project DynamicSurroundings by OreCruncher.
the class CommandDS method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] parms) throws CommandException {
try {
final EntityPlayerMP player = getCommandSenderAsPlayer(sender);
final World world = player.world;
final DimensionEffectData data = DimensionEffectData.get(world);
boolean showHelp = false;
TextComponentString feedback = null;
if (parms.length == 0) {
showHelp = true;
} else if (COMMAND_OPTION_RESET.compareToIgnoreCase(parms[0]) == 0) {
world.provider.resetRainAndThunder();
feedback = new TextComponentString(Localization.format("dsurround.msg.RainReset"));
} else if (COMMAND_OPTION_RELOAD.compareToIgnoreCase(parms[0]) == 0) {
MinecraftForge.EVENT_BUS.post(new ReloadEvent.Configuration());
feedback = new TextComponentString(Localization.format("dsurround.msg.BiomeReload"));
} else if (COMMAND_OPTION_CONFIG.compareToIgnoreCase(parms[0]) == 0) {
feedback = new TextComponentString(config(world, data));
} else if (COMMAND_OPTION_STATUS.compareToIgnoreCase(parms[0]) == 0) {
if (parms.length < 2) {
showHelp = true;
} else if (COMMAND_OPTION_RAIN.compareToIgnoreCase(parms[1]) == 0) {
feedback = new TextComponentString(rainStatusOutput(world, data));
} else if (COMMAND_OPTION_THUNDER.compareToIgnoreCase(parms[1]) == 0) {
feedback = new TextComponentString(thunderStatusOutput(world, data));
}
} else if (COMMAND_OPTION_SETTIME.compareToIgnoreCase(parms[0]) == 0) {
if (parms.length < 3) {
showHelp = true;
} else {
final double d = parseDouble(parms[2], 0.0D, 1000.0D) * 20.0D * 60.0D;
if (COMMAND_OPTION_RAIN.compareToIgnoreCase(parms[1]) == 0) {
world.getWorldInfo().setRainTime((int) d);
feedback = new TextComponentString(Localization.format("dsurround.msg.RainTimeSet", FORMATTER.format(d)));
} else if (COMMAND_OPTION_THUNDER.compareToIgnoreCase(parms[1]) == 0) {
world.getWorldInfo().setThunderTime((int) d);
feedback = new TextComponentString(Localization.format("dsurround.msg.ThunderTimeSet", FORMATTER.format(d)));
} else {
showHelp = true;
}
}
} else if (COMMAND_OPTION_SETSTRENGTH.compareToIgnoreCase(parms[0]) == 0) {
if (parms.length < 3) {
showHelp = true;
} else {
final double d = parseDouble(parms[2], 0.0D, 100.0D) / 100.0D;
if (COMMAND_OPTION_RAIN.compareToIgnoreCase(parms[1]) == 0) {
data.setRainIntensity((float) d);
feedback = new TextComponentString(Localization.format("dsurround.msg.RainIntensitySet", FORMATTER.format(data.getRainIntensity() * 100)));
} else {
showHelp = true;
}
}
} else if (COMMAND_OPTION_SETMIN.compareToIgnoreCase(parms[0]) == 0) {
if (parms.length < 3) {
showHelp = true;
} else {
final double d = parseDouble(parms[2], 0.0D, 100.0D) / 100.0D;
if (COMMAND_OPTION_RAIN.compareToIgnoreCase(parms[1]) == 0) {
data.setMinRainIntensity((float) d);
feedback = new TextComponentString(Localization.format("dsurround.msg.MinRainIntensitySet", FORMATTER.format(data.getMinRainIntensity() * 100)));
} else {
showHelp = true;
}
}
} else if (COMMAND_OPTION_SETMAX.compareToIgnoreCase(parms[0]) == 0) {
if (parms.length < 3) {
showHelp = true;
} else {
final double d = parseDouble(parms[2], 0.0D, 100.0D) / 100.0D;
if (COMMAND_OPTION_RAIN.compareToIgnoreCase(parms[1]) == 0) {
data.setMaxRainIntensity((float) d);
feedback = new TextComponentString(Localization.format("dsurround.msg.MaxRainIntensitySet", FORMATTER.format(data.getMaxRainIntensity() * 100)));
} else {
showHelp = true;
}
}
} else {
showHelp = true;
}
if (showHelp) {
for (final String line : HELP) sender.sendMessage(new TextComponentString(line));
} else if (feedback != null) {
player.sendMessage(feedback);
}
} catch (final Exception ex) {
ex.printStackTrace();
}
}
Aggregations