Skip to content

Commit

Permalink
Merge pull request #19 from Project-Poseidon-Plugins/readdweathercommand
Browse files Browse the repository at this point in the history
Readd multiworld weather command from reverted "Add extended chat/command functionality" PR
  • Loading branch information
sshshark authored Jan 17, 2025
2 parents 66979d2 + 9421eaf commit 36c1a9c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public void onEnable() {
// Bukkit.getPluginCommand("time").setExecutor(new CommandTime(plugin));
// Bukkit.getPluginCommand("ptime").setExecutor(new CommandPTime(plugin));
Bukkit.getPluginCommand("vanish").setExecutor(new CommandVanish(plugin));
Bukkit.getPluginCommand("weather").setExecutor(new CommandWeather());
Bukkit.getPluginCommand("bank").setExecutor(new CommandBank(plugin));
Bukkit.getPluginCommand("balancetop").setExecutor(new CommandBalanceTop(plugin));
Bukkit.getPluginCommand("fakequit").setExecutor(new CommandFakeQuit(plugin));
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ private void loadDefaults() {
map.put("vanish_successful_other_disabled", "&4Disabled vanish for another player.");
map.put("vanish_disable", "&4Vanish Disabled.");
map.put("vanish_enable", "&7Vanish Enabled.");
//Weather
map.put("weather_invalid_usage", "&6Invalid usage: &a/weather <clear|sun|rain|storm> [worldname|all]");
map.put("weather_set_weather", "&7Weather has been set to %var1% in %var2%");
//Clear Inventory
map.put("clearinventory_notice", "&9Your inventory has been cleared");
map.put("clearinventory_successfully", "&9Inventory cleared successfully");
Expand Down
3 changes: 3 additions & 0 deletions FundamentalsCore/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ commands:
vanish:
description: Command to vanish player.
usage: /<command>
weather:
description: Command to change the weather in a world.
usage: /<command> <clear|sun|rain|storm> [worldname|all]
bank:
description: Command to do bank stuff.
usage: /<command>
Expand Down

0 comments on commit 36c1a9c

Please sign in to comment.