Skip to content

Commit

Permalink
update: uploading 1.2.0 version (#25)
Browse files Browse the repository at this point in the history
* update: uploading 1.2.0 version

* fix: fix some mistakes in 1.2.0

* fix: fix some mistakes in 1.2.0

* fix: brack check task fails sometimes

* fix: brand check task fails sometimes

* update: new cache system, various fixes and refactoring

* fix: respect wait mode setting

* fix: make it works
  • Loading branch information
f4n74z14 authored Nov 21, 2023
1 parent 47eb503 commit d9271dc
Show file tree
Hide file tree
Showing 97 changed files with 2,422 additions and 2,011 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.v4guard</groupId>
<artifactId>v4guard-plugin</artifactId>
<version>1.1.4b</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -95,7 +95,7 @@
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
Expand All @@ -104,7 +104,7 @@
</repository>
<repository>
<id>papermc</id>
<url> https://repo.papermc.io/repository/maven-public/</url>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
Expand Down Expand Up @@ -140,7 +140,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<version>20230227</version>
</dependency>

<dependency>
Expand Down
137 changes: 0 additions & 137 deletions src/main/java/io/v4guard/plugin/bungee/BungeeCheckProcessor.java

This file was deleted.

149 changes: 149 additions & 0 deletions src/main/java/io/v4guard/plugin/bungee/BungeeInstance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package io.v4guard.plugin.bungee;

import io.v4guard.plugin.bungee.accounts.BungeeMessageReceiver;
import io.v4guard.plugin.bungee.adapter.BungeeMessenger;
import io.v4guard.plugin.bungee.cache.BungeeCheckDataCache;
import io.v4guard.plugin.bungee.check.BungeeCheckProcessor;
import io.v4guard.plugin.bungee.listener.PlayerListener;
import io.v4guard.plugin.bungee.listener.PluginMessagingListener;
import io.v4guard.plugin.core.CoreInstance;
import io.v4guard.plugin.core.accounts.MessageReceiver;
import io.v4guard.plugin.core.cache.CheckDataCache;
import io.v4guard.plugin.core.check.brand.BrandCheckProcessor;
import io.v4guard.plugin.core.compatibility.PlayerFetchResult;
import io.v4guard.plugin.core.compatibility.ServerPlatform;
import io.v4guard.plugin.core.compatibility.UniversalPlugin;
import io.v4guard.plugin.core.compatibility.UniversalTask;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;

import java.util.concurrent.TimeUnit;
import java.util.logging.Level;

public class BungeeInstance extends Plugin implements UniversalPlugin {

private static BungeeInstance instance;
private BungeeMessenger messenger;
private BungeeCheckDataCache checkDataCache;
private BungeeMessageReceiver messageReceiver;
private BungeeCheckProcessor checkProcessor;
private PluginMessagingListener brandCheckProcessor;
private CoreInstance coreInstance;

@Override
public void onEnable() {
getLogger().info("(Bungee) Enabling...");
getLogger().warning("(Bungee) Remember to allow Metrics on your firewall.");

new Metrics(this, 16219);

instance = this;

this.checkProcessor = new BungeeCheckProcessor(this);
this.brandCheckProcessor = new PluginMessagingListener();
this.messenger = new BungeeMessenger();
this.checkDataCache = new BungeeCheckDataCache();
this.messageReceiver = new BungeeMessageReceiver();

try {
this.coreInstance = new CoreInstance(ServerPlatform.BUNGEE, this);
this.coreInstance.initialize();
} catch (Exception exception) {
getLogger().log(Level.SEVERE, "(Bungee) Enabling... [ERROR]", exception);
return;
}

//this.getProxy().registerChannel(MessageReceiver.CHANNEL);
this.getProxy().getPluginManager().registerListener(this, this.messageReceiver);
this.getProxy().getPluginManager().registerListener(this, this.brandCheckProcessor);
this.getProxy().getPluginManager().registerListener(this, new PlayerListener(this));

getLogger().info("(Bungee) Enabling... [DONE]");
}

@Override
public void onDisable() {
getLogger().info("(Bungee) Disabling...");
getLogger().info("(Bungee) Disconnecting from the backend...");

try {
this.coreInstance.getBackend().getSocket().disconnect();
} catch (Exception exception) {
getLogger().log(Level.SEVERE, "(Bungee) Disabling... [ERROR]", exception);
return;
}

getLogger().info("(Bungee) Disabling... [DONE]");
}

public static BungeeInstance get() {
return instance;
}

public String getPluginName() {
return getDescription().getName();
}

public boolean isPluginEnabled(String pluginName) {
return this.getProxy().getPluginManager().getPlugin(pluginName) != null;
}

@Override
public PlayerFetchResult<ProxiedPlayer> fetchPlayer(String playerName) {
ProxiedPlayer player = getProxy().getPlayer(playerName);

if (player == null) {
return new PlayerFetchResult<>(null, null, false);
}

Server server = player.getServer();

return new PlayerFetchResult<>(
player
, server == null ? null : server.getInfo().getName()
, true
);
}

public void kickPlayer(String playerName, String reason) {
PlayerFetchResult<ProxiedPlayer> fetchedPlayer = fetchPlayer(playerName);

if (fetchedPlayer.isOnline()) {
fetchedPlayer.getPlayer().disconnect(TextComponent.fromLegacyText(reason));
}
}

@Override
public UniversalTask schedule(Runnable runnable, long delay, long period, TimeUnit timeUnit) {
return new BungeeTask(getProxy().getScheduler().schedule(this, runnable, delay, period, timeUnit));
}

@Override
public BungeeMessenger getMessenger() {
return messenger;
}

@Override
public BungeeCheckDataCache getCheckDataCache() {
return checkDataCache;
}

@Override
public MessageReceiver getMessageReceiver() {
return messageReceiver;
}

@Override
public BungeeCheckProcessor getCheckProcessor() {
return checkProcessor;
}

@Override
public BrandCheckProcessor getBrandCheckProcessor() {
return brandCheckProcessor;
}

}
17 changes: 17 additions & 0 deletions src/main/java/io/v4guard/plugin/bungee/BungeeTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.v4guard.plugin.bungee;

import io.v4guard.plugin.core.compatibility.UniversalTask;
import net.md_5.bungee.api.scheduler.ScheduledTask;

public class BungeeTask implements UniversalTask {
private final ScheduledTask TASK;

public BungeeTask(ScheduledTask task) {
this.TASK = task;
}

@Override
public void cancel() {
TASK.cancel();
}
}
Loading

0 comments on commit d9271dc

Please sign in to comment.