Skip to content

Commit

Permalink
1.17 support
Browse files Browse the repository at this point in the history
Loading issues with Wildstacker and GriefPrevention (hopefully for good now!)
  • Loading branch information
Sefiraat committed Jul 2, 2021
1 parent f752856 commit 09364d6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sefiraat</groupId>
<artifactId>DankTech</artifactId>
<version>1.2.7</version>
<version>1.2.8</version>

<build>
<plugins>
Expand Down Expand Up @@ -158,6 +158,7 @@
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
Expand Down Expand Up @@ -195,6 +196,7 @@
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.17.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand Down Expand Up @@ -269,6 +271,7 @@
<groupId>com.bgsoftware</groupId>
<artifactId>WildStackerAPI</artifactId>
<version>latest</version>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/io/github/sefiraat/danktech/DankTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public PaperCommandManager getCommandManager() {
public Protection getProtection() {
return protection;
}
public void setProtection(Protection protection) {
this.protection = protection;
}
public Config getConfigClass() {
return configClass;
}
Expand Down Expand Up @@ -98,8 +101,6 @@ public void onEnable() {
sortConfigs();

configClass = new Config();
supportedPlugins = new SupportedPlugins(this);
protection = new Protection();

registerCommands();

Expand All @@ -113,8 +114,7 @@ public void onEnable() {
TimerSave timerSave = new TimerSave(this);
timerSave.runTaskTimerAsynchronously (this, 0, 1200L);

TimerHooks timerHooks = new TimerHooks(this);
timerHooks.runTaskTimer(this, 1L, 100L);
this.getServer().getScheduler().runTask(this, this::afterStart);

if (!isUnitTest) {
int pluginId = 11208;
Expand Down Expand Up @@ -208,4 +208,8 @@ private void addRecipes() {
this.getServer().addRecipe(Recipes.recipeTrash());
}

public void afterStart() {
this.supportedPlugins = new SupportedPlugins(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static GuiItem guiUnassignedSlot() {
public static GuiItem guiPackAssignedSlot(@Nonnull Long dankID, @Nonnull Integer slot) {
ItemStack i = DankTech.getInstance().getDankStorageConfig().getItemStack(CONFIG_GETTER_SECTION_DANK_ID + "." + dankID + "." + CONFIG_GETTER_VAL_SLOT + slot + "." + CONFIG_GETTER_VAL_STACK);
assert i != null;
GuiItem g = ItemBuilder.from(i).asGuiItem();
GuiItem g = ItemBuilder.from(i.clone()).asGuiItem();
g.setAction(event -> event.setCancelled(true));
return g;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class Protection {
private WorldGuardPlugin worldGuard;
private FPlayers factions;

public Protection() {
supportedPlugins = DankTech.getInstance().getSupportedPlugins();
public Protection(SupportedPlugins supportedPlugins) {
this.supportedPlugins = supportedPlugins;
Utils.dbgMsg("Protection plugins sorted");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ public boolean isWildStacker() {
}

public SupportedPlugins(DankTech plugin) {

this.plugin = plugin;

Utils.dbgMsg("Setting up supported plugins");
Utils.dbgMsg("Setting up post-load supported plugins");
mcMMO = plugin.getServer().getPluginManager().getPlugin("mcMMO") != null;
Utils.dbgMsg("-- mcMMO : " + mcMMO);
griefPrevention = plugin.getServer().getPluginManager().getPlugin("GriefPrevention") != null;
griefPrevention = plugin.getServer().getPluginManager().isPluginEnabled("GriefPrevention");
Utils.dbgMsg("-- griefPrevention : " + griefPrevention);
worldGuard = plugin.getServer().getPluginManager().getPlugin("WorldGuard") != null;
Utils.dbgMsg("-- worldGuard : " + worldGuard);
Expand All @@ -68,10 +66,8 @@ public SupportedPlugins(DankTech plugin) {
Utils.dbgMsg("Skipping Slimefun Integration");
}

plugin.setProtection(new Protection(this));
}

public void setupPostLoadPlugins() {
Utils.dbgMsg("Setting up post-load supported plugins");
}

}
16 changes: 14 additions & 2 deletions src/main/java/io/github/sefiraat/danktech/timers/TimerHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ public TimerHooks(DankTech parent) {
this.parent = parent;
}


/**
* When an object implementing interface {@code Runnable} is used
* to create a thread, starting the thread causes the object's
* {@code run} method to be called in that separately executing
* thread.
* <p>
* The general contract of the method {@code run} is that it may
* take any action whatsoever.
*
* @see Thread#run()
*/
@Override
public void run() {
parent.getSupportedPlugins().setupPostLoadPlugins();
this.cancel();

}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DankTech
version: 1.2.7
version: 1.2.8
main: io.github.sefiraat.danktech.DankTech
api-version: 1.16
softdepend: [Slimefun, mcMMO]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ void testConfigurations() {
}

@Test
@DisplayName("Protections loaded")
void testProtection() {
Assertions.assertNotNull(plugin.getProtection());
}

@Test
@DisplayName("Protections loaded")
@DisplayName("Commands loaded")
void testCommandManager() {
Assertions.assertNotNull(plugin.getCommandManager());
}
Expand Down

0 comments on commit 09364d6

Please sign in to comment.