mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-08 16:31:58 +01:00
[trunk] weather / thunder refactor
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1277 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
80eee83f10
commit
6a892fcfc1
@ -4,10 +4,12 @@ import com.earth2me.essentials.Essentials;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
|
||||||
public class Commandthunder extends EssentialsCommand
|
public class Commandthunder extends EssentialsCommand
|
||||||
{
|
{
|
||||||
public Commandthunder()
|
public Commandthunder()
|
||||||
{
|
{
|
||||||
super("thunder");
|
super("thunder");
|
||||||
}
|
}
|
||||||
@ -15,56 +17,34 @@ public class Commandthunder extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
switch (args.length)
|
|
||||||
{
|
if (args.length < 1)
|
||||||
case 0:
|
{
|
||||||
if (user.isAuthorized("essentials.thunder"))
|
user.sendMessage("§cUsage: /" + commandLabel + " <true/false> [duration]");
|
||||||
{
|
return;
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <true/false> [duration]");
|
}
|
||||||
break;
|
|
||||||
}
|
if (!user.isAuthorized(this))
|
||||||
user.sendMessage("§cYou are not allowed to change the thunder");
|
{
|
||||||
break;
|
user.sendMessage("§cThe power of the Thor has been denied to you");
|
||||||
case 1:
|
return;
|
||||||
if (user.isAuthorized("essentials.thunder"))
|
}
|
||||||
{
|
|
||||||
if(args[0].equalsIgnoreCase("true"))
|
user.charge(this);
|
||||||
{
|
World world = user.getWorld();
|
||||||
user.getWorld().setThundering(true);
|
boolean setThunder = args[0].equalsIgnoreCase("true");
|
||||||
user.sendMessage("§7You enabled thunder in your world");
|
if (!args[1].isEmpty() || args[1] != null)
|
||||||
break;
|
{
|
||||||
}
|
|
||||||
if(args[0].equalsIgnoreCase("false"))
|
world.setThundering(setThunder ? true : false);
|
||||||
{
|
world.setThunderDuration(Integer.parseInt(args[1]) * 20);
|
||||||
user.getWorld().setThundering(false);
|
user.sendMessage("§7You " + (setThunder ? "enabled" : "disabled") + " thunder in your world for " + args[1] + " seconds");
|
||||||
user.sendMessage("§7You disabled thunder in your world");
|
}
|
||||||
break;
|
else
|
||||||
}
|
{
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <true/false> [duration]");
|
world.setThundering(setThunder ? true : false);
|
||||||
}
|
user.sendMessage("§7You " + (setThunder ? "enabled" : "disabled") + " thunder in your world");
|
||||||
user.sendMessage("§cYou are not allowed to change the thunder");
|
}
|
||||||
break;
|
|
||||||
case 2:
|
}
|
||||||
if (user.isAuthorized("essentials.thunder"))
|
|
||||||
{
|
|
||||||
if(args[0].equalsIgnoreCase("true"))
|
|
||||||
{
|
|
||||||
user.getWorld().setThundering(true);
|
|
||||||
user.getWorld().setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
|
||||||
user.sendMessage("§7You enabled thunder in your world for " + args[1] + " seconds");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(args[0].equalsIgnoreCase("false"))
|
|
||||||
{
|
|
||||||
user.getWorld().setThundering(false);
|
|
||||||
user.getWorld().setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
|
||||||
user.sendMessage("§7You disabled thunder in your world for " + args[1] + " seconds");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <true/false> [duration]");
|
|
||||||
}
|
|
||||||
user.sendMessage("§cYou are not allowed to change the thunder");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.Essentials;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
|
||||||
public class Commandweather extends EssentialsCommand
|
public class Commandweather extends EssentialsCommand
|
||||||
@ -16,41 +17,37 @@ public class Commandweather extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
switch (args.length)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
case 0:
|
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <storm/sun> [duration]");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (args[0].equalsIgnoreCase("storm"))
|
|
||||||
{
|
|
||||||
user.getWorld().setStorm(true);
|
|
||||||
user.sendMessage("§7You set the weather in your world to storm");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("sun"))
|
|
||||||
{
|
|
||||||
user.getWorld().setStorm(false);
|
|
||||||
user.sendMessage("§7You set the weather in your world to sun");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <storm/sun> [duration]");
|
|
||||||
case 2:
|
|
||||||
if (args[0].equalsIgnoreCase("storm"))
|
|
||||||
{
|
|
||||||
user.getWorld().setStorm(true);
|
|
||||||
user.getWorld().setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
|
||||||
user.sendMessage("§7You set the weather in your world to storm for " + args[1] + " seconds");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("sun"))
|
|
||||||
{
|
|
||||||
user.getWorld().setStorm(false);
|
|
||||||
user.getWorld().setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
|
||||||
user.sendMessage("§7You set the weather in your world to sun for " + args[1] + " seconds");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " <storm/sun> [duration]");
|
user.sendMessage("§cUsage: /" + commandLabel + " <storm/sun> [duration]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.isAuthorized(this))
|
||||||
|
{
|
||||||
|
user.sendMessage("§cThe power of the sky has been denied to you");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isStorm = args[0].equalsIgnoreCase("storm");
|
||||||
|
World world = user.getWorld();
|
||||||
|
user.charge(this);
|
||||||
|
if (!args[1].isEmpty() || args[1] != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
world.setStorm(isStorm ? true : false);
|
||||||
|
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
||||||
|
user.sendMessage("§7You set the weather to " + (isStorm ? "storm" : "sun") + " in your world for " + args[1] + " seconds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
world.setStorm(isStorm ? true : false);
|
||||||
|
user.sendMessage("§7You set the weather to " + (isStorm ? "storm" : "sun") + " in your world");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user