Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei1058 committed Aug 20, 2024
1 parent 7de1317 commit 1fdc3f4
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 140 deletions.
17 changes: 5 additions & 12 deletions bedwars-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@
<artifactId>versionsupport_v1_20_R4</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>versionsupport_v1_21_R1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.andrei1058.bedwars</groupId>
<artifactId>versionsupport-common</artifactId>
Expand Down Expand Up @@ -326,18 +331,6 @@
<version>24.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R4</artifactId>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.andrei1058.spigot.sidebar</groupId>
<artifactId>sidebar-v1_20_R4</artifactId>
<version>23.12</version>
<scope>compile</scope>
</dependency>
<!-- End of Sidebar LIB-->
<!-- Slime Paper -->
<dependency>
Expand Down
42 changes: 34 additions & 8 deletions bedwars-plugin/src/main/java/com/andrei1058/bedwars/BedWars.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class BedWars extends JavaPlugin {
private static Chat chat = new NoChat();
protected static Level level;
private static Economy economy;
private static final String version = Bukkit.getServer().getClass().getName().split("\\.")[3];
private static String version;
private static String lobbyWorld = "";
private static boolean shuttingDown = false;

Expand Down Expand Up @@ -162,28 +162,37 @@ public void onLoad() {
Class supp;

try {
supp = Class.forName("com.andrei1058.bedwars.support.version." + version + "." + version);
supp = Class.forName(
"com.andrei1058.bedwars.support.version." + getServerVersion() + "." + getServerVersion());
} catch (ClassNotFoundException e) {
serverSoftwareSupport = false;
this.getLogger().severe("I can't run on your version: " + version);
this.getLogger().severe("I can't run on your version: " + getServerVersion());
return;
}

api = new API();
Bukkit.getServicesManager().register(com.andrei1058.bedwars.api.BedWars.class, api, this, ServicePriority.Highest);

try {
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
Bukkit.getLogger().severe(Bukkit.getServer().getClass().getName());
//noinspection unchecked
nms = (VersionSupport) supp.getConstructor(Class.forName("org.bukkit.plugin.Plugin"), String.class).newInstance(this, version);
nms = (VersionSupport) supp.getConstructor(
Class.forName("org.bukkit.plugin.Plugin"), String.class
).newInstance(this, getServerVersion());
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException |
ClassNotFoundException e) {
e.printStackTrace();
serverSoftwareSupport = false;
this.getLogger().severe("Could not load support for server version: " + version);
this.getLogger().severe("Could not load support for server version: " + getServerVersion());
return;
}

this.getLogger().info("Loading support for paper/spigot: " + version);
this.getLogger().info("Loading support for paper/spigot: " + getServerVersion());

// Setup languages
new English();
Expand Down Expand Up @@ -211,6 +220,12 @@ public void onLoad() {

@Override
public void onEnable() {
getLogger().severe(Bukkit.getServer().getClass().getName());
getLogger().severe(Bukkit.getServer().getClass().getName());
getLogger().severe(Bukkit.getServer().getClass().getName());
getLogger().severe(Bukkit.getServer().getClass().getName());
getLogger().severe(Bukkit.getServer().getClass().getName());
getLogger().severe(Bukkit.getServer().getClass().getName());
if (!serverSoftwareSupport) {
Bukkit.getPluginManager().disablePlugin(this);
return;
Expand Down Expand Up @@ -315,7 +330,11 @@ public void onEnable() {
registerEvents(new InvisibilityPotionListener());

/* Load join signs. */
loadArenasAndSigns();
try {
loadArenasAndSigns();
} catch (Exception exception) {
exception.printStackTrace();
}

statsManager = new StatsManager();

Expand Down Expand Up @@ -726,6 +745,13 @@ public static void setLobbyWorld(String lobbyWorld) {
* @since v0.6.5beta
*/
public static String getServerVersion() {
if (null == version) {
version = Bukkit.getServer().getClass().getName().split("\\.")[3];
if (version.equals("CraftServer")) {
// todo it is probably PAPER, find out how to get nms version
}

}
return version;
}

Expand Down Expand Up @@ -759,7 +785,7 @@ public static void setParty(Party party) {
public void performDeprecationCheck() {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
if (Arrays.stream(nms.getClass().getAnnotations()).anyMatch(annotation -> annotation instanceof Deprecated)) {
this.getLogger().warning("Support for "+getServerVersion()+" is scheduled for removal. " +
this.getLogger().warning("Support for " + getServerVersion() + " is scheduled for removal. " +
"Please consider upgrading your server software to a newer Minecraft version.");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ public class ShopManager extends ConfigManager {

public ShopManager() {
super(BedWars.plugin, "shop", BedWars.plugin.getDataFolder().getPath());
saveDefaults();
loadShop();
registerListeners();
try {
saveDefaults();
loadShop();
registerListeners();
} catch (Exception exception){
exception.printStackTrace();
}
}

private void saveDefaults() {
Expand Down
Loading

0 comments on commit 1fdc3f4

Please sign in to comment.