Skip to content

Commit

Permalink
Clean the code
Browse files Browse the repository at this point in the history
  • Loading branch information
luluxe committed Feb 14, 2023
1 parent 9b89a9f commit 343504d
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

public class BungeePlugin extends Plugin {
public static BungeePlugin instance;

public BungeePlugin() {
instance = this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/communityanalytics/spigot/SpigotAPI.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.communityanalytics.spigot;

import com.google.gson.JsonObject;
import net.communityanalytics.spigot.api.MethodEnum;
import net.communityanalytics.spigot.api.APIRequest;
import net.communityanalytics.spigot.api.MethodEnum;

public class SpigotAPI {
public static APIRequest sessionStore(JsonObject data) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/net/communityanalytics/spigot/SpigotPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@

public class SpigotPlugin extends JavaPlugin {
public static SpigotPlugin instance;

public SpigotPlugin() {
instance = this;
}

private SessionManager manager = null;
private ILogger logger = null;
private SpigotConfig config = null;
private PlatformManager platformManager = null;

public SpigotPlugin() {
instance = this;
}

public static SessionManager manager() {
return instance.manager;
}

public static ILogger logger() {
return instance.logger;
}

public static SpigotConfig config() {
return instance.config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
// TODO class for each command

// Main command
if(args.length == 0) {
if (args.length == 0) {
try {
ApiResponse response = SpigotAPI.platformShow().sendRequest();
if(response.getStatus() == 403) {
if (response.getStatus() == 403) {
sender.sendMessage("§f(§b§lCommunityAnalytics§f) §cCan't auth to API:");
sender.sendMessage("§e» §cCheck your token in config.yml");
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.communityanalytics.spigot.configs;

import net.communityanalytics.common.interfaces.ConfigLoader;
import net.communityanalytics.spigot.SpigotPlugin;
import net.communityanalytics.spigot.configs.SpigotConfig;
import org.bukkit.configuration.file.YamlConfiguration;

public class SpigotConfigLoader implements ConfigLoader {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/communityanalytics/spigot/data/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ public class Session {

private final UUID uuid;
private final String name;
private final LocalDateTime join_at;
private String ip_connect;
private String ip_user;
private final LocalDateTime join_at;
private LocalDateTime quit_at = null;

/**
* @param uuid Player's UUID
* @param name Player's name
* @param ip_connect Player's ip used for join the server
* @param ip_user Player's ip
* @param ip_user Player's ip
*/
public Session(UUID uuid, String name, String ip_connect, String ip_user) {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onQuit(PlayerQuitEvent event) {
* Get ip_connect and ip_user from proxy
*
* @param channel String
* @param player Player
* @param player Player
* @param message byte[]
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PlatformManager {
public void getPlatformInfo() {
try {
ApiResponse response = SpigotAPI.platformShow().sendRequest();
if(response.getStatus() != 200) {
if (response.getStatus() != 200) {
SpigotPlugin.logger().printError("Can't auth to API:");
SpigotPlugin.logger().printError("Check your token in config.yml");
error();
Expand All @@ -21,10 +21,10 @@ public void getPlatformInfo() {
version = response.getStringArg("plugin_version");

SpigotPlugin.logger().printInfo("Connected to CommunityAnalytics API");
if(isOutdated()) {
if (isOutdated()) {
SpigotPlugin.logger().printError("Your plugin is outdated! (Last version " + version + ")");
}
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
error();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.concurrent.TimeUnit;

public class SessionManager {
private ScheduledFuture<?> scheduledFuture = null;
private final List<Session> sessions = new ArrayList<Session>();
private ScheduledFuture<?> scheduledFuture = null;

public SessionManager() {
SpigotPlugin.logger().printDebug("Session manager started");
Expand Down Expand Up @@ -82,7 +82,7 @@ public void sendAPI() {

try {
request.sendRequest();
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/net/communityanalytics/velocity/VelocityPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@

@Plugin(id = "communityanalytics", name = "CommunityAnalytics", version = "1.0.0")
public class VelocityPlugin {
public static VelocityPlugin instance;
private final ChannelIdentifier channel = new LegacyChannelIdentifier(CommunityAnalytics.CHANNEL_INFO);
private ProxyServer server = null;
private Logger logger = null;

public static VelocityPlugin instance;
public VelocityPlugin() {
instance = this;
}

@Inject
public VelocityPlugin(ProxyServer server, Logger logger) {
// Register velocity things
this.server = server;
this.logger = logger;
}

public ChannelIdentifier getChannel() {
return channel;
}
Expand All @@ -31,17 +38,10 @@ public ProxyServer getServer() {
return server;
}

public Logger getLogger() {
return logger;
}

// Events

@Inject
public VelocityPlugin(ProxyServer server, Logger logger) {
// Register velocity things
this.server = server;
this.logger = logger;
public Logger getLogger() {
return logger;
}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void onMessage(PluginMessageEvent event) {
serverConnection.sendPluginMessage(VelocityPlugin.instance.getChannel(), out.toByteArray());
}
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CommunityAnalytics
author: Maxlego08
author: FNetwork
main: net.communityanalytics.bungee.BungeePlugin
version: 1.0.0
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CommunityAnalytics
author: Maxlego08
author: FNetwork
main: net.communityanalytics.spigot.SpigotPlugin
website: https://communityanalytics.net
version: 1.0.0
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/velocity-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"name": "CommunityAnalytics",
"version": "1.0.0",
"authors": [
"Maxlego08",
"luluxe"
"FNetwork"
],
"dependencies": [],
"main": "net.communityanalytics.velocity.VelocityPlugin"
Expand Down

0 comments on commit 343504d

Please sign in to comment.