mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Papi support
This commit is contained in:
parent
8ee39d3822
commit
e1e0368f8c
@ -99,4 +99,5 @@ dependencies {
|
|||||||
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT'
|
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT'
|
||||||
implementation 'io.lumine.xikage:MythicMobs:4.9.1'
|
implementation 'io.lumine.xikage:MythicMobs:4.9.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
|
implementation 'me.clip:placeholderapi:2.10.10'
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ import com.volmit.iris.core.*;
|
|||||||
import com.volmit.iris.core.command.CommandIris;
|
import com.volmit.iris.core.command.CommandIris;
|
||||||
import com.volmit.iris.core.command.PermissionIris;
|
import com.volmit.iris.core.command.PermissionIris;
|
||||||
import com.volmit.iris.core.command.world.CommandLocate;
|
import com.volmit.iris.core.command.world.CommandLocate;
|
||||||
|
import com.volmit.iris.core.link.IrisPapiExpansion;
|
||||||
import com.volmit.iris.core.link.MultiverseCoreLink;
|
import com.volmit.iris.core.link.MultiverseCoreLink;
|
||||||
import com.volmit.iris.core.link.MythicMobsLink;
|
import com.volmit.iris.core.link.MythicMobsLink;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
@ -94,6 +95,46 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
installDataPacks();
|
installDataPacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
try {
|
||||||
|
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Iris.reportError(e);
|
||||||
|
}
|
||||||
|
proj = new ProjectManager();
|
||||||
|
convert = new ConversionManager();
|
||||||
|
wand = new WandManager();
|
||||||
|
board = new IrisBoardManager();
|
||||||
|
linkMultiverseCore = new MultiverseCoreLink();
|
||||||
|
linkMythicMobs = new MythicMobsLink();
|
||||||
|
saplingManager = new TreeManager();
|
||||||
|
edit = new EditManager();
|
||||||
|
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||||
|
getServer().getPluginManager().registerEvents(new CommandLocate(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new WandManager(), this);
|
||||||
|
super.onEnable();
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
|
J.s(this::lateBind);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lateBind() {
|
||||||
|
J.a(() -> PaperLib.suggestPaper(this));
|
||||||
|
J.a(() -> IO.delete(getTemp()));
|
||||||
|
J.a(this::bstats);
|
||||||
|
J.a(this::splash, 20);
|
||||||
|
J.ar(this::checkConfigHotload, 60);
|
||||||
|
J.sr(this::tickQueue, 0);
|
||||||
|
J.a(this::setupPapi);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupPapi() {
|
||||||
|
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
|
new IrisPapiExpansion().register();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public File getDatapacksFolder() {
|
public File getDatapacksFolder() {
|
||||||
File props = new File("server.properties");
|
File props = new File("server.properties");
|
||||||
|
|
||||||
@ -166,34 +207,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
|
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
|
||||||
instance = this;
|
|
||||||
try {
|
|
||||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
Iris.reportError(e);
|
|
||||||
}
|
|
||||||
proj = new ProjectManager();
|
|
||||||
convert = new ConversionManager();
|
|
||||||
wand = new WandManager();
|
|
||||||
board = new IrisBoardManager();
|
|
||||||
linkMultiverseCore = new MultiverseCoreLink();
|
|
||||||
linkMythicMobs = new MythicMobsLink();
|
|
||||||
saplingManager = new TreeManager();
|
|
||||||
edit = new EditManager();
|
|
||||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
|
||||||
J.a(() -> IO.delete(getTemp()));
|
|
||||||
J.a(this::bstats);
|
|
||||||
J.s(this::splash, 20);
|
|
||||||
J.sr(this::tickQueue, 0);
|
|
||||||
J.ar(this::checkConfigHotload, 40);
|
|
||||||
PaperLib.suggestPaper(this);
|
|
||||||
getServer().getPluginManager().registerEvents(new CommandLocate(), this);
|
|
||||||
getServer().getPluginManager().registerEvents(new WandManager(), this);
|
|
||||||
super.onEnable();
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkConfigHotload() {
|
private void checkConfigHotload() {
|
||||||
if (configWatcher.checkModified()) {
|
if (configWatcher.checkModified()) {
|
||||||
IrisSettings.invalidate();
|
IrisSettings.invalidate();
|
||||||
|
156
src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java
Normal file
156
src/main/java/com/volmit/iris/core/link/IrisPapiExpansion.java
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.core.link;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.tools.IrisWorlds;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.framework.IrisAccess;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
// See/update https://app.gitbook.com/@volmitsoftware/s/iris/compatability/papi/
|
||||||
|
public class IrisPapiExpansion extends PlaceholderExpansion {
|
||||||
|
@Override
|
||||||
|
public @NotNull String getIdentifier() {
|
||||||
|
return "iris";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthor() {
|
||||||
|
return "Volmit Software";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getVersion() {
|
||||||
|
return Iris.instance.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean persist() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onRequest(OfflinePlayer player, String p) {
|
||||||
|
Location l = null;
|
||||||
|
IrisAccess a = null;
|
||||||
|
|
||||||
|
if(player.isOnline())
|
||||||
|
{
|
||||||
|
l = player.getPlayer().getLocation();
|
||||||
|
a = IrisWorlds.access(l.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.equalsIgnoreCase("biome_name"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getBiome(l).getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("biome_id"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getBiome(l).getLoadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("biome_file"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getBiome(l).getLoadFile().getPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("region_name"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getRegion(l).getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("region_id"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getRegion(l).getLoadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("region_file"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getRegion(l).getLoadFile().getPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("terrain_slope"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return ((Engine)a.getEngineAccess(l.getBlockY()))
|
||||||
|
.getFramework().getComplex().getSlopeStream()
|
||||||
|
.get(l.getX(), l.getZ()) + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("terrain_height"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return (int)Math.round(a.getHeight(l)) + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("world_mode"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.isStudio() ? "Studio" : "Production";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("world_seed"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getTarget().getWorld().seed() + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (p.equalsIgnoreCase("world_speed"))
|
||||||
|
{
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
return a.getGeneratedPerSecond() + "/s";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,7 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
|
|||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@ -65,6 +66,31 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
void printMetrics(CommandSender sender);
|
void printMetrics(CommandSender sender);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignores the world, just uses the position
|
||||||
|
* @param l the location
|
||||||
|
* @return the biome
|
||||||
|
*/
|
||||||
|
default IrisBiome getBiome(Location l)
|
||||||
|
{
|
||||||
|
return getBiome(l.toVector());
|
||||||
|
}
|
||||||
|
|
||||||
|
default IrisRegion getRegion(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return getEngineAccess(y).getRegion(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
default IrisRegion getRegion(Location l)
|
||||||
|
{
|
||||||
|
return getRegion(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
default IrisBiome getBiome(Vector l)
|
||||||
|
{
|
||||||
|
return getBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
IrisBiome getBiome(int x, int y, int z);
|
IrisBiome getBiome(int x, int y, int z);
|
||||||
|
|
||||||
IrisBiome getCaveBiome(int x, int y, int z);
|
IrisBiome getCaveBiome(int x, int y, int z);
|
||||||
@ -266,4 +292,9 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default double getHeight(Location l)
|
||||||
|
{
|
||||||
|
return getHeight(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user