mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Hopefully the last hot update for now
This commit is contained in:
commit
c836838f51
@ -1,4 +1,4 @@
|
||||
# TotalFreedomMod [![Build Status](https://travis-ci.org/TFPatches/TotalFreedomMod.svg?branch=TFM-1.15)](https://travis-ci.org/TFPatches/TotalFreedomMod) [![codebeat badge](https://codebeat.co/badges/5f078e55-8a02-4120-9076-70f6994f48d1)](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||
# TotalFreedomMod [![Build Status](https://travis-ci.org/TFPatches/TotalFreedomMod.svg?branch=development)](https://travis-ci.org/TFPatches/TotalFreedomMod) [![codebeat badge](https://codebeat.co/badges/5f078e55-8a02-4120-9076-70f6994f48d1)](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||
|
||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>5.5</version>
|
||||
<version>5.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<tfm.build.codename>lttstore.com</tfm.build.codename>
|
||||
<tfm.build.codename>Antaeus</tfm.build.codename>
|
||||
<jar.finalName>${project.name}</jar.finalName>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||
|
@ -1,218 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "No Description Yet", usage = "/<command>")
|
||||
public class Command_cbtool extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player)
|
||||
{
|
||||
Block targetBlock = DepreciationAggregator.getTargetBlock(playerSender, null, 100);
|
||||
msg("Your target block: " + targetBlock.getLocation().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final StringBuffer generatedCommand = new StringBuffer();
|
||||
|
||||
final Matcher matcher = Pattern.compile("\\[(.+?)\\]").matcher(StringUtils.join(args, " ").trim());
|
||||
while (matcher.find())
|
||||
{
|
||||
matcher.appendReplacement(generatedCommand, processSubCommand(matcher.group(1)));
|
||||
}
|
||||
matcher.appendTail(generatedCommand);
|
||||
|
||||
if (plugin.cb.isCommandBlocked(generatedCommand.toString(), sender, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
server.dispatchCommand(sender, generatedCommand.toString());
|
||||
}
|
||||
catch (SubCommandFailureException ex)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String processSubCommand(final String subcommand) throws SubCommandFailureException
|
||||
{
|
||||
final String[] args = StringUtils.split(subcommand, " ");
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
throw new SubCommandFailureException("Invalid subcommand name.");
|
||||
}
|
||||
|
||||
return SubCommand.getByName(args[0]).getExecutable().execute(ArrayUtils.remove(args, 0));
|
||||
}
|
||||
|
||||
private static enum SubCommand
|
||||
{
|
||||
|
||||
PLAYER_DETECT("playerdetect", new SubCommandExecutable()
|
||||
{
|
||||
@Override
|
||||
public String execute(String[] args) throws SubCommandFailureException
|
||||
{
|
||||
if (args.length != 5)
|
||||
{
|
||||
throw new SubCommandFailureException("Invalid # of arguments.");
|
||||
}
|
||||
|
||||
double x, y, z;
|
||||
try
|
||||
{
|
||||
x = Double.parseDouble(args[0].trim());
|
||||
y = Double.parseDouble(args[1].trim());
|
||||
z = Double.parseDouble(args[2].trim());
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
throw new SubCommandFailureException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
World world = null;
|
||||
final String needleWorldName = args[3].trim();
|
||||
final List<World> worlds = Bukkit.getWorlds();
|
||||
for (final World testWorld : worlds)
|
||||
{
|
||||
if (testWorld.getName().trim().equalsIgnoreCase(needleWorldName))
|
||||
{
|
||||
world = testWorld;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (world == null)
|
||||
{
|
||||
throw new SubCommandFailureException("Invalid world name.");
|
||||
}
|
||||
|
||||
final Location testLocation = new Location(world, x, y, z);
|
||||
|
||||
double radius;
|
||||
try
|
||||
{
|
||||
radius = Double.parseDouble(args[4].trim());
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
throw new SubCommandFailureException("Invalid radius.");
|
||||
}
|
||||
|
||||
final double radiusSq = radius * radius;
|
||||
|
||||
final List<Player> worldPlayers = testLocation.getWorld().getPlayers();
|
||||
for (final Player testPlayer : worldPlayers)
|
||||
{
|
||||
if (testPlayer.getLocation().distanceSquared(testLocation) < radiusSq)
|
||||
{
|
||||
return testPlayer.getName();
|
||||
}
|
||||
}
|
||||
|
||||
throw new SubCommandFailureException("No player found in range.");
|
||||
}
|
||||
}),
|
||||
PLAYER_DETECT_BOOLEAN("playerdetectboolean", new SubCommandExecutable()
|
||||
{
|
||||
@Override
|
||||
public String execute(String[] args) throws SubCommandFailureException
|
||||
{
|
||||
try
|
||||
{
|
||||
PLAYER_DETECT.getExecutable().execute(args);
|
||||
}
|
||||
catch (SubCommandFailureException ex)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
|
||||
return "1";
|
||||
}
|
||||
});
|
||||
//
|
||||
private final String name;
|
||||
private final SubCommandExecutable executable;
|
||||
|
||||
private SubCommand(String subCommandName, SubCommandExecutable subCommandImpl)
|
||||
{
|
||||
this.name = subCommandName;
|
||||
this.executable = subCommandImpl;
|
||||
}
|
||||
|
||||
public SubCommandExecutable getExecutable()
|
||||
{
|
||||
return executable;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public static SubCommand getByName(String needle) throws SubCommandFailureException
|
||||
{
|
||||
needle = needle.trim();
|
||||
for (SubCommand subCommand : values())
|
||||
{
|
||||
if (subCommand.getName().equalsIgnoreCase(needle))
|
||||
{
|
||||
return subCommand;
|
||||
}
|
||||
}
|
||||
throw new SubCommandFailureException("Invalid subcommand name.");
|
||||
}
|
||||
}
|
||||
|
||||
private interface SubCommandExecutable
|
||||
{
|
||||
|
||||
public String execute(String[] args) throws SubCommandFailureException;
|
||||
}
|
||||
|
||||
private static class SubCommandFailureException extends Exception
|
||||
{
|
||||
|
||||
public SubCommandFailureException()
|
||||
{
|
||||
}
|
||||
|
||||
public SubCommandFailureException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -43,17 +42,20 @@ public class Command_manageshop extends FreedomCommand
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully added " + amount + " coins to " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
msg("Successfully added " + amount + " coins to " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -80,21 +82,24 @@ public class Command_manageshop extends FreedomCommand
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
if (!args[3].equals("all"))
|
||||
{
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(playerData.getCoins() + amount);
|
||||
if (playerData.getCoins() < 0)
|
||||
{
|
||||
playerData.setCoins(0);
|
||||
}
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully removed " + amount + " coins from " + player.getName() + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
msg("Successfully removed " + amount + " coins from " + args[3] + ". Their new balance is " + playerData.getCoins(), ChatColor.GREEN);
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -123,17 +128,20 @@ public class Command_manageshop extends FreedomCommand
|
||||
try
|
||||
{
|
||||
int amount = Math.max(0, Math.min(1000000, Integer.parseInt(args[2])));
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.setCoins(amount);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully set " + player.getName() + "'s coins to " + amount, ChatColor.GREEN);
|
||||
msg("Successfully set " + args[3] + "'s coins to " + amount, ChatColor.GREEN);
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
@ -165,18 +173,20 @@ public class Command_manageshop extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.giveItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully gave the " + item.getName() + " to " + player.getName(), ChatColor.GREEN);
|
||||
msg("Successfully gave the " + item.getName() + " to " + args[3], ChatColor.GREEN);
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (args[1].equals("take"))
|
||||
@ -188,18 +198,20 @@ public class Command_manageshop extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player == null)
|
||||
PlayerData playerData = plugin.pl.getData(args[3]);
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
playerData.removeItem(item);
|
||||
plugin.pl.save(playerData);
|
||||
msg("Successfully took the " + item.getName() + " from " + player.getName(), ChatColor.GREEN);
|
||||
msg("Successfully took the " + item.getName() + " from " + args[3], ChatColor.GREEN);
|
||||
Player player = getPlayer(args[3]);
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Set a player's total votes", usage = "/<command> <player> <votes>")
|
||||
public class Command_settotalvotes extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (!ConfigEntry.SERVER_OWNERS.getStringList().contains(sender.getName()))
|
||||
{
|
||||
return noPerms();
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int votes = 0;
|
||||
try
|
||||
{
|
||||
votes = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
msg("Invalid number: " + args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(args[1]);
|
||||
|
||||
if (playerData == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
playerData.setTotalVotes(votes);
|
||||
plugin.pl.save(playerData);
|
||||
|
||||
Player player = getPlayer(args[1]);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + sender.getName() + " has set your total votes to " + votes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user