-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Project-Poseidon-Plugins/readdweathercommand
Readd multiworld weather command from reverted "Add extended chat/command functionality" PR
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...amentalsCore/src/main/java/com/johnymuffin/beta/fundamentals/commands/CommandWeather.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.johnymuffin.beta.fundamentals.commands; | ||
import com.johnymuffin.beta.fundamentals.settings.FundamentalsLanguage; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.World; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
public class CommandWeather implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { | ||
Player player; | ||
List<World> worlds = new ArrayList<>(); | ||
String worldarg; | ||
if (!(commandSender.hasPermission("fundamentals.weather") || commandSender.isOp())) { | ||
commandSender.sendMessage(FundamentalsLanguage.getInstance().getMessage("no_permission")); | ||
return true; | ||
} | ||
if (strings.length < 1) { | ||
commandSender.sendMessage(FundamentalsLanguage.getInstance().getMessage("weather_invalid_usage")); | ||
return true; | ||
} | ||
if (strings.length < 2) { | ||
player = (Player) commandSender; | ||
worlds.add(0, player.getWorld()); | ||
} | ||
else { | ||
worldarg = strings[1]; | ||
if (worldarg.equals("all")) { | ||
worlds = Bukkit.getWorlds(); | ||
} | ||
else { | ||
worlds.add(0, Bukkit.getWorld(worldarg)); | ||
} | ||
} | ||
String arg = strings[0].toLowerCase(); | ||
for (World world : worlds) { | ||
switch (arg) { | ||
case "clear": | ||
case "sun": | ||
if (world.hasStorm()) { | ||
world.setThundering(false); | ||
world.setWeatherDuration(5); | ||
} | ||
break; | ||
case "storm": | ||
if (!world.hasStorm()) { | ||
world.setWeatherDuration(5); | ||
} | ||
world.setThundering(true); | ||
break; | ||
case "rain": | ||
if (!world.hasStorm()) { | ||
world.setWeatherDuration(5); | ||
} | ||
world.setThundering(false); | ||
break; | ||
default: | ||
commandSender.sendMessage(FundamentalsLanguage.getInstance().getMessage("weather_invalid_usage")); | ||
return true; | ||
} | ||
commandSender.sendMessage(FundamentalsLanguage.getInstance().getMessage("weather_set_weather") | ||
.replace("%var1%", arg) | ||
.replace("%var2%", world.getName()) | ||
); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters