-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: uploading 1.2.0 version (#25)
* 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
Showing
97 changed files
with
2,422 additions
and
2,011 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 0 additions & 137 deletions
137
src/main/java/io/v4guard/plugin/bungee/BungeeCheckProcessor.java
This file was deleted.
Oops, something went wrong.
149 changes: 149 additions & 0 deletions
149
src/main/java/io/v4guard/plugin/bungee/BungeeInstance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.