mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-25 18:07:43 +01:00
clean up
This commit is contained in:
parent
46419db995
commit
0a801f03e8
4
.gitignore
vendored
4
.gitignore
vendored
@ -140,3 +140,7 @@ target/classes/plugin\.yml
|
||||
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles\.lst
|
||||
|
||||
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles\.lst
|
||||
|
||||
\.idea/vcs\.xml
|
||||
|
||||
UltimateStacker\.iml
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="spigot-1.12.2" level="project" />
|
||||
<orderEntry type="library" name="Arconix" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot:1.13.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.songoda:arconix:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: org:kingdoms:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.milkbowl.vault:VaultAPI:1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.9-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||
<orderEntry type="library" name="Maven: me.ryanhamshire:GriefPrevention:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sk89q:worldedit:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sk89q:worldguard:6.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com:plotsquared:RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.palmergames.bukkit:towny:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.wasteofplastic:askyblock:3.0.6.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: us.talabrek:ultimateskyblock:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: me.markeh:factionsframework:1.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: br.net.fabiozumbi12:RedProtect:7.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.songoda:epicspawners:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.massivecraft:factions:LATEST" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.massivecraft:factionsuuid:LATEST" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -5,6 +5,7 @@ import com.songoda.arconix.api.methods.serialize.Serialize;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.ultimatestacker.command.CommandManager;
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.events.*;
|
||||
import com.songoda.ultimatestacker.handlers.HologramHandler;
|
||||
import com.songoda.ultimatestacker.spawner.SpawnerStack;
|
||||
@ -14,7 +15,6 @@ import com.songoda.ultimatestacker.storage.StorageItem;
|
||||
import com.songoda.ultimatestacker.storage.StorageRow;
|
||||
import com.songoda.ultimatestacker.storage.types.StorageMysql;
|
||||
import com.songoda.ultimatestacker.storage.types.StorageYaml;
|
||||
import com.songoda.ultimatestacker.entity.EntityStackManager;
|
||||
import com.songoda.ultimatestacker.tasks.StackingTask;
|
||||
import com.songoda.ultimatestacker.utils.ServerVersion;
|
||||
import com.songoda.ultimatestacker.utils.SettingsManager;
|
||||
@ -57,6 +57,10 @@ public class UltimateStacker extends JavaPlugin {
|
||||
private ServerVersion serverVersion = ServerVersion.fromPackageName(Bukkit.getServer().getClass().getPackage().getName());
|
||||
private Storage storage;
|
||||
|
||||
public static UltimateStacker getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
this.saveToFile();
|
||||
this.storage.closeConnection();
|
||||
@ -323,8 +327,4 @@ public class UltimateStacker extends JavaPlugin {
|
||||
public ConfigWrapper getSpawnerFile() {
|
||||
return spawnerFile;
|
||||
}
|
||||
|
||||
public static UltimateStacker getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ package com.songoda.ultimatestacker.command;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.command.AbstractCommand;
|
||||
import com.songoda.ultimatestacker.command.commands.*;
|
||||
import com.songoda.ultimatestacker.command.commands.CommandGive;
|
||||
import com.songoda.ultimatestacker.command.commands.CommandReload;
|
||||
import com.songoda.ultimatestacker.command.commands.CommandUltimateStacker;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,9 +16,8 @@ import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private UltimateStacker instance;
|
||||
|
||||
private static final List<AbstractCommand> commands = new ArrayList<>();
|
||||
private UltimateStacker instance;
|
||||
|
||||
public CommandManager(UltimateStacker instance) {
|
||||
this.instance = instance;
|
||||
|
@ -28,7 +28,7 @@ public class CommandGive extends AbstractCommand {
|
||||
EntityType type = null;
|
||||
for (EntityType types : EntityType.values()) {
|
||||
String input = args[2].toUpperCase().replace("_", "").replace(" ", "");
|
||||
String compare = types.name().toUpperCase().replace("_", "").replace(" ", "");
|
||||
String compare = types.name().toUpperCase().replace("_", "").replace(" ", "");
|
||||
if (input.equals(compare))
|
||||
type = types;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.ultimatestacker.entity;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class EntityStackManager {
|
||||
// These are all stacked mobs loaded into memory.
|
||||
private static final Map<UUID, EntityStack> stacks = new HashMap<>();
|
||||
|
||||
public EntityStack addStack (EntityStack stack) {
|
||||
public EntityStack addStack(EntityStack stack) {
|
||||
stacks.put(stack.getEntity().getUniqueId(), stack);
|
||||
return stack;
|
||||
}
|
||||
@ -46,5 +46,4 @@ public class EntityStackManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class BlockListeners implements Listener {
|
||||
int specific = instance.getSpawnerFile().getConfig().getInt("Spawners." + cs.getSpawnedType().name() + ".Max Stack Size");
|
||||
int maxStackSize = specific == -1 ? instance.getConfig().getInt("Spawners.Max Stack Size") : specific;
|
||||
|
||||
cs = (CreatureSpawner)block.getState();
|
||||
cs = (CreatureSpawner) block.getState();
|
||||
|
||||
EntityType blockType = cs.getSpawnedType();
|
||||
|
||||
@ -102,7 +102,7 @@ public class BlockListeners implements Listener {
|
||||
|
||||
if (!instance.getConfig().getBoolean("Main.Stack Spawners")) return;
|
||||
|
||||
CreatureSpawner cs = (CreatureSpawner)block.getState();
|
||||
CreatureSpawner cs = (CreatureSpawner) block.getState();
|
||||
|
||||
EntityType blockType = cs.getSpawnedType();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.entity.EntityStackManager;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -30,7 +30,7 @@ public class DeathListeners implements Listener {
|
||||
EntityStack stack = stackManager.getStack(killed);
|
||||
|
||||
if (instance.getConfig().getBoolean("Entity.Kill Whole Stack On Death")) {
|
||||
for (int i = 1; i < stack.getAmount(); i ++) {
|
||||
for (int i = 1; i < stack.getAmount(); i++) {
|
||||
LivingEntity newEntity = newEntity(killed);
|
||||
newEntity.damage(99999);
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class DeathListeners implements Listener {
|
||||
}
|
||||
|
||||
private LivingEntity newEntity(LivingEntity killed) {
|
||||
LivingEntity newEntity = (LivingEntity)killed.getWorld().spawnEntity(killed.getLocation(), killed.getType());
|
||||
LivingEntity newEntity = (LivingEntity) killed.getWorld().spawnEntity(killed.getLocation(), killed.getType());
|
||||
newEntity.setVelocity(killed.getVelocity());
|
||||
if (killed instanceof Ageable && !((Ageable) killed).isAdult()) {
|
||||
((Ageable) newEntity).setBaby();
|
||||
@ -59,7 +59,7 @@ public class DeathListeners implements Listener {
|
||||
}
|
||||
|
||||
if (killed instanceof Villager) {
|
||||
((Villager)newEntity).setProfession(((Villager)killed).getProfession());
|
||||
((Villager) newEntity).setProfession(((Villager) killed).getProfession());
|
||||
}
|
||||
return newEntity;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DropListeners implements Listener {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.entity.EntityStackManager;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -1,16 +1,10 @@
|
||||
package com.songoda.ultimatestacker.events;
|
||||
|
||||
import com.songoda.ultimatestacker.UltimateStacker;
|
||||
import com.songoda.ultimatestacker.entity.EntityStack;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnerListeners implements Listener {
|
||||
|
||||
private UltimateStacker instance;
|
||||
|
@ -7,7 +7,6 @@ import com.songoda.ultimatestacker.spawner.SpawnerStack;
|
||||
import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
|
||||
@ -36,13 +35,13 @@ public class HologramHandler {
|
||||
}
|
||||
|
||||
public void updateHologram(SpawnerStack spawner) {
|
||||
if (spawner == null) return;
|
||||
if (spawner == null) return;
|
||||
|
||||
Location location = spawner.getLocation().add(0.5, 1, 0.5);
|
||||
Location location = spawner.getLocation().add(0.5, 1, 0.5);
|
||||
|
||||
if (!instance.getConfig().getBoolean("Spawners.Holograms Enabled")) return;
|
||||
if (!instance.getConfig().getBoolean("Spawners.Holograms Enabled")) return;
|
||||
|
||||
addHologram(location, spawner);
|
||||
addHologram(location, spawner);
|
||||
}
|
||||
|
||||
public void despawn(Block b) {
|
||||
@ -51,19 +50,19 @@ public class HologramHandler {
|
||||
}
|
||||
|
||||
private void addHologram(Location location, SpawnerStack spawner) {
|
||||
int amount = spawner.getAmount();
|
||||
int amount = spawner.getAmount();
|
||||
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner)spawner.getLocation().getBlock().getState();
|
||||
String name = Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), amount);
|
||||
CreatureSpawner creatureSpawner = (CreatureSpawner) spawner.getLocation().getBlock().getState();
|
||||
String name = Methods.compileSpawnerName(creatureSpawner.getSpawnedType(), amount);
|
||||
|
||||
HologramObject hologram = new HologramObject(null, location, name);
|
||||
HologramObject hologram = new HologramObject(null, location, name);
|
||||
|
||||
Arconix.pl().getApi().packetLibrary.getHologramManager().addHologram(hologram);
|
||||
Arconix.pl().getApi().packetLibrary.getHologramManager().addHologram(hologram);
|
||||
}
|
||||
|
||||
public void processChange(Block block) {
|
||||
if (!block.getType().name().contains("SPAWNER")) return;
|
||||
SpawnerStack spawner = instance.getSpawnerStackManager().getSpawner(block);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> updateHologram(spawner), 1L);
|
||||
SpawnerStack spawner = instance.getSpawnerStackManager().getSpawner(block);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> updateHologram(spawner), 1L);
|
||||
}
|
||||
}
|
@ -3,7 +3,10 @@ package com.songoda.ultimatestacker.spawner;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpawnerStackManager {
|
||||
|
||||
|
@ -17,8 +17,8 @@ import java.util.Map;
|
||||
|
||||
public class StorageMysql extends Storage {
|
||||
|
||||
private MySQLDatabase database;
|
||||
private static List<String> toSave = new ArrayList<>();
|
||||
private MySQLDatabase database;
|
||||
|
||||
public StorageMysql(UltimateStacker instance) {
|
||||
super(instance);
|
||||
@ -65,29 +65,29 @@ public class StorageMysql extends Storage {
|
||||
|
||||
@Override
|
||||
public void prepareSaveItem(String group, StorageItem... items) {
|
||||
StringBuilder sql = new StringBuilder(String.format("INSERT INTO `" + instance.getConfig().getString("Database.Prefix") + "%s`", group));
|
||||
StringBuilder sql = new StringBuilder(String.format("INSERT INTO `" + instance.getConfig().getString("Database.Prefix") + "%s`", group));
|
||||
|
||||
sql.append(" (");
|
||||
sql.append(" (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("`%s`, ", item.getKey()));
|
||||
}
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("`%s`, ", item.getKey()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(") VALUES (");
|
||||
sql.append(") VALUES (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("'%s', ", item.asObject().toString()));
|
||||
}
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("'%s', ", item.asObject().toString()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(");");
|
||||
sql.append(");");
|
||||
|
||||
toSave.add(sql.toString());
|
||||
toSave.add(sql.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,10 @@ import com.songoda.ultimatestacker.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@ -54,10 +57,11 @@ public class StackingTask extends BukkitRunnable {
|
||||
|
||||
nextEntity:
|
||||
for (Entity entityO : world.getEntities()) {
|
||||
if (entityO instanceof Item && instance.getConfig().getBoolean( "Main.Stack Items")) {
|
||||
if (entityO instanceof Item && instance.getConfig().getBoolean("Main.Stack Items")) {
|
||||
ItemStack item = ((Item) entityO).getItemStack();
|
||||
|
||||
if (entityO.isCustomNameVisible() && !entityO.getCustomName().contains(TextComponent.convertToInvisibleString("IS")) || item.hasItemMeta() && item.getItemMeta().hasDisplayName()) continue;
|
||||
if (entityO.isCustomNameVisible() && !entityO.getCustomName().contains(TextComponent.convertToInvisibleString("IS")) || item.hasItemMeta() && item.getItemMeta().hasDisplayName())
|
||||
continue;
|
||||
|
||||
if (item.getMaxStackSize() != maxItemStackSize && item.getMaxStackSize() != 1)
|
||||
setMax(item, false);
|
||||
@ -130,7 +134,7 @@ public class StackingTask extends BukkitRunnable {
|
||||
int maxItemStackSize = specific == -1 ? instance.getConfig().getInt("Item.Max Stack Size") : specific;
|
||||
Object objItemStack = methodGetItem.invoke(methodAsNMSCopy.invoke(null, item));
|
||||
fieldMaxStackSize.set(objItemStack, reset ? new ItemStack(item.getType()).getMaxStackSize() : maxItemStackSize);
|
||||
} catch(ReflectiveOperationException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return item;
|
||||
|
@ -42,7 +42,7 @@ public class Methods {
|
||||
}
|
||||
|
||||
if (initalEntity instanceof Villager) {
|
||||
Villager villager = ((Villager)initalEntity);
|
||||
Villager villager = ((Villager) initalEntity);
|
||||
entityList.removeIf(entity -> ((Villager) entity).getProfession() != villager.getProfession());
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class Methods {
|
||||
ItemStack item = new ItemStack(Material.MOB_SPAWNER, 1);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Methods.compileSpawnerName(entityType, amount));
|
||||
CreatureSpawner cs = (CreatureSpawner) ((BlockStateMeta)meta).getBlockState();
|
||||
CreatureSpawner cs = (CreatureSpawner) ((BlockStateMeta) meta).getBlockState();
|
||||
cs.setSpawnedType(entityType);
|
||||
((BlockStateMeta) meta).setBlockState(cs);
|
||||
item.setItemMeta(meta);
|
||||
|
Loading…
Reference in New Issue
Block a user