mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Codacy Complacency Part 2
This commit is contained in:
parent
7a394e52e4
commit
a4e23dc03f
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.sun.org.apache.xml.internal.security.Init;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -288,8 +287,10 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
/**
|
/**
|
||||||
* This class is provided to please Codacy.
|
* This class is provided to please Codacy.
|
||||||
*/
|
*/
|
||||||
private final class Initializer {
|
private final class Initializer
|
||||||
public Initializer() {
|
{
|
||||||
|
public Initializer()
|
||||||
|
{
|
||||||
initServices();
|
initServices();
|
||||||
initAdminUtils();
|
initAdminUtils();
|
||||||
initBridges();
|
initBridges();
|
||||||
@ -297,7 +298,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
initHTTPD();
|
initHTTPD();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initServices() {
|
private void initServices()
|
||||||
|
{
|
||||||
// Start services
|
// Start services
|
||||||
si = new ServerInterface();
|
si = new ServerInterface();
|
||||||
sf = new SavedFlags();
|
sf = new SavedFlags();
|
||||||
@ -335,7 +337,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
ptero = new Pterodactyl();
|
ptero = new Pterodactyl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAdminUtils() {
|
private void initAdminUtils()
|
||||||
|
{
|
||||||
// Single admin utils
|
// Single admin utils
|
||||||
cs = new CommandSpy();
|
cs = new CommandSpy();
|
||||||
ca = new Cager();
|
ca = new Cager();
|
||||||
@ -350,7 +353,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
mo = new Monitors();
|
mo = new Monitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBridges() {
|
private void initBridges()
|
||||||
|
{
|
||||||
// Start bridges
|
// Start bridges
|
||||||
btb = new BukkitTelnetBridge();
|
btb = new BukkitTelnetBridge();
|
||||||
cpb = new CoreProtectBridge();
|
cpb = new CoreProtectBridge();
|
||||||
@ -361,7 +365,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
wgb = new WorldGuardBridge();
|
wgb = new WorldGuardBridge();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFun() {
|
private void initFun()
|
||||||
|
{
|
||||||
// Fun
|
// Fun
|
||||||
cul = new CurseListener();
|
cul = new CurseListener();
|
||||||
it = new ItemFun();
|
it = new ItemFun();
|
||||||
@ -371,7 +376,8 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
tr = new Trailer();
|
tr = new Trailer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initHTTPD() {
|
private void initHTTPD()
|
||||||
|
{
|
||||||
// HTTPD
|
// HTTPD
|
||||||
hd = new HTTPDaemon();
|
hd = new HTTPDaemon();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.httpd.module;
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.httpd.module;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -181,6 +180,7 @@ public class Module_schematic extends HTTPDModule
|
|||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reduced NPath Complexity.
|
||||||
private void uploadSchematic(String remoteAddress) throws SchematicTransferException
|
private void uploadSchematic(String remoteAddress) throws SchematicTransferException
|
||||||
{
|
{
|
||||||
Map<String, String> files = getFiles();
|
Map<String, String> files = getFiles();
|
||||||
@ -203,6 +203,21 @@ public class Module_schematic extends HTTPDModule
|
|||||||
throw new SchematicTransferException("Can't resolve original file name.");
|
throw new SchematicTransferException("Can't resolve original file name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func1(tempFile, origFileName);
|
||||||
|
|
||||||
|
final File targetFile = new File(SCHEMATIC_FOLDER.getPath(), origFileName);
|
||||||
|
|
||||||
|
if (targetFile.exists())
|
||||||
|
{
|
||||||
|
throw new SchematicTransferException("Schematic already exists on the server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
func2(tempFile, targetFile, remoteAddress);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void func1(File tempFile, String origFileName) throws SchematicTransferException
|
||||||
|
{
|
||||||
if (tempFile.length() > FileUtils.ONE_MB)
|
if (tempFile.length() > FileUtils.ONE_MB)
|
||||||
{
|
{
|
||||||
throw new SchematicTransferException("Schematic is too big (1mb max).");
|
throw new SchematicTransferException("Schematic is too big (1mb max).");
|
||||||
@ -217,13 +232,10 @@ public class Module_schematic extends HTTPDModule
|
|||||||
{
|
{
|
||||||
throw new SchematicTransferException("File name must be alphanumeric, between 1 and 30 characters long (inclusive), and have a \".schematic\" extension.");
|
throw new SchematicTransferException("File name must be alphanumeric, between 1 and 30 characters long (inclusive), and have a \".schematic\" extension.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final File targetFile = new File(SCHEMATIC_FOLDER.getPath(), origFileName);
|
private void func2(File tempFile, File targetFile, String remoteAddress) throws SchematicTransferException
|
||||||
if (targetFile.exists())
|
{
|
||||||
{
|
|
||||||
throw new SchematicTransferException("Schematic already exists on the server.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileUtils.copyFile(tempFile, targetFile);
|
FileUtils.copyFile(tempFile, targetFile);
|
||||||
@ -251,7 +263,6 @@ public class Module_schematic extends HTTPDModule
|
|||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
throw new SchematicTransferException();
|
throw new SchematicTransferException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response downloadSchematic(String schematicName) throws SchematicTransferException
|
private Response downloadSchematic(String schematicName) throws SchematicTransferException
|
||||||
|
Loading…
Reference in New Issue
Block a user