Skip to content
Merged
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
compileOnly(libs.blockstudio)
compileOnly(libs.paperApi)
implementation(libs.cloudPaper)
implementation(libs.jspecify)
}

// Project Settings
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ bukkit = "1.14.4-R0.1-SNAPSHOT"
spigot = "1.14.4-R0.1-SNAPSHOT"
spigotApi = "1.14.4-R0.1-SNAPSHOT"
cloudPaper = "2.0.0-beta.10"
jspecify = "1.0.0"

[plugins]
runPaper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }
Expand All @@ -28,4 +29,5 @@ lunachat = { module = "com.github.ucchyocean:LunaChat", version.ref = "lunachat"
bukkit = { module = "org.bukkit:bukkit", version.ref = "bukkit" }
spigot = { module = "org.spigotmc:spigot", version.ref = "spigot" }
spigotApi = { module = "org.spigotmc:spigot-api", version.ref = "spigotApi" }
cloudPaper = { module = "org.incendo:cloud-paper", version.ref = "cloudPaper" }
cloudPaper = { module = "org.incendo:cloud-paper", version.ref = "cloudPaper" }
jspecify = { module = "org.jspecify:jspecify", version.ref = "jspecify" }
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import be4rjp.blockstudio.BlockStudio;
import be4rjp.blockstudio.api.BlockStudioAPI;
import be4rjp.dadadachecker.DADADACheckerAPI;
import be4rjp.sclat.api.Sclat;
import be4rjp.sclat.api.Plugins;
import be4rjp.sclat.api.SclatUtil;
import be4rjp.sclat.api.ServerType;
import be4rjp.sclat.api.async.AsyncPlayerListener;
import be4rjp.sclat.api.async.AsyncThreadManager;
import be4rjp.sclat.api.config.CustomConfig;
import be4rjp.sclat.api.holo.PlayerHolograms;
import be4rjp.sclat.api.wiremesh.Wiremesh;
import be4rjp.sclat.commands.sclatCommandExecutor;
import be4rjp.sclat.config.Config;
import be4rjp.sclat.data.DataMgr;
import be4rjp.sclat.data.MapData;
import be4rjp.sclat.data.Match;
import be4rjp.sclat.data.PaintData;
import be4rjp.sclat.data.Wiremesh;
import be4rjp.sclat.gui.ClickListener;
import be4rjp.sclat.listener.SquidListener;
import be4rjp.sclat.lunachat.LunaChatListener;
Expand Down Expand Up @@ -50,6 +52,8 @@
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.ScoreboardManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -58,11 +62,12 @@
*
* @author Be4rJP
*/
public class Main extends JavaPlugin implements PluginMessageListener {
public class Sclat extends JavaPlugin implements PluginMessageListener {
private static final Logger logger = LoggerFactory.getLogger(Sclat.class);

public static Config conf;

private static Main plugin;
private static Sclat plugin;

public static Location lobby;

Expand Down Expand Up @@ -90,10 +95,6 @@ public class Main extends JavaPlugin implements PluginMessageListener {
// EquipmentShare
public static EquipmentServer es = null;

// API
public static boolean NoteBlockAPI = true;
public static boolean LunaChat = true;

// 重複しない数字
// ボム等で使用
private static int NDNumber = 0;
Expand All @@ -111,6 +112,8 @@ public class Main extends JavaPlugin implements PluginMessageListener {
public static double PARTICLE_RENDER_DISTANCE = 0;
public static double PARTICLE_RENDER_DISTANCE_SQUARED;

public static final PlayerHolograms playerHolograms = new PlayerHolograms();

@Override
public void onEnable() {
plugin = this;
Expand All @@ -122,35 +125,14 @@ public void onEnable() {
AsyncThreadManager.setup(1);

// ----------------------------APICheck-------------------------------
NoteBlockAPI = true;
if (!Bukkit.getPluginManager().isPluginEnabled("NoteBlockAPI")) {
getLogger().severe("*** NoteBlockAPI is not installed or not enabled. ***");
NoteBlockAPI = false;
if (!Plugins.onInit(logger))
return;
}
logger.info("API check was complted.");

// LunaChat
if (!Bukkit.getPluginManager().isPluginEnabled("LunaChat")) {
getLogger().severe("*** LunaChat is not installed or not enabled. ***");
LunaChat = false;
}
protocolManager = ProtocolLibrary.getProtocolManager();
SclatPacketListener.init();

// ProtocolLib
if (!Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
getLogger().severe("*** ProtocolLib is not installed or not enabled. ***");
return;
} else {
protocolManager = ProtocolLibrary.getProtocolManager();
new SclatPacketListener();
}

// DADADAChecker
if (!Bukkit.getPluginManager().isPluginEnabled("DADADAChecker")) {
getLogger().severe("*** DADADAChecker is not installed or not enabled. ***");
return;
} else {
dadadaCheckerAPI = new DADADACheckerAPI(this);
}
dadadaCheckerAPI = new DADADACheckerAPI(this);
// -------------------------------------------------------------------

// --------------------------Load config------------------------------
Expand Down Expand Up @@ -196,7 +178,7 @@ public void onEnable() {
pm.registerEvents(new SnowballListener(), this);
pm.registerEvents(new AsyncPlayerListener(), this);

if (LunaChat)
if (Plugins.LUNACHAT.isLoaded())
pm.registerEvents(new LunaChatListener(), this);
// -------------------------------------------------------------------

Expand Down Expand Up @@ -277,7 +259,7 @@ public void onEnable() {
// -------------------------------------------------------------------

// ------------------------Load NBS songs-----------------------------
if (NoteBlockAPI)
if (Plugins.NOTEBLOCKAPI.isLoaded())
NoteBlockAPIMgr.LoadSongFiles();
// -------------------------------------------------------------------

Expand Down Expand Up @@ -324,7 +306,7 @@ public void onEnable() {

// --------------------Send restarted server info---------------------
if (conf.getConfig().contains("RestartMatchCount"))
Sclat.sendRestartedServerInfo();
SclatUtil.sendRestartedServerInfo();
// -------------------------------------------------------------------

// -----------------------------Shop----------------------------------
Expand Down Expand Up @@ -369,7 +351,7 @@ public void onEnable() {
// -------------------------------------------------------------------

// ------------------------Tutorial wire mesh-------------------------
if (Main.tutorial) {
if (Sclat.tutorial) {
for (MapData mData : DataMgr.maplist) {
for (Wiremesh wiremesh : mData.getWiremeshListTask().getWiremeshsList()) {
wiremesh.startTask();
Expand Down Expand Up @@ -442,7 +424,7 @@ public void onDisable() {
as.remove();

// Worldが保存される前にアンロードして塗られた状態で保存されるのを防ぐ
if (Main.type == ServerType.LOBBY) {
if (Sclat.type == ServerType.LOBBY) {
for (String mapname : conf.getMapConfig().getConfigurationSection("Maps").getKeys(false)) {
String worldName = conf.getMapConfig().getString("Maps." + mapname + ".WorldName");
Bukkit.unloadWorld(worldName, false);
Expand All @@ -454,7 +436,7 @@ public void onDisable() {
}
}

public static Main getPlugin() {
public static Sclat getPlugin() {
return plugin;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

package be4rjp.sclat;
package be4rjp.sclat.api;

import be4rjp.sclat.api.GaugeAPI;
import be4rjp.sclat.api.Sclat;
import be4rjp.sclat.api.SoundType;
import be4rjp.sclat.Sclat;
import be4rjp.sclat.api.team.Team;
import be4rjp.sclat.data.DataMgr;
import be4rjp.sclat.data.Team;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -61,13 +59,13 @@ public void run() {
}
if (i == 40) {
if (winteam == DataMgr.getPlayerData(player).getTeam())
Sclat.playGameSound(player, SoundType.CONGRATULATIONS);
SclatUtil.playGameSound(player, SoundType.CONGRATULATIONS);
cancel();
}
i++;
}
};
task.runTaskTimer(Main.getPlugin(), 0, 2);
task.runTaskTimer(Sclat.getPlugin(), 0, 2);
}

public static void AreaResultAnimation(Player p, int team0point, int team1point, String team0color,
Expand Down Expand Up @@ -103,13 +101,13 @@ public void run() {
}
if (i == 40) {
if (winteam == DataMgr.getPlayerData(player).getTeam())
Sclat.playGameSound(player, SoundType.CONGRATULATIONS);
SclatUtil.playGameSound(player, SoundType.CONGRATULATIONS);
cancel();
}
i++;
}
};
task.runTaskTimer(Main.getPlugin(), 0, 2);
task.runTaskTimer(Sclat.getPlugin(), 0, 2);
}

public static void TDMResultAnimation(Player p, int team0point, int team1point, String team0color,
Expand Down Expand Up @@ -173,12 +171,12 @@ public void run() {
}
if (i == 40) {
if (winteam == DataMgr.getPlayerData(player).getTeam())
Sclat.playGameSound(player, SoundType.CONGRATULATIONS);
SclatUtil.playGameSound(player, SoundType.CONGRATULATIONS);
cancel();
}
i++;
}
};
task.runTaskTimer(Main.getPlugin(), 0, 2);
task.runTaskTimer(Sclat.getPlugin(), 0, 2);
}
}
6 changes: 3 additions & 3 deletions src/main/java/be4rjp/sclat/api/GlowingAPI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package be4rjp.sclat.api;

import be4rjp.sclat.Main;
import be4rjp.sclat.Sclat;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
Expand All @@ -9,15 +9,15 @@

public class GlowingAPI {
public static void setGlowing(Entity entity, Player player, boolean flag) {
PacketContainer packet = Main.protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
PacketContainer packet = Sclat.protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, entity.getEntityId());
WrappedDataWatcher watcher = new WrappedDataWatcher();
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class);
watcher.setEntity(entity);
watcher.setObject(0, serializer, (byte) (flag ? 0x40 : 0));
packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
try {
Main.protocolManager.sendServerPacket(player, packet);
Sclat.protocolManager.sendServerPacket(player, packet);
} catch (RuntimeException e) {
e.printStackTrace();
}
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/be4rjp/sclat/api/Plugins.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package be4rjp.sclat.api;

import org.bukkit.Bukkit;
import org.slf4j.Logger;

import java.util.ArrayList;

public enum Plugins {
DADADACHECKER("DADADAChecker"), LUNACHAT("LunaChat",
false), NOTEBLOCKAPI("NoteBlockAPI"), PROTOCOLLIB("ProtocolLib");

public final String pluginName;
public final boolean isRequired;
private Boolean _isLoaded = null;
Plugins(String pluginName) {
this(pluginName, true);
}
Plugins(String pluginName, boolean isRequired) {
this.pluginName = pluginName;
this.isRequired = isRequired;
}

public boolean isLoaded() {
if (_isLoaded == null) {
_isLoaded = Bukkit.getPluginManager().isPluginEnabled(pluginName);
}
return _isLoaded;
}

/**
* To support plugman load.
*/
private void resetLoadedState() {
_isLoaded = false;
}

/**
* Initialize check
*
* @return is init-check succeeded
*/
public static boolean onInit(Logger logger) {
ArrayList<String> missingPlugins = new ArrayList<>();
for (Plugins plugin : Plugins.values()) {
plugin.resetLoadedState();
if (!plugin.isLoaded() && plugin.isRequired) {
missingPlugins.add(plugin.pluginName);
}
}

// If some required plugins are missing
if (!missingPlugins.isEmpty()) {
logger.error("Some plugins are missing. Please install or enable.");
logger.error("*** Missing required plugins ***");
missingPlugins.forEach(p -> logger.error("- {}", p));
logger.error("********************************");
return false;
}

return true;
}
}
Loading