mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-20 14:25:00 +00:00
c4fce3f0f9
* Command_adminworld.java * Command_adventure.java * Command_banip.java * Command_blockedit.java * Command_blockpvp.java * Command_cage.java * Command_cartsit.java * Command_clearchat.java * Command_clearinventory.java * Command_commandlist.java * Command_creative.java * Command_deop.java * Command_deopall.java * Command_dispfill.java * Command_doom.java * Command_gcmd.java * Command_hubworld.java * Command_inspect.java * Command_list.java * Command_lockup.java * Command_manageshop.java * Command_manuallyverify.java * Command_masterbuilderworld.java * Command_mbconfig.java * Command_moblimiter.java * Command_mp44.java * Command_mute.java * Command_nickfilter.java * Command_op.java * Command_opall.java * Command_opme.java * Command_potion.java (Also corrected the inconsistent "player not found" message's color) * Command_rank.java * Command_ride.java * Command_saconfig.java * Command_scare.java * Command_setplayerlimit.java * Command_settotalvotes.java * Command_smite.java * Command_spectator.java * Command_survival.java * Command_unblockcmd.java * Command_uncage.java * Command_unmute.java * Command_verifynoadmin.java Here are some commands I added functionality to: * Command_dispfill.java: Added some code that hooks into the CoreProtect API to log the items being removed from and added into the dispensers. * Command_setlever.java: Added some code that hooks into the CoreProtect API to log the levers being interacted with. Here's a command I fixed a critical bug in: * Command_setlever.java
149 lines
4.5 KiB
Java
149 lines
4.5 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
|
public class Command_cage extends FreedomCommand
|
|
{
|
|
|
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
|
{
|
|
if (args.length == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
String skullName = null;
|
|
if (args[0].equalsIgnoreCase("purge"))
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
|
for (Player player : server.getOnlinePlayers())
|
|
{
|
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
fPlayer.getCageData().setCaged(false);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
Player player = getPlayer(args[0]);
|
|
if (player == null)
|
|
{
|
|
msg(PLAYER_NOT_FOUND);
|
|
return true;
|
|
}
|
|
|
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
if (fPlayer.getCageData().isCaged())
|
|
{
|
|
msg("That player is already caged.", ChatColor.RED);
|
|
return true;
|
|
}
|
|
|
|
Material outerMaterial = Material.GLASS;
|
|
Material innerMaterial = Material.AIR;
|
|
if (args.length >= 2 && args[1] != null)
|
|
{
|
|
final String s = args[1];
|
|
switch (s)
|
|
{
|
|
case "head":
|
|
{
|
|
outerMaterial = Material.PLAYER_HEAD;
|
|
if (args.length >= 3)
|
|
{
|
|
skullName = args[2];
|
|
}
|
|
else
|
|
{
|
|
outerMaterial = Material.SKELETON_SKULL;
|
|
}
|
|
break;
|
|
}
|
|
case "block":
|
|
{
|
|
if (Material.matchMaterial(args[2]) != null)
|
|
{
|
|
outerMaterial = Material.matchMaterial(args[2]);
|
|
break;
|
|
}
|
|
msg("Invalid block!", ChatColor.RED);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
|
|
|
if (skullName != null)
|
|
{
|
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
|
}
|
|
else
|
|
{
|
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
|
}
|
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
|
|
if (outerMaterial == Material.PLAYER_HEAD)
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
|
}
|
|
else
|
|
{
|
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
{
|
|
if (!plugin.al.isAdmin(sender))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (args.length == 1)
|
|
{
|
|
List<String> arguments = new ArrayList<>();
|
|
arguments.add("purge");
|
|
arguments.addAll(FUtil.getPlayerList());
|
|
return arguments;
|
|
}
|
|
else if (args.length == 2)
|
|
{
|
|
if (!args[0].equals("purge"))
|
|
{
|
|
return Arrays.asList("head", "block");
|
|
}
|
|
}
|
|
else if (args.length == 3)
|
|
{
|
|
if (args[1].equals("block"))
|
|
{
|
|
return FUtil.getAllMaterialNames();
|
|
}
|
|
else if (args[1].equals("head"))
|
|
{
|
|
return FUtil.getPlayerList();
|
|
}
|
|
}
|
|
|
|
return Collections.emptyList();
|
|
}
|
|
} |