Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
BeepSterr committed Jun 11, 2024
2 parents 2ba218d + 9b91ef4 commit a2fe9e5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev_server/server.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Minecraft server properties
#Tue Jun 11 02:30:47 CEST 2024
#Tue Jun 11 06:14:47 CEST 2024
accepts-transfers=false
allow-flight=false
allow-nether=false
Expand Down
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -76,6 +76,10 @@
<id>glaremasters repo</id>
<url>https://repo.glaremasters.me/repository/towny/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -100,7 +104,13 @@
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>0.99.5.0</version>
<version>0.99.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/dev/beeps/plugins/BetterConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public enum EconMode {
PERCENTAGE
}

public enum OverrideTypes {
ALL,
ITEMS,
ARMOR,
INVENTORY,
HOTBAR,
EXP,
EXP_LEVEL,
POTIONS,
HUNGER,
ECO
}

public BetterConfig(BetterKeepInventory _plugin, FileConfiguration _config){

// set instance to config object
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/beeps/plugins/BetterKeepInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import dev.beeps.plugins.Commands.CmdMain;
import dev.beeps.plugins.Depends.Papi;
import dev.beeps.plugins.Events.OnPlayerDeath;
import dev.beeps.plugins.Events.OnPlayerRespawn;
import org.bstats.bukkit.Metrics;
Expand Down Expand Up @@ -34,9 +35,12 @@ public final class BetterKeepInventory extends JavaPlugin implements Listener {
public Map<UUID, ArrayList<PotionEffect>> potionMap = new HashMap<UUID, ArrayList<org.bukkit.potion.PotionEffect>>();
public Map<UUID, Integer> graceMap = new HashMap<UUID, Integer>();

static public BetterKeepInventory instance;

@Override
public void onEnable() {

instance = this;
config = new BetterConfig(this, _config);

// event handlers
Expand All @@ -53,6 +57,12 @@ public void onEnable() {
// loops
startGraceCheck();

// Enable PAPI Integration
if(checkDependency("PlaceholderAPI")){
log(Level.INFO, "PlaceholderAPI found, enabling extension");
new Papi().register();
}

}

@Override
Expand Down
54 changes: 54 additions & 0 deletions src/main/java/dev/beeps/plugins/Depends/Papi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dev.beeps.plugins.Depends;

import dev.beeps.plugins.BetterConfig;
import dev.beeps.plugins.BetterKeepInventory;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.jetbrains.annotations.NotNull;

public class Papi extends PlaceholderExpansion {



@Override
public @NotNull String getIdentifier() {
return "BetterKeepInventory";
}

@Override
public @NotNull String getAuthor() {
return "Beepsterr";
}

@Override
public @NotNull String getVersion() {
return "1.0.0";
}

@Override
public String onPlaceholderRequest(org.bukkit.entity.Player player, @NotNull String identifier) {

identifier = identifier.toLowerCase();

// Seconds left on grace
if (identifier.equals("grace_timer_seconds")) {
return String.valueOf(BetterKeepInventory.instance.graceMap.get(player.getUniqueId()));
}

// If grace is active
if(identifier.equals("grace_timer_active")) {
return BetterKeepInventory.instance.graceMap.get(player.getUniqueId()) != null ? "true" : "false";
}

// Overrides!
for(BetterConfig.OverrideTypes key : BetterConfig.OverrideTypes.values()) {
if(identifier.equals("is_active_" + key.toString().toLowerCase())) {
if(BetterKeepInventory.instance.config.GetOverrideForMode("ALL", player)){
return "true";
}
return BetterKeepInventory.instance.config.GetOverrideForMode(key.toString().toUpperCase(), player) ? "true" : "false";
}
}

return null;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ prefix: BetterKeepInventory
authors: [ BeepSterr ]
website: beeps.dev

softdepend: [Vault,Towny,Essentials,GriefPrevention]
softdepend: [Vault,Towny,Essentials,GriefPrevention,PlaceholderAPI]

# AutoPlug
spigot-id: 93081
Expand Down

0 comments on commit a2fe9e5

Please sign in to comment.