mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-26 18:37:43 +01:00
Initial commit
This commit is contained in:
parent
549a1ce9f4
commit
cef0ce7d33
63
Bootstrap/pom.xml
Normal file
63
Bootstrap/pom.xml
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerParent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Bootstrap</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerAPI</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
7
Bootstrap/src/main/java/com/craftaro/Main.java
Normal file
7
Bootstrap/src/main/java/com/craftaro/Main.java
Normal file
@ -0,0 +1,7 @@
|
||||
package com.craftaro;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
113
UltimateStacker/.gitignore
vendored
Normal file
113
UltimateStacker/.gitignore
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
155
UltimateStacker/pom.xml
Normal file
155
UltimateStacker/pom.xml
Normal file
@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerParent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateStacker-${revision}</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>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.ultimatestacker.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.21</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerAPI</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>WildStackerAPI</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.antiperson</groupId>
|
||||
<artifactId>stackmob</artifactId>
|
||||
<version>4-0-2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.minebuilders</groupId>
|
||||
<artifactId>Clearlag</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>Mythic-Dist</artifactId>
|
||||
<version>5.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,5 +1,41 @@
|
||||
package com.songoda.ultimatestacker;
|
||||
package com.craftaro.ultimatestacker;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.item.ItemStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStackManager;
|
||||
import com.craftaro.ultimatestacker.commands.CommandConvert;
|
||||
import com.craftaro.ultimatestacker.commands.CommandGiveSpawner;
|
||||
import com.craftaro.ultimatestacker.commands.CommandLootables;
|
||||
import com.craftaro.ultimatestacker.commands.CommandReload;
|
||||
import com.craftaro.ultimatestacker.commands.CommandRemoveAll;
|
||||
import com.craftaro.ultimatestacker.commands.CommandSettings;
|
||||
import com.craftaro.ultimatestacker.commands.CommandSpawn;
|
||||
import com.craftaro.ultimatestacker.database.DataManager;
|
||||
import com.craftaro.ultimatestacker.database.migrations._1_InitialMigration;
|
||||
import com.craftaro.ultimatestacker.database.migrations._2_EntityStacks;
|
||||
import com.craftaro.ultimatestacker.database.migrations._3_BlockStacks;
|
||||
import com.craftaro.ultimatestacker.database.migrations._6_RemoveStackedEntityTable;
|
||||
import com.craftaro.ultimatestacker.hook.hooks.JobsHook;
|
||||
import com.craftaro.ultimatestacker.listeners.ShearListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.SheepDyeListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.SpawnerListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.TameListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.item.ItemCurrentListener;
|
||||
import com.craftaro.ultimatestacker.listeners.item.ItemLegacyListener;
|
||||
import com.craftaro.ultimatestacker.listeners.item.ItemListeners;
|
||||
import com.craftaro.ultimatestacker.lootables.LootablesManager;
|
||||
import com.craftaro.ultimatestacker.stackable.block.BlockStackImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntityManager;
|
||||
import com.craftaro.ultimatestacker.stackable.item.ItemStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.spawner.SpawnerStackImpl;
|
||||
import com.craftaro.ultimatestacker.utils.Async;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
@ -16,47 +52,19 @@ import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.core.hooks.ProtectionManager;
|
||||
import com.songoda.core.hooks.WorldGuardHook;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.commands.CommandConvert;
|
||||
import com.songoda.ultimatestacker.commands.CommandGiveSpawner;
|
||||
import com.songoda.ultimatestacker.commands.CommandLootables;
|
||||
import com.songoda.ultimatestacker.commands.CommandReload;
|
||||
import com.songoda.ultimatestacker.commands.CommandRemoveAll;
|
||||
import com.songoda.ultimatestacker.commands.CommandSettings;
|
||||
import com.songoda.ultimatestacker.commands.CommandSpawn;
|
||||
import com.songoda.ultimatestacker.database.DataManager;
|
||||
import com.songoda.ultimatestacker.database.migrations._1_InitialMigration;
|
||||
import com.songoda.ultimatestacker.database.migrations._2_EntityStacks;
|
||||
import com.songoda.ultimatestacker.database.migrations._3_BlockStacks;
|
||||
import com.songoda.ultimatestacker.database.migrations._6_RemoveStackedEntityTable;
|
||||
import com.songoda.ultimatestacker.hook.StackerHook;
|
||||
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
|
||||
import com.songoda.ultimatestacker.listeners.BlockListeners;
|
||||
import com.songoda.ultimatestacker.listeners.BreedListeners;
|
||||
import com.songoda.ultimatestacker.listeners.ClearLagListeners;
|
||||
import com.songoda.ultimatestacker.listeners.DeathListeners;
|
||||
import com.songoda.ultimatestacker.listeners.InteractListeners;
|
||||
import com.songoda.ultimatestacker.listeners.ShearListeners;
|
||||
import com.songoda.ultimatestacker.listeners.SheepDyeListeners;
|
||||
import com.songoda.ultimatestacker.listeners.SpawnerListeners;
|
||||
import com.songoda.ultimatestacker.listeners.TameListeners;
|
||||
import com.songoda.ultimatestacker.listeners.entity.EntityCurrentListener;
|
||||
import com.songoda.ultimatestacker.listeners.entity.EntityListeners;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemCurrentListener;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemLegacyListener;
|
||||
import com.songoda.ultimatestacker.listeners.item.ItemListeners;
|
||||
import com.songoda.ultimatestacker.lootables.LootablesManager;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.Hologramable;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStack;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntityManager;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStackManager;
|
||||
import com.songoda.ultimatestacker.tasks.StackingTask;
|
||||
import com.songoda.ultimatestacker.utils.Async;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.hook.StackerHook;
|
||||
import com.craftaro.ultimatestacker.listeners.BlockListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.BreedListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.ClearLagListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.DeathListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.InteractListeners;
|
||||
import com.craftaro.ultimatestacker.listeners.entity.EntityCurrentListener;
|
||||
import com.craftaro.ultimatestacker.listeners.entity.EntityListeners;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.api.utils.Hologramable;
|
||||
import com.craftaro.ultimatestacker.stackable.block.BlockStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.spawner.SpawnerStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.tasks.StackingTask;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -90,6 +98,7 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
private EntityStackManager entityStackManager;
|
||||
private SpawnerStackManager spawnerStackManager;
|
||||
private BlockStackManager blockStackManager;
|
||||
private ItemStackManager itemStackManager;
|
||||
private LootablesManager lootablesManager;
|
||||
private CommandManager commandManager;
|
||||
private CustomEntityManager customEntityManager;
|
||||
@ -98,6 +107,7 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataMigrationManager dataMigrationManager;
|
||||
private DataManager dataManager;
|
||||
private UltimateStackerAPI API;
|
||||
|
||||
public static UltimateStacker getInstance() {
|
||||
return INSTANCE;
|
||||
@ -182,9 +192,10 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
ProtectionManager.load(Bukkit.getPluginManager().getPlugin("BentoBox"));
|
||||
}
|
||||
|
||||
this.spawnerStackManager = new SpawnerStackManager();
|
||||
this.entityStackManager = new EntityStackManager(this);
|
||||
this.blockStackManager = new BlockStackManager();
|
||||
this.spawnerStackManager = new SpawnerStackManagerImpl();
|
||||
this.entityStackManager = new EntityStackManagerImpl(this);
|
||||
this.blockStackManager = new BlockStackManagerImpl();
|
||||
this.itemStackManager = new ItemStackManagerImpl();
|
||||
this.customEntityManager = new CustomEntityManager();
|
||||
|
||||
guiManager.init();
|
||||
@ -249,6 +260,8 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
new _3_BlockStacks(),
|
||||
new _6_RemoveStackedEntityTable());
|
||||
this.dataMigrationManager.runMigrations();
|
||||
|
||||
API = new UltimateStackerAPI(entityStackManager, itemStackManager, spawnerStackManager, blockStackManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -288,6 +301,10 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
public UltimateStackerAPI getAPI() {
|
||||
return API;
|
||||
}
|
||||
|
||||
public void addExp(Player player, EntityStack stack) {
|
||||
for (StackerHook stackerHook : stackerHooks) {
|
||||
stackerHook.applyExperience(player, stack);
|
||||
@ -331,14 +348,6 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
return lootablesManager;
|
||||
}
|
||||
|
||||
public EntityStackManager getEntityStackManager() {
|
||||
return entityStackManager;
|
||||
}
|
||||
|
||||
public SpawnerStackManager getSpawnerStackManager() {
|
||||
return spawnerStackManager;
|
||||
}
|
||||
|
||||
public StackingTask getStackingTask() {
|
||||
return stackingTask;
|
||||
}
|
||||
@ -371,6 +380,18 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
return blockStackManager;
|
||||
}
|
||||
|
||||
public EntityStackManager getEntityStackManager() {
|
||||
return entityStackManager;
|
||||
}
|
||||
|
||||
public ItemStackManager getItemStackManager() {
|
||||
return itemStackManager;
|
||||
}
|
||||
|
||||
public SpawnerStackManager getSpawnerStackManager() {
|
||||
return spawnerStackManager;
|
||||
}
|
||||
|
||||
public CustomEntityManager getCustomEntityManager() {
|
||||
return customEntityManager;
|
||||
}
|
||||
@ -378,9 +399,9 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
public void updateHologram(Hologramable stack) {
|
||||
// Is this stack invalid?
|
||||
if (!stack.isValid())
|
||||
if (stack instanceof BlockStack)
|
||||
if (stack instanceof BlockStackImpl)
|
||||
blockStackManager.removeBlock(stack.getLocation());
|
||||
else if (stack instanceof SpawnerStack)
|
||||
else if (stack instanceof SpawnerStackImpl)
|
||||
spawnerStackManager.removeSpawner(stack.getLocation());
|
||||
// are holograms enabled?
|
||||
if (!stack.areHologramsEnabled() && !HologramManager.getManager().isEnabled()) return;
|
||||
@ -565,5 +586,4 @@ public class UltimateStacker extends SongodaPlugin {
|
||||
return !whitelist.isEmpty() && !whitelist.contains(combined)
|
||||
|| !blacklist.isEmpty() && blacklist.contains(combined);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.craftaro.ultimatestacker.gui.GUIConvert;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.gui.GUIConvert;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.lootables.gui.GuiEditor;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -48,7 +49,7 @@ public class CommandRemoveAll extends AbstractCommand {
|
||||
|
||||
if (entityO instanceof LivingEntity && (stackManager.isStackedEntity(entityO) || all)
|
||||
&& type.equalsIgnoreCase("entities")) {
|
||||
EntityStack stack = plugin.getEntityStackManager().getStack((LivingEntity) entityO);
|
||||
EntityStack stack = plugin.getEntityStackManager().getStackedEntity((LivingEntity) entityO);
|
||||
if (stack == null) continue;
|
||||
stack.destroy();
|
||||
amountRemoved++;
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.configuration.editor.PluginConfigGui;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.commands;
|
||||
package com.craftaro.ultimatestacker.commands;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -52,7 +52,7 @@ public class CommandSpawn extends AbstractCommand {
|
||||
sender.sendMessage(TextUtils.formatText("&6" + list));
|
||||
} else {
|
||||
LivingEntity entity = (LivingEntity)player.getWorld().spawnEntity(player.getLocation(), type);
|
||||
EntityStack stack = plugin.getEntityStackManager().createStack(entity, Integer.parseInt(args[1]));
|
||||
EntityStack stack = plugin.getEntityStackManager().createStackedEntity(entity, Integer.parseInt(args[1]));
|
||||
plugin.getStackingTask().attemptSplit(stack, entity);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.convert;
|
||||
package com.craftaro.ultimatestacker.convert;
|
||||
|
||||
public interface Convert {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.convert;
|
||||
package com.craftaro.ultimatestacker.convert;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.Bukkit;
|
||||
import uk.antiperson.stackmob.StackMob;
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.songoda.ultimatestacker.convert;
|
||||
package com.craftaro.ultimatestacker.convert;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.WildStackerAPI;
|
||||
import com.bgsoftware.wildstacker.api.objects.StackedSpawner;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -41,7 +42,7 @@ public class WildStackerConvert implements Convert {
|
||||
@Override
|
||||
public void convertSpawners() {
|
||||
for (StackedSpawner spawner : WildStackerAPI.getWildStacker().getSystemManager().getStackedSpawners()) {
|
||||
SpawnerStack stack = plugin.getSpawnerStackManager().getSpawner(spawner.getLocation());
|
||||
SpawnerStack stack = UltimateStackerAPI.getSpawnerStackManager().getSpawner(spawner.getLocation());
|
||||
|
||||
stack.setAmount(WildStackerAPI
|
||||
.getSpawnersAmount((CreatureSpawner) spawner.getLocation().getBlock().getState()));
|
@ -1,11 +1,13 @@
|
||||
package com.songoda.ultimatestacker.database;
|
||||
package com.craftaro.ultimatestacker.database;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.stackable.block.BlockStackImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.spawner.SpawnerStackImpl;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.database.DataManagerAbstract;
|
||||
import com.songoda.core.database.DatabaseConnector;
|
||||
import com.songoda.core.database.DatabaseType;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStack;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -102,13 +104,13 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setInt(1, blockStack.getAmount());
|
||||
statement.setString(2, blockStack.getMaterial().name());
|
||||
|
||||
statement.setString(3, blockStack.getWorld().getName());
|
||||
statement.setInt(4, blockStack.getX());
|
||||
statement.setInt(5, blockStack.getY());
|
||||
statement.setInt(6, blockStack.getZ());
|
||||
statement.setString(3, blockStack.getLocation().getWorld().getName());
|
||||
statement.setInt(4, (int) blockStack.getLocation().getX());
|
||||
statement.setInt(5, (int) blockStack.getLocation().getY());
|
||||
statement.setInt(6, (int) blockStack.getLocation().getZ());
|
||||
statement.executeUpdate();
|
||||
int blockId = this.lastInsertedId(connection, "blocks");
|
||||
this.sync(() -> blockStack.setId(blockId));
|
||||
this.sync(() -> ((BlockStackImpl)blockStack).setId(blockId));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -128,7 +130,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteBlock(BlockStack blockStack) {
|
||||
public void deleteBlock(BlockStackImpl blockStack) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String deleteBlock = "DELETE FROM " + this.getTablePrefix() + "blocks WHERE id = ?";
|
||||
@ -165,7 +167,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
int z = result.getInt("z");
|
||||
Location location = new Location(world, x, y, z);
|
||||
|
||||
SpawnerStack spawnerStack = new SpawnerStack(location, amount);
|
||||
SpawnerStack spawnerStack = new SpawnerStackImpl(location, amount);
|
||||
spawnerStack.setId(spawnerId);
|
||||
spawners.put(location, spawnerStack);
|
||||
}
|
||||
@ -207,7 +209,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
int z = result.getInt("z");
|
||||
Location location = new Location(world, x, y, z);
|
||||
|
||||
BlockStack blockStack = new BlockStack(material, location, amount);
|
||||
BlockStackImpl blockStack = new BlockStackImpl(material, location, amount);
|
||||
blockStack.setId(blockId);
|
||||
if (amount == 0) {
|
||||
//remove from database
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatestacker.database.migrations;
|
||||
package com.craftaro.ultimatestacker.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatestacker.database.migrations;
|
||||
package com.craftaro.ultimatestacker.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatestacker.database.migrations;
|
||||
package com.craftaro.ultimatestacker.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.database.migrations;
|
||||
package com.craftaro.ultimatestacker.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.ultimatestacker.gui;
|
||||
package com.craftaro.ultimatestacker.gui;
|
||||
|
||||
import com.craftaro.ultimatestacker.convert.StackMobConvert;
|
||||
import com.craftaro.ultimatestacker.convert.WildStackerConvert;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.ultimatestacker.convert.StackMobConvert;
|
||||
import com.songoda.ultimatestacker.convert.WildStackerConvert;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.ultimatestacker.gui;
|
||||
package com.craftaro.ultimatestacker.gui;
|
||||
|
||||
import com.craftaro.ultimatestacker.convert.Convert;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.convert.Convert;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.hook;
|
||||
package com.craftaro.ultimatestacker.hook;
|
||||
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface StackerHook {
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.ultimatestacker.hook.hooks;
|
||||
package com.craftaro.ultimatestacker.hook.hooks;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.objects.StackedEntity;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.songoda.core.hooks.jobs.JobsPlayerHandler;
|
||||
import com.songoda.ultimatestacker.hook.StackerHook;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.hook.StackerHook;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
@ -1,17 +1,19 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.api.events.spawner.SpawnerBreakEvent;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.spawner.SpawnerStackImpl;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.songoda.core.compatibility.CompatibleHand;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.hooks.ProtectionManager;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.events.SpawnerBreakEvent;
|
||||
import com.songoda.ultimatestacker.events.SpawnerPlaceEvent;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStack;
|
||||
import com.songoda.ultimatestacker.stackable.block.BlockStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.api.events.spawner.SpawnerPlaceEvent;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -174,7 +176,7 @@ public class BlockListeners implements Listener {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (itemType == blockType) {
|
||||
SpawnerStack stack = plugin.getSpawnerStackManager().getSpawner(block);
|
||||
SpawnerStack stack = UltimateStackerAPI.getSpawnerStackManager().getSpawner(block);
|
||||
if (player.isSneaking()) return;
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (stack.getAmount() == maxStackSize) return;
|
||||
@ -229,7 +231,7 @@ public class BlockListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnerStack stack = plugin.getSpawnerStackManager().addSpawner(new SpawnerStack(block.getLocation(), amount));
|
||||
SpawnerStack stack = UltimateStackerAPI.getSpawnerStackManager().addSpawner(new SpawnerStackImpl(block.getLocation(), amount));
|
||||
plugin.getDataManager().createSpawner(stack);
|
||||
|
||||
cs.setSpawnedType(cs2.getSpawnedType());
|
||||
@ -254,7 +256,7 @@ public class BlockListeners implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = player.getInventory().getItemInHand();
|
||||
|
||||
SpawnerStack stack = plugin.getSpawnerStackManager().getSpawner(block);
|
||||
SpawnerStack stack = UltimateStackerAPI.getSpawnerStackManager().getSpawner(block);
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -276,7 +278,7 @@ public class BlockListeners implements Listener {
|
||||
if (remove) {
|
||||
event.setCancelled(false);
|
||||
plugin.removeHologram(stack);
|
||||
SpawnerStack spawnerStack = plugin.getSpawnerStackManager().removeSpawner(block.getLocation());
|
||||
SpawnerStack spawnerStack = UltimateStackerAPI.getSpawnerStackManager().removeSpawner(block.getLocation());
|
||||
plugin.getDataManager().deleteSpawner(spawnerStack);
|
||||
} else {
|
||||
stack.setAmount(stack.getAmount() - 1);
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import me.minebuilders.clearlag.events.EntityRemoveEvent;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -19,7 +19,7 @@ public class ClearLagListeners implements Listener {
|
||||
public void onClearLaggTask(EntityRemoveEvent event) {
|
||||
for (Entity entity : event.getWorld().getEntities()) {
|
||||
if (entity instanceof LivingEntity && plugin.getEntityStackManager().isStackedEntity(entity)) {
|
||||
plugin.getEntityStackManager().getStack((LivingEntity) entity).destroy();
|
||||
plugin.getEntityStackManager().getStackedEntity((LivingEntity) entity).destroy();
|
||||
event.addEntity(entity);
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackImpl;
|
||||
import com.songoda.core.compatibility.ServerProject;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.lootables.loot.Drop;
|
||||
import com.songoda.core.lootables.loot.DropUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.GameRule;
|
||||
@ -88,7 +89,7 @@ public class DeathListeners implements Listener {
|
||||
runCommands(entity, drops);
|
||||
|
||||
if (plugin.getEntityStackManager().isStackedEntity(event.getEntity())) {
|
||||
plugin.getEntityStackManager().getStack(event.getEntity()).onDeath(entity, drops, custom, event.getDroppedExp(), event);
|
||||
((EntityStackImpl)plugin.getEntityStackManager().getStackedEntity(event.getEntity())).onDeath(entity, drops, custom, event.getDroppedExp(), event);
|
||||
} else {
|
||||
DropUtils.processStackedDrop(event.getEntity(), drops, event);
|
||||
}
|
||||
@ -182,7 +183,7 @@ public class DeathListeners implements Listener {
|
||||
if (!(event.getEntity() instanceof LivingEntity)) return;
|
||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||
if (!plugin.getEntityStackManager().isStackedEntity(entity)) return;
|
||||
EntityStack stack = plugin.getEntityStackManager().getStack(entity);
|
||||
EntityStack stack = plugin.getEntityStackManager().getStackedEntity(entity);
|
||||
|
||||
Player player = (Player) event.getDamager();
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Split;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Split;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Ageable;
|
||||
@ -41,7 +41,7 @@ public class InteractListeners implements Listener {
|
||||
|
||||
if (item.getType() != Material.NAME_TAG && !correctFood(item, entity)) return;
|
||||
|
||||
EntityStack stack = plugin.getEntityStackManager().getStack(entity);
|
||||
EntityStack stack = plugin.getEntityStackManager().getStackedEntity(entity);
|
||||
|
||||
if (stack.getAmount() <= 1
|
||||
|| item.getType() == Material.NAME_TAG
|
@ -1,12 +1,13 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Split;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Split;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -48,7 +49,7 @@ public class ShearListeners implements Listener {
|
||||
return;
|
||||
|
||||
|
||||
EntityStack stack = stackManager.getStack(entity);
|
||||
EntityStack stack = stackManager.getStackedEntity(entity);
|
||||
|
||||
if (Settings.SHEAR_IN_ONE_CLICK.getBoolean()) {
|
||||
World world = entity.getLocation().getWorld();
|
@ -1,10 +1,11 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Split;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Split;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -28,7 +29,7 @@ public class SheepDyeListeners implements Listener {
|
||||
if (Settings.SPLIT_CHECKS.getStringList().stream().noneMatch(line -> Split.valueOf(line) == Split.SHEEP_DYE))
|
||||
return;
|
||||
|
||||
EntityStack stack = stackManager.getStack(entity);
|
||||
EntityStack stack = stackManager.getStackedEntity(entity);
|
||||
if (stack == null) return;
|
||||
stack.releaseHost();
|
||||
}
|
@ -1,14 +1,16 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStackManager;
|
||||
import com.songoda.core.compatibility.CompatibleHand;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.core.utils.EntityUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStackManager;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.spawner.SpawnerStackImpl;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -19,7 +21,6 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
@ -43,7 +44,7 @@ public class SpawnerListeners implements Listener {
|
||||
if (!plugin.spawnersEnabled()
|
||||
|| plugin.getStackingTask().isWorldDisabled(event.getLocation().getWorld())) return;
|
||||
|
||||
SpawnerStackManager spawnerStackManager = plugin.getSpawnerStackManager();
|
||||
SpawnerStackManager spawnerStackManager = UltimateStackerAPI.getSpawnerStackManager();
|
||||
if (!spawnerStackManager.isSpawner(event.getSpawner().getLocation())) return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
@ -77,7 +78,7 @@ public class SpawnerListeners implements Listener {
|
||||
entity.setMetadata("mcMMO: Spawned Entity", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
UltimateStacker.getInstance().getEntityStackManager().setStack(e, amountToSpawn);
|
||||
UltimateStacker.getInstance().getEntityStackManager().createStackedEntity(e, amountToSpawn);
|
||||
return true;
|
||||
}, event.getEntityType());
|
||||
}
|
||||
@ -109,10 +110,10 @@ public class SpawnerListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnerStackManager manager = plugin.getSpawnerStackManager();
|
||||
SpawnerStackManager manager = UltimateStackerAPI.getSpawnerStackManager();
|
||||
|
||||
SpawnerStack spawner = manager.isSpawner(block.getLocation())
|
||||
? manager.getSpawner(block) : manager.addSpawner(new SpawnerStack(block.getLocation(), 1));
|
||||
? manager.getSpawner(block) : manager.addSpawner(new SpawnerStackImpl(block.getLocation(), 1));
|
||||
|
||||
int stackSize = spawner.getAmount();
|
||||
int amt = player.getInventory().getItemInHand().getAmount();
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.ultimatestacker.listeners;
|
||||
package com.craftaro.ultimatestacker.listeners;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -23,7 +24,7 @@ public class TameListeners implements Listener {
|
||||
EntityStackManager stackManager = plugin.getEntityStackManager();
|
||||
if (!stackManager.isStackedEntity(entity)) return;
|
||||
|
||||
EntityStack stack = plugin.getEntityStackManager().getStack(entity);
|
||||
EntityStack stack = plugin.getEntityStackManager().getStackedEntity(entity);
|
||||
|
||||
if (stack.getAmount() <= 1) return;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.ultimatestacker.listeners.entity;
|
||||
package com.craftaro.ultimatestacker.listeners.entity;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
@ -1,12 +1,13 @@
|
||||
package com.songoda.ultimatestacker.listeners.entity;
|
||||
package com.craftaro.ultimatestacker.listeners.entity;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.spawner.SpawnerStack;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -20,7 +21,6 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -64,7 +64,7 @@ public class EntityListeners implements Listener {
|
||||
|
||||
if (!stackManager.isStackedEntity(entity)) return;
|
||||
|
||||
EntityStack stack = stackManager.getStack(entity);
|
||||
EntityStack stack = stackManager.getStackedEntity(entity);
|
||||
|
||||
ItemStack item = event.getEntity().getItemStack();
|
||||
int amount = (stack.getAmount() - 1) + item.getAmount();
|
||||
@ -114,7 +114,7 @@ public class EntityListeners implements Listener {
|
||||
|
||||
Location spawnLocation = block.getLocation();
|
||||
|
||||
SpawnerStack spawner = plugin.getSpawnerStackManager().getSpawner(block);
|
||||
SpawnerStack spawner = UltimateStackerAPI.getSpawnerStackManager().getSpawner(block);
|
||||
|
||||
if (Settings.SPAWNERS_DONT_EXPLODE.getBoolean())
|
||||
toCancel.add(block);
|
||||
@ -132,7 +132,7 @@ public class EntityListeners implements Listener {
|
||||
ItemStack item = Methods.getSpawnerItem(blockType, spawner.getAmount());
|
||||
spawnLocation.getWorld().dropItemNaturally(spawnLocation.clone().add(.5, 0, .5), item);
|
||||
|
||||
SpawnerStack spawnerStack = plugin.getSpawnerStackManager().removeSpawner(spawnLocation);
|
||||
SpawnerStack spawnerStack = UltimateStackerAPI.getSpawnerStackManager().removeSpawner(spawnLocation);
|
||||
plugin.getDataManager().deleteSpawner(spawnerStack);
|
||||
plugin.removeHologram(spawnerStack);
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.listeners.item;
|
||||
package com.craftaro.ultimatestacker.listeners.item;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.listeners.item;
|
||||
package com.craftaro.ultimatestacker.listeners.item;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.ultimatestacker.listeners.item;
|
||||
package com.craftaro.ultimatestacker.listeners.item;
|
||||
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.lootables;
|
||||
package com.craftaro.ultimatestacker.lootables;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
@ -9,8 +9,8 @@ import com.songoda.core.lootables.loot.Loot;
|
||||
import com.songoda.core.lootables.loot.LootBuilder;
|
||||
import com.songoda.core.lootables.loot.LootManager;
|
||||
import com.songoda.core.lootables.loot.Lootable;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Creeper;
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.ultimatestacker.settings;
|
||||
package com.craftaro.ultimatestacker.settings;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Check;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Split;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Check;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Split;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
@ -1,17 +1,15 @@
|
||||
package com.songoda.ultimatestacker.stackable.block;
|
||||
package com.craftaro.ultimatestacker.stackable.block;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStack;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.Hologramable;
|
||||
import com.songoda.ultimatestacker.utils.Stackable;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BlockStack implements Stackable, Hologramable {
|
||||
public class BlockStackImpl implements BlockStack {
|
||||
|
||||
// This is the unique identifier for this stack.
|
||||
// It is reset on every plugin load.
|
||||
@ -25,51 +23,56 @@ public class BlockStack implements Stackable, Hologramable {
|
||||
private final CompatibleMaterial material;
|
||||
private final Location location;
|
||||
|
||||
public BlockStack(CompatibleMaterial material, Location location) {
|
||||
public BlockStackImpl(CompatibleMaterial material, Location location) {
|
||||
this.material = material;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public BlockStack(CompatibleMaterial material, Location location, int amount) {
|
||||
public BlockStackImpl(CompatibleMaterial material, Location location, int amount) {
|
||||
this.amount = amount;
|
||||
this.material = material;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
if (amount < 1) {
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return CompatibleMaterial.getMaterial(location.getBlock()) == material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int amount) {
|
||||
this.amount = this.amount + amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void take(int amount) {
|
||||
this.amount = this.amount - amount;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return location.getBlockX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return location.getBlockY();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return location.getBlockZ();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return location.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
amount = 0;
|
||||
UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
@ -83,6 +86,7 @@ public class BlockStack implements Stackable, Hologramable {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getMaterial() {
|
||||
return material;
|
||||
}
|
||||
@ -103,14 +107,6 @@ public class BlockStack implements Stackable, Hologramable {
|
||||
return Settings.BLOCK_HOLOGRAMS.getBoolean();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHologramId() {
|
||||
return "UltimateStacker-" + uniqueId;
|
||||
@ -118,7 +114,7 @@ public class BlockStack implements Stackable, Hologramable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BlockStack{" +
|
||||
return "BlockStackImpl{" +
|
||||
"id=" + id +
|
||||
", amount=" + amount +
|
||||
", material=" + material +
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.ultimatestacker.stackable.block;
|
||||
package com.craftaro.ultimatestacker.stackable.block;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStackManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@ -9,7 +11,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockStackManager {
|
||||
public class BlockStackManagerImpl implements BlockStackManager {
|
||||
|
||||
private final Map<Location, BlockStack> registeredBlocks = new HashMap<>();
|
||||
|
||||
@ -35,7 +37,7 @@ public class BlockStackManager {
|
||||
}
|
||||
|
||||
public BlockStack createBlock(Location location, CompatibleMaterial material) {
|
||||
return this.registeredBlocks.computeIfAbsent(location, b -> new BlockStack(material, location));
|
||||
return this.registeredBlocks.computeIfAbsent(location, b -> new BlockStackImpl(material, location));
|
||||
}
|
||||
|
||||
public BlockStack createBlock(Block block) {
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity;
|
||||
package com.craftaro.ultimatestacker.stackable.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
@ -1,58 +1,106 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity;
|
||||
package com.craftaro.ultimatestacker.stackable.entity;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.events.entity.EntityStackKillEvent;
|
||||
import com.craftaro.ultimatestacker.utils.Async;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.lootables.loot.Drop;
|
||||
import com.songoda.core.lootables.loot.DropUtils;
|
||||
import com.songoda.core.utils.EntityUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.events.EntityStackKillEvent;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.utils.Async;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityStack extends StackedEntity {
|
||||
public class EntityStackImpl implements EntityStack {
|
||||
|
||||
private static final UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
private final UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
private int amount;
|
||||
private LivingEntity hostEntity;
|
||||
|
||||
public EntityStack(LivingEntity hostEntity) {
|
||||
super(hostEntity);
|
||||
/**
|
||||
* Gets an existing stack from an entity or creates a new one if it doesn't exist.
|
||||
* @param entity The entity to get the stack from.
|
||||
*/
|
||||
public EntityStackImpl(LivingEntity entity) {
|
||||
if (entity == null) return;
|
||||
if (!UltimateStacker.getInstance().getEntityStackManager().isStackedEntity(entity)) {
|
||||
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), 1));
|
||||
this.amount = 1;
|
||||
updateNameTag();
|
||||
} else {
|
||||
//get the amount from the entity
|
||||
this.amount = UltimateStacker.getInstance().getEntityStackManager().getStackedEntity(entity).getAmount();
|
||||
}
|
||||
this.hostEntity = entity;
|
||||
}
|
||||
|
||||
public EntityStack(LivingEntity hostEntity, int amount) {
|
||||
super(hostEntity, amount);
|
||||
/**
|
||||
* Creates a new stack or overrides an existing stack.
|
||||
* @param entity The entity to create the stack for.
|
||||
* @param amount The amount of entities in the stack.
|
||||
*/
|
||||
public EntityStackImpl(LivingEntity entity, int amount) {
|
||||
if (entity == null) return;
|
||||
this.hostEntity = entity;
|
||||
this.amount = amount;
|
||||
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
|
||||
updateNameTag();
|
||||
}
|
||||
|
||||
public synchronized EntityStack addEntityToStack(int amount) {
|
||||
setAmount(getAmount() + amount);
|
||||
return this;
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return hostEntity.getType();
|
||||
}
|
||||
|
||||
public synchronized EntityStack removeEntityFromStack(int amount) {
|
||||
setAmount(getAmount() - amount);
|
||||
return this;
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
this.hostEntity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
|
||||
updateNameTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int amount) {
|
||||
this.amount += amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void take(int amount) {
|
||||
this.amount -= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return hostEntity.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getHostEntity() {
|
||||
return hostEntity;
|
||||
}
|
||||
|
||||
protected synchronized void setHostEntity(LivingEntity hostEntity) {
|
||||
this.hostEntity = hostEntity;
|
||||
}
|
||||
|
||||
private void handleWholeStackDeath(LivingEntity killed, List<Drop> drops, boolean custom, int droppedExp, EntityDeathEvent event) {
|
||||
|
||||
EntityStack stack = plugin.getEntityStackManager().getStack(killed);
|
||||
EntityStack stack = plugin.getEntityStackManager().getStackedEntity(killed);
|
||||
// In versions 1.14 and below experience is not dropping. Because of this we are doing this ourselves.
|
||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_14)) {
|
||||
Location killedLocation = killed.getLocation();
|
||||
@ -75,13 +123,12 @@ public class EntityStack extends StackedEntity {
|
||||
}
|
||||
|
||||
event.getDrops().clear();
|
||||
stack.destroy();
|
||||
destroy();
|
||||
if (killed.getKiller() == null) return;
|
||||
plugin.addExp(killed.getKiller(), this);
|
||||
}
|
||||
|
||||
private void handleSingleStackDeath(LivingEntity killed, List<Drop> drops, int droppedExp, EntityDeathEvent event) {
|
||||
EntityStackManager stackManager = plugin.getEntityStackManager();
|
||||
Bukkit.getPluginManager().callEvent(new EntityStackKillEvent(this, false));
|
||||
|
||||
Vector velocity = killed.getVelocity().clone();
|
||||
@ -102,7 +149,7 @@ public class EntityStack extends StackedEntity {
|
||||
}
|
||||
|
||||
newEntity.setVelocity(velocity);
|
||||
stackManager.updateStack(killed, newEntity);
|
||||
plugin.getEntityStackManager().updateStack(killed, newEntity);
|
||||
}
|
||||
|
||||
public void onDeath(LivingEntity killed, List<Drop> drops, boolean custom, int droppedExp, EntityDeathEvent event) {
|
||||
@ -130,6 +177,7 @@ public class EntityStack extends StackedEntity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized LivingEntity takeOneAndSpawnEntity(Location location) {
|
||||
if (amount <= 0) return null;
|
||||
LivingEntity entity = Objects.requireNonNull(location.getWorld()).spawn(location, hostEntity.getClass());
|
||||
@ -142,6 +190,7 @@ public class EntityStack extends StackedEntity {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void releaseHost() {
|
||||
LivingEntity oldHost = hostEntity;
|
||||
LivingEntity entity = takeOneAndSpawnEntity(hostEntity.getLocation());
|
||||
@ -153,17 +202,18 @@ public class EntityStack extends StackedEntity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void destroy() {
|
||||
if (hostEntity == null) return;
|
||||
Bukkit.getScheduler().runTask(plugin, hostEntity::remove);
|
||||
hostEntity = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EntityStack{" +
|
||||
"hostEntity=" + hostEntity +
|
||||
", amount=" + amount +
|
||||
'}';
|
||||
private void updateNameTag() {
|
||||
if (hostEntity == null) {
|
||||
return;
|
||||
}
|
||||
hostEntity.setCustomNameVisible(!Settings.HOLOGRAMS_ON_LOOK_ENTITY.getBoolean());
|
||||
hostEntity.setCustomName(Methods.compileEntityName(hostEntity, getAmount()));
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.craftaro.ultimatestacker.stackable.entity;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityStackManagerImpl implements EntityStackManager {
|
||||
|
||||
private final UltimateStacker plugin;
|
||||
|
||||
public EntityStackManagerImpl(UltimateStacker plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStack createStackedEntity(LivingEntity entity, int amount) {
|
||||
return new EntityStackImpl(entity, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackedEntity(Entity entity) {
|
||||
return entity.hasMetadata("US_AMOUNT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStack getStackedEntity(UUID entityUUID) {
|
||||
Entity entity = Bukkit.getEntity(entityUUID);
|
||||
if (entity == null) return null;
|
||||
if (!isStackedEntity(entity)) return null;
|
||||
return new EntityStackImpl((LivingEntity) entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStack getStackedEntity(LivingEntity entity) {
|
||||
if (!isStackedEntity(entity)) return null;
|
||||
return new EntityStackImpl(entity);
|
||||
}
|
||||
|
||||
@Deprecated()
|
||||
public boolean isStackedAndLoaded(LivingEntity entity) {
|
||||
return isStackedEntity(entity);
|
||||
}
|
||||
|
||||
public int getAmount(Entity entity) {
|
||||
if (!isStackedEntity(entity)) return 1;
|
||||
if (entity.getMetadata("US_AMOUNT").isEmpty()) return 1;
|
||||
return entity.getMetadata("US_AMOUNT").get(0).asInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastPlayerDamage(Entity entity) {
|
||||
if (!entity.hasMetadata("US_LAST_PLAYER_DAMAGE")) return null;
|
||||
if (entity.getMetadata("US_LAST_PLAYER_DAMAGE").isEmpty()) return null;
|
||||
return entity.getMetadata("US_LAST_PLAYER_DAMAGE").get(0).asString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastPlayerDamage(Entity entity, Player player) {
|
||||
if (player == null) return;
|
||||
if (entity == null) return;
|
||||
if (entity instanceof Player) return;
|
||||
entity.setMetadata("US_LAST_PLAYER_DAMAGE", new FixedMetadataValue(plugin, player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStack transferStack(LivingEntity oldEntity, LivingEntity newEntity, boolean takeOne) {
|
||||
EntityStack stack = getStackedEntity(oldEntity);
|
||||
if (stack == null) return null;
|
||||
EntityStack newStack = new EntityStackImpl(newEntity, takeOne ? stack.getAmount()-1 : stack.getAmount());
|
||||
stack.destroy();
|
||||
return newStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStack updateStack(LivingEntity oldEntity, LivingEntity newEntity) {
|
||||
EntityStack stack = getStackedEntity(oldEntity);
|
||||
if (stack == null) return null;
|
||||
int amount = stack.getAmount()-1;
|
||||
stack.destroy();
|
||||
if (amount == 0 && newEntity != null) {
|
||||
newEntity.remove();
|
||||
return null;
|
||||
}
|
||||
return createStackedEntity(newEntity, amount);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity;
|
||||
package com.craftaro.ultimatestacker.stackable.entity;
|
||||
|
||||
public enum Split {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity.custom;
|
||||
package com.craftaro.ultimatestacker.stackable.entity.custom;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity.custom;
|
||||
package com.craftaro.ultimatestacker.stackable.entity.custom;
|
||||
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.entities.MythicMobsCustomEntity;
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.entities.MythicMobsCustomEntityLegacy;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.entities.MythicMobsCustomEntity;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.entities.MythicMobsCustomEntityLegacy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity.custom.entities;
|
||||
package com.craftaro.ultimatestacker.stackable.entity.custom.entities;
|
||||
|
||||
import io.lumine.mythic.api.mobs.MobManager;
|
||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity.custom.entities;
|
||||
package com.craftaro.ultimatestacker.stackable.entity.custom.entities;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity.custom.entities;
|
||||
package com.craftaro.ultimatestacker.stackable.entity.custom.entities;
|
||||
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public abstract class MythicMobsProvider extends CustomEntity {
|
@ -0,0 +1,35 @@
|
||||
package com.craftaro.ultimatestacker.stackable.item;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.item.ItemStack;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.entity.Item;
|
||||
|
||||
public class ItemStackImpl implements ItemStack {
|
||||
|
||||
private CompatibleMaterial material;
|
||||
private Item item;
|
||||
private int amount;
|
||||
|
||||
public ItemStackImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int amount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void take(int amount) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.craftaro.ultimatestacker.stackable.item;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.item.ItemStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.item.ItemStackManager;
|
||||
import org.bukkit.entity.Item;
|
||||
|
||||
public class ItemStackManagerImpl implements ItemStackManager {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(Item item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createStack(Item item, int amount) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +1,23 @@
|
||||
package com.songoda.ultimatestacker.stackable.spawner;
|
||||
package com.craftaro.ultimatestacker.stackable.spawner;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerAPI;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.utils.Methods;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.nms.world.SpawnedEntity;
|
||||
import com.songoda.core.world.SSpawner;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.Hologramable;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import com.songoda.ultimatestacker.utils.Stackable;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
public class SpawnerStackImpl extends SSpawner implements SpawnerStack {
|
||||
|
||||
// This is the unique identifier for this spawner.
|
||||
// It is reset on every plugin load.
|
||||
@ -28,7 +30,7 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
|
||||
private static final UltimateStacker plugin = UltimateStacker.getInstance();
|
||||
|
||||
public SpawnerStack(Location location, int amount) {
|
||||
public SpawnerStackImpl(Location location, int amount) {
|
||||
super(location);
|
||||
this.amount = amount;
|
||||
}
|
||||
@ -43,11 +45,22 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
return CompatibleMaterial.getMaterial(location.getBlock()) == CompatibleMaterial.SPAWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
plugin.getDataManager().updateSpawner(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int amount) {
|
||||
this.amount += amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void take(int amount) {
|
||||
this.amount -= amount;
|
||||
}
|
||||
|
||||
public int calculateSpawnCount(EntityType type) {
|
||||
if (!UltimateStacker.getInstance().getMobFile().getBoolean("Mobs." + type.name() + ".Enabled")) {
|
||||
return 0;
|
||||
@ -61,6 +74,14 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
return count;
|
||||
}
|
||||
|
||||
public int spawn(int amountToSpawn, EntityType... types) {
|
||||
return super.spawn(amountToSpawn, types);
|
||||
}
|
||||
|
||||
public int spawn(int amountToSpawn, String particle, Set<CompatibleMaterial> canSpawnOn, SpawnedEntity spawned, EntityType... types) {
|
||||
return super.spawn(amountToSpawn, particle, canSpawnOn, spawned, types);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
@ -76,7 +97,7 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
@Override
|
||||
public String getHologramName() {
|
||||
if (!(location.getBlock().getState() instanceof CreatureSpawner)) {
|
||||
plugin.getSpawnerStackManager().removeSpawner(location);
|
||||
UltimateStackerAPI.getSpawnerStackManager().removeSpawner(location);
|
||||
return null;
|
||||
}
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner) location.getBlock().getState();
|
||||
@ -111,7 +132,7 @@ public class SpawnerStack extends SSpawner implements Stackable, Hologramable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SpawnerStack:{"
|
||||
return "SpawnerStackImpl:{"
|
||||
+ "Amount:\"" + amount + "\","
|
||||
+ "Location:{"
|
||||
+ "World:\"" + location.getWorld().getName() + "\","
|
@ -1,6 +1,8 @@
|
||||
package com.songoda.ultimatestacker.stackable.spawner;
|
||||
package com.craftaro.ultimatestacker.stackable.spawner;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStackManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@ -9,40 +11,47 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpawnerStackManager {
|
||||
public class SpawnerStackManagerImpl implements SpawnerStackManager {
|
||||
|
||||
private final Map<Location, SpawnerStack> registeredSpawners = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void addSpawners(Map<Location, SpawnerStack> spawners) {
|
||||
this.registeredSpawners.putAll(spawners);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerStack addSpawner(SpawnerStack spawnerStack) {
|
||||
this.registeredSpawners.put(roundLocation(spawnerStack.getLocation()), spawnerStack);
|
||||
return spawnerStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerStack removeSpawner(Location location) {
|
||||
return registeredSpawners.remove(roundLocation(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerStack getSpawner(Location location) {
|
||||
if (!this.registeredSpawners.containsKey(roundLocation(location))) {
|
||||
SpawnerStack spawnerStack = addSpawner(new SpawnerStack(roundLocation(location), 1));
|
||||
SpawnerStack spawnerStack = addSpawner(new SpawnerStackImpl(roundLocation(location), 1));
|
||||
UltimateStacker.getInstance().getDataManager().createSpawner(spawnerStack);
|
||||
return spawnerStack;
|
||||
}
|
||||
return this.registeredSpawners.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnerStack getSpawner(Block block) {
|
||||
return this.getSpawner(block.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawner(Location location) {
|
||||
return this.registeredSpawners.get(location) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SpawnerStack> getStacks() {
|
||||
return Collections.unmodifiableCollection(this.registeredSpawners.values());
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
package com.songoda.ultimatestacker.tasks;
|
||||
package com.craftaro.ultimatestacker.tasks;
|
||||
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.Check;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.EntityStackManagerImpl;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import com.craftaro.ultimatestacker.utils.CachedChunk;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.hooks.WorldGuardHook;
|
||||
import com.songoda.core.world.SWorld;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.Check;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import com.songoda.ultimatestacker.utils.CachedChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -61,6 +62,8 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.craftaro.ultimatestacker.stackable.entity.Check.*;
|
||||
|
||||
public class StackingTask extends TimerTask {
|
||||
|
||||
private final UltimateStacker plugin;
|
||||
@ -78,7 +81,7 @@ public class StackingTask extends TimerTask {
|
||||
maxPerTypeStacksPerChunk = Settings.MAX_PER_TYPE_STACKS_PER_CHUNK.getInt();
|
||||
private final List<String> disabledWorlds = Settings.DISABLED_WORLDS.getStringList(),
|
||||
stackReasons = Settings.STACK_REASONS.getStringList();
|
||||
private final List<Check> checks = Check.getChecks(Settings.STACK_CHECKS.getStringList());
|
||||
private final List<Check> checks = getChecks(Settings.STACK_CHECKS.getStringList());
|
||||
private final boolean stackFlyingDown = Settings.ONLY_STACK_FLYING_DOWN.getBoolean(),
|
||||
stackWholeChunk = Settings.STACK_WHOLE_CHUNK.getBoolean(),
|
||||
weaponsArentEquipment = Settings.WEAPONS_ARENT_EQUIPMENT.getBoolean(),
|
||||
@ -220,7 +223,7 @@ public class StackingTask extends TimerTask {
|
||||
|
||||
// Get the stack from the entity. It should be noted that this value will
|
||||
// be null if our entity is not a stack.
|
||||
EntityStack baseStack = plugin.getEntityStackManager().getStack(baseEntity);
|
||||
EntityStack baseStack = plugin.getEntityStackManager().getStackedEntity(baseEntity);
|
||||
|
||||
// Get the maximum stack size for this entity.
|
||||
int maxEntityStackSize = getEntityStackSize(baseEntity);
|
||||
@ -265,7 +268,7 @@ public class StackingTask extends TimerTask {
|
||||
if (this.processed.contains(friendlyEntity.getUniqueId())) continue;
|
||||
|
||||
// Get this entities friendStack.
|
||||
EntityStack friendStack = stackManager.getStack(friendlyEntity);
|
||||
EntityStack friendStack = stackManager.getStackedEntity(friendlyEntity);
|
||||
int amount = friendStack != null ? friendStack.getAmount() : 1;
|
||||
|
||||
// Check to see if this friendlyEntity is stacked and friendStack plus
|
||||
@ -275,7 +278,7 @@ public class StackingTask extends TimerTask {
|
||||
boolean overstack = (amount + amountToStack) > maxEntityStackSize;
|
||||
|
||||
if (!overstack) {
|
||||
stackManager.createStack(friendlyEntity, amount + amountToStack);
|
||||
stackManager.createStackedEntity(friendlyEntity, amount + amountToStack);
|
||||
processed.add(baseEntity.getUniqueId());
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
@ -303,7 +306,7 @@ public class StackingTask extends TimerTask {
|
||||
// Create a new stack, summon entity and add to stack.
|
||||
LivingEntity newEntity = (LivingEntity) livingEntity.getWorld().spawnEntity(livingEntity.getLocation(), livingEntity.getType());
|
||||
int toAdd = Math.min(finalStackSize, maxEntityStackAmount);
|
||||
EntityStack newStack = stackManager.createStack(newEntity, toAdd);
|
||||
EntityStack newStack = stackManager.createStackedEntity(newEntity, toAdd);
|
||||
processed.add(newEntity.getUniqueId());
|
||||
finalStackSize -= maxEntityStackAmount;
|
||||
} while (finalStackSize >= 0);
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.utils;
|
||||
package com.craftaro.ultimatestacker.utils;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.utils;
|
||||
package com.craftaro.ultimatestacker.utils;
|
||||
|
||||
import com.songoda.core.world.SWorld;
|
||||
import org.bukkit.Chunk;
|
@ -1,11 +1,11 @@
|
||||
package com.songoda.ultimatestacker.utils;
|
||||
package com.craftaro.ultimatestacker.utils;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import com.craftaro.ultimatestacker.UltimateStacker;
|
||||
import com.craftaro.ultimatestacker.settings.Settings;
|
||||
import com.craftaro.ultimatestacker.stackable.entity.custom.CustomEntity;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.CreatureSpawner;
|
113
UltimateStackerAPI/.gitignore
vendored
Normal file
113
UltimateStackerAPI/.gitignore
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
78
UltimateStackerAPI/pom.xml
Normal file
78
UltimateStackerAPI/pom.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerParent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>UltimateStackerAPI</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,59 @@
|
||||
package com.craftaro.ultimatestacker.api;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.stack.block.BlockStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.item.ItemStackManager;
|
||||
import com.craftaro.ultimatestacker.api.stack.spawner.SpawnerStackManager;
|
||||
|
||||
public final class UltimateStackerAPI {
|
||||
|
||||
private static EntityStackManager entityStackManager;
|
||||
private static ItemStackManager itemStackManager;
|
||||
private static SpawnerStackManager spawnerStackManager;
|
||||
private static BlockStackManager blockStackManager;
|
||||
private static UltimateStackerAPI instance;
|
||||
|
||||
public UltimateStackerAPI(EntityStackManager entityStackManager, ItemStackManager itemStackManager, SpawnerStackManager spawnerStackManager, BlockStackManager blockStackManager) {
|
||||
if (UltimateStackerAPI.entityStackManager != null || UltimateStackerAPI.itemStackManager != null || UltimateStackerAPI.spawnerStackManager != null || UltimateStackerAPI.blockStackManager != null) {
|
||||
throw new IllegalStateException("UltimateStackerAPI has already been initialized!");
|
||||
}
|
||||
UltimateStackerAPI.entityStackManager = entityStackManager;
|
||||
UltimateStackerAPI.itemStackManager = itemStackManager;
|
||||
UltimateStackerAPI.spawnerStackManager = spawnerStackManager;
|
||||
UltimateStackerAPI.blockStackManager = blockStackManager;
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static UltimateStackerAPI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to interact with EntityStacks
|
||||
* @return The EntityStackManager
|
||||
*/
|
||||
public static EntityStackManager getEntityStackManager() {
|
||||
return entityStackManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to interact with ItemStacks
|
||||
* @return The ItemStackManager
|
||||
*/
|
||||
public static ItemStackManager getItemStackManager() {
|
||||
return itemStackManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to interact with SpawnerStacks
|
||||
* @return The SpawnerStackManager
|
||||
*/
|
||||
public static SpawnerStackManager getSpawnerStackManager() {
|
||||
return spawnerStackManager;
|
||||
}
|
||||
|
||||
public static BlockStackManager getBlockStackManager() {
|
||||
return blockStackManager;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
package com.craftaro.ultimatestacker.api.events.entity;
|
||||
|
||||
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
|
||||
import com.craftaro.ultimatestacker.api.stack.entity.EntityStack;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
package com.craftaro.ultimatestacker.api.events.spawner;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
package com.craftaro.ultimatestacker.api.events.spawner;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
package com.craftaro.ultimatestacker.api.events.spawner;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
@ -0,0 +1,19 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.block;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.utils.Hologramable;
|
||||
import com.craftaro.ultimatestacker.api.utils.Stackable;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.hooks.stackers.UltimateStacker;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public interface BlockStack extends Stackable, Hologramable {
|
||||
|
||||
|
||||
int getId();
|
||||
|
||||
void destroy();
|
||||
|
||||
CompatibleMaterial getMaterial();
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.block;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BlockStackManager {
|
||||
|
||||
void addBlocks(Map<Location, BlockStack> blocks);
|
||||
|
||||
BlockStack addBlock(BlockStack blockStack);
|
||||
|
||||
BlockStack removeBlock(Location location);
|
||||
|
||||
BlockStack getBlock(Location location);
|
||||
|
||||
BlockStack getBlock(Block block, CompatibleMaterial material);
|
||||
|
||||
BlockStack createBlock(Location location, CompatibleMaterial material);
|
||||
|
||||
BlockStack createBlock(Block block);
|
||||
|
||||
boolean isBlock(Location location);
|
||||
|
||||
Collection<BlockStack> getStacks();
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.entity;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.events.entity.EntityStackKillEvent;
|
||||
import com.craftaro.ultimatestacker.api.utils.StackableEntity;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.lootables.loot.Drop;
|
||||
import com.songoda.core.lootables.loot.DropUtils;
|
||||
import com.songoda.core.utils.EntityUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityStack extends StackableEntity {
|
||||
|
||||
|
||||
EntityType getType();
|
||||
|
||||
UUID getUuid();
|
||||
|
||||
LivingEntity getHostEntity();
|
||||
|
||||
LivingEntity takeOneAndSpawnEntity(Location location);
|
||||
|
||||
void releaseHost();
|
||||
|
||||
void destroy();
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityStackManager {
|
||||
|
||||
/**
|
||||
* Creates a new stack with the given entity and amount.
|
||||
* @param entity The entity to create the stack with.
|
||||
* @param amount The amount to create the stack with.
|
||||
* @return The EntityStack created.
|
||||
*/
|
||||
EntityStack createStackedEntity(LivingEntity entity, int amount);
|
||||
|
||||
/**
|
||||
* @return if the entity is a stacked entity.
|
||||
*/
|
||||
boolean isStackedEntity(Entity entity);
|
||||
|
||||
/**
|
||||
* Used to get the EntityStack of a stacked entity.
|
||||
* @param entityUUID The UUID of the entity to get the stack of.
|
||||
* @return The EntityStack of the entity or null if the entity is not stacked.
|
||||
*/
|
||||
EntityStack getStackedEntity(UUID entityUUID);
|
||||
|
||||
/**
|
||||
* Used to get the EntityStack of a stacked entity.
|
||||
* @param entity The entity to get the stack of.
|
||||
* @return The EntityStack of the entity or null if the entity is not stacked.
|
||||
*/
|
||||
EntityStack getStackedEntity(LivingEntity entity);
|
||||
|
||||
/**
|
||||
* Used to get the last player to damage the entity.
|
||||
* @param entity The entity to get the last player to damage it.
|
||||
* @return The player's name or null if no player has damaged the entity.
|
||||
*/
|
||||
String getLastPlayerDamage(Entity entity);
|
||||
|
||||
/**
|
||||
* Used to set the last player who damaged the entity.
|
||||
* @param entity The entity to set the last player to damage it.
|
||||
* @param player The player who damaged the entity.
|
||||
*/
|
||||
void setLastPlayerDamage(Entity entity, Player player);
|
||||
|
||||
/**
|
||||
* Transfers the stack from one entity to another.
|
||||
* (e.g. slimes split)
|
||||
* @param oldEntity The old entity to transfer the stack from.
|
||||
* @param newEntity The new entity to transfer the stack to.
|
||||
* @return The new stack.
|
||||
*/
|
||||
EntityStack transferStack(LivingEntity oldEntity, LivingEntity newEntity, boolean takeOne);
|
||||
|
||||
/**
|
||||
* TODO: Add javadoc
|
||||
*/
|
||||
EntityStack updateStack(LivingEntity oldEntity, LivingEntity newEntity);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.item;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.utils.StackableEntity;
|
||||
|
||||
public interface ItemStack extends StackableEntity {
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.item;
|
||||
|
||||
import org.bukkit.entity.Item;
|
||||
|
||||
public interface ItemStackManager {
|
||||
|
||||
ItemStack getItem(Item item);
|
||||
|
||||
ItemStack createStack(Item item, int amount);
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.spawner;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.utils.Hologramable;
|
||||
import com.craftaro.ultimatestacker.api.utils.Stackable;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.nms.world.SpawnedEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SpawnerStack extends Stackable, Hologramable {
|
||||
|
||||
int getAmount();
|
||||
|
||||
boolean isValid();
|
||||
|
||||
void setAmount(int amount);
|
||||
|
||||
int calculateSpawnCount(EntityType type);
|
||||
|
||||
int getId();
|
||||
|
||||
void setId(int id);
|
||||
|
||||
Location getLocation();
|
||||
|
||||
String getHologramName();
|
||||
|
||||
boolean areHologramsEnabled();
|
||||
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
int getZ();
|
||||
|
||||
World getWorld();
|
||||
|
||||
String getHologramId();
|
||||
|
||||
int spawn(int amountToSpawn, EntityType... types);
|
||||
|
||||
int spawn(int amountToSpawn, String particle, Set<CompatibleMaterial> canSpawnOn, SpawnedEntity spawned, EntityType... types);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.craftaro.ultimatestacker.api.stack.spawner;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SpawnerStackManager {
|
||||
void addSpawners(Map<Location, SpawnerStack> spawners);
|
||||
|
||||
SpawnerStack addSpawner(SpawnerStack spawnerStack);
|
||||
|
||||
SpawnerStack getSpawner(Block block);
|
||||
|
||||
SpawnerStack getSpawner(Location location);
|
||||
|
||||
boolean isSpawner(Location location);
|
||||
|
||||
SpawnerStack removeSpawner(Location location);
|
||||
|
||||
Collection<SpawnerStack> getStacks();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimatestacker.stackable;
|
||||
package com.craftaro.ultimatestacker.api.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.craftaro.ultimatestacker.api.utils;
|
||||
|
||||
|
||||
public interface Stackable {
|
||||
|
||||
int getAmount();
|
||||
|
||||
void setAmount(int amount);
|
||||
|
||||
void add(int amount);
|
||||
|
||||
void take(int amount);
|
||||
|
||||
boolean isValid();
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.craftaro.ultimatestacker.api.utils;
|
||||
|
||||
public interface StackableEntity {
|
||||
|
||||
int getAmount();
|
||||
|
||||
void setAmount(int amount);
|
||||
|
||||
void add(int amount);
|
||||
|
||||
void take(int amount);
|
||||
|
||||
//int getMaxStackSize();
|
||||
}
|
4
UltimateStackerAPI/src/main/resources/plugin.yml
Normal file
4
UltimateStackerAPI/src/main/resources/plugin.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: UltimateStackerAPI
|
||||
version: '${project.version}'
|
||||
main: com.craftaro.ultimatestacker.api.UltimateStackerAPI
|
||||
api-version: 1.18
|
147
pom.xml
147
pom.xml
@ -1,90 +1,28 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.4.3</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateStacker-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>UltimateStackerParent</artifactId>
|
||||
<version>${revision}</version>
|
||||
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<modules>
|
||||
<module>UltimateStackerAPI</module>
|
||||
<module>UltimateStacker</module>
|
||||
<module>Bootstrap</module>
|
||||
</modules>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.ultimatestacker.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<revision>2.5.0-DEV</revision>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bg-repo</id>
|
||||
<url>https://repo.bg-software.com/repository/api/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
@ -100,58 +38,9 @@
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>bg-repo</id>
|
||||
<url>https://repo.bg-software.com/repository/api/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>lumine-repo</id>
|
||||
<url>https://mvn.lumine.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.21</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>WildStackerAPI</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>uk.antiperson</groupId>
|
||||
<artifactId>stackmob</artifactId>
|
||||
<version>4-0-2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.minebuilders</groupId>
|
||||
<artifactId>Clearlag</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>Mythic-Dist</artifactId>
|
||||
<version>5.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,134 +0,0 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityStackManager {
|
||||
|
||||
private final UltimateStacker plugin;
|
||||
|
||||
public EntityStackManager(UltimateStacker plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public EntityStack createStack(LivingEntity entity, int amount) {
|
||||
return new EntityStack(entity, amount);
|
||||
}
|
||||
|
||||
public boolean isStackedEntity(Entity entity) {
|
||||
return entity.hasMetadata("US_AMOUNT");
|
||||
}
|
||||
|
||||
public int getAmount(Entity entity) {
|
||||
if (!isStackedEntity(entity)) return 1;
|
||||
if (entity.getMetadata("US_AMOUNT").isEmpty()) return 1;
|
||||
return entity.getMetadata("US_AMOUNT").get(0).asInt();
|
||||
}
|
||||
|
||||
public String getLastPlayerDamage(Entity entity) {
|
||||
if (!entity.hasMetadata("US_LAST_PLAYER_DAMAGE")) return null;
|
||||
if (entity.getMetadata("US_LAST_PLAYER_DAMAGE").isEmpty()) return null;
|
||||
return entity.getMetadata("US_LAST_PLAYER_DAMAGE").get(0).asString();
|
||||
}
|
||||
|
||||
public void setLastPlayerDamage(Entity entity, Player player) {
|
||||
if (player == null) return;
|
||||
if (entity == null) return;
|
||||
if (entity instanceof Player) return;
|
||||
entity.setMetadata("US_LAST_PLAYER_DAMAGE", new FixedMetadataValue(plugin, player.getName()));
|
||||
}
|
||||
|
||||
public EntityStack addStack(LivingEntity entity) {
|
||||
return addStack(entity, getAmount(entity) == 1 ? 1 : getAmount(entity));
|
||||
}
|
||||
|
||||
public EntityStack addStack(LivingEntity entity, int amount) {
|
||||
if (entity == null) return null;
|
||||
if (isStackedEntity(entity)) {
|
||||
EntityStack stack = getStack(entity);
|
||||
stack.addEntityToStack(amount);
|
||||
return stack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EntityStack getStack(UUID uuid) {
|
||||
Entity entity = Bukkit.getEntity(uuid);
|
||||
if (entity == null) return null;
|
||||
if (isStackedEntity(entity)) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
return new EntityStack((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EntityStack getStack(LivingEntity entity) {
|
||||
if (!isStackedEntity(entity)) return null;
|
||||
return new EntityStack(entity);
|
||||
}
|
||||
|
||||
public EntityStack decreaseStack(Entity entity) {
|
||||
EntityStack stack = getStack((LivingEntity) entity);
|
||||
if (stack == null) return null;
|
||||
stack.removeEntityFromStack(1);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EntityStack decreaseStack(Entity entity, int amount) {
|
||||
EntityStack stack = getStack((LivingEntity) entity);
|
||||
if (stack == null) return null;
|
||||
stack.removeEntityFromStack(amount);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EntityStack updateStack(LivingEntity entity) {
|
||||
EntityStack stack = getStack(entity);
|
||||
if (stack == null) return null;
|
||||
stack.updateNameTag();
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers the stack from one entity to another.
|
||||
* (e.g. slimes split)
|
||||
* @param oldEntity The old entity to transfer the stack from.
|
||||
* @param newEntity The new entity to transfer the stack to.
|
||||
* @return The new stack.
|
||||
*/
|
||||
public EntityStack transferStack(LivingEntity oldEntity, LivingEntity newEntity, boolean takeOne) {
|
||||
EntityStack stack = getStack(oldEntity);
|
||||
if (stack == null) return null;
|
||||
EntityStack newStack = new EntityStack(newEntity, takeOne ? stack.getAmount()-1 : stack.getAmount());
|
||||
stack.destroy();
|
||||
return newStack;
|
||||
}
|
||||
|
||||
public EntityStack updateStack(LivingEntity oldEntity, LivingEntity newEntity) {
|
||||
EntityStack stack = getStack(oldEntity);
|
||||
if (stack == null) return null;
|
||||
int amount = stack.getAmount()-1;
|
||||
stack.destroy();
|
||||
if (amount == 0 && newEntity != null) {
|
||||
newEntity.remove();
|
||||
return null;
|
||||
}
|
||||
return createStack(newEntity, amount);
|
||||
}
|
||||
|
||||
public void setStack(LivingEntity newEntity, int amount) {
|
||||
if (amount <= 0) return;
|
||||
if (isStackedEntity(newEntity)) {
|
||||
EntityStack stack = getStack(newEntity);
|
||||
stack.setAmount(amount);
|
||||
} else {
|
||||
createStack(newEntity, amount);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.songoda.ultimatestacker.stackable.entity;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.settings.Settings;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class StackedEntity {
|
||||
|
||||
protected int amount;
|
||||
protected LivingEntity hostEntity;
|
||||
|
||||
/**
|
||||
* Gets an existing stack from an entity or creates a new one if it doesn't exist.
|
||||
* @param entity The entity to get the stack from.
|
||||
*/
|
||||
public StackedEntity(LivingEntity entity) {
|
||||
if (entity == null) return;
|
||||
if (!UltimateStacker.getInstance().getEntityStackManager().isStackedEntity(entity)) {
|
||||
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), 1));
|
||||
this.amount = 1;
|
||||
updateNameTag();
|
||||
} else {
|
||||
//get the amount from the entity
|
||||
this.amount = UltimateStacker.getInstance().getEntityStackManager().getAmount(entity);
|
||||
}
|
||||
this.hostEntity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stack or overrides an existing stack.
|
||||
* @param entity The entity to create the stack for.
|
||||
* @param amount The amount of entities in the stack.
|
||||
*/
|
||||
public StackedEntity(LivingEntity entity, int amount) {
|
||||
if (entity == null) return;
|
||||
this.hostEntity = entity;
|
||||
this.amount = amount;
|
||||
entity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
|
||||
updateNameTag();
|
||||
}
|
||||
|
||||
|
||||
public EntityType getType() {
|
||||
return hostEntity.getType();
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
this.hostEntity.setMetadata("US_AMOUNT", new FixedMetadataValue(UltimateStacker.getInstance(), amount));
|
||||
updateNameTag();
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return hostEntity.getUniqueId();
|
||||
}
|
||||
|
||||
public LivingEntity getHostEntity() {
|
||||
return hostEntity;
|
||||
}
|
||||
|
||||
protected void updateNameTag() {
|
||||
if (hostEntity == null) {
|
||||
return;
|
||||
}
|
||||
hostEntity.setCustomNameVisible(!Settings.HOLOGRAMS_ON_LOOK_ENTITY.getBoolean());
|
||||
hostEntity.setCustomName(Methods.compileEntityName(hostEntity, getAmount()));
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.songoda.ultimatestacker.utils;
|
||||
|
||||
|
||||
public interface Stackable {
|
||||
|
||||
int getAmount();
|
||||
|
||||
boolean isValid();
|
||||
}
|
Loading…
Reference in New Issue
Block a user