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
commit b2abc1db45
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
9 changed files with 100 additions and 14 deletions

View File

@ -8,3 +8,7 @@ This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van d
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md). For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
### Compiling ###
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now.

View File

@ -171,7 +171,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return hasExpiry() && expiryUnix < FUtil.getUnixTime(); return hasExpiry() && expiryUnix < FUtil.getUnixTime();
} }
public String bakeKickMessage() public String bakeKickMessage(String ip)
{ {
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You"); final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
@ -203,6 +203,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix))); .append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
} }
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
.append(ip);
return message.toString(); return message.toString();
} }

View File

@ -246,7 +246,7 @@ public class BanManager extends FreedomService
if (ban != null && !ban.isExpired()) if (ban != null && !ban.isExpired())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage()); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip));
} }
} }

View File

@ -8,11 +8,12 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType; import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.ChatColor;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg; import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@ -103,7 +104,7 @@ public class Command_glist extends FreedomCommand
if (player != null) 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)); 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) if (player != null)
{ {
player.kickPlayer(nameBan.bakeKickMessage()); player.kickPlayer(nameBan.bakeKickMessage(Ips.getIp(player)));
} }
return true; return true;

View File

@ -56,7 +56,8 @@ public class Command_gtfo extends FreedomCommand
{ {
final PlayerData entry = plugin.pl.getData(player); final PlayerData entry = plugin.pl.getData(player);
username = player.getName(); username = player.getName();
ips.addAll(entry.getIps()); //ips.addAll(entry.getIps());
ips.add(Ips.getIp(player));
// Deop // Deop
player.setOp(false); player.setOp(false);
@ -182,7 +183,7 @@ public class Command_gtfo extends FreedomCommand
// Kick player and handle others on IP // Kick player and handle others on IP
if (player != null) if (player != null)
{ {
player.kickPlayer(ban.bakeKickMessage()); player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers())
{ {
if (Ips.getIp(p).equals(Ips.getIp(player))) 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.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.shop.ShopData; import me.totalfreedom.totalfreedommod.shop.ShopData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) @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 public class Command_manageshop extends FreedomCommand
{ {
@Override @Override
@ -21,9 +23,9 @@ public class Command_manageshop extends FreedomCommand
msg("The shop is currently disabled!", ChatColor.RED); msg("The shop is currently disabled!", ChatColor.RED);
return true; 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; return true;
} }
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " "); final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
@ -158,6 +160,63 @@ public class Command_manageshop extends FreedomCommand
return true; 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; return false;
} }

View File

@ -76,6 +76,10 @@ public class Command_shop extends FreedomCommand
msg(prefix + ChatColor.GREEN + "Available items:"); msg(prefix + ChatColor.GREEN + "Available items:");
for (ShopItem item : ShopItem.values()) for (ShopItem item : ShopItem.values())
{ {
if (!item.isPurchaseable())
{
continue;
}
msg(prefix + ChatColor.AQUA + item.getName() + ChatColor.GREEN + " - " + ChatColor.RED + item.getCost()); msg(prefix + ChatColor.AQUA + item.getName() + ChatColor.GREEN + " - " + ChatColor.RED + item.getCost());
} }
return true; return true;
@ -133,14 +137,14 @@ public class Command_shop extends FreedomCommand
case "get": case "get":
{ {
ShopItem item = ShopItem.findItem(args[1]); ShopItem item = ShopItem.findItem(args[1]);
if (item == null || !item.isPurchaseable()) if (item == null)
{ {
msg("Invalid item: " + item); msg("Invalid item: " + item);
return true; return true;
} }
if (!sd.hasItem(item)) 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; return true;
} }
Inventory inv = playerSender.getInventory(); Inventory inv = playerSender.getInventory();

View File

@ -366,13 +366,13 @@ public class ItemFun extends FreedomService
} }
String key = psd.giveItem(ShopItem.SUPERIOR_SWORD); String key = psd.giveItem(ShopItem.SUPERIOR_SWORD);
FUtil.bcastMsg("THOR'S STAR HAS GRANTED " + rplayer.getName().toUpperCase() + " A " + ChatColor.GOLD + "SUPERIOR SWORD" + ChatColor.RED + "!!!!", ChatColor.RED); FUtil.bcastMsg("THOR'S STAR HAS GRANTED " + rplayer.getName().toUpperCase() + " A " + ChatColor.GOLD + "SUPERIOR SWORD" + ChatColor.RED + "!!!!", ChatColor.RED);
FUtil.give(player, ShopItem.SUPERIOR_SWORD, "&7RMB - Shoot fireball", ChatColor.DARK_GRAY + key); FUtil.give(rplayer, ShopItem.SUPERIOR_SWORD, "&7RMB - Shoot fireball", ChatColor.DARK_GRAY + key);
} }
else else
{ {
String key = psd.giveItem(ShopItem.ELECTRICAL_DIAMOND_SWORD); String key = psd.giveItem(ShopItem.ELECTRICAL_DIAMOND_SWORD);
FUtil.bcastMsg("Thor's Star has granted " + rplayer.getName() + " an " + ChatColor.YELLOW + "Electrical Diamond Sword" + ChatColor.RED + "!", ChatColor.RED); FUtil.bcastMsg("Thor's Star has granted " + rplayer.getName() + " an " + ChatColor.YELLOW + "Electrical Diamond Sword" + ChatColor.RED + "!", ChatColor.RED);
FUtil.give(player, ShopItem.ELECTRICAL_DIAMOND_SWORD, "&7RMB - Strike lightning", ChatColor.DARK_GRAY + key); FUtil.give(rplayer, ShopItem.ELECTRICAL_DIAMOND_SWORD, "&7RMB - Strike lightning", ChatColor.DARK_GRAY + key);
} }
plugin.sh.save(psd); plugin.sh.save(psd);
cooldown(player, "nether_star", 600); cooldown(player, "nether_star", 600);

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.shop;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -222,6 +223,19 @@ public class ShopData implements ConfigLoadable, ConfigSavable, Validatable
return true; return true;
} }
public void takeItem(ShopItem item)
{
Iterator<String> it = items.iterator();
while (it.hasNext())
{
String i = it.next();
if (i.startsWith(item.ordinal() + ""))
{
it.remove();
}
}
}
@Override @Override
public boolean isValid() public boolean isValid()
{ {