mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-11-29 12:55:11 +01:00
Added PlaceholderAPI support
This commit is contained in:
parent
cbf41729a9
commit
7eccbb3882
13
pom.xml
13
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.butzlabben.world</groupId>
|
||||
<artifactId>WorldSystem</artifactId>
|
||||
<version>2.4.4.1</version>
|
||||
<version>2.4.4.2</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.build.number>-</project.build.number>
|
||||
@ -101,6 +101,10 @@
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -157,5 +161,12 @@
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -4,6 +4,7 @@ import de.butzlabben.autoupdater.AutoUpdater;
|
||||
import de.butzlabben.world.command.*;
|
||||
import de.butzlabben.world.config.*;
|
||||
import de.butzlabben.world.listener.*;
|
||||
import de.butzlabben.world.util.PapiExtension;
|
||||
import de.butzlabben.world.wrapper.AsyncCreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.CreatorAdapter;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
@ -113,6 +114,9 @@ public class WorldSystem extends JavaPlugin {
|
||||
DependenceConfig.checkWorlds();
|
||||
}
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI"))
|
||||
new PapiExtension().register();
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "Succesfully enabled WorldSystem v" + version);
|
||||
}
|
||||
|
||||
|
57
src/main/java/de/butzlabben/world/util/PapiExtension.java
Normal file
57
src/main/java/de/butzlabben/world/util/PapiExtension.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.butzlabben.world.util;
|
||||
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PapiExtension extends PlaceholderExpansion {
|
||||
|
||||
WorldSystem worldSystem = WorldSystem.getInstance();
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "worldsystem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "Butzlabben";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return worldSystem.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer p, String params) {
|
||||
DependenceConfig config = new DependenceConfig(p);
|
||||
switch (params) {
|
||||
case "has_world":
|
||||
return new DependenceConfig(p).hasWorld() + "";
|
||||
case "is_creator":
|
||||
WorldPlayer player = new WorldPlayer(Objects.requireNonNull(Bukkit.getPlayer(p.getUniqueId())));
|
||||
if(!player.isOnSystemWorld())
|
||||
return "false";
|
||||
return player.isOwnerofWorld() + "";
|
||||
case "world_name_of_player":
|
||||
if(!config.hasWorld())
|
||||
return "none";
|
||||
else
|
||||
return config.getWorldname();
|
||||
case "world_of_player_loaded":
|
||||
if(!config.hasWorld())
|
||||
return "none";
|
||||
return SystemWorld.getSystemWorld(config.getWorldname()).isLoaded() + "";
|
||||
|
||||
}
|
||||
return super.onRequest(p, params);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user