Remove some implementation redundancies

This commit is contained in:
ME1312 2020-08-16 14:30:36 -04:00
parent 26490dc140
commit b68fa0fec1
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
11 changed files with 160 additions and 158 deletions

View File

@ -182,15 +182,6 @@ public class ExternalHost extends Host implements ClientHandler {
}
@Override
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, false);
}
@Override
public boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, true);
}
protected boolean removeSubServer(UUID player, String name, boolean forced) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
SubServer server = servers.get(name.toLowerCase());
@ -212,15 +203,6 @@ public class ExternalHost extends Host implements ClientHandler {
}
@Override
public boolean recycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, false);
}
@Override
public boolean forceRecycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, true);
}
protected boolean recycleSubServer(UUID player, String name, boolean forced) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
SubServer s = servers.get(name.toLowerCase());
@ -261,15 +243,6 @@ public class ExternalHost extends Host implements ClientHandler {
}
@Override
public boolean deleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, false);
}
@Override
public boolean forceDeleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, true);
}
protected boolean deleteSubServer(UUID player, String name, boolean forced) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
SubServer s = servers.get(name.toLowerCase());

View File

@ -211,16 +211,9 @@ public class ExternalSubServer extends SubServerImpl {
} else return false;
}
public int edit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, false);
}
public int permaEdit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, true);
}
@SuppressWarnings({"deprecation", "unchecked"})
private int edit(UUID player, ObjectMap<String> edit, boolean perma) {
@Override
protected int edit(UUID player, ObjectMap<String> edit, boolean perma) {
if (isAvailable()) {
int c = 0;
boolean state = isRunning();

View File

@ -317,7 +317,20 @@ public abstract class Host implements ExtraDataHandler {
* @throws InterruptedException
* @return Success Status
*/
public abstract boolean removeSubServer(UUID player, String name) throws InterruptedException;
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, false);
}
/**
* Removes a SubServer
*
* @param player Player Removing
* @param name SubServer Name
* @param forced Forces the Removal
* @throws InterruptedException
* @return Success Status
*/
protected abstract boolean removeSubServer(UUID player, String name, boolean forced) throws InterruptedException;
/**
* Forces the Removal of a SubServer
@ -330,16 +343,18 @@ public abstract class Host implements ExtraDataHandler {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
* @return Success Status
*/
public abstract boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException;
public boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, true);
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @return Success Status
@ -349,16 +364,28 @@ public abstract class Host implements ExtraDataHandler {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
* @return Success Status
*/
public abstract boolean recycleSubServer(UUID player, String name) throws InterruptedException;
public boolean recycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, false);
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
* @param forced Forces the Deletion
* @return Success Status
*/
protected abstract boolean recycleSubServer(UUID player, String name, boolean forced) throws InterruptedException;
/**
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @return Success Status
@ -374,10 +401,12 @@ public abstract class Host implements ExtraDataHandler {
* @param name SubServer Name
* @return Success Status
*/
public abstract boolean forceRecycleSubServer(UUID player, String name) throws InterruptedException;
public boolean forceRecycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, true);
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -387,16 +416,28 @@ public abstract class Host implements ExtraDataHandler {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
* @return Success Status
*/
public abstract boolean deleteSubServer(UUID player, String name) throws InterruptedException;
public boolean deleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, false);
}
/**
* Forced the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
* @param forced Forces the Deletion
* @return Success Status
*/
protected abstract boolean deleteSubServer(UUID player, String name, boolean forced) throws InterruptedException;
/**
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -412,7 +453,9 @@ public abstract class Host implements ExtraDataHandler {
* @param name SubServer Name
* @return Success Status
*/
public abstract boolean forceDeleteSubServer(UUID player, String name) throws InterruptedException;
public boolean forceDeleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, true);
}
/**
* Resets this Host object

View File

@ -113,15 +113,6 @@ public class InternalHost extends Host {
}
@Override
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, false);
}
@Override
public boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException {
return removeSubServer(player, name, true);
}
protected boolean removeSubServer(UUID player, String name, boolean forced) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
SubServer server = servers.get(name.toLowerCase());
@ -140,15 +131,19 @@ public class InternalHost extends Host {
}
@Override
public boolean recycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, false, true);
}
@Override
public boolean forceRecycleSubServer(UUID player, String name) throws InterruptedException {
return recycleSubServer(player, name, true, true);
protected boolean recycleSubServer(UUID player, String name, boolean forced) throws InterruptedException {
return recycleSubServer(player, name, forced, true);
}
/**
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
* @param forced Forces the Deletion
* @param multithreading Uses Multithreading for I/O
* @return Success Status
*/
protected boolean recycleSubServer(UUID player, String name, boolean forced, boolean multithreading) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
@ -198,15 +193,19 @@ public class InternalHost extends Host {
}
@Override
public boolean deleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, false, true);
}
@Override
public boolean forceDeleteSubServer(UUID player, String name) throws InterruptedException {
return deleteSubServer(player, name, true, true);
protected boolean deleteSubServer(UUID player, String name, boolean forced) throws InterruptedException {
return deleteSubServer(player, name, forced, true);
}
/**
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
* @param forced Forces the Deletion
* @param multithreading Uses Multithreading for I/O
* @return Success Status
*/
protected boolean deleteSubServer(UUID player, String name, boolean forced, boolean multithreading) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();

View File

@ -287,16 +287,9 @@ public class InternalSubServer extends SubServerImpl {
} else return false;
}
public int edit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, false);
}
public int permaEdit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, true);
}
@SuppressWarnings({"deprecation", "unchecked"})
private int edit(UUID player, ObjectMap<String> edit, boolean perma) {
@Override
protected int edit(UUID player, ObjectMap<String> edit, boolean perma) {
if (isAvailable()) {
int c = 0;
boolean state = isRunning();

View File

@ -87,13 +87,8 @@ public abstract class SubServerController {
}
@Override
public int permaEdit(ObjectMap<String> edit) {
return SubServerController.this.edit(edit);
}
@Override
public int permaEdit(UUID player, ObjectMap<String> edit) {
return SubServerController.this.edit(player, edit);
public int edit(UUID player, ObjectMap<String> edit, boolean perma) {
return SubServerController.this.edit(player, edit, perma);
}
@Override
@ -256,19 +251,10 @@ public abstract class SubServerController {
*
* @param player Player Editing
* @param edit Edits
* @param perma Saves Changes
* @return Success Status
*/
public int edit(UUID player, ObjectMap<String> edit) {
return -1;
}
/**
* Edits the Server
*
* @param edit Edits
* @return Success Status
*/
public int edit(ObjectMap<String> edit) {
protected int edit(UUID player, ObjectMap<String> edit, boolean perma) {
return -1;
}

View File

@ -75,9 +75,24 @@ public abstract class SubServerImpl extends ServerImpl implements SubServer {
return command(null, command);
}
@Override
public int permaEdit(ObjectMap<String> edit) {
return permaEdit(null, edit);
public int edit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, false);
}
public int permaEdit(UUID player, ObjectMap<String> edit) {
return edit(player, edit, true);
}
/**
* Edits the Server
*
* @param player Player Editing
* @param edit Edits
* @param perma Saves Changes
* @return Success Status
*/
protected int edit(UUID player, ObjectMap<String> edit, boolean perma) {
return -1;
}
@Override

View File

@ -463,7 +463,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -506,7 +506,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -532,7 +532,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -541,7 +541,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -552,7 +552,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -572,7 +572,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -582,7 +582,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -594,7 +594,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -616,7 +616,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -626,7 +626,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -638,7 +638,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -660,7 +660,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -670,7 +670,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -682,7 +682,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status

View File

@ -463,7 +463,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -506,7 +506,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -532,7 +532,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -541,7 +541,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -552,7 +552,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -572,7 +572,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -582,7 +582,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -594,7 +594,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -616,7 +616,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -626,7 +626,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -638,7 +638,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -660,7 +660,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -670,7 +670,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -682,7 +682,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status

View File

@ -439,7 +439,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -482,7 +482,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -508,7 +508,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -517,7 +517,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -528,7 +528,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -548,7 +548,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -558,7 +558,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -570,7 +570,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -592,7 +592,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -602,7 +602,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -614,7 +614,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -636,7 +636,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -646,7 +646,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -658,7 +658,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status

View File

@ -439,7 +439,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -482,7 +482,7 @@ public class Host {
}
/**
* Forces the Removal of a SubServer (will move to 'Recently Deleted')
* Forces the Removal of a SubServer
*
* @param player Player Removing
* @param name SubServer Name
@ -508,7 +508,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -517,7 +517,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -528,7 +528,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
*/
@ -548,7 +548,7 @@ public class Host {
}
/**
* Delete a SubServer (will move to 'Recently Deleted')
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -558,7 +558,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer (will move to 'Recently Deleted')
*
* @param player Player Deleting
* @param name SubServer Name
@ -570,7 +570,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer (will move to 'Recently Deleted')
* Forces the Deletion of a SubServer (will move to 'Recently Deleted')
*
* @param name SubServer Name
* @param response Response Code
@ -592,7 +592,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -602,7 +602,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -614,7 +614,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -636,7 +636,7 @@ public class Host {
}
/**
* Delete a SubServer
* Deletes a SubServer
*
* @param name SubServer Name
* @return Success Status
@ -646,7 +646,7 @@ public class Host {
}
/**
* Forces the Deletion of a SubServer
* Deletes a SubServer
*
* @param player Player Deleting
* @param name SubServer Name
@ -658,7 +658,7 @@ public class Host {
}
/**
* Forced the Deletion of a SubServer
* Forces the Deletion of a SubServer
*
* @param name SubServer Name
* @return Success Status