Finalized lombok removal

Finally removed all lomboks, also reduced npath complexity for FreedomCommand.FCommand#execute and removed empty constructor from Discord
This commit is contained in:
Paldiu 2020-12-29 21:37:50 -06:00
parent fd725ca6c5
commit 9352a48650
7 changed files with 95 additions and 74 deletions

View File

@ -9,24 +9,6 @@
</value>
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />

View File

@ -4,14 +4,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.reflections.Reflections;
public class CommandLoader extends FreedomService
{
@Getter
private final List<FreedomCommand> commands;
public CommandLoader()
@ -79,4 +77,9 @@ public class CommandLoader extends FreedomService
FLog.info("Loaded " + commands.size() + " commands");
}
public List<FreedomCommand> getCommands()
{
return commands;
}
}

View File

@ -27,6 +27,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class FreedomCommand implements CommandExecutor, TabCompleter
{
@ -334,53 +335,75 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
{
cmd.sender = sender;
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
{
msg(ChatColor.RED + "You are on cooldown for this command.");
return true;
}
if (func4()) return true;
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
{
msg(ChatColor.RED + "Host console is not allowed to use this command!");
return true;
}
if (func1()) return true;
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
{
msg(NO_PERMISSION);
return true;
}
if (func2()) return true;
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
{
msg(ONLY_CONSOLE);
return true;
}
func3();
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
{
msg(ONLY_IN_GAME);
return true;
}
if (perms.cooldown() != 0 && !isAdmin(sender))
{
COOLDOWN_TIMERS.put(sender, cmd);
timer.schedule(new TimerTask()
{
@Override
public void run()
{
COOLDOWN_TIMERS.remove(sender);
}
}, perms.cooldown() * 1000L);
}
return cmd.onCommand(sender, this, commandLabel, args);
}
return false;
}
public boolean func1() {
if (perms.source() == SourceType.ONLY_CONSOLE && sender instanceof Player)
{
msg(ONLY_CONSOLE);
return true;
}
if (perms.source() == SourceType.ONLY_IN_GAME && sender instanceof ConsoleCommandSender)
{
msg(ONLY_IN_GAME);
return true;
}
return false;
}
public boolean func2() {
if (!plugin.rm.getRank(sender).isAtLeast(perms.level()))
{
msg(NO_PERMISSION);
return true;
}
if (perms.blockHostConsole() && FUtil.isFromHostConsole(sender.getName()) && !FUtil.inDeveloperMode())
{
msg(ChatColor.RED + "Host console is not allowed to use this command!");
return true;
}
return false;
}
public void func3() {
if (perms.cooldown() != 0 && !isAdmin(sender))
{
COOLDOWN_TIMERS.put(sender, cmd);
timer.schedule(new TimerTask()
{
@Override
public void run()
{
COOLDOWN_TIMERS.remove(sender);
}
}, perms.cooldown() * 1000L);
}
}
public boolean func4() {
if (COOLDOWN_TIMERS.containsKey(sender) && COOLDOWN_TIMERS.containsValue(cmd))
{
msg(ChatColor.RED + "You are on cooldown for this command.");
return true;
}
return false;
}
@NotNull
@Override
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, String[] args)
{

View File

@ -503,10 +503,6 @@ public class Discord extends FreedomService
// Do no ask why this is here. I spent two hours trying to make a simple thing work
public class StartEvent
{
public StartEvent()
{
}
public void start()
{
messageChatChannel("**Server has started**");

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.fun;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.GameMode;
@ -101,12 +100,8 @@ public class Landminer extends FreedomService
public static class Landmine
{
@Getter
private final Location location;
@Getter
private final Player planter;
@Getter
private final double radius;
public Landmine(Location location, Player player, double radius)
@ -121,5 +116,20 @@ public class Landminer extends FreedomService
{
return this.location.toString() + ", " + this.radius + ", " + this.planter.getName();
}
public Location getLocation()
{
return location;
}
public Player getPlanter()
{
return planter;
}
public double getRadius()
{
return radius;
}
}
}

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.httpd;
import java.lang.reflect.Constructor;
import java.util.Objects;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -10,8 +9,6 @@ import org.bukkit.Bukkit;
public abstract class ModuleExecutable
{
@Getter
private final boolean async;
public ModuleExecutable(boolean async)
@ -71,4 +68,8 @@ public abstract class ModuleExecutable
public abstract NanoHTTPD.Response getResponse(NanoHTTPD.HTTPSession session);
public boolean isAsync()
{
return async;
}
}

View File

@ -8,7 +8,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -21,10 +20,7 @@ import org.bukkit.entity.Player;
public class PlayerList extends FreedomService
{
@Getter
public final Map<String, FPlayer> playerMap = Maps.newHashMap(); // ip,dataMap
@Getter
public final Map<String, PlayerData> dataMap = Maps.newHashMap(); // username, data
@Override
@ -303,4 +299,14 @@ public class PlayerList extends FreedomService
return player;
}
public Map<String, FPlayer> getPlayerMap()
{
return playerMap;
}
public Map<String, PlayerData> getDataMap()
{
return dataMap;
}
}