mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
Merge branch 'moduletest' into 'development'
Add anvil, cmi, nms classes See merge request Songoda/songodaupdater!12
This commit is contained in:
commit
5dd6022b0d
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,3 +9,5 @@ release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
|
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.1.4"
|
||||
version: "2.1.6"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
@ -15,7 +15,7 @@ build:
|
||||
- find $path/ -type f -name "*SongodaCore.java" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- mvn clean package
|
||||
- find $path/ -depth -path '*original*' -delete
|
||||
- mv $path/target/*.jar $path/
|
||||
- mv $path/Core/target/*.jar $path/
|
||||
artifacts:
|
||||
name: $name-$version
|
||||
paths:
|
||||
|
300
Core/pom.xml
Normal file
300
Core/pom.xml
Normal file
@ -0,0 +1,300 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>SongodaCore-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<includes>
|
||||
<include>com/</include>
|
||||
<include>META-INF/MANIFEST.MF</include>
|
||||
<include>META-INF/maven/com.songoda/SongodaCore/</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptors>
|
||||
<descriptor>../assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<finalName>SongodaCore-${project.version}</finalName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.papermc</groupId>
|
||||
<artifactId>paper</artifactId>
|
||||
<version>1.14.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.4</version>
|
||||
</dependency-->
|
||||
<!-- Need to include all NMS modules here -->
|
||||
<!-- Note when adding a new module: include the class in NmsManager -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_8_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_8_R2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_8_R3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_9_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_9_R2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_10_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_11_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_12_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_13_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_13_R2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>SongodaCore-NMS-v1_14_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End NMS -->
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sainttx.holograms</groupId>
|
||||
<artifactId>Holograms</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zrips</groupId>
|
||||
<artifactId>CMI</artifactId>
|
||||
<version>8.4.0.2_1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.tnemc</groupId>
|
||||
<artifactId>Reserve</artifactId>
|
||||
<version>0.1.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.black_ixx</groupId>
|
||||
<artifactId>PlayerPoints</artifactId>
|
||||
<version>2.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.myles.viaversion-bukkit</groupId>
|
||||
<artifactId>ViaVersion</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>protocolsupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
<version>4.29</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.23.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<version>1.9.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>WildStacker</artifactId>
|
||||
<version>2-9-0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.antiperson</groupId>
|
||||
<artifactId>stackmob</artifactId>
|
||||
<version>4-0-2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -76,6 +76,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
console.sendMessage(""); // blank line to speparate chatter
|
||||
console.sendMessage(ChatColor.GREEN + "=============================");
|
||||
console.sendMessage(String.format("%s%s %s by %sSongoda <3!", ChatColor.GRAY.toString(),
|
||||
getDescription().getName(), getDescription().getVersion(), ChatColor.DARK_PURPLE.toString()));
|
||||
@ -88,6 +89,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
onPluginEnable();
|
||||
if(emergencyStop) {
|
||||
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
console.sendMessage("");
|
||||
return;
|
||||
}
|
||||
// Start Metrics
|
||||
@ -96,10 +98,12 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
getLogger().log(Level.SEVERE, "Unexpected error while loading " + getDescription().getName() + ": Disabling plugin!", t);
|
||||
emergencyStop();
|
||||
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
console.sendMessage("");
|
||||
return;
|
||||
}
|
||||
|
||||
console.sendMessage(ChatColor.GREEN + "=============================");
|
||||
console.sendMessage(""); // blank line to speparate chatter
|
||||
}
|
||||
|
||||
protected void emergencyStop() {
|
||||
@ -112,6 +116,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
if (emergencyStop) {
|
||||
return;
|
||||
}
|
||||
console.sendMessage(""); // blank line to speparate chatter
|
||||
console.sendMessage(ChatColor.GREEN + "=============================");
|
||||
console.sendMessage(String.format("%s%s %s by %sSongoda <3!", ChatColor.GRAY.toString(),
|
||||
getDescription().getName(), getDescription().getVersion(), ChatColor.DARK_PURPLE.toString()));
|
||||
@ -119,6 +124,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
ChatColor.RED.toString(), "Disabling", ChatColor.GRAY.toString()));
|
||||
onPluginDisable();
|
||||
console.sendMessage(ChatColor.GREEN + "=============================");
|
||||
console.sendMessage(""); // blank line to speparate chatter
|
||||
}
|
||||
|
||||
public ConsoleCommandSender getConsole() {
|
@ -25,10 +25,18 @@ public enum ServerVersion {
|
||||
return this.ordinal() < other.ordinal();
|
||||
}
|
||||
|
||||
public boolean isAtOrBelow(ServerVersion other) {
|
||||
return this.ordinal() <= other.ordinal();
|
||||
}
|
||||
|
||||
public boolean isGreaterThan(ServerVersion other) {
|
||||
return this.ordinal() > other.ordinal();
|
||||
}
|
||||
|
||||
public boolean isAtLeast(ServerVersion other) {
|
||||
return this.ordinal() >= other.ordinal();
|
||||
}
|
||||
|
||||
public static String getServerVersionString() {
|
||||
return serverPackageVersion;
|
||||
}
|
100
Core/src/main/java/com/songoda/core/gui/AnvilGui.java
Normal file
100
Core/src/main/java/com/songoda/core/gui/AnvilGui.java
Normal file
@ -0,0 +1,100 @@
|
||||
package com.songoda.core.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.methods.Clickable;
|
||||
import com.songoda.core.nms.CoreNMS;
|
||||
import com.songoda.core.nms.CustomAnvil;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Anvil GUI for text prompts
|
||||
*
|
||||
* @since 2019-09-15
|
||||
* @author jascotty2
|
||||
*/
|
||||
public class AnvilGui extends Gui {
|
||||
|
||||
final Player player;
|
||||
CustomAnvil anvil;
|
||||
|
||||
public AnvilGui(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public AnvilGui(Player player, Gui parent) {
|
||||
super(parent);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AnvilGui setAction(@Nullable Clickable action) {
|
||||
return (AnvilGui) setAction(2, action);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AnvilGui setAction(@Nullable ClickType type, @Nullable Clickable action) {
|
||||
return (AnvilGui) setAction(2, type, action);
|
||||
}
|
||||
|
||||
protected void open() {
|
||||
anvil.open();
|
||||
}
|
||||
|
||||
public AnvilGui setInput(ItemStack item) {
|
||||
return (AnvilGui) this.setItem(0, item);
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return this.getItem(0);
|
||||
}
|
||||
|
||||
public AnvilGui setOutput(ItemStack item) {
|
||||
return (AnvilGui) this.setItem(2, item);
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return this.getItem(2);
|
||||
}
|
||||
|
||||
public String getInputText() {
|
||||
return anvil != null ? anvil.getRenameText() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Inventory generateInventory(@NotNull GuiManager manager) {
|
||||
this.guiManager = manager;
|
||||
|
||||
createInventory();
|
||||
ItemStack item;
|
||||
if ((item = cellItems.get(0)) != null) {
|
||||
inventory.setItem(0, item);
|
||||
} else if ((item = cellItems.get(1)) != null) {
|
||||
inventory.setItem(1, item);
|
||||
} else if (!acceptsItems) {
|
||||
inventory.setItem(0, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, " ", " "));
|
||||
}
|
||||
if ((item = cellItems.get(2)) != null) {
|
||||
inventory.setItem(2, item);
|
||||
}
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createInventory() {
|
||||
CoreNMS nms = NmsManager.getNMS();
|
||||
if (nms != null) {
|
||||
anvil = nms.createAnvil(player, new GuiHolder(guiManager, this));
|
||||
anvil.setCustomTitle(title);
|
||||
anvil.setLevelCost(0);
|
||||
inventory = anvil.getInventory();
|
||||
}
|
||||
}
|
||||
}
|
@ -74,24 +74,43 @@ public class GuiManager {
|
||||
*/
|
||||
public void showGUI(Player player, Gui gui) {
|
||||
if (shutdown) {
|
||||
return;
|
||||
if(plugin.isEnabled()) {
|
||||
// recover if reloaded without calling init manually
|
||||
init();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (!initialized) {
|
||||
init();
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
if (gui instanceof AnvilGui) {
|
||||
// bukkit throws a fit now if you try to set anvil stuff asynchronously
|
||||
Gui openInv = openInventories.get(player);
|
||||
if (openInv != null) {
|
||||
openInv.open = false;
|
||||
}
|
||||
Inventory inv = gui.getOrCreateInventory(this);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
player.openInventory(inv);
|
||||
gui.onOpen(this, player);
|
||||
synchronized(lock) {
|
||||
openInventories.put(player, gui);
|
||||
gui.getOrCreateInventory(this);
|
||||
((AnvilGui) gui).open();
|
||||
gui.onOpen(this, player);
|
||||
synchronized (lock) {
|
||||
openInventories.put(player, gui);
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
Gui openInv = openInventories.get(player);
|
||||
if (openInv != null) {
|
||||
openInv.open = false;
|
||||
}
|
||||
Inventory inv = gui.getOrCreateInventory(this);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
player.openInventory(inv);
|
||||
gui.onOpen(this, player);
|
||||
synchronized(lock) {
|
||||
openInventories.put(player, gui);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void showPopup(Player player, String message) {
|
||||
@ -103,7 +122,7 @@ public class GuiManager {
|
||||
}
|
||||
|
||||
public void showPopup(Player player, String message, CompatibleMaterial icon, BackgroundType background) {
|
||||
if (ClientVersion.getClientVersion(player).isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
if (ClientVersion.getClientVersion(player).isAtLeast(ServerVersion.V1_12)) {
|
||||
PopupMessage popup = new PopupMessage(plugin, icon, message, background);
|
||||
popup.add();
|
||||
popup.grant(player);
|
||||
@ -195,7 +214,11 @@ public class GuiManager {
|
||||
if (openInv.getHolder() != null && openInv.getHolder() instanceof GuiHolder
|
||||
&& ((GuiHolder) openInv.getHolder()).manager.uuid.equals(manager.uuid)) {
|
||||
Gui gui = ((GuiHolder) openInv.getHolder()).getGUI();
|
||||
if(!gui.open) {
|
||||
if (gui instanceof AnvilGui) {
|
||||
gui.inventory.clear();
|
||||
gui.inventory = null;
|
||||
}
|
||||
if (!gui.open) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getPlayer();
|
@ -31,9 +31,8 @@ class PopupMessage {
|
||||
private final NamespacedKey key;
|
||||
private final TextComponent title;
|
||||
CompatibleMaterial icon;
|
||||
int iconAmount = 1; // experimental, untested
|
||||
TriggerType trigger = TriggerType.IMPOSSIBLE;
|
||||
FrameType frame = FrameType.GOAL;
|
||||
FrameType frame = FrameType.GOAL; // TASK is the default
|
||||
BackgroundType background = BackgroundType.ADVENTURE;
|
||||
|
||||
PopupMessage(Plugin source, CompatibleMaterial icon, String title) {
|
||||
@ -58,9 +57,6 @@ class PopupMessage {
|
||||
if (this.icon.usesData()) {
|
||||
displayIcon.addProperty("data", this.icon.getData());
|
||||
}
|
||||
if (this.iconAmount > 1) {
|
||||
displayIcon.addProperty("amount", this.iconAmount); // not entirely sure if this works
|
||||
}
|
||||
advDisplay.add("icon", displayIcon);
|
||||
}
|
||||
advDisplay.add("title", gson.fromJson(ComponentSerializer.toString(this.title), JsonElement.class));
|
@ -4,6 +4,7 @@ import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.core.hooks.economies.PlayerPointsEconomy;
|
||||
import com.songoda.core.hooks.economies.ReserveEconomy;
|
||||
import com.songoda.core.hooks.economies.VaultEconomy;
|
||||
import com.songoda.core.hooks.holograms.CMIHolograms;
|
||||
import com.songoda.core.hooks.stackers.StackMob;
|
||||
import com.songoda.core.hooks.stackers.Stacker;
|
||||
import com.songoda.core.hooks.stackers.UltimateStacker;
|
||||
@ -33,6 +34,7 @@ public final class PluginHook <T extends Class> {
|
||||
public static final PluginHook STACKER_STACK_MOB = new PluginHook(Stacker.class, "StackMob", StackMob.class);
|
||||
public static final PluginHook HOLO_DISPLAYS = new PluginHook(Holograms.class, "HolographicDisplays", HolographicDisplaysHolograms.class);
|
||||
public static final PluginHook HOLO_HOLOGRAMS = new PluginHook(Holograms.class, "Holograms", HologramsHolograms.class);
|
||||
public static final PluginHook HOLO_CMI = new PluginHook(Holograms.class, "CMI", CMIHolograms.class);
|
||||
|
||||
/******* Start Manager stuff *******/
|
||||
|
@ -0,0 +1,135 @@
|
||||
package com.songoda.core.hooks.holograms;
|
||||
|
||||
import com.Zrips.CMI.CMI;
|
||||
import com.Zrips.CMI.Modules.Holograms.CMIHologram;
|
||||
import com.Zrips.CMI.Modules.Holograms.HologramManager;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class CMIHolograms extends Holograms {
|
||||
|
||||
CMI cmi;
|
||||
HologramManager cmiHologramManager;
|
||||
HashSet<String> ourHolograms = new HashSet();
|
||||
Method cmi_CMIHologram_getLines;
|
||||
|
||||
{
|
||||
try {
|
||||
// test if we need to watch if the lines is an array
|
||||
if (CMIHologram.class.getDeclaredField("lines").getDeclaringClass() == String[].class) {
|
||||
cmi_CMIHologram_getLines = CMIHologram.class.getMethod("getLines");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public CMIHolograms(Plugin plugin) {
|
||||
super(plugin);
|
||||
cmi = (CMI) Bukkit.getPluginManager().getPlugin("CMI");
|
||||
if (cmi != null) {
|
||||
cmiHologramManager = cmi.getHologramManager();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CMI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return cmi != null && cmi.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double defaultHeightOffset() {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createHologram(Location location, List<String> lines) {
|
||||
createAt(fixLocation(location), lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram(Location location) {
|
||||
location = fixLocation(location);
|
||||
final String id = locStr(location);
|
||||
CMIHologram holo = cmiHologramManager.getByName(id);
|
||||
if (holo != null) {
|
||||
cmiHologramManager.removeHolo(holo);
|
||||
}
|
||||
ourHolograms.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllHolograms() {
|
||||
for (String id : ourHolograms) {
|
||||
CMIHologram holo = cmiHologramManager.getByName(id);
|
||||
if (holo != null) {
|
||||
cmiHologramManager.removeHolo(holo);
|
||||
}
|
||||
}
|
||||
ourHolograms.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHologram(Location location, List<String> lines) {
|
||||
location = fixLocation(location);
|
||||
CMIHologram holo = cmiHologramManager.getByName(locStr(location));
|
||||
if (holo != null) {
|
||||
// only update if there is a change to the text
|
||||
List<String> holoLines;
|
||||
if (cmi_CMIHologram_getLines != null) {
|
||||
try {
|
||||
holoLines = Arrays.asList((String[]) cmi_CMIHologram_getLines.invoke(holo));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(CMIHolograms.class.getName()).log(Level.SEVERE, "CMI Hologram error!", ex);
|
||||
holoLines = Collections.EMPTY_LIST;
|
||||
}
|
||||
} else {
|
||||
holoLines = holo.getLines();
|
||||
}
|
||||
boolean isChanged = lines.size() != holoLines.size();
|
||||
if (!isChanged) {
|
||||
// double-check the lines
|
||||
for (int i = 0; !isChanged && i < lines.size(); ++i) {
|
||||
isChanged = !holo.getLine(i).equals(lines.get(i));
|
||||
}
|
||||
}
|
||||
if (isChanged) {
|
||||
holo.setLines(lines);
|
||||
holo.update();
|
||||
}
|
||||
return;
|
||||
}
|
||||
createAt(location, lines);
|
||||
}
|
||||
|
||||
private String locStr(Location loc) {
|
||||
return String.format("%s-%d-%d-%d", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
private void createAt(Location location, List<String> lines) {
|
||||
|
||||
final String id = locStr(location);
|
||||
CMIHologram holo = new CMIHologram(id, location);
|
||||
holo.setLines(lines);
|
||||
|
||||
cmiHologramManager.addHologram(holo);
|
||||
holo.update();
|
||||
|
||||
if (!ourHolograms.contains(id)) {
|
||||
ourHolograms.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -5,11 +5,10 @@ import com.sainttx.holograms.api.HologramPlugin;
|
||||
import com.sainttx.holograms.api.line.HologramLine;
|
||||
import com.sainttx.holograms.api.line.TextLine;
|
||||
import java.util.HashSet;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class HologramsHolograms extends Holograms {
|
||||
|
55
Core/src/main/java/com/songoda/core/nms/NmsManager.java
Normal file
55
Core/src/main/java/com/songoda/core/nms/NmsManager.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.songoda.core.nms;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NmsManager {
|
||||
|
||||
private final static String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
|
||||
private final static String serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
|
||||
private final static CoreNMS nms = _getNMS();
|
||||
|
||||
private static CoreNMS _getNMS() {
|
||||
// try {
|
||||
// return (CoreNMS) Class.forName("com.songoda.core.nms." + serverPackageVersion + ".NMS").newInstance();
|
||||
// } catch (Exception ex) {
|
||||
// Logger.getLogger(NmsManager.class.getName()).log(Level.SEVERE, "Failed to load NMS for this server version", ex);
|
||||
// }
|
||||
// this block was only added to keep minimizeJar happy
|
||||
switch (serverPackageVersion) {
|
||||
case "v1_8_R1":
|
||||
return new com.songoda.core.nms.v1_8_R1.NMS();
|
||||
case "v1_8_R2":
|
||||
return new com.songoda.core.nms.v1_8_R2.NMS();
|
||||
case "v1_8_R3":
|
||||
return new com.songoda.core.nms.v1_8_R3.NMS();
|
||||
case "v1_9_R1":
|
||||
return new com.songoda.core.nms.v1_9_R1.NMS();
|
||||
case "v1_9_R2":
|
||||
return new com.songoda.core.nms.v1_9_R2.NMS();
|
||||
case "v1_10_R1":
|
||||
return new com.songoda.core.nms.v1_10_R1.NMS();
|
||||
case "v1_11_R1":
|
||||
return new com.songoda.core.nms.v1_11_R1.NMS();
|
||||
case "v1_12_R1":
|
||||
return new com.songoda.core.nms.v1_12_R1.NMS();
|
||||
case "v1_13_R1":
|
||||
return new com.songoda.core.nms.v1_13_R1.NMS();
|
||||
case "v1_13_R2":
|
||||
return new com.songoda.core.nms.v1_13_R2.NMS();
|
||||
case "v1_14_R1":
|
||||
return new com.songoda.core.nms.v1_14_R1.NMS();
|
||||
}
|
||||
Logger.getLogger(NmsManager.class.getName()).log(Level.SEVERE, "Failed to load NMS for this server version: version {0} not found", serverPackageVersion);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CoreNMS getNMS() {
|
||||
return nms;
|
||||
}
|
||||
|
||||
public static boolean hasNMS() {
|
||||
return nms != null;
|
||||
}
|
||||
}
|
22
NMS/NMS-API/pom.xml
Normal file
22
NMS/NMS-API/pom.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
|
||||
<parent>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore-Modules</artifactId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../../</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user