mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Finished /potion command.
Added /lockup all and /lockup purge.
This commit is contained in:
parent
1551d29cc2
commit
5ed6df2306
@ -1,32 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Command_levelup extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.isOp())
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
sender_p.setExp(1.0f);
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "Level up!");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -21,11 +21,33 @@ public class Command_lockup extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 2)
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
startLockup(p);
|
||||
}
|
||||
sender.sendMessage(ChatColor.GRAY + "Locking up all players.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
cancelLockup(p);
|
||||
}
|
||||
sender.sendMessage(ChatColor.GRAY + "Not locking up all players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("on"))
|
||||
{
|
||||
final Player p;
|
||||
try
|
||||
{
|
||||
@ -37,40 +59,34 @@ public class Command_lockup extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||
|
||||
if (args[1].equalsIgnoreCase("on"))
|
||||
{
|
||||
cancelLockup(playerdata);
|
||||
|
||||
playerdata.setLockupScheduleID(server.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
private Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.openWorkbench(null, true);
|
||||
|
||||
Location l = p.getLocation().clone();
|
||||
l.setPitch(random.nextFloat() * 360.0f);
|
||||
l.setYaw(random.nextFloat() * 360.0f);
|
||||
p.teleport(l);
|
||||
}
|
||||
}, 0L, 5L));
|
||||
|
||||
startLockup(p);
|
||||
sender.sendMessage(ChatColor.GRAY + "Locking up " + p.getName());
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("off"))
|
||||
{
|
||||
cancelLockup(playerdata);
|
||||
final Player p;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
cancelLockup(p);
|
||||
sender.sendMessage(ChatColor.GRAY + "Not locking up " + p.getName() + " anymore.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -85,4 +101,32 @@ public class Command_lockup extends TFM_Command
|
||||
playerdata.setLockupScheduleID(-1);
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelLockup(final Player p)
|
||||
{
|
||||
cancelLockup(TFM_UserInfo.getPlayerData(p));
|
||||
}
|
||||
|
||||
private void startLockup(final Player p)
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
||||
|
||||
cancelLockup(playerdata);
|
||||
|
||||
playerdata.setLockupScheduleID(server.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
private Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.openWorkbench(null, true);
|
||||
|
||||
Location l = p.getLocation().clone();
|
||||
l.setPitch(random.nextFloat() * 360.0f);
|
||||
l.setYaw(random.nextFloat() * 360.0f);
|
||||
p.teleport(l);
|
||||
}
|
||||
}, 0L, 5L));
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,15 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Command_potion extends TFM_Command
|
||||
{
|
||||
@ -27,21 +29,128 @@ public class Command_potion extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
if (args.length == 1 || args.length == 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
List potionTypeNames = new ArrayList<String>();
|
||||
for (PotionType potion_type : PotionType.values())
|
||||
List<String> potionEffectTypeNames = new ArrayList<String>();
|
||||
for (PotionEffectType potion_effect_type : PotionEffectType.values())
|
||||
{
|
||||
potionTypeNames.add(potion_type.name());
|
||||
if (potion_effect_type != null)
|
||||
{
|
||||
potionEffectTypeNames.add(potion_effect_type.getName());
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "Potion types: " + StringUtils.join(potionTypeNames, ", "));
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "Potion effect types: " + StringUtils.join(potionEffectTypeNames, ", "));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
Player target = sender_p;
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
target = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!target.equals(sender_p) && !TFM_Util.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage("Only superadmins can clear potion effects from other players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PotionEffect potion_effect : sender_p.getActivePotionEffects())
|
||||
{
|
||||
target.removePotionEffect(potion_effect.getType());
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "Cleared all active potion effects " + (!target.equals(sender_p) ? "from player " + target.getName() + "." : "from yourself."));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (args.length == 4 || args.length == 5)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
Player target = sender_p;
|
||||
|
||||
if (args.length == 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
target = getPlayer(args[4]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!target.equals(sender_p) && !TFM_Util.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage("Only superadmins can apply potion effects to other players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
|
||||
if (potion_effect_type == null)
|
||||
{
|
||||
sender.sendMessage(ChatColor.AQUA + "Invalid potion effect type.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int duration;
|
||||
try
|
||||
{
|
||||
duration = Integer.parseInt(args[2]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.AQUA + "Invalid potion duration.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int amplifier;
|
||||
try
|
||||
{
|
||||
amplifier = Integer.parseInt(args[3]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.AQUA + "Invalid potion amplifier.");
|
||||
return true;
|
||||
}
|
||||
|
||||
PotionEffect new_effect = potion_effect_type.createEffect(duration, amplifier);
|
||||
target.addPotionEffect(new_effect, true);
|
||||
sender.sendMessage(ChatColor.AQUA
|
||||
+ "Added potion effect: " + new_effect.getType().getName()
|
||||
+ ", Duration: " + new_effect.getDuration()
|
||||
+ ", Amplifier: " + new_effect.getAmplifier()
|
||||
+ (!target.equals(sender_p) ? " to player " + target.getName() + "." : " to yourself."));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -455,6 +455,10 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
else if (Pattern.compile("^/toggledownfall").matcher(command).find())
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (block_command)
|
||||
|
@ -88,16 +88,13 @@ commands:
|
||||
lavaplace:
|
||||
description: Superadmin command - Enable/disable lava placement.
|
||||
usage: /<command> <on | off>
|
||||
# levelup:
|
||||
# description: Level up!
|
||||
# usage: /<command>
|
||||
list:
|
||||
description: Lists the real names of all online players.
|
||||
usage: /<command>
|
||||
aliases: [who]
|
||||
lockup:
|
||||
description: Console command - Block target's minecraft input. This is evil, and I never should have wrote it.
|
||||
usage: /<command> <partialname> <on | off>
|
||||
usage: /<command> <all | purge | <<partialname> on | off>>
|
||||
moblimiter:
|
||||
description: Owner command - Controll mob rezzing parameters.
|
||||
usage: /<command> <on|off|setmax <count>|dragon|giant|ghast|slime>
|
||||
@ -134,9 +131,9 @@ commands:
|
||||
permban:
|
||||
description: Manage permanently banned players and IPs
|
||||
usage: /<command> <list | reload>
|
||||
# potion:
|
||||
# description: Manipulate potion effects.
|
||||
# usage: /<command> <list>
|
||||
potion:
|
||||
description: Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).
|
||||
usage: /<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>
|
||||
prelog:
|
||||
description: Superadmin command - Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.
|
||||
usage: /<command> <on | off>
|
||||
@ -216,7 +213,7 @@ commands:
|
||||
wildcard:
|
||||
description: Superadmin command - Run any command on all users, username placeholder = ?.
|
||||
usage: /<command> [fluff] ? [fluff] ?
|
||||
# wipeflatlands:
|
||||
# wipeflatlands: - Currently broken.
|
||||
# description: Owner command - Wipe the flatlands map.
|
||||
# usage: /<command>
|
||||
ziptool:
|
||||
|
Loading…
Reference in New Issue
Block a user