diff --git a/src/main/java/org/ultramine/commands/basic/VanillaCommands.java b/src/main/java/org/ultramine/commands/basic/VanillaCommands.java index 5e66a84..2be8ae1 100644 --- a/src/main/java/org/ultramine/commands/basic/VanillaCommands.java +++ b/src/main/java/org/ultramine/commands/basic/VanillaCommands.java @@ -14,6 +14,7 @@ import static net.minecraft.util.EnumChatFormatting.*; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.WorldServer; +import net.minecraft.world.storage.WorldInfo; import org.ultramine.commands.Command; import org.ultramine.commands.CommandContext; @@ -172,4 +173,73 @@ ICommandSender to = name.equalsIgnoreCase("server") ? MinecraftServer.getServer() : MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); sendMessage(ctx.getSender(), to, ctx.get("msg").asString()); } + + @Command( + name = "weather", + group = "vanilla", + permissions = {"command.vanilla.weather"}, + syntax = { + "[clear sun rain thunder]", + "[clear sun rain thunder] ", + " [clear sun rain thunder]", + " [clear sun rain thunder] " + } + ) + public static void weather(CommandContext ctx) + { + WorldServer world = ctx.contains("world") ? ctx.get("world").asWorld() : ctx.getSenderAsPlayer().getServerForPlayer(); + WorldInfo wi = world.getWorldInfo(); + int nextchange = ctx.contains("nextchange") ? ctx.get("nextchange").asInt(1, 1000000) * 20 : (300 + world.rand.nextInt(600)) * 20; + + wi.setRainTime(nextchange); + wi.setThunderTime(nextchange); + if(ctx.getAction().equals("clear") || ctx.getAction().equals("sun")) + { + wi.setRaining(false); + wi.setThundering(false); + world.prevRainingStrength = world.rainingStrength = 0F; + world.prevThunderingStrength = world.thunderingStrength = 0F; + ctx.sendMessage("commands.weather.clear"); + } + else if(ctx.getAction().equals("rain")) + { + wi.setRaining(true); + ctx.sendMessage("commands.weather.rain"); + } + else if(ctx.getAction().equals("thunder")) + { + wi.setRaining(true); + wi.setThundering(true); + ctx.sendMessage("commands.weather.thunder"); + } + } + + @Command( + name = "time", + group = "vanilla", + permissions = {"command.vanilla.time"}, + syntax = { + "", + "[set add] ", + " ", + " [set add] ", + } + ) + public static void time(CommandContext ctx) + { + WorldServer world = ctx.contains("world") ? ctx.get("world").asWorld() : ctx.getSenderAsPlayer().getServerForPlayer(); + String timeS = ctx.get("worldtime").asString(); + int time = timeS.equals("day") ? 1000 : timeS.equals("night") ? 13000 : ctx.get("worldtime").asInt(0); + long curTime = world.getWorldInfo().getWorldTime(); + if(ctx.getAction().isEmpty() || ctx.getAction().equals("set")) + { + world.setWorldTime(curTime - (curTime % 24000) + 24000 + time); + ctx.sendMessage("commands.time.set", time); + } + else if(ctx.getAction().equals("add")) + { + world.setWorldTime(curTime + time); + ctx.sendMessage("commands.time.added", time); + } + } } diff --git a/src/main/resources/assets/ultramine/lang/en_US.lang b/src/main/resources/assets/ultramine/lang/en_US.lang index 681a9f0..228e77d 100644 --- a/src/main/resources/assets/ultramine/lang/en_US.lang +++ b/src/main/resources/assets/ultramine/lang/en_US.lang @@ -30,6 +30,12 @@ command.reply.description=Send private message to the last player which you sent message with /msg command.reply.fail=Use /msg command first +command.weather.usage=/weather [world] [nextchange] +command.weather.description=Sets weather in current or specified world + +command.time.usage=/time [world] [add|set] +command.time.description=Sets time in current or specified world + # Permissions command.pconfig.usage=/pconfig command.pconfig.description=Save or reload all permissions configs diff --git a/src/main/resources/assets/ultramine/lang/ru_RU.lang b/src/main/resources/assets/ultramine/lang/ru_RU.lang index feb98b7..7b13568 100644 --- a/src/main/resources/assets/ultramine/lang/ru_RU.lang +++ b/src/main/resources/assets/ultramine/lang/ru_RU.lang @@ -30,6 +30,12 @@ command.reply.description=Отправка приватного сообщения последнему игроку, которому вы отправляли сообщение командой /msg command.reply.fail=Сначала используйте команду /msg +command.weather.usage=/weather [мир] [следующее изменение (секунд)] +command.weather.description=Устанавливает погоду в текущем или указанном мире + +command.time.usage=/time [мир] [add|set] +command.time.description=Устанавливает время суток в текущем или указанном мире + # Permissions command.pconfig.usage=/pconfig command.pconfig.description=Save or reload all permissions configs