use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.
the class Command_tag method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 1) {
if ("list".equalsIgnoreCase(args[0])) {
msg("Tags for all online players:");
for (final Player player : server.getOnlinePlayers()) {
final FPlayer playerdata = plugin.pl.getPlayer(player);
if (playerdata.getTag() != null) {
msg(player.getName() + ": " + playerdata.getTag());
}
}
return true;
} else if ("clearall".equalsIgnoreCase(args[0])) {
if (!plugin.al.isAdmin(sender)) {
noPerms();
return true;
}
FUtil.adminAction(sender.getName(), "Removing all tags", false);
int count = 0;
for (final Player player : server.getOnlinePlayers()) {
final FPlayer playerdata = plugin.pl.getPlayer(player);
if (playerdata.getTag() != null) {
count++;
playerdata.setTag(null);
}
}
msg(count + " tag(s) removed.");
return true;
} else if ("off".equalsIgnoreCase(args[0])) {
if (senderIsConsole) {
msg("\"/tag off\" can't be used from the console. Use \"/tag clear <player>\" or \"/tag clearall\" instead.");
} else {
plugin.pl.getPlayer(playerSender).setTag(null);
msg("Your tag has been removed.");
}
return true;
} else {
return false;
}
} else if (args.length >= 2) {
if ("clear".equalsIgnoreCase(args[0])) {
if (!plugin.al.isAdmin(sender)) {
noPerms();
return true;
}
final Player player = getPlayer(args[1]);
if (player == null) {
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
plugin.pl.getPlayer(player).setTag(null);
msg("Removed " + player.getName() + "'s tag.");
return true;
} else if ("set".equalsIgnoreCase(args[0])) {
final String inputTag = StringUtils.join(args, " ", 1, args.length);
final String outputTag = FUtil.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag), new String[] { "" + ChatColor.COLOR_CHAR, "&k" }, new String[] { "", "" })) + ChatColor.RESET;
if (!plugin.al.isAdmin(sender)) {
final String rawTag = ChatColor.stripColor(outputTag).toLowerCase();
if (rawTag.length() > 20) {
msg("That tag is too long (Max is 20 characters).");
return true;
}
for (String word : FORBIDDEN_WORDS) {
if (rawTag.contains(word)) {
msg("That tag contains a forbidden word.");
return true;
}
}
}
plugin.pl.getPlayer(playerSender).setTag(outputTag);
msg("Tag set to '" + outputTag + "'.");
return true;
} else {
return false;
}
} else {
return false;
}
}
use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.
the class Command_tagnyan method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length < 1) {
return false;
}
final StringBuilder tag = new StringBuilder();
for (char c : ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))).toCharArray()) {
tag.append(FUtil.randomChatColor()).append(c);
}
String tagStr = tag.toString();
for (String word : Command_tag.FORBIDDEN_WORDS) {
if (tagStr.contains(word)) {
msg("That tag contains a forbidden word.");
return true;
}
}
final FPlayer data = plugin.pl.getPlayer(playerSender);
data.setTag(tagStr);
msg("Set tag to " + tag);
return true;
}
use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.
the class Command_tossmob method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (!ConfigEntry.TOSSMOB_ENABLED.getBoolean()) {
msg("Tossmob is currently disabled.");
return true;
}
FPlayer playerData = plugin.pl.getPlayer(playerSender);
EntityType type = null;
if (args.length >= 1) {
if ("off".equals(args[0])) {
playerData.disableMobThrower();
msg("MobThrower is disabled.", ChatColor.GREEN);
return true;
}
if (args[0].equalsIgnoreCase("list")) {
StringBuilder sb = new StringBuilder();
for (EntityType loop : EntityType.values()) {
if (loop.isAlive()) {
sb.append(" ").append(DepreciationAggregator.getName_EntityType(loop));
}
}
msg("Supported mobs: " + sb.toString().trim(), ChatColor.GREEN);
return true;
}
for (EntityType loopType : EntityType.values()) {
if (DepreciationAggregator.getName_EntityType(loopType).toLowerCase().equalsIgnoreCase(args[0])) {
type = loopType;
break;
}
}
if (type == null) {
msg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
msg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
type = EntityType.PIG;
}
}
double speed = 1.0;
if (args.length >= 2) {
try {
speed = Double.parseDouble(args[1]);
} catch (NumberFormatException nfex) {
}
}
if (speed < 1.0) {
speed = 1.0;
} else if (speed > 5.0) {
speed = 5.0;
}
playerData.enableMobThrower(type, speed);
msg("MobThrower is enabled. Creature: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
return true;
}
use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.
the class RankManager method onPlayerJoin.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
//plugin.pl.getData(player);
final FPlayer fPlayer = plugin.pl.getPlayer(player);
// Unban admins
boolean isAdmin = plugin.al.isAdmin(player);
if (isAdmin) {
// Verify strict IP match
if (!plugin.al.isIdentityMatched(player)) {
FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
fPlayer.setSuperadminIdVerified(false);
} else {
fPlayer.setSuperadminIdVerified(true);
plugin.al.updateLastLogin(player);
}
}
// Handle impostors
if (plugin.al.isAdminImpostor(player)) {
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
player.getInventory().clear();
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
plugin.pl.getPlayer(player).getFreezeData().setFrozen(true);
player.sendMessage(ChatColor.RED + "You are marked as an impostor, please verify yourself!");
return;
}
// Set display
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName())) {
final Displayable display = getDisplay(player);
String loginMsg = display.getColoredLoginMessage();
if (isAdmin) {
Admin admin = plugin.al.getAdmin(player);
if (admin.hasLoginMessage()) {
loginMsg = ChatUtils.colorize(admin.getLoginMessage());
}
}
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg);
plugin.pl.getPlayer(player).setTag(display.getColoredTag());
String displayName = display.getColor() + player.getName();
try {
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
} catch (IllegalArgumentException ex) {
}
}
}
use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.
the class Command_orbit method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 0) {
return false;
}
Player player = getPlayer(args[0]);
if (player == null) {
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
double strength = 10.0;
if (args.length >= 2) {
if (args[1].equals("stop")) {
msg("Stopped orbiting " + player.getName());
playerdata.stopOrbiting();
return true;
}
try {
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
} catch (NumberFormatException ex) {
msg(ex.getMessage(), ChatColor.RED);
return true;
}
}
player.setGameMode(GameMode.SURVIVAL);
playerdata.startOrbiting(strength);
player.setVelocity(new Vector(0, strength, 0));
FUtil.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
return true;
}
Aggregations