Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
# Gradle
.gradle
build/

# Ignore Gradle build output directory
build
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import com.azuriom.azlink.bukkit.command.BukkitCommandSender;
import com.azuriom.azlink.bukkit.injector.InjectedHttpServer;
import com.azuriom.azlink.bukkit.injector.NettyLibraryLoader;
import com.azuriom.azlink.bukkit.integrations.AuthMeIntegration;
import com.azuriom.azlink.bukkit.integrations.FoliaSchedulerAdapter;
import com.azuriom.azlink.bukkit.integrations.MoneyPlaceholderExpansion;
import com.azuriom.azlink.bukkit.integrations.SkinsRestorerIntegration;
import com.azuriom.azlink.bukkit.integrations.NLoginIntegration;
import com.azuriom.azlink.bukkit.integrations.*;
import com.azuriom.azlink.common.AzLinkPlatform;
import com.azuriom.azlink.common.AzLinkPlugin;
import com.azuriom.azlink.common.command.CommandSender;
Expand Down Expand Up @@ -58,45 +54,39 @@ public void onEnable() {
@Override
protected HttpServer createHttpServer() {
NettyLibraryLoader libraryLoader = new NettyLibraryLoader(this);

try {
libraryLoader.loadRequiredLibraries();
} catch (Exception e) {
getLogger().error("Unable to load required libraries for instant commands", e);
return null;
}

if (plugin.getConfig().getHttpPort() == getServer().getPort()) {
return new InjectedHttpServer(AzLinkBukkitPlugin.this);
}

return super.createHttpServer();
}
};

saveDefaultConfig();

this.plugin.init();

getCommand("azlink").setExecutor(new BukkitCommandExecutor(this.plugin));
if (getCommand("azlink") != null) {
getCommand("azlink").setExecutor(new BukkitCommandExecutor(this.plugin));
}

scheduleTpsTask();

if (getConfig().getBoolean("authme-integration")
&& getServer().getPluginManager().getPlugin("AuthMe") != null) {
if (getConfig().getBoolean("authme-integration") && getServer().getPluginManager().getPlugin("AuthMe") != null) {
getServer().getPluginManager().registerEvents(new AuthMeIntegration(this), this);
}

if (getConfig().getBoolean("nlogin-integration")
&& getServer().getPluginManager().getPlugin("nLogin") != null) {
if (getConfig().getBoolean("nlogin-integration") && getServer().getPluginManager().getPlugin("nLogin") != null) {
NLoginIntegration.register(this);
}

if (getConfig().getBoolean("skinrestorer-integration")
&& getServer().getPluginManager().getPlugin("SkinsRestorer") != null) {
if (getConfig().getBoolean("skinrestorer-integration") && getServer().getPluginManager().getPlugin("SkinsRestorer") != null) {
try {
Class.forName("net.skinsrestorer.api.SkinsRestorer");

getServer().getPluginManager().registerEvents(new SkinsRestorerIntegration(this), this);
} catch (ClassNotFoundException e) {
getLogger().severe("SkinsRestorer integration requires SkinsRestorer v15.0.0 or higher");
Expand All @@ -105,6 +95,7 @@ && getServer().getPluginManager().getPlugin("SkinsRestorer") != null) {

if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
MoneyPlaceholderExpansion.enable(this);
VoteAndShopPlaceholderExpansion.enable(this);
}
}

Expand Down Expand Up @@ -141,9 +132,8 @@ public PlatformInfo getPlatformInfo() {
}

@Override
@SuppressWarnings("deprecation") // Folia support
public String getPluginVersion() {
return getDescription().getVersion();
return getPluginMeta().getVersion();
}

@Override
Expand All @@ -153,27 +143,16 @@ public Path getDataDirectory() {

@Override
public Optional<WorldData> getWorldData() {
int loadedChunks = getServer().getWorlds().stream()
.mapToInt(w -> w.getLoadedChunks().length)
.sum();

// Prevent 'Accessing entity state off owning region's thread' exception on Folia
int entities = isFolia() ? 0 : getServer().getWorlds().stream()
.mapToInt(w -> w.getEntities().size())
.sum();

int loadedChunks = getServer().getWorlds().stream().mapToInt(w -> w.getLoadedChunks().length).sum();
int entities = isFolia() ? 0 : getServer().getWorlds().stream().mapToInt(w -> w.getEntities().size()).sum();
return Optional.of(new WorldData(this.tpsTask.getTps(), loadedChunks, entities));
}

@Override
public Stream<CommandSender> getOnlinePlayers() {
if (getConfig().getBoolean("ignore-vanished-players", false)) {
return getServer().getOnlinePlayers()
.stream()
.filter(this::isPlayerVisible)
.map(BukkitCommandSender::new);
return getServer().getOnlinePlayers().stream().filter(this::isPlayerVisible).map(BukkitCommandSender::new);
}

return getServer().getOnlinePlayers().stream().map(BukkitCommandSender::new);
}

Expand All @@ -182,6 +161,7 @@ public int getMaxPlayers() {
return getServer().getMaxPlayers();
}


@Override
public void dispatchConsoleCommand(String command) {
getServer().dispatchCommand(getServer().getConsoleSender(), command);
Expand All @@ -199,17 +179,14 @@ private boolean isPlayerVisible(Player player) {
private void scheduleTpsTask() {
if (isFolia()) {
FoliaSchedulerAdapter.scheduleSyncTask(this, this.tpsTask, 1, 1);

return;
}

getServer().getScheduler().runTaskTimer(this, this.tpsTask, 1, 1);
}

private SchedulerAdapter createSchedulerAdapter() {
try {
Class.forName("io.papermc.paper.threadedregions.scheduler.ScheduledTask");

return FoliaSchedulerAdapter.create(this);
} catch (ClassNotFoundException e) {
return new JavaSchedulerAdapter(
Expand Down
Loading
Loading