Bug fixes (#92)

* Bug fixes

- Now checks if nothing was ejected
- Fix NPE in saconfig
- Module_permbans now checks if you are an admin

* Discord is better
This commit is contained in:
Telesphoreo 2018-07-24 22:54:00 -07:00 committed by Seth
parent c0b43f26ea
commit 113ab62f0b
6 changed files with 55 additions and 23 deletions

View File

@ -27,6 +27,12 @@ public class Command_eject extends FreedomCommand
names.add(entity.getName());
}
if (names.isEmpty())
{
msg("Nothing was ejected.", ChatColor.GREEN);
return true;
}
msg("Ejecting " + StringUtils.join(names, ", ") + ".", ChatColor.GREEN);
playerSender.eject();

View File

@ -32,7 +32,6 @@ public class Command_saconfig extends FreedomCommand
case "list":
{
msg("Admins: " + StringUtils.join(plugin.al.getAdminNames(), ", "), ChatColor.GOLD);
return true;
}
@ -154,6 +153,13 @@ public class Command_saconfig extends FreedomCommand
// Player already an admin?
final Player player = getPlayer(args[1]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (player != null && plugin.al.isAdmin(player))
{
msg("That player is already admin.");
@ -176,7 +182,7 @@ public class Command_saconfig extends FreedomCommand
{
if (plugin.mbl.isMasterBuilderImpostor(player))
{
msg("This player was labeled as a Master Builder imposter and is not an admin, therefore they can not be added to the admin list.", ChatColor.RED);
msg("This player was labeled as a Master Builder impostor and is not an admin, therefore they can not be added to the admin list.", ChatColor.RED);
return true;
}
if (player == null)
@ -296,5 +302,4 @@ public class Command_saconfig extends FreedomCommand
}
}
}
}

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -17,6 +18,12 @@ public class Command_wipeflatlands extends FreedomCommand
{
plugin.sf.setSavedFlag("do_wipe_flatlands", true);
if (!ConfigEntry.FLATLANDS_GENERATE.getBoolean())
{
msg("Flatlands generation is disabled, therefore it cannot be wiped.");
return true;
}
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
if (plugin.wgb.isPluginEnabled())

View File

@ -1,11 +1,13 @@
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.PermbanList;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import java.io.File;
public class Module_permbans extends HTTPDModule
{
@ -18,6 +20,12 @@ public class Module_permbans extends HTTPDModule
public NanoHTTPD.Response getResponse()
{
File permbanFile = new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME);
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 permban list. Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
}
if (permbanFile.exists())
{
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
@ -28,4 +36,10 @@ public class Module_permbans extends HTTPDModule
"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();
}
}

View File

@ -17,24 +17,23 @@
*/
package me.totalfreedom.totalfreedommod.world;
import static java.lang.System.arraycopy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import static java.lang.System.arraycopy;
@SuppressWarnings("deprecation")
public class CleanroomChunkGenerator extends ChunkGenerator
{
private static final Logger log = Bukkit.getLogger();
private short[] layer;
private byte[] layerDataValues;
@ -77,7 +76,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
int height = Integer.parseInt(tokens[i]);
if (height <= 0)
{
log.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
FLog.warning("[CleanroomGenerator] Invalid height '" + tokens[i] + "'. Using 64 instead.");
height = 64;
}
@ -92,7 +91,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
}
catch (Exception e)
{
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
FLog.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
dataValue = 0;
}
}
@ -111,14 +110,14 @@ public class CleanroomChunkGenerator extends ChunkGenerator
if (mat == null)
{
log.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone.");
FLog.warning("[CleanroomGenerator] Invalid Block ID '" + materialTokens[0] + "'. Defaulting to stone.");
mat = Material.STONE;
}
}
if (!mat.isBlock())
{
log.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to stone.");
FLog.warning("[CleanroomGenerator] Error, '" + materialTokens[0] + "' is not a block. Defaulting to stone.");
mat = Material.STONE;
}
@ -164,7 +163,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
}
catch (Exception e)
{
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
FLog.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
e.printStackTrace();
layerDataValues = null;
layer = new short[65];
@ -186,7 +185,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
int maxHeight = world.getMaxHeight();
if (layer.length > maxHeight)
{
log.warning("[CleanroomGenerator] Error, chunk height " + layer.length + " is greater than the world max height (" + maxHeight + "). Trimming to world max height.");
FLog.warning("[CleanroomGenerator] Error, chunk height " + layer.length + " is greater than the world max height (" + maxHeight + "). Trimming to world max height.");
short[] newLayer = new short[maxHeight];
arraycopy(layer, 0, newLayer, 0, maxHeight);
layer = newLayer;

View File

@ -266,13 +266,14 @@ announcer:
- 'Somebody breaking the rules? Report it! /report <user> <reason>'
- 'Griefing is not allowed!'
- 'Hacked clients are allowed!'
- 'Interested in becoming admin? Do "/ai" for more information!'
- 'Interested in becoming admin? Type "/ai" for more information!'
- 'You may view all online administrators via "/list -a"'
- 'Save your buildings via WorldEdit! http://totalfreedom.me for more information!'
- 'Famous players, such as Notch, are always fake! We are an offline/cracked server!'
- 'You may contact TotalFreedom support on Twitter! https://tiny.re/tfsupport'
- 'You may download TotalFreedomMod here: https://tiny.re/tfm+'
- 'MarkByron is the owner of TotalFreedom.'
- 'TheMinecraft is the owner of TotalFreedom.'
- 'MarkByron is the founder of TotalFreedom.'
- 'Server lagging? Check the lag via "/tps"'
- 'You are allowed to record and stream videos on TotalFreedom.'
- 'Player vs player while in creative or god mode is forbidden!'
@ -281,7 +282,7 @@ announcer:
- 'Serial griefing and trolling will result in a permanent ban!'
- 'TotalFreedom does not accept any form of donations!'
- 'Racism, nazism, and sexism are strictly forbidden!'
- 'Join our Mumble server! IP: 64.34.202.140:2862'
- 'Join our Discord server! Link: https://discordapp.com/invite/XXjmAmV/'
# Famous players - cannot be banned by username
famous_players: