mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Bug fixes and improvements (#16)
* Bug fixes and improvements * Re-add Marco's name * Actually make the logfile page load.
This commit is contained in:
parent
059bf14d90
commit
3f360a4d5e
@ -26,6 +26,9 @@ import org.bukkit.entity.Minecart;
|
|||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.ThrownExpBottle;
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.entity.DragonFireball;
|
||||||
|
import org.bukkit.entity.Fireball;
|
||||||
|
import org.bukkit.entity.EnderPearl;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
@ -48,6 +51,7 @@ public class EntityWiper extends FreedomService
|
|||||||
super(plugin);
|
super(plugin);
|
||||||
wipables.add(EnderCrystal.class);
|
wipables.add(EnderCrystal.class);
|
||||||
wipables.add(EnderSignal.class);
|
wipables.add(EnderSignal.class);
|
||||||
|
wipables.add(EnderPearl.class);
|
||||||
wipables.add(ExperienceOrb.class);
|
wipables.add(ExperienceOrb.class);
|
||||||
wipables.add(Projectile.class);
|
wipables.add(Projectile.class);
|
||||||
wipables.add(FallingBlock.class);
|
wipables.add(FallingBlock.class);
|
||||||
@ -60,6 +64,8 @@ public class EntityWiper extends FreedomService
|
|||||||
wipables.add(Boat.class);
|
wipables.add(Boat.class);
|
||||||
wipables.add(FallingBlock.class);
|
wipables.add(FallingBlock.class);
|
||||||
wipables.add(ArmorStand.class);
|
wipables.add(ArmorStand.class);
|
||||||
|
wipables.add(Fireball.class);
|
||||||
|
wipables.add(DragonFireball.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -166,6 +172,7 @@ public class EntityWiper extends FreedomService
|
|||||||
for (Entity e : cel)
|
for (Entity e : cel)
|
||||||
{
|
{
|
||||||
e.remove();
|
e.remove();
|
||||||
|
removed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedomMod", "Deactivating superadmin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
|
@ -38,12 +38,14 @@ public class Command_doom extends FreedomCommand
|
|||||||
|
|
||||||
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
// Remove from superadmin
|
// Remove from admin
|
||||||
Admin admin = getAdmin(player);
|
Admin admin = getAdmin(player);
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list", true);
|
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the admin list", true);
|
||||||
plugin.al.removeAdmin(admin);
|
admin.setActive(false);
|
||||||
|
plugin.al.save();
|
||||||
|
plugin.al.updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove from whitelist
|
// Remove from whitelist
|
||||||
|
@ -89,7 +89,8 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
// Broadcast
|
// Broadcast
|
||||||
final StringBuilder bcast = new StringBuilder()
|
final StringBuilder bcast = new StringBuilder()
|
||||||
.append(ChatColor.RED)
|
.append(ChatColor.RED)
|
||||||
.append("Banning: ")
|
.append(sender.getName())
|
||||||
|
.append(" - Banning ")
|
||||||
.append(player.getName())
|
.append(player.getName())
|
||||||
.append(", IP: ")
|
.append(", IP: ")
|
||||||
.append(ip);
|
.append(ip);
|
||||||
|
@ -38,7 +38,7 @@ public class Command_opall extends FreedomCommand
|
|||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
player.sendMessage(FreedomCommand.YOU_ARE_OP);
|
player.sendMessage(FreedomCommand.YOU_ARE_OP);
|
||||||
|
|
||||||
if (doSetGamemode && !plugin.al.isAdmin(player))
|
if (doSetGamemode && !player.getGameMode().equals(GameMode.SPECTATOR))
|
||||||
{
|
{
|
||||||
player.setGameMode(targetGamemode);
|
player.setGameMode(targetGamemode);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class Command_radar extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Location playerSenderos = playerSender.getLocation();
|
Location playerSenderos = playerSender.getLocation();
|
||||||
|
|
||||||
List<TFM_RadarData> radar_data = new ArrayList<>();
|
List<RadarData> radar_data = new ArrayList<>();
|
||||||
|
|
||||||
for (Player player : playerSenderos.getWorld().getPlayers())
|
for (Player player : playerSenderos.getWorld().getPlayers())
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ public class Command_radar extends FreedomCommand
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
radar_data.add(new TFM_RadarData(player, playerSenderos.distance(player.getLocation()), player.getLocation()));
|
radar_data.add(new RadarData(player, playerSenderos.distance(player.getLocation()), player.getLocation()));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex)
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ public class Command_radar extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(radar_data, new TFM_RadarData());
|
Collections.sort(radar_data, new RadarData());
|
||||||
|
|
||||||
msg("People nearby in " + playerSenderos.getWorld().getName() + ":", ChatColor.YELLOW);
|
msg("People nearby in " + playerSenderos.getWorld().getName() + ":", ChatColor.YELLOW);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class Command_radar extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TFM_RadarData i : radar_data)
|
for (RadarData i : radar_data)
|
||||||
{
|
{
|
||||||
msg(String.format("%s - %d",
|
msg(String.format("%s - %d",
|
||||||
i.player.getName(),
|
i.player.getName(),
|
||||||
@ -74,26 +74,26 @@ public class Command_radar extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TFM_RadarData implements Comparator<TFM_RadarData>
|
private class RadarData implements Comparator<RadarData>
|
||||||
{
|
{
|
||||||
|
|
||||||
public Player player;
|
public Player player;
|
||||||
public double distance;
|
public double distance;
|
||||||
public Location location;
|
public Location location;
|
||||||
|
|
||||||
public TFM_RadarData(Player player, double distance, Location location)
|
public RadarData(Player player, double distance, Location location)
|
||||||
{
|
{
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TFM_RadarData()
|
public RadarData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(TFM_RadarData t1, TFM_RadarData t2)
|
public int compare(RadarData t1, RadarData t2)
|
||||||
{
|
{
|
||||||
if (t1.distance > t2.distance)
|
if (t1.distance > t2.distance)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list":
|
case "list":
|
||||||
{
|
{
|
||||||
msg("Superadmins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
FUtil.adminAction(sender.getName(), "Cleaning admin list", true);
|
||||||
plugin.al.deactivateOldEntries(true);
|
plugin.al.deactivateOldEntries(true);
|
||||||
msg("Superadmins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
msg("Superadmin not found: " + args[1]);
|
msg("Admin not found: " + args[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -220,7 +220,7 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
if (admin == null)
|
if (admin == null)
|
||||||
{
|
{
|
||||||
msg("Superadmin not found: " + args[1]);
|
msg("Admin not found: " + args[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class Command_verify extends FreedomCommand
|
|||||||
{
|
{
|
||||||
plugin.dc.VERIFY_CODES.remove(code);
|
plugin.dc.VERIFY_CODES.remove(code);
|
||||||
FUtil.bcastMsg(playerSender.getName() + " has verified themself!", ChatColor.GOLD);
|
FUtil.bcastMsg(playerSender.getName() + " has verified themself!", ChatColor.GOLD);
|
||||||
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the staff list", true);
|
FUtil.adminAction(ConfigEntry.SERVER_NAME.getString(), "Readding " + admin.getName() + " to the admin list", true);
|
||||||
if (playerSender != null)
|
if (playerSender != null)
|
||||||
{
|
{
|
||||||
admin.setName(playerSender.getName());
|
admin.setName(playerSender.getName());
|
||||||
|
@ -13,10 +13,13 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_bans;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_dump;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_dump;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_file;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_help;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_help;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_list;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||||
@ -24,6 +27,7 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
public class HTTPDaemon extends FreedomService
|
public class HTTPDaemon extends FreedomService
|
||||||
{
|
{
|
||||||
@ -53,10 +57,13 @@ public class HTTPDaemon extends FreedomService
|
|||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
modules.clear();
|
modules.clear();
|
||||||
|
module("admins", Module_admins.class, true);
|
||||||
|
module("bans", Module_bans.class, true);
|
||||||
module("dump", Module_dump.class, true);
|
module("dump", Module_dump.class, true);
|
||||||
module("file", Module_file.class, true);
|
module("file", Module_file.class, true);
|
||||||
module("help", Module_help.class, false);
|
module("help", Module_help.class, false);
|
||||||
module("list", Module_list.class, false);
|
module("list", Module_list.class, false);
|
||||||
|
module("logfile", Module_logfile.class, true);
|
||||||
module("logs", Module_logs.class, true);
|
module("logs", Module_logs.class, true);
|
||||||
module("permbans", Module_permbans.class, true);
|
module("permbans", Module_permbans.class, true);
|
||||||
module("players", Module_players.class, false);
|
module("players", Module_players.class, false);
|
||||||
@ -160,6 +167,12 @@ public class HTTPDaemon extends FreedomService
|
|||||||
{
|
{
|
||||||
mimetype = MIME_DEFAULT_BINARY;
|
mimetype = MIME_DEFAULT_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some browsers like firefox download the file for text/yaml mime types
|
||||||
|
if (FilenameUtils.getExtension(file.getName()).equals("yml"))
|
||||||
|
{
|
||||||
|
mimetype = NanoHTTPD.MIME_PLAINTEXT;
|
||||||
|
}
|
||||||
|
|
||||||
response = new Response(Response.Status.OK, mimetype, new FileInputStream(file));
|
response = new Response(Response.Status.OK, mimetype, new FileInputStream(file));
|
||||||
response.addHeader("Content-Length", "" + file.length());
|
response.addHeader("Content-Length", "" + file.length());
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
|
||||||
|
public class Module_admins extends HTTPDModule
|
||||||
|
{
|
||||||
|
|
||||||
|
public Module_admins(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
|
{
|
||||||
|
super(plugin, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NanoHTTPD.Response getResponse()
|
||||||
|
{
|
||||||
|
File adminFile = new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME);
|
||||||
|
if (adminFile.exists())
|
||||||
|
{
|
||||||
|
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||||
|
if (!isAuthorized(remoteAddress))
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"You may not view the admin list, Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), Admin.CONFIG_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isAuthorized(String remoteAddress)
|
||||||
|
{
|
||||||
|
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
|
return entry != null && entry.isActive();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
|
||||||
|
public class Module_bans extends HTTPDModule
|
||||||
|
{
|
||||||
|
|
||||||
|
public Module_bans(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
|
{
|
||||||
|
super(plugin, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NanoHTTPD.Response getResponse()
|
||||||
|
{
|
||||||
|
File banFile = new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME);
|
||||||
|
if (banFile.exists())
|
||||||
|
{
|
||||||
|
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||||
|
if (!isAuthorized(remoteAddress))
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"You may not view the ban list, Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), BanManager.CONFIG_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isAuthorized(String remoteAddress)
|
||||||
|
{
|
||||||
|
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
|
return entry != null && entry.isActive();
|
||||||
|
}
|
||||||
|
}
|
@ -37,7 +37,7 @@ public class FUtil
|
|||||||
//
|
//
|
||||||
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
|
||||||
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
|
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
|
||||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Commodore64x", "Wild1145");
|
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "aggelosQQ", "OxLemonxO", "Commodore64x", "Wild1145", "marcocorriero");
|
||||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
||||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||||
|
Loading…
Reference in New Issue
Block a user