Merge branch 'TFM-1.15' of https://github.com/TFPatches/TotalFreedomMod into TFM-1.15

This commit is contained in:
ZeroEpoch1969
2020-02-08 20:54:43 -07:00
9 changed files with 100 additions and 14 deletions

View File

@ -8,11 +8,12 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
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.ChatColor;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@ -103,7 +104,7 @@ public class Command_glist extends FreedomCommand
if (player != null)
{
player.kickPlayer(playerBan.bakeKickMessage());
player.kickPlayer(playerBan.bakeKickMessage(Ips.getIp(player)));
}
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
@ -148,7 +149,7 @@ public class Command_glist extends FreedomCommand
if (player != null)
{
player.kickPlayer(nameBan.bakeKickMessage());
player.kickPlayer(nameBan.bakeKickMessage(Ips.getIp(player)));
}
return true;

View File

@ -56,7 +56,8 @@ public class Command_gtfo extends FreedomCommand
{
final PlayerData entry = plugin.pl.getData(player);
username = player.getName();
ips.addAll(entry.getIps());
//ips.addAll(entry.getIps());
ips.add(Ips.getIp(player));
// Deop
player.setOp(false);
@ -182,7 +183,7 @@ public class Command_gtfo extends FreedomCommand
// Kick player and handle others on IP
if (player != null)
{
player.kickPlayer(ban.bakeKickMessage());
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
for (Player p : Bukkit.getOnlinePlayers())
{
if (Ips.getIp(p).equals(Ips.getIp(player)))

View File

@ -3,14 +3,16 @@ package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all>>", aliases = "ms")
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | remove> <player> <item>>", aliases = "ms")
public class Command_manageshop extends FreedomCommand
{
@Override
@ -21,9 +23,9 @@ public class Command_manageshop extends FreedomCommand
msg("The shop is currently disabled!", ChatColor.RED);
return true;
}
if (!FUtil.isExecutive(sender.getName()))
if (!FUtil.isExecutive(sender.getName()) && !FUtil.isDeveloper(sender.getName()))
{
msg("Only executives can use this command!", ChatColor.RED);
msg("Only executives and developers can use this command!", ChatColor.RED);
return true;
}
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
@ -158,6 +160,63 @@ public class Command_manageshop extends FreedomCommand
return true;
}
}
if (args[0].equalsIgnoreCase("items"))
{
switch (args[1])
{
case "give":
{
Player player = Bukkit.getPlayer(args[2]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
ShopItem item = ShopItem.findItem(args[3]);
if (item == null)
{
msg("Invalid item: " + item);
return true;
}
ShopData sd = plugin.sh.getData(player);
if (sd.hasItem(item))
{
msg("That player already has a(n) " + item.getName() + "!");
return true;
}
String key = sd.giveItem(item);
plugin.sh.save(sd);
FUtil.give(player, item, ChatColor.DARK_GRAY + key);
msg(prefix + ChatColor.GREEN + "Gave " + ChatColor.RED + player.getName() + ChatColor.GREEN + " a(n) " + item.getColoredName());
return true;
}
case "remove":
{
Player player = Bukkit.getPlayer(args[2]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
ShopItem item = ShopItem.findItem(args[3]);
if (item == null)
{
msg("Invalid item: " + item);
return true;
}
ShopData sd = plugin.sh.getData(player);
if (!sd.hasItem(item))
{
msg("That player doesn't have a(n) " + item.getName() + "!");
return true;
}
sd.takeItem(item);
plugin.sh.save(sd);
msg(prefix + ChatColor.GREEN + "Took " + ChatColor.RED + player.getName() + ChatColor.GREEN + "'s " + item.getColoredName());
return true;
}
}
}
}
return false;
}

View File

@ -76,6 +76,10 @@ public class Command_shop extends FreedomCommand
msg(prefix + ChatColor.GREEN + "Available items:");
for (ShopItem item : ShopItem.values())
{
if (!item.isPurchaseable())
{
continue;
}
msg(prefix + ChatColor.AQUA + item.getName() + ChatColor.GREEN + " - " + ChatColor.RED + item.getCost());
}
return true;
@ -133,14 +137,14 @@ public class Command_shop extends FreedomCommand
case "get":
{
ShopItem item = ShopItem.findItem(args[1]);
if (item == null || !item.isPurchaseable())
if (item == null)
{
msg("Invalid item: " + item);
return true;
}
if (!sd.hasItem(item))
{
msg(prefix + ChatColor.GREEN + "You don't have that item! To buy iy, use " + ChatColor.RED + "/shop buy " + item.name() + ChatColor.GREEN + "!");
msg(prefix + ChatColor.GREEN + "You don't have that item! To buy it, use " + ChatColor.RED + "/shop buy " + item.name() + ChatColor.GREEN + "!");
return true;
}
Inventory inv = playerSender.getInventory();