Merge branch 'TFM1.12-Alpha' of https://github.com/TFPatches/TotalFreedomMod into TFM1.12-Alpha

This commit is contained in:
Mafrans 2018-06-02 23:01:24 +02:00
commit d38d780887
11 changed files with 150 additions and 111 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# TFM excludes
/lib
build.properties
git.properties
# Netbeans excludes
/nbproject/private

108
pom.xml
View File

@ -4,14 +4,14 @@
<groupId>me.totalfreedom</groupId>
<artifactId>totalfreedom</artifactId>
<version>5.0</version>
<version>5.2</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.version>${project.version}</tfm.build.version>
<tfm.build.codename>Electrum</tfm.build.codename>
<!-- <tfm.build.number>${maven.buildnumber}</tfm.build.number> -->
<tfm.build.codename>God</tfm.build.codename>
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
<tfm.build.author>${buildAuthor}</tfm.build.author>
<tfm.build.head>${buildHead}</tfm.build.head>
@ -60,7 +60,7 @@
</repository>
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
<url>http://maven.sk89q.com/artifactory/repo/</url>
</repository>
</repositories>
@ -159,9 +159,9 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.5.1_339-withDependencies</version>
<version>JDA-3.6.0_354-withDependencies</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/JDA-3.5.1_339-withDependencies.jar</systemPath>
<systemPath>${project.basedir}/lib/JDA-3.6.0_354-withDependencies.jar</systemPath>
</dependency>
</dependencies>
@ -184,14 +184,15 @@
<version>3.3</version>
<configuration>
<outputFileName>TotalFreedomMod.jar</outputFileName>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Antrun -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
@ -199,8 +200,11 @@
<phase>initialize</phase>
<configuration>
<target>
<propertyfile file="build.properties" comment="Build information. Edit this to your liking.">
<propertyfile file="src/main/resources/build.properties" comment="Build information. Edit this to your liking.">
<entry key="buildAuthor" default="unknown" />
<entry key="buildNumber" default="0" />
<entry key="buildCodeName" default="${tfm.build.codename}" />
<entry key="buildVersion" default="${project.version}" />
</propertyfile>
</target>
</configuration>
@ -209,8 +213,10 @@
</goals>
</execution>
</executions>
</plugin>
<!-- Properties -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
@ -224,7 +230,7 @@
</goals>
<configuration>
<files>
<file>${basedir}/build.properties</file>
<file>${basedir}/src/main/resources/build.properties</file>
</files>
</configuration>
</execution>
@ -254,26 +260,47 @@
<!-- Git describe -->
<plugin>
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>3.0</version>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>git-describe</id>
<phase>initialize</phase>
<id>get-the-git-infos</id>
<goals>
<goal>gitdescribe</goal>
<goal>revision</goal>
</goals>
<configuration>
<descriptionProperty>buildHead</descriptionProperty>
<extraArguments>
<param>--tags</param>
<param>--always</param>
<param>HEAD</param>
</extraArguments>
</configuration>
</execution>
<execution>
<id>validate-the-git-infos</id>
<goals>
<goal>validateRevision</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix>git</prefix>
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${basedir}/src/main/resources/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<includeOnlyProperties>
<includeOnlyProperty>git.build.time</includeOnlyProperty>
<includeOnlyProperty>git.commit.id</includeOnlyProperty>
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
</includeOnlyProperties>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
<match>*</match>
</gitDescribe>
</configuration>
</plugin>
<!-- Buildnumber -->
@ -292,42 +319,13 @@
<configuration>
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
<buildNumberPropertiesFileLocation>${basedir}/src/main/resources/build.properties</buildNumberPropertiesFileLocation>
<format>{0,number,#}</format>
<items>
<item>buildNumber</item>
</items>
</configuration>
</plugin>
<!-- Maven jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
</configuration>
</plugin>
<!-- Maven shade -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>target/${project.name}.jar</outputFile>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -1,13 +1,13 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.base.Strings;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -106,9 +106,11 @@ public class ChatManager extends FreedomService
event.setFormat(format);
}
public String getOldPrefix(Displayable display)
public ChatColor getColor(Admin admin, Displayable display)
{
ChatColor color = display.getColor();
if (admin.getOldTags())
{
if (color.equals(ChatColor.AQUA))
{
@ -118,10 +120,26 @@ public class ChatManager extends FreedomService
{
color = ChatColor.LIGHT_PURPLE;
}
}
return color;
}
String prefix = "(" + display.getAbbr() + ")";
public String getColoredTag(Admin admin, Displayable display)
{
ChatColor color = display.getColor();
if (admin.getOldTags())
{
return color + prefix;
if (color.equals(ChatColor.AQUA))
{
color = ChatColor.GOLD;
}
else if (color.equals(ChatColor.GOLD))
{
color = ChatColor.LIGHT_PURPLE;
}
}
return color + display.getAbbr();
}
public void adminChat(CommandSender sender, String message)
@ -134,9 +152,12 @@ public class ChatManager extends FreedomService
if (plugin.al.isAdmin(player))
{
Admin admin = plugin.al.getAdmin(player);
if (admin.getOldAdminMode())
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + " " + getOldPrefix(display) + ChatColor.WHITE + ": " + ChatColor.AQUA + message);
String format = admin.getAcFormat();
ChatColor color = getColor(admin, display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
else
{

View File

@ -283,18 +283,24 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
try
{
final Properties props;
final Properties gitprops;
try (InputStream in = plugin.getResource("build.properties"))
{
props = new Properties();
props.load(in);
}
try (InputStream in = plugin.getResource("git.properties"))
{
gitprops = new Properties();
gitprops.load(in);
}
author = props.getProperty("program.build.author", "unknown");
codename = props.getProperty("program.build.codename", "unknown");
version = props.getProperty("program.build.version", "unknown");
number = props.getProperty("program.build.number", "1");
date = props.getProperty("program.build.date", "unknown");
head = props.getProperty("program.build.head", "unknown");
author = props.getProperty("buildAuthor", "unknown");
codename = props.getProperty("buildCodeName", "unknown");
version = props.getProperty("buildVersion", pluginVersion);
number = props.getProperty("buildNumber", "1");
date = gitprops.getProperty("git.build.time", "unknown");
head = gitprops.getProperty("git.commit.id.abbrev", "unknown");
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists;
import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
@ -53,7 +54,10 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
private Boolean potionSpy = false;
@Getter
@Setter
private Boolean oldAdminMode = false;
private String acFormat = null;
@Getter
@Setter
private Boolean oldTags = null;
public static final String CONFIG_FILENAME = "admins.yml";
@ -81,7 +85,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
.append("- Rank: ").append(rank.getName()).append("\n")
.append("- Is Active: ").append(active).append("\n")
.append("- Discord ID: ").append(discordID).append("\n")
.append("- Tag: ").append(tag);
.append("- Tag: ").append(tag).append("\n")
.append("- Admin Chat Format:").append(acFormat);
return output.toString();
}
@ -108,7 +113,9 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
tag = cs.getString("tag", null);
commandSpy = cs.getBoolean("command_spy", false);
potionSpy = cs.getBoolean("potion_spy", false);
oldAdminMode = cs.getBoolean("old_admin_mode", false);
acFormat = cs.getString("acformat", null);
oldTags = cs.getBoolean("oldtags", false);
}
@Override
@ -125,7 +132,8 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
cs.set("tag", tag);
cs.set("command_spy", commandSpy);
cs.set("potion_spy", potionSpy);
cs.set("old_admin_mode", oldAdminMode);
cs.set("acformat", acFormat);
cs.set("oldtags", oldTags);
}
public boolean isAtLeast(Rank pRank)

View File

@ -107,7 +107,7 @@ public class Command_list extends FreedomCommand
}
final Displayable display = plugin.rm.getDisplay(p);
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldAdminMode())
if (!senderIsConsole && plugin.al.isAdmin(playerSender) && plugin.al.getAdmin(playerSender).getOldTags())
{
n.add(getOldPrefix(display) + p.getName());
}

View File

@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | settag <tag> | cleartag>")
@CommandParameters(description = "Manage my admin entry", usage = "/<command> [-o <admin>] <clearips | clearip <ip> | setlogin <message> | clearlogin | settag <tag> | cleartag | setacformat <format> | clearacformat> | oldtags>")
public class Command_myadmin extends FreedomCommand
{
@ -174,12 +174,38 @@ public class Command_myadmin extends FreedomCommand
case "cleartag":
{
FUtil.adminAction(sender.getName(), "Clearing personal default tag" + (init == null ? "" : " for " + targetPlayer.getName()), false);
String tag = StringUtils.join(args, " ", 1, args.length);
target.setTag(null);
plugin.al.save();
plugin.al.updateTables();
return true;
}
case "setacformat":
{
String format = StringUtils.join(args, " ", 1, args.length);
target.setAcFormat(format);
plugin.al.save();
plugin.al.updateTables();
msg("Set admin chat format to \"" + format + "\".", ChatColor.GRAY);
String example = format.replace("%name%", "ExampleAdmin").replace("%rank%", Rank.TELNET_ADMIN.getAbbr()).replace("%rankcolor%", Rank.TELNET_ADMIN.getColor().toString()).replace("%msg%", "The quick brown fox jumps over the lazy dog.");
msg(ChatColor.GRAY + "Example: " + FUtil.colorize(example));
return true;
}
case "clearacformat":
{
target.setAcFormat(null);
plugin.al.save();
plugin.al.updateTables();
msg("Cleared admin chat format.", ChatColor.GRAY);
return true;
}
case "oldtags":
{
target.setOldTags(!target.getOldTags());
plugin.al.save();
plugin.al.updateTables();
msg((target.getOldTags() ? "Enabled" : "Disabled") + " old tags.");
return true;
}
default:
{

View File

@ -1,26 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Toggle old admin formatting", usage = "/<command>", aliases = "oam")
public class Command_oldadminmode extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Admin admin = plugin.al.getAdmin(playerSender);
admin.setOldAdminMode(!admin.getOldAdminMode());
plugin.al.save();
plugin.al.updateTables();
msg("Old admin mode has been " + (admin.getOldAdminMode() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -52,7 +52,7 @@ public class Command_totalfreedommod extends FreedomCommand
msg("Running on " + ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
msg("Created by Madgeek1450 and Prozza.", ChatColor.GOLD);
msg(String.format("Version "
+ ChatColor.BLUE + "%s %s.%s " + ChatColor.GOLD + "("
+ ChatColor.BLUE + "%s - %s Build %s " + ChatColor.GOLD + "("
+ ChatColor.BLUE + "%s" + ChatColor.GOLD + ")",
build.codename,
build.version,

View File

@ -25,6 +25,7 @@ public class Module_players extends HTTPDModule
final JSONObject responseObject = new JSONObject();
final JSONArray players = new JSONArray();
final JSONArray onlineadmins = new JSONArray();
final JSONArray masterbuilders = new JSONArray();
final JSONArray superadmins = new JSONArray();
final JSONArray telnetadmins = new JSONArray();
@ -35,6 +36,10 @@ public class Module_players extends HTTPDModule
for (Player player : Bukkit.getOnlinePlayers())
{
players.add(player.getName());
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))
{
onlineadmins.add(player.getName());
}
}
// Admins

View File

@ -6,7 +6,7 @@ import org.bukkit.ChatColor;
public enum Title implements Displayable
{
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "Master-Builder"),
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB"),
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec"),
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev"),
OWNER("the", "Owner", ChatColor.BLUE, "Owner");