mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-05-08 00:26:18 +00:00
Made a couple commands available for the console (ones that make sense to be able to
access from the command line).
This commit is contained in:
parent
238748f360
commit
a86a1990cd
5 changed files with 124 additions and 13 deletions
|
@ -5,6 +5,7 @@ import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,4 +70,36 @@ public class Commandmail extends EssentialsCommand
|
||||||
}
|
}
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||||
|
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
throw new Exception(Util.format("onlyPlayers", commandLabel+" read"));
|
||||||
|
}
|
||||||
|
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
Player player = server.getPlayer(args[1]);
|
||||||
|
User u;
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
u = ess.getUser(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u = ess.getOfflineUser(args[1]);
|
||||||
|
}
|
||||||
|
if (u == null)
|
||||||
|
{
|
||||||
|
throw new Exception(Util.format("playerNeverOnServer", args[1]));
|
||||||
|
}
|
||||||
|
u.addMail("Server: " + getFinalArg(args, 2));
|
||||||
|
sender.sendMessage(Util.i18n("mailSent"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
throw new Exception(Util.format("onlyPlayers", commandLabel+" clear"));
|
||||||
|
}
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
|
@ -13,10 +14,9 @@ public class Commandrealname extends EssentialsCommand
|
||||||
{
|
{
|
||||||
super("realname");
|
super("realname");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||||
{
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
|
@ -36,7 +36,7 @@ public class Commandrealname extends EssentialsCommand
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
user.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
|
sender.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
public class Commandweather extends EssentialsCommand
|
public class Commandweather extends EssentialsCommand
|
||||||
|
@ -29,16 +30,48 @@ public class Commandweather extends EssentialsCommand
|
||||||
world.setStorm(isStorm ? true : false);
|
world.setStorm(isStorm ? true : false);
|
||||||
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
||||||
user.sendMessage(isStorm
|
user.sendMessage(isStorm
|
||||||
? Util.format("weatherStormFor", args[1])
|
? Util.format("weatherStormFor", world.getName(), args[1])
|
||||||
: Util.format("weatherSunFor", args[1]));
|
: Util.format("weatherSunFor", world.getName(), args[1]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
world.setStorm(isStorm ? true : false);
|
world.setStorm(isStorm ? true : false);
|
||||||
user.sendMessage(isStorm
|
user.sendMessage(isStorm
|
||||||
? Util.i18n("weatherStorm")
|
? Util.format("weatherStorm", world.getName())
|
||||||
: Util.i18n("weatherSun"));
|
: Util.format("weatherSun", world.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||||
|
if (args.length < 2) //running from console means inserting a world arg before other args
|
||||||
|
{
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isStorm = args[1].equalsIgnoreCase("storm");
|
||||||
|
World world = server.getWorld(args[0]);
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
throw new Exception("World named "+args[0]+" not found!");
|
||||||
|
}
|
||||||
|
if (args.length > 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
world.setStorm(isStorm ? true : false);
|
||||||
|
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
||||||
|
sender.sendMessage(isStorm
|
||||||
|
? Util.format("weatherStormFor", world.getName(), args[1])
|
||||||
|
: Util.format("weatherSunFor", world.getName(), args[1]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
world.setStorm(isStorm ? true : false);
|
||||||
|
sender.sendMessage(isStorm
|
||||||
|
? Util.format("weatherStorm", world.getName())
|
||||||
|
: Util.format("weatherSun", world.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,4 +58,47 @@ public class Commandworth extends EssentialsCommand
|
||||||
amount,
|
amount,
|
||||||
Util.formatCurrency(worth, ess)));
|
Util.formatCurrency(worth, ess)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack is = ess.getItemDb().get(args[0]);// = user.getInventory().getItemInHand();
|
||||||
|
int amount = is.getAmount();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
amount = Integer.parseInt(args[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
amount = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
is.setAmount(amount);
|
||||||
|
double worth = ess.getWorth().getPrice(is);
|
||||||
|
if (Double.isNaN(worth))
|
||||||
|
{
|
||||||
|
throw new Exception(Util.i18n("itemCannotBeSold"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(is.getDurability() != 0
|
||||||
|
? Util.format("worthMeta",
|
||||||
|
is.getType().toString().toLowerCase().replace("_", ""),
|
||||||
|
is.getDurability(),
|
||||||
|
Util.formatCurrency(worth * amount, ess),
|
||||||
|
amount,
|
||||||
|
Util.formatCurrency(worth, ess))
|
||||||
|
: Util.format("worth",
|
||||||
|
is.getType().toString().toLowerCase().replace("_", ""),
|
||||||
|
Util.formatCurrency(worth * amount, ess),
|
||||||
|
amount,
|
||||||
|
Util.formatCurrency(worth, ess)));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,10 +351,10 @@ warpSet = \u00a77Warp {0} set.
|
||||||
warpUsePermission = \u00a7cYou do not have Permission to use that warp.
|
warpUsePermission = \u00a7cYou do not have Permission to use that warp.
|
||||||
warpingTo = \u00a77Warping to {0}.
|
warpingTo = \u00a77Warping to {0}.
|
||||||
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
|
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
|
||||||
weatherStorm = \u00a77You set the weather to storm in your world
|
weatherStorm = \u00a77You set the weather to storm in {0}
|
||||||
weatherStormFor = \u00a77You set the weather to storm in your world for {0} seconds
|
weatherStormFor = \u00a77You set the weather to storm in {0} for {1} seconds
|
||||||
weatherSun = \u00a77You set the weather to sun in your world
|
weatherSun = \u00a77You set the weather to sun in {0}
|
||||||
weatherSunFor = \u00a77You set the weather to sun in your world for {0} seconds
|
weatherSunFor = \u00a77You set the weather to sun in {0} for {1} seconds
|
||||||
whoisGeoLocation = \u00a79 - Location: {0}
|
whoisGeoLocation = \u00a79 - Location: {0}
|
||||||
whoisHealth = \u00a79 - Health: {0}/20
|
whoisHealth = \u00a79 - Health: {0}/20
|
||||||
whoisIPAddress = \u00a79 - IP Address: {0}
|
whoisIPAddress = \u00a79 - IP Address: {0}
|
||||||
|
|
Loading…
Reference in a new issue