9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-28 03:19:12 +00:00

rename entity & optimize market

This commit is contained in:
XiaoMoMi
2023-09-11 04:24:05 +08:00
parent c878ec7c4a
commit 2068a3b178
35 changed files with 196 additions and 129 deletions

View File

@@ -40,7 +40,7 @@ import net.momirealms.customfishing.mechanic.item.ItemManagerImpl;
import net.momirealms.customfishing.mechanic.loot.LootManagerImpl;
import net.momirealms.customfishing.mechanic.market.MarketManagerImpl;
import net.momirealms.customfishing.mechanic.misc.CoolDownManager;
import net.momirealms.customfishing.mechanic.mob.MobManagerImpl;
import net.momirealms.customfishing.mechanic.entity.EntityManagerImpl;
import net.momirealms.customfishing.mechanic.requirement.RequirementManagerImpl;
import net.momirealms.customfishing.mechanic.statistic.StatisticsManagerImpl;
import net.momirealms.customfishing.scheduler.SchedulerImpl;
@@ -88,7 +88,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
this.itemManager = new ItemManagerImpl(this);
this.lootManager = new LootManagerImpl(this);
this.marketManager = new MarketManagerImpl(this);
this.mobManager = new MobManagerImpl(this);
this.entityManager = new EntityManagerImpl(this);
this.placeholderManager = new PlaceholderManagerImpl(this);
this.requirementManager = new RequirementManagerImpl(this);
this.scheduler = new SchedulerImpl(this);
@@ -116,7 +116,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
((ItemManagerImpl) this.itemManager).disable();
((LootManagerImpl) this.lootManager).disable();
((MarketManagerImpl) this.marketManager).disable();
((MobManagerImpl) this.mobManager).disable();
((EntityManagerImpl) this.entityManager).disable();
((RequirementManagerImpl) this.requirementManager).disable();
((SchedulerImpl) this.scheduler).shutdown();
((IntegrationManagerImpl) this.integrationManager).disable();
@@ -154,8 +154,8 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
((BagManagerImpl) this.bagManager).load();
((BlockManagerImpl) this.blockManager).unload();
((BlockManagerImpl) this.blockManager).load();
((MobManagerImpl) this.mobManager).unload();
((MobManagerImpl) this.mobManager).load();
((EntityManagerImpl) this.entityManager).unload();
((EntityManagerImpl) this.entityManager).load();
((CompetitionManagerImpl) this.competitionManager).unload();
((CompetitionManagerImpl) this.competitionManager).load();
((StorageManagerImpl) this.storageManager).reload();

View File

@@ -45,7 +45,7 @@ public class ItemCommand {
return new CommandAPICommand("items")
.withPermission("customfishing.command.items")
.withSubcommands(
getSubCommand("loot"),
getSubCommand("item"),
getSubCommand("util"),
getSubCommand("bait"),
getSubCommand("rod")

View File

@@ -17,7 +17,6 @@
package net.momirealms.customfishing.compatibility;
import net.momirealms.customfishing.adventure.AdventureManagerImpl;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.integration.EnchantmentInterface;
import net.momirealms.customfishing.api.integration.LevelInterface;
@@ -27,9 +26,10 @@ import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.compatibility.block.ItemsAdderBlockImpl;
import net.momirealms.customfishing.compatibility.enchant.AdvancedEnchantmentsImpl;
import net.momirealms.customfishing.compatibility.enchant.VanillaEnchantmentsImpl;
import net.momirealms.customfishing.compatibility.entity.ItemsAdderEntityImpl;
import net.momirealms.customfishing.compatibility.item.*;
import net.momirealms.customfishing.compatibility.level.*;
import net.momirealms.customfishing.compatibility.mob.MythicMobsLibraryImpl;
import net.momirealms.customfishing.compatibility.entity.MythicEntityImpl;
import net.momirealms.customfishing.compatibility.season.CustomCropsSeasonImpl;
import net.momirealms.customfishing.compatibility.season.RealisticSeasonsImpl;
import org.bukkit.inventory.ItemStack;
@@ -62,6 +62,7 @@ public class IntegrationManagerImpl implements IntegrationManager {
if (plugin.isHookedPluginEnabled("ItemsAdder")) {
plugin.getItemManager().registerItemLibrary(new ItemsAdderItemImpl());
plugin.getBlockManager().registerBlockLibrary(new ItemsAdderBlockImpl());
plugin.getEntityManager().registerEntityLibrary(new ItemsAdderEntityImpl());
hookMessage("ItemsAdder");
}
if (plugin.isHookedPluginEnabled("MMOItems")) {
@@ -78,7 +79,7 @@ public class IntegrationManagerImpl implements IntegrationManager {
}
if (plugin.isHookedPluginEnabled("MythicMobs")) {
plugin.getItemManager().registerItemLibrary(new MythicMobsItemImpl());
plugin.getMobManager().registerMobLibrary(new MythicMobsLibraryImpl());
plugin.getEntityManager().registerEntityLibrary(new MythicEntityImpl());
hookMessage("MythicMobs");
}
if (plugin.isHookedPluginEnabled("EcoJobs")) {
@@ -99,7 +100,7 @@ public class IntegrationManagerImpl implements IntegrationManager {
}
if (plugin.isHookedPluginEnabled("mcMMO")) {
try {
plugin.getItemManager().registerCustomItem("loot", "mcmmo", new McMMOBuildableItem());
plugin.getItemManager().registerCustomItem("item", "mcmmo", new McMMOBuildableItem());
} catch (ClassNotFoundException | NoSuchMethodException e) {
LogUtils.warn("Failed to initialize mcMMO Treasure");
}
@@ -152,7 +153,7 @@ public class IntegrationManagerImpl implements IntegrationManager {
}
private void hookMessage(String plugin) {
AdventureManagerImpl.getInstance().sendConsoleMessage("[CustomFishing] <green>" + plugin + "</green> hooked!");
LogUtils.info( plugin + " hooked!");
}
@Override

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.compatibility.entity;
import dev.lone.itemsadder.api.CustomEntity;
import net.momirealms.customfishing.api.mechanic.entity.EntityLibrary;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import java.util.Map;
public class ItemsAdderEntityImpl implements EntityLibrary {
@Override
public String identification() {
return "vanilla";
}
@Override
public Entity spawn(Location location, String id, Map<String, Object> propertyMap) {
CustomEntity customEntity = CustomEntity.spawn(
id,
location,
(Boolean) propertyMap.get("frustumCulling"),
(Boolean) propertyMap.get("noBase"),
(Boolean) propertyMap.get("noHitbox")
);
return customEntity.getEntity();
}
}

View File

@@ -15,25 +15,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.compatibility.mob;
package net.momirealms.customfishing.compatibility.entity;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.utils.serialize.Position;
import io.lumine.mythic.core.mobs.ActiveMob;
import net.momirealms.customfishing.api.mechanic.mob.MobLibrary;
import net.momirealms.customfishing.api.mechanic.entity.EntityLibrary;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import java.util.Map;
import java.util.Optional;
public class MythicMobsLibraryImpl implements MobLibrary {
public class MythicEntityImpl implements EntityLibrary {
private MythicBukkit mythicBukkit;
public MythicMobsLibraryImpl() {
public MythicEntityImpl() {
this.mythicBukkit = MythicBukkit.inst();
}
@@ -43,7 +43,7 @@ public class MythicMobsLibraryImpl implements MobLibrary {
}
@Override
public Entity spawn(Location location, String id, Map<String, Object> mobPropertyMap) {
public Entity spawn(Location location, String id, Map<String, Object> propertyMap) {
if (this.mythicBukkit == null || mythicBukkit.isClosed()) {
this.mythicBukkit = MythicBukkit.inst();
}
@@ -52,7 +52,7 @@ public class MythicMobsLibraryImpl implements MobLibrary {
MythicMob theMob = mythicMob.get();
Position position = Position.of(location);
AbstractLocation abstractLocation = new AbstractLocation(position);
ActiveMob activeMob = theMob.spawn(abstractLocation, (Double) mobPropertyMap.get("{level}"));
ActiveMob activeMob = theMob.spawn(abstractLocation, (Double) propertyMap.get("{level}"));
return activeMob.getEntity().getBukkitEntity();
}
throw new NullPointerException("MythicMobs: " + id + " doesn't exist.");

View File

@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.compatibility.mob;
package net.momirealms.customfishing.compatibility.entity;
import net.momirealms.customfishing.api.mechanic.mob.MobLibrary;
import net.momirealms.customfishing.api.mechanic.entity.EntityLibrary;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -25,7 +25,7 @@ import org.bukkit.entity.EntityType;
import java.util.Locale;
import java.util.Map;
public class VanillaMobImpl implements MobLibrary {
public class VanillaEntityImpl implements EntityLibrary {
@Override
public String identification() {
@@ -33,7 +33,7 @@ public class VanillaMobImpl implements MobLibrary {
}
@Override
public Entity spawn(Location location, String id, Map<String, Object> mobPropertyMap) {
public Entity spawn(Location location, String id, Map<String, Object> propertyMap) {
return location.getWorld().spawnEntity(location, EntityType.valueOf(id.toUpperCase(Locale.ENGLISH)));
}
}

View File

@@ -165,7 +165,7 @@ public class BlockManagerImpl implements BlockManager, Listener {
@SuppressWarnings("DuplicatedCode")
private void loadConfig() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("blocks")) {
for (String type : List.of("block")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
@@ -215,8 +215,8 @@ public class BlockManagerImpl implements BlockManager, Listener {
BlockConfig blockConfig = new BlockConfig.Builder()
.blockID(blockID)
.persist(false)
.horizontalVector(section.getDouble("vector.horizontal", 1.1))
.verticalVector(section.getDouble("vector.vertical", 1.2))
.horizontalVector(section.getDouble("velocity.horizontal", 1.1))
.verticalVector(section.getDouble("velocity.vertical", 1.2))
.dataModifiers(dataModifiers)
.stateModifiers(stateModifiers)
.build();

View File

@@ -93,7 +93,7 @@ public class CompetitionManagerImpl implements CompetitionManager {
@SuppressWarnings("DuplicatedCode")
private void loadConfig() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("competitions")) {
for (String type : List.of("competition")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;

View File

@@ -73,7 +73,7 @@ public class EffectManagerImpl implements EffectManager {
@SuppressWarnings("DuplicatedCode")
public void load() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("rods", "baits", "enchants", "utils", "totems")) {
for (String type : List.of("rod", "bait", "enchant", "util", "totem")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
@@ -88,7 +88,7 @@ public class EffectManagerImpl implements EffectManager {
if (subFile.isDirectory()) {
fileDeque.push(subFile);
} else if (subFile.isFile() && subFile.getName().endsWith(".yml")) {
this.loadSingleFile(subFile, StringUtils.chop(type));
this.loadSingleFile(subFile, type);
}
}
}

View File

@@ -15,15 +15,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.mechanic.mob;
package net.momirealms.customfishing.mechanic.entity;
import net.momirealms.customfishing.api.CustomFishingPlugin;
import net.momirealms.customfishing.api.manager.MobManager;
import net.momirealms.customfishing.api.manager.EntityManager;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import net.momirealms.customfishing.api.mechanic.mob.MobConfig;
import net.momirealms.customfishing.api.mechanic.mob.MobLibrary;
import net.momirealms.customfishing.api.mechanic.entity.EntityConfig;
import net.momirealms.customfishing.api.mechanic.entity.EntityLibrary;
import net.momirealms.customfishing.api.util.LogUtils;
import net.momirealms.customfishing.compatibility.mob.VanillaMobImpl;
import net.momirealms.customfishing.compatibility.entity.VanillaEntityImpl;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -33,28 +33,28 @@ import org.bukkit.util.Vector;
import java.io.File;
import java.util.*;
public class MobManagerImpl implements MobManager {
public class EntityManagerImpl implements EntityManager {
private final CustomFishingPlugin plugin;
private final HashMap<String, MobLibrary> mobLibraryMap;
private final HashMap<String, MobConfig> mobConfigMap;
private final HashMap<String, EntityLibrary> entityLibraryMap;
private final HashMap<String, EntityConfig> entityConfigMap;
public MobManagerImpl(CustomFishingPlugin plugin) {
public EntityManagerImpl(CustomFishingPlugin plugin) {
this.plugin = plugin;
this.mobLibraryMap = new HashMap<>();
this.mobConfigMap = new HashMap<>();
this.registerMobLibrary(new VanillaMobImpl());
this.entityLibraryMap = new HashMap<>();
this.entityConfigMap = new HashMap<>();
this.registerEntityLibrary(new VanillaEntityImpl());
}
public void load() {
this.loadConfig();
LogUtils.info("Loaded " + mobConfigMap.size() + " mobs.");
LogUtils.info("Loaded " + entityConfigMap.size() + " entities.");
}
public void unload() {
HashMap<String, MobConfig> tempMap = new HashMap<>(this.mobConfigMap);
this.mobConfigMap.clear();
for (Map.Entry<String, MobConfig> entry : tempMap.entrySet()) {
HashMap<String, EntityConfig> tempMap = new HashMap<>(this.entityConfigMap);
this.entityConfigMap.clear();
for (Map.Entry<String, EntityConfig> entry : tempMap.entrySet()) {
if (entry.getValue().isPersist()) {
tempMap.put(entry.getKey(), entry.getValue());
}
@@ -62,26 +62,26 @@ public class MobManagerImpl implements MobManager {
}
@Override
public boolean registerMobLibrary(MobLibrary mobLibrary) {
if (mobLibraryMap.containsKey(mobLibrary.identification())) return false;
else mobLibraryMap.put(mobLibrary.identification(), mobLibrary);
public boolean registerEntityLibrary(EntityLibrary entityLibrary) {
if (entityLibraryMap.containsKey(entityLibrary.identification())) return false;
else entityLibraryMap.put(entityLibrary.identification(), entityLibrary);
return true;
}
@Override
public boolean unregisterMobLibrary(String lib) {
return mobLibraryMap.remove(lib) != null;
public boolean unregisterEntityLibrary(String lib) {
return entityLibraryMap.remove(lib) != null;
}
@Override
public boolean unregisterMobLibrary(MobLibrary mobLibrary) {
return unregisterMobLibrary(mobLibrary.identification());
public boolean unregisterEntityLibrary(EntityLibrary entityLibrary) {
return unregisterEntityLibrary(entityLibrary.identification());
}
@SuppressWarnings("DuplicatedCode")
private void loadConfig() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("mobs")) {
for (String type : List.of("entity")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
@@ -107,9 +107,9 @@ public class MobManagerImpl implements MobManager {
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) {
if (entry.getValue() instanceof ConfigurationSection section) {
String mobID = section.getString("mob");
if (mobID == null) {
LogUtils.warn("Mob can't be null. File:" + file.getAbsolutePath() + "; Section:" + section.getCurrentPath());
String entityID = section.getString("entity");
if (entityID == null) {
LogUtils.warn("Entity can't be null. File:" + file.getAbsolutePath() + "; Section:" + section.getCurrentPath());
continue;
}
HashMap<String, Object> propertyMap = new HashMap<>();
@@ -117,41 +117,41 @@ public class MobManagerImpl implements MobManager {
if (property != null) {
propertyMap.putAll(property.getValues(false));
}
MobConfig mobConfig = new MobConfig.Builder()
.mobID(mobID)
EntityConfig entityConfig = new EntityConfig.Builder()
.entityID(entityID)
.persist(false)
.horizontalVector(section.getDouble("vector.horizontal", 1.1))
.verticalVector(section.getDouble("vector.vertical", 1.2))
.horizontalVector(section.getDouble("velocity.horizontal", 1.1))
.verticalVector(section.getDouble("velocity.vertical", 1.2))
.propertyMap(propertyMap)
.build();
mobConfigMap.put(entry.getKey(), mobConfig);
entityConfigMap.put(entry.getKey(), entityConfig);
}
}
}
public void disable() {
unload();
this.mobConfigMap.clear();
this.mobLibraryMap.clear();
this.entityConfigMap.clear();
this.entityLibraryMap.clear();
}
@Override
public void summonMob(Location hookLocation, Location playerLocation, Loot loot) {
MobConfig config = mobConfigMap.get(loot.getID());
public void summonEntity(Location hookLocation, Location playerLocation, Loot loot) {
EntityConfig config = entityConfigMap.get(loot.getID());
if (config == null) {
LogUtils.warn("Mob: " + loot.getID() + " doesn't exist.");
LogUtils.warn("Entity: " + loot.getID() + " doesn't exist.");
return;
}
String mobID = config.getMobID();
String entityID = config.getEntityID();
Entity entity;
if (mobID.contains(":")) {
String[] split = mobID.split(":", 2);
if (entityID.contains(":")) {
String[] split = entityID.split(":", 2);
String identification = split[0];
String id = split[1];
MobLibrary library = mobLibraryMap.get(identification);
EntityLibrary library = entityLibraryMap.get(identification);
entity = library.spawn(hookLocation, id, config.getPropertyMap());
} else {
entity = mobLibraryMap.get("vanilla").spawn(hookLocation, mobID, config.getPropertyMap());
entity = entityLibraryMap.get("vanilla").spawn(hookLocation, entityID, config.getPropertyMap());
}
Vector vector = playerLocation.subtract(hookLocation).toVector().multiply((config.getHorizontalVector()) - 1);
vector = vector.setY((vector.getY() + 0.2) * config.getVerticalVector());

View File

@@ -208,7 +208,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
Loot loot = plugin.getLootManager().getLoot(id);
if (loot != null) {
Condition condition = new Condition(event.getPlayer());
GlobalSettings.triggerLootActions(ActionTrigger.CONSUME, condition);
GlobalSettings.triggerItemActions(ActionTrigger.CONSUME, condition);
loot.triggerActions(ActionTrigger.CONSUME, condition);
}
}
@@ -522,7 +522,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
return;
}
GlobalSettings.triggerLootActions(ActionTrigger.FAILURE, fishingPreparation);
GlobalSettings.triggerItemActions(ActionTrigger.FAILURE, fishingPreparation);
loot.triggerActions(ActionTrigger.FAILURE, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.FAILURE);
@@ -551,7 +551,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
switch (loot.getType()) {
case LOOT -> {
case ITEM -> {
int amount = (int) effect.getMultipleLootChance();
amount += Math.random() < (effect.getMultipleLootChance() - amount) ? 2 : 1;
// build the items for multiple times instead of using setAmount() to make sure that each item is unique
@@ -572,7 +572,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
return;
}
case MOB -> plugin.getMobManager().summonMob(hook.getLocation(), player.getLocation(), loot);
case ENTITY -> plugin.getEntityManager().summonEntity(hook.getLocation(), player.getLocation(), loot);
case BLOCK -> plugin.getBlockManager().summonBlock(player, hook.getLocation(), player.getLocation(), loot);
}
doSuccessActions(loot, effect, fishingPreparation, player);
@@ -611,7 +611,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
// events and actions
GlobalSettings.triggerLootActions(ActionTrigger.SUCCESS, fishingPreparation);
GlobalSettings.triggerItemActions(ActionTrigger.SUCCESS, fishingPreparation);
loot.triggerActions(ActionTrigger.SUCCESS, fishingPreparation);
fishingPreparation.triggerActions(ActionTrigger.SUCCESS);

View File

@@ -141,10 +141,10 @@ public class GameManagerImpl implements GameManager {
public void loadGamesFromPluginFolder() {
Deque<File> fileDeque = new ArrayDeque<>();
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + "minigames");
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + "minigame");
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
plugin.saveResource("contents" + File.separator + "minigames" + File.separator + "default.yml", false);
plugin.saveResource("contents" + File.separator + "minigame" + File.separator + "default.yml", false);
}
fileDeque.push(typeFolder);
while (!fileDeque.isEmpty()) {

View File

@@ -97,7 +97,7 @@ public class ItemManagerImpl implements ItemManager {
@SuppressWarnings("DuplicatedCode")
public void loadItemsFromPluginFolder() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("loots", "baits", "rods", "utils")) {
for (String type : List.of("item", "bait", "rod", "util")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
@@ -112,7 +112,7 @@ public class ItemManagerImpl implements ItemManager {
if (subFile.isDirectory()) {
fileDeque.push(subFile);
} else if (subFile.isFile() && subFile.getName().endsWith(".yml")) {
this.loadSingleFile(subFile, StringUtils.chop(type));
this.loadSingleFile(subFile, type);
}
}
}
@@ -271,7 +271,7 @@ public class ItemManagerImpl implements ItemManager {
@Override
public void dropItem(Player player, Location hookLocation, Location playerLocation, Loot loot, Map<String, String> args) {
ItemStack item = build(player, "loot", loot.getID(), args);
ItemStack item = build(player, "item", loot.getID(), args);
if (item == null) {
LogUtils.warn(String.format("Item %s not exists", loot.getID()));
return;

View File

@@ -61,7 +61,7 @@ public class LootManagerImpl implements LootManager {
@SuppressWarnings("DuplicatedCode")
public void loadLootsFromPluginFolder() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("loots", "mobs", "blocks")) {
for (String type : List.of("item", "entity", "block")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;
@@ -76,7 +76,7 @@ public class LootManagerImpl implements LootManager {
if (subFile.isDirectory()) {
fileDeque.push(subFile);
} else if (subFile.isFile() && subFile.getName().endsWith(".yml")) {
loadSingleFile(subFile, StringUtils.chop(type));
loadSingleFile(subFile, type);
}
}
}

View File

@@ -193,6 +193,8 @@ public class MarketManagerImpl implements MarketManager, Listener {
return;
}
}
plugin.getScheduler().runTaskSyncLater(gui::refresh, player.getLocation(), 50, TimeUnit.MILLISECONDS);
}
@EventHandler
@@ -278,10 +280,30 @@ public class MarketManagerImpl implements MarketManager, Listener {
if ((event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT)
&& (current != null && current.getType() != Material.AIR)) {
event.setCancelled(true);
int slot = gui.getEmptyItemSlot();
if (slot != -1) {
gui.getInventory().setItem(slot, current.clone());
current.setAmount(0);
MarketGUIElement element = gui.getElement(itemSlot);
if (element == null) return;
for (int slot : element.getSlots()) {
ItemStack itemStack = gui.getInventory().getItem(slot);
if (itemStack != null && itemStack.getType() != Material.AIR) {
if (current.getType() == itemStack.getType()
&& itemStack.getAmount() != itemStack.getType().getMaxStackSize()
&& current.getItemMeta().getAsString().equals(itemStack.getItemMeta().getAsString())
) {
int left = itemStack.getType().getMaxStackSize() - itemStack.getAmount();
if (current.getAmount() <= left) {
itemStack.setAmount(itemStack.getAmount() + current.getAmount());
current.setAmount(0);
return;
} else {
current.setAmount(current.getAmount() - left);
itemStack.setAmount(itemStack.getType().getMaxStackSize());
}
}
} else {
gui.getInventory().setItem(slot, current.clone());
current.setAmount(0);
return;
}
}
}
}

View File

@@ -61,7 +61,7 @@ public class StatisticsManagerImpl implements StatisticsManager {
@SuppressWarnings("DuplicatedCode")
public void loadCategoriesFromPluginFolder() {
Deque<File> fileDeque = new ArrayDeque<>();
for (String type : List.of("categories")) {
for (String type : List.of("category")) {
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
if (!typeFolder.exists()) {
if (!typeFolder.mkdirs()) return;

View File

@@ -9,7 +9,7 @@ apple_crate:
disable-stat: true
nick: Apple Crate
block: barrel
vector:
velocity:
horizontal: 1.07
vertical: 1.5
properties:
@@ -52,7 +52,7 @@ carrot_crate:
disable-stat: true
nick: Carrot Crate
block: barrel
vector:
velocity:
horizontal: 1.07
vertical: 1.5
properties:

View File

@@ -7,36 +7,36 @@
skeleton:
show-in-fishfinder: false
disable-stat: true
mob: skeleton
entity: skeleton
nick: <white>Skeleton</white>
vector:
velocity:
horizontal: 1
vertical: 1.3
wither_skeleton:
show-in-fishfinder: false
disable-stat: true
mob: wither_skeleton
entity: wither_skeleton
nick: <black>Wither Skeleton</black>
vector:
velocity:
horizontal: 1.1
vertical: 1.2
magma_cube:
show-in-fishfinder: false
disable-stat: true
mob: magma_cube
entity: magma_cube
nick: <red>Magma Cube</black>
vector:
velocity:
horizontal: 1.1
vertical: 1.3
skeletalknight:
show-in-fishfinder: false
disable-stat: true
mob: MythicMobs:SkeletalKnight
entity: MythicMobs:SkeletalKnight
nick: Skeletal Knight
vector:
velocity:
horizontal: 1.1
vertical: 1.2
properties:

View File

@@ -42,7 +42,6 @@ functional-icons:
name: '<#00CED1><b>● <!b>Ship the fish'
lore:
- '<font:uniform><gradient:#E6E6FA:#48D1CC:#E6E6FA>You will get <green>{money}$</green> by selling the fish</gradient></font>'
- '<dark_gray>You can earn {rest}'
action:
sound_action:
type: sound