mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merged Devel into 1.12 Alpha Branch
This commit is contained in:
commit
299e0ccd4a
@ -2,4 +2,11 @@ language: java
|
|||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- sshpass
|
||||||
|
script: mvn clean install
|
||||||
|
after_success:
|
||||||
|
- ./travis-upload.sh
|
||||||
|
12
README.md
12
README.md
@ -1,6 +1,10 @@
|
|||||||
# TotalFreedomMod #
|
# TotalFreedomMod #
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
[![Build Status](https://travis-ci.org/TotalFreedom/TotalFreedomMod.svg?branch=TFM1.12-Alpha)](https://travis-ci.org/TotalFreedom/TotalFreedomMod)
|
[![Build Status](https://travis-ci.org/TotalFreedom/TotalFreedomMod.svg?branch=TFM1.12-Alpha)](https://travis-ci.org/TotalFreedom/TotalFreedomMod)
|
||||||
|
=======
|
||||||
|
[![Build Status](https://travis-ci.org/TotalFreedom/TotalFreedomMod.svg?branch=devel)](https://travis-ci.org/TotalFreedom/TotalFreedomMod)
|
||||||
|
>>>>>>> devel
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
@ -9,5 +13,11 @@ This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van d
|
|||||||
### Download ###
|
### Download ###
|
||||||
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
||||||
|
|
||||||
|
Additionally, Travis CI generates a binary for each commit to the repository. While they might not be stable or 100% functional, these binaries are accessible at [tfmbuilds.win](https://tfmbuilds.win/).
|
||||||
|
|
||||||
### Contributing ###
|
### Contributing ###
|
||||||
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).
|
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).
|
||||||
|
|
||||||
|
Please [join our Discord server](https://discord.gg/fb9J2TD) for any discussion on TFM development and other TotalFreedom Organization projects.
|
||||||
|
45
pom.xml
45
pom.xml
@ -11,7 +11,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<tfm.build.version>${project.version}</tfm.build.version>
|
<tfm.build.version>${project.version}</tfm.build.version>
|
||||||
<tfm.build.codename>Electrum</tfm.build.codename>
|
<tfm.build.codename>Electrum</tfm.build.codename>
|
||||||
<!-- <tfm.build.number>${maven.buildnumber}</tfm.build.number> -->
|
<!-- <tfm.build.number>${maven.buildnumber}</tfm.build.number> -->
|
||||||
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
||||||
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
||||||
<tfm.build.head>${buildHead}</tfm.build.head>
|
<tfm.build.head>${buildHead}</tfm.build.head>
|
||||||
@ -54,10 +54,10 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<!-- <repository>
|
||||||
<id>elmakers-repo</id>
|
<id>elmakers-repo</id>
|
||||||
<url>http://maven.elmakers.com/repository/</url>
|
<url>http://maven.elmakers.com/repository/</url>
|
||||||
</repository>
|
</repository>-->
|
||||||
<repository>
|
<repository>
|
||||||
<id>sk89q-snapshots</id>
|
<id>sk89q-snapshots</id>
|
||||||
<url>http://maven.sk89q.com/artifactory/repo</url>
|
<url>http://maven.sk89q.com/artifactory/repo</url>
|
||||||
@ -65,6 +65,17 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@ -74,8 +85,9 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.12-R0.1-SNAPSHOT</version>
|
<version>1.12-pre5-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -90,6 +102,12 @@
|
|||||||
<version>4.5-pre1</version>
|
<version>4.5-pre1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.ess3</groupId>
|
||||||
|
<artifactId>Essentials</artifactId>
|
||||||
|
<version>2.13.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
|
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
|
||||||
<artifactId>worldedit-bukkit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
@ -102,23 +120,6 @@
|
|||||||
<version>6.1.0-TF</version>
|
<version>6.1.0-TF</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.12-R0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.ess3</groupId>
|
|
||||||
<artifactId>Essentials</artifactId>
|
|
||||||
<version>2.13.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- <dependency>
|
|
||||||
<groupId>com.github.TotalFreedom</groupId>
|
|
||||||
<artifactId>TF-LibsDisguises</artifactId>
|
|
||||||
<version>-SNAPSHOT</version>
|
|
||||||
</dependency> -->
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.net.HttpURLConnection;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.*;
|
||||||
import java.net.URL;
|
import java.security.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -38,10 +36,10 @@ public class LogViewer extends FreedomService
|
|||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
|
updateLogsRegistration(sender, target.getName(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
@ -63,14 +61,16 @@ public class LogViewer extends FreedomService
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = new URLBuilder(logsRegisterUrl)
|
final String key = SecureCodeGenerator.generateCode(20);
|
||||||
.addQueryParameter("mode", mode.toString())
|
|
||||||
|
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.name())
|
||||||
.addQueryParameter("password", logsRegisterPassword)
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
.addQueryParameter("name", targetName)
|
.addQueryParameter("name", targetName)
|
||||||
.addQueryParameter("ip", targetIP)
|
.addQueryParameter("key", key)
|
||||||
.getURL();
|
.getURL();
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection connection = (HttpURLConnection) urlAdd.openConnection();
|
||||||
connection.setConnectTimeout(1000 * 5);
|
connection.setConnectTimeout(1000 * 5);
|
||||||
connection.setReadTimeout(1000 * 5);
|
connection.setReadTimeout(1000 * 5);
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
@ -92,7 +92,29 @@ public class LogViewer extends FreedomService
|
|||||||
{
|
{
|
||||||
if (responseCode == 200)
|
if (responseCode == 200)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
|
if (mode == LogsRegistrationMode.ADD)
|
||||||
|
{
|
||||||
|
String link = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final URL urlVerify = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("key", key)
|
||||||
|
.getURL();
|
||||||
|
link = urlVerify.toString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,30 +132,10 @@ public class LogViewer extends FreedomService
|
|||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivateSuperadmin(Admin superadmin)
|
|
||||||
{
|
|
||||||
for (String ip : superadmin.getIps())
|
|
||||||
{
|
|
||||||
updateLogsRegistration(null, superadmin.getName(), ip, LogsRegistrationMode.DELETE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum LogsRegistrationMode
|
public static enum LogsRegistrationMode
|
||||||
{
|
{
|
||||||
|
|
||||||
UPDATE("update"), DELETE("delete");
|
ADD, DELETE, VERIFY;
|
||||||
private final String mode;
|
|
||||||
|
|
||||||
private LogsRegistrationMode(String mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class URLBuilder
|
private static class URLBuilder
|
||||||
@ -160,11 +162,44 @@ public class LogViewer extends FreedomService
|
|||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
Map.Entry<String, String> pair = it.next();
|
Map.Entry<String, String> pair = it.next();
|
||||||
pairs.add(pair.getKey() + "=" + pair.getValue());
|
try
|
||||||
|
{
|
||||||
|
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SecureCodeGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
public static String generateCode(final int length)
|
||||||
|
{
|
||||||
|
SecureRandom random;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
|
||||||
|
{
|
||||||
|
random = new SecureRandom();
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,15 +168,15 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whitelist
|
// // Whitelist
|
||||||
if (plugin.si.isWhitelisted())
|
// if (plugin.si.isWhitelisted())
|
||||||
{
|
// {
|
||||||
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
// if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
||||||
{
|
// {
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
// event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
|
||||||
import net.minecraft.server.v1_12_R1.MinecraftServer;
|
|
||||||
import net.minecraft.server.v1_12_R1.PropertyManager;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
|
||||||
|
|
||||||
public class ServerInterface extends FreedomService
|
public class ServerInterface extends FreedomService
|
||||||
{
|
{
|
||||||
@ -41,52 +34,52 @@ public class ServerInterface extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnlineMode(boolean mode)
|
// public void setOnlineMode(boolean mode)
|
||||||
{
|
// {
|
||||||
final PropertyManager manager = getServer().getPropertyManager();
|
// final PropertyManager manager = getServer().getPropertyManager();
|
||||||
manager.setProperty("online-mode", mode);
|
// manager.setProperty("online-mode", mode);
|
||||||
manager.savePropertiesFile();
|
// manager.savePropertiesFile();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public int purgeWhitelist()
|
// public int purgeWhitelist()
|
||||||
{
|
// {
|
||||||
String[] whitelisted = getServer().getPlayerList().getWhitelisted();
|
// String[] whitelisted = getServer().getPlayerList().getWhitelisted();
|
||||||
int size = whitelisted.length;
|
// int size = whitelisted.length;
|
||||||
for (EntityPlayer player : getServer().getPlayerList().players)
|
// for (EntityPlayer player : getServer().getPlayerList().players)
|
||||||
{
|
// {
|
||||||
getServer().getPlayerList().getWhitelist().remove(player.getProfile());
|
// getServer().getPlayerList().getWhitelist().remove(player.getProfile());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
getServer().getPlayerList().getWhitelist().save();
|
// getServer().getPlayerList().getWhitelist().save();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
FLog.warning("Could not purge the whitelist!");
|
// FLog.warning("Could not purge the whitelist!");
|
||||||
FLog.warning(ex);
|
// FLog.warning(ex);
|
||||||
}
|
// }
|
||||||
return size;
|
// return size;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public boolean isWhitelisted()
|
// public boolean isWhitelisted()
|
||||||
{
|
// {
|
||||||
return getServer().getPlayerList().getHasWhitelist();
|
// return getServer().getPlayerList().getHasWhitelist();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public List<?> getWhitelisted()
|
// public List<?> getWhitelisted()
|
||||||
{
|
// {
|
||||||
return Arrays.asList(getServer().getPlayerList().getWhitelisted());
|
// return Arrays.asList(getServer().getPlayerList().getWhitelisted());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getVersion()
|
// public String getVersion()
|
||||||
{
|
// {
|
||||||
return getServer().getVersion();
|
// return getServer().getVersion();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private MinecraftServer getServer()
|
// private MinecraftServer getServer()
|
||||||
{
|
// {
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
// return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
// String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||||
|
String baseMotd = ConfigEntry.SERVER_MOTD.getString();
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
baseMotd = FUtil.colorize(baseMotd);
|
baseMotd = FUtil.colorize(baseMotd);
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
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.base.ConfigLoadable;
|
import net.pravian.aero.base.ConfigLoadable;
|
||||||
@ -25,7 +27,6 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
@Setter
|
@Setter
|
||||||
private String name;
|
private String name;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -138,6 +139,26 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
ips.clear();
|
ips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean active)
|
||||||
|
{
|
||||||
|
this.active = active;
|
||||||
|
|
||||||
|
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
if (getRank().isAtLeast(Rank.TELNET_ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
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.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -272,6 +271,14 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
public boolean removeAdmin(Admin admin)
|
public boolean removeAdmin(Admin admin)
|
||||||
{
|
{
|
||||||
|
if (admin.getRank().isAtLeast(Rank.TELNET_ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(admin.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove admin, update views
|
// Remove admin, update views
|
||||||
if (allAdmins.remove(admin.getConfigKey()) == null)
|
if (allAdmins.remove(admin.getConfigKey()) == null)
|
||||||
{
|
{
|
||||||
@ -345,7 +352,6 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.lv.deactivateSuperadmin(admin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
@ -1,21 +1,29 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class BukkitTelnetBridge extends FreedomService
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
@ -94,4 +102,69 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BukkitTelnet getBukkitTelnetPlugin()
|
||||||
|
{
|
||||||
|
if (bukkitTelnetPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||||
|
if (bukkitTelnet != null)
|
||||||
|
{
|
||||||
|
if (bukkitTelnet instanceof BukkitTelnet)
|
||||||
|
{
|
||||||
|
bukkitTelnetPlugin = (BukkitTelnet) bukkitTelnet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bukkitTelnetPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void killTelnetSessions(final String name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final List<ClientSession> sessionsToRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final ClientSession session = it.next();
|
||||||
|
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
||||||
|
{
|
||||||
|
sessionsToRemove.add(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final ClientSession session : sessionsToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
telnet.appender.removeSession(session);
|
||||||
|
session.syncTerminateSession();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.apache.commons.lang3.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.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
|
||||||
@ -30,16 +14,13 @@ public class Command_logs extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
LogsRegistrationMode mode = LogsRegistrationMode.UPDATE;
|
LogsRegistrationMode mode = LogsRegistrationMode.ADD;
|
||||||
|
if (args.length == 1 && "off".equalsIgnoreCase(args[0]))
|
||||||
if (args.length == 1)
|
|
||||||
{
|
{
|
||||||
mode = ("off".equals(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
|
mode = LogsRegistrationMode.DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
|
plugin.lv.updateLogsRegistration(sender, playerSender, mode);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -44,26 +43,27 @@ public class Command_onlinemode extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
plugin.si.setOnlineMode(onlineMode);
|
// plugin.si.setOnlineMode(onlineMode);
|
||||||
|
//
|
||||||
if (onlineMode)
|
// if (onlineMode)
|
||||||
{
|
// {
|
||||||
for (Player player : server.getOnlinePlayers())
|
// for (Player player : server.getOnlinePlayers())
|
||||||
{
|
// {
|
||||||
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
// player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true);
|
// FUtil.adminAction(sender.getName(), "Turning player validation " + (onlineMode ? "on" : "off") + ".", true);
|
||||||
|
//
|
||||||
server.reload();
|
// server.reload();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
FLog.severe(ex);
|
// FLog.severe(ex);
|
||||||
}
|
// }
|
||||||
|
FUtil.adminAction(sender.getName(), "Online-Mode toggling is temporarily disabled.", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -158,8 +158,10 @@ public class Command_whitelist extends FreedomCommand
|
|||||||
//purge
|
//purge
|
||||||
if (args[0].equalsIgnoreCase("purge"))
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false);
|
// FUtil.adminAction(sender.getName(), "Removing all players from the whitelist.", false);
|
||||||
msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist.");
|
// msg("Removed " + plugin.si.purgeWhitelist() + " players from the whitelist.");
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Whitelist purging is temporarily disabled.", true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
13
travis-upload.sh
Executable file
13
travis-upload.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
|
||||||
|
mv target/TotalFreedomMod.jar target/TotalFreedomMod-${TRAVIS_COMMIT}.jar
|
||||||
|
export SSHPASS=${SFTP_PASSWORD}
|
||||||
|
sshpass -e sftp -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=ERROR -oBatchMode=no -b - ${SFTP_USER}@${SFTP_HOST}:${SFTP_PATH} << !
|
||||||
|
put target/TotalFreedomMod-${TRAVIS_COMMIT}.jar
|
||||||
|
bye
|
||||||
|
!
|
||||||
|
echo "Artifact upload status: "$?
|
||||||
|
else
|
||||||
|
echo "Skipping artifact upload for pull request build."
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user