mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
水
This commit is contained in:
@@ -41,6 +41,8 @@ public final class CustomFishing extends JavaPlugin {
|
||||
private BonusManager bonusManager;
|
||||
private LootManager lootManager;
|
||||
private LayoutManager layoutManager;
|
||||
private DataManager dataManager;
|
||||
private TotemManager totemManager;
|
||||
|
||||
// _ooOoo_
|
||||
// o8888888o
|
||||
@@ -80,6 +82,8 @@ public final class CustomFishing extends JavaPlugin {
|
||||
this.bonusManager = new BonusManager();
|
||||
this.lootManager = new LootManager();
|
||||
this.layoutManager = new LayoutManager();
|
||||
this.dataManager = new DataManager();
|
||||
this.totemManager = new TotemManager(integrationManager.getBlockInterface());
|
||||
ConfigUtil.reload();
|
||||
|
||||
PluginCommand pluginCommand = new PluginCommand();
|
||||
@@ -120,4 +124,12 @@ public final class CustomFishing extends JavaPlugin {
|
||||
public LayoutManager getLayoutManager() {
|
||||
return layoutManager;
|
||||
}
|
||||
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public TotemManager getTotemManager() {
|
||||
return totemManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.customfishing.api.event;
|
||||
|
||||
import net.momirealms.customfishing.object.Difficulty;
|
||||
import net.momirealms.customfishing.object.fishing.Difficulty;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.customfishing.api.event;
|
||||
|
||||
import net.momirealms.customfishing.object.FishResult;
|
||||
import net.momirealms.customfishing.object.fishing.FishResult;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.customfishing.api.event;
|
||||
|
||||
import net.momirealms.customfishing.object.Bonus;
|
||||
import net.momirealms.customfishing.object.fishing.Bonus;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class Competition {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null){
|
||||
for (ActionInterface action : rewardsMap.get(String.valueOf(i))) {
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@@ -155,7 +155,7 @@ public class Competition {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null){
|
||||
for (ActionInterface action : actions) {
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.momirealms.customfishing.competition;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.manager.CompetitionManager;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.momirealms.customfishing.competition.bossbar;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.competition.Competition;
|
||||
import net.momirealms.customfishing.listener.SimpleListener;
|
||||
import net.momirealms.customfishing.manager.MessageManager;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -25,9 +25,9 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.competition.Competition;
|
||||
import net.momirealms.customfishing.object.Reflection;
|
||||
import net.momirealms.customfishing.object.TextCache;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.Reflection;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* 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.competition.bossbar;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.InternalStructure;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.competition.Competition;
|
||||
import net.momirealms.customfishing.object.Reflection;
|
||||
import net.momirealms.customfishing.object.TextCache;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Sender {
|
||||
|
||||
private final Player player;
|
||||
private int timer_1;
|
||||
private int timer_2;
|
||||
private int counter;
|
||||
private final int size;
|
||||
private final TextCache[] texts;
|
||||
private TextCache text;
|
||||
private BukkitTask bukkitTask;
|
||||
private final UUID uuid;
|
||||
private boolean force;
|
||||
private final BossBarConfig config;
|
||||
private boolean isShown;
|
||||
private final BossBarManager bossBarManager;
|
||||
|
||||
public void setText(int position) {
|
||||
this.text = texts[position];
|
||||
this.force = true;
|
||||
}
|
||||
|
||||
public Sender(Player player, BossBarConfig config, BossBarManager bossBarManager){
|
||||
this.bossBarManager = bossBarManager;
|
||||
String[] str = config.getText();
|
||||
this.size = str.length;
|
||||
texts = new TextCache[str.length];
|
||||
for (int i = 0; i < str.length; i++) {
|
||||
texts[i] = new TextCache(player, str[i]);
|
||||
}
|
||||
text = texts[0];
|
||||
this.player = player;
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.config = config;
|
||||
this.isShown = false;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
this.isShown = true;
|
||||
|
||||
try {
|
||||
CustomFishing.protocolManager.sendServerPacket(player, getPacket());
|
||||
} catch (InvocationTargetException e){
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to display bossbar for " + player.getName());
|
||||
}
|
||||
|
||||
this.bukkitTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (size != 1) {
|
||||
timer_2++;
|
||||
if (timer_2 > config.getInterval()) {
|
||||
timer_2 = 0;
|
||||
counter++;
|
||||
if (counter == size) {
|
||||
counter = 0;
|
||||
}
|
||||
setText(counter);
|
||||
}
|
||||
}
|
||||
if (timer_1 < config.getRate()){
|
||||
timer_1++;
|
||||
}
|
||||
else {
|
||||
timer_1 = 0;
|
||||
if (text.update() || force) {
|
||||
force = false;
|
||||
try{
|
||||
CustomFishing.protocolManager.sendServerPacket(player, getPacket());
|
||||
}
|
||||
catch (InvocationTargetException e){
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to update bossbar for " + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(CustomFishing.plugin,1,1);
|
||||
}
|
||||
|
||||
private PacketContainer getPacket() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
InternalStructure internalStructure = packet.getStructures().read(1);
|
||||
internalStructure.getChatComponents().write(0, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(
|
||||
text.getLatestValue()
|
||||
.replace("{rank}", Competition.currentCompetition.getPlayerRank(player))
|
||||
.replace("{minute}", String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60))
|
||||
.replace("{second}",String.format("%02d", Competition.currentCompetition.getRemainingTime() % 60))
|
||||
.replace("{point}", String.format("%.1f", Competition.currentCompetition.getScore(player))
|
||||
.replace("{1st_score}", String.format("%.1f", Competition.currentCompetition.getFirstScore()))
|
||||
.replace("{1st_player}", Competition.currentCompetition.getFirstPlayer())
|
||||
)))));
|
||||
internalStructure.getFloat().write(0,1F);
|
||||
internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor());
|
||||
internalStructure.getEnumModifier(Overlay.class, 3).write(0, config.getOverlay());
|
||||
internalStructure.getModifier().write(4, false);
|
||||
internalStructure.getModifier().write(5, false);
|
||||
internalStructure.getModifier().write(6, false);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
remove();
|
||||
if (bukkitTask != null) bukkitTask.cancel();
|
||||
this.isShown = false;
|
||||
}
|
||||
|
||||
private void remove() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
|
||||
packet.getModifier().write(0, uuid);
|
||||
packet.getModifier().write(1, Reflection.removeBar);
|
||||
try{
|
||||
CustomFishing.protocolManager.sendServerPacket(player, packet);
|
||||
}catch (InvocationTargetException e){
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to remove bossbar for " + player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getStatus() {
|
||||
return this.isShown;
|
||||
}
|
||||
|
||||
public BossBarConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public abstract class AbstractSQLStorage {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public interface DataStorageInterface {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public class FileStorageImpl {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public class MongoDBStorageImpl {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public class MySQLStorageImpl extends AbstractSQLStorage implements DataStorageInterface {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.momirealms.customfishing.data;
|
||||
|
||||
public class SQLiteStorageImpl extends AbstractSQLStorage implements DataStorageInterface {
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.integration;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AntiGriefInterface {
|
||||
|
||||
boolean canBreak(Location location, Player player);
|
||||
|
||||
boolean canPlace(Location location, Player player);
|
||||
|
||||
static boolean testBreak(Player player, Location location) {
|
||||
for (AntiGriefInterface antiGrief : CustomFishing.plugin.getIntegrationManager().getAntiGriefs()) {
|
||||
if(!antiGrief.canBreak(location, player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean testPlace(Player player, Location location) {
|
||||
for (AntiGriefInterface antiGrief : CustomFishing.plugin.getIntegrationManager().getAntiGriefs()) {
|
||||
if(!antiGrief.canPlace(location, player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,19 @@ public interface BlockInterface {
|
||||
void placeBlock(String id, Location location);
|
||||
@Nullable
|
||||
String getID(Block block);
|
||||
|
||||
default void replaceBlock(Location location, String id) {
|
||||
removeBlock(location.getBlock());
|
||||
placeBlock(id, location);
|
||||
}
|
||||
|
||||
static boolean isVanillaItem(String item) {
|
||||
char[] chars = item.toCharArray();
|
||||
for (char character : chars) {
|
||||
if ((character < 65 || character > 90) && character != 95) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.integration.antigrief;
|
||||
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BentoBoxHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
User user = User.getInstance(player);
|
||||
Optional<Island> islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location);
|
||||
return islandOptional.map(island -> island.isAllowed(user, Flags.BREAK_BLOCKS)).orElse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
User user = User.getInstance(player);
|
||||
Optional<Island> islandOptional = BentoBox.getInstance().getIslands().getIslandAt(location);
|
||||
return islandOptional.map(island -> island.isAllowed(user, Flags.PLACE_BLOCKS)).orElse(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import net.crashcraft.crashclaim.api.CrashClaimAPI;
|
||||
import net.crashcraft.crashclaim.permissions.PermissionRoute;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CrashClaimHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi();
|
||||
return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
CrashClaimAPI crashClaimAPI = net.crashcraft.crashclaim.CrashClaim.getPlugin().getApi();
|
||||
return crashClaimAPI.getPermissionHelper().hasPermission(player.getUniqueId(), location, PermissionRoute.BUILD);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GriefDefenderHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
return com.griefdefender.api.GriefDefender.getCore().getUser(player.getUniqueId()).canBreak(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
return com.griefdefender.api.GriefDefender.getCore().getUser(player.getUniqueId()).canPlace(player.getInventory().getItemInMainHand(), location);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,21 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.competition.bossbar;
|
||||
package net.momirealms.customfishing.integration.antigrief;
|
||||
|
||||
public enum Overlay {
|
||||
NOTCHED_6,
|
||||
NOTCHED_10,
|
||||
NOTCHED_12,
|
||||
NOTCHED_20,
|
||||
PROGRESS
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GriefPreventionHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBreak(player, location.getBlock(), location) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
return me.ryanhamshire.GriefPrevention.GriefPrevention.instance.allowBuild(player, location) == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kingdoms.constants.group.Kingdom;
|
||||
import org.kingdoms.constants.land.Land;
|
||||
import org.kingdoms.constants.player.KingdomPlayer;
|
||||
|
||||
public class KingdomsXHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
return kingdomsCheck(location, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
return kingdomsCheck(location, player);
|
||||
}
|
||||
|
||||
private boolean kingdomsCheck(Location location, Player player) {
|
||||
Land land = Land.getLand(location);
|
||||
if (land == null) return true;
|
||||
if (land.isClaimed()) {
|
||||
KingdomPlayer kp = KingdomPlayer.getKingdomPlayer(player);
|
||||
Kingdom cropKingdom = land.getKingdom();
|
||||
if (kp.getKingdom() != null) {
|
||||
Kingdom kingdom = kp.getKingdom();
|
||||
return kingdom != cropKingdom;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import me.angeschossen.lands.api.flags.Flags;
|
||||
import me.angeschossen.lands.api.land.Area;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LandsHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location);
|
||||
if (area != null) return area.hasFlag(player, Flags.BLOCK_BREAK, false);
|
||||
else return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
Area area = new me.angeschossen.lands.api.integration.LandsIntegration(CustomCrops.plugin).getAreaByLoc(location);
|
||||
if (area != null) return area.hasFlag(player, Flags.BLOCK_PLACE, false);
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import com.plotsquared.core.location.Location;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlotSquaredHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(org.bukkit.Location location, Player player) {
|
||||
return isAllowed(location, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(org.bukkit.Location location, Player player) {
|
||||
return isAllowed(location, player);
|
||||
}
|
||||
|
||||
private boolean isAllowed(org.bukkit.Location location, Player player) {
|
||||
Location plotLoc = Location.at(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
if (plotLoc.isPlotRoad()) return false;
|
||||
if (plotLoc.getPlotArea() != null) return plotLoc.getPlotArea().getPlot(plotLoc).isAdded(player.getUniqueId());
|
||||
else return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import com.bekvon.bukkit.residence.containers.Flags;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ResidenceHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||
if(res!=null){
|
||||
ResidencePermissions perms = res.getPermissions();
|
||||
return perms.playerHas(player, Flags.destroy, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
|
||||
if(res!=null){
|
||||
ResidencePermissions perms = res.getPermissions();
|
||||
return perms.playerHas(player, Flags.build, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.TownyPermission;
|
||||
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TownyHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
return TownyPermission(player, location, TownyPermission.ActionType.DESTROY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
return TownyPermission(player, location, TownyPermission.ActionType.BUILD);
|
||||
}
|
||||
|
||||
private boolean TownyPermission(Player player, Location location, TownyPermission.ActionType actionType){
|
||||
return PlayerCacheUtil.getCachePermission(player, location, location.getBlock().getType(), actionType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.integration.antigrief;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import net.momirealms.customfishing.integration.AntiGriefInterface;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WorldGuardHook implements AntiGriefInterface {
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, Player player) {
|
||||
if (player.isOp()) return true;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
World world = BukkitAdapter.adapt(location.getWorld());
|
||||
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
||||
if (hasRegion(world, BukkitAdapter.asBlockVector(location))){
|
||||
RegionQuery query = platform.getRegionContainer().createQuery();
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BUILD);
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Location location, Player player) {
|
||||
if (player.isOp()) return true;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
World world = BukkitAdapter.adapt(location.getWorld());
|
||||
WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform();
|
||||
if (hasRegion(world, BukkitAdapter.asBlockVector(location))){
|
||||
RegionQuery query = platform.getRegionContainer().createQuery();
|
||||
return query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.BLOCK_BREAK);
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
private boolean hasRegion(World world, BlockVector3 vector){
|
||||
RegionContainer container = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regionManager = container.get(world);
|
||||
if (regionManager == null) return true;
|
||||
return regionManager.getApplicableRegions(vector).size() > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.momirealms.customfishing.integration.block;
|
||||
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import net.momirealms.customfishing.integration.BlockInterface;
|
||||
import net.momirealms.customfishing.manager.TotemManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemsAdderBlockImpl implements BlockInterface {
|
||||
|
||||
@Override
|
||||
public void removeBlock(Block block) {
|
||||
if (CustomBlock.byAlreadyPlaced(block) != null) {
|
||||
CustomBlock.remove(block.getLocation());
|
||||
}
|
||||
else {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeBlock(String id, Location location) {
|
||||
if (BlockInterface.isVanillaItem(id)) {
|
||||
location.getBlock().setType(Material.valueOf(id));
|
||||
}
|
||||
else {
|
||||
CustomBlock.place(id, location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getID(Block block) {
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
|
||||
String id;
|
||||
if (customBlock == null) {
|
||||
id = block.getType().name();
|
||||
}
|
||||
else {
|
||||
id = customBlock.getNamespacedID();
|
||||
}
|
||||
return TotemManager.BLOCKS.get(id);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicListener;
|
||||
import net.momirealms.customfishing.integration.BlockInterface;
|
||||
import net.momirealms.customfishing.manager.TotemManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class OraxenBlockHook implements BlockInterface {
|
||||
public class OraxenBlockImpl implements BlockInterface {
|
||||
|
||||
@Override
|
||||
public void removeBlock(Block block) {
|
||||
@@ -18,14 +19,30 @@ public class OraxenBlockHook implements BlockInterface {
|
||||
|
||||
@Override
|
||||
public void placeBlock(String id, Location location) {
|
||||
NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
if (BlockInterface.isVanillaItem(id)) {
|
||||
location.getBlock().setType(Material.valueOf(id));
|
||||
}
|
||||
else {
|
||||
NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceBlock(Location location, String id) {
|
||||
placeBlock(id, location);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getID(Block block) {
|
||||
NoteBlockMechanic mechanic = NoteBlockMechanicListener.getNoteBlockMechanic(block);
|
||||
if (mechanic == null) return null;
|
||||
else return mechanic.getItemID();
|
||||
String id;
|
||||
if (mechanic == null) {
|
||||
id = block.getType().name();
|
||||
}
|
||||
else {
|
||||
id = mechanic.getItemID();
|
||||
}
|
||||
return TotemManager.BLOCKS.get(id);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,31 @@
|
||||
package net.momirealms.customfishing.integration.block;
|
||||
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import net.momirealms.customfishing.integration.BlockInterface;
|
||||
import net.momirealms.customfishing.manager.TotemManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemsAdderBlockHook implements BlockInterface {
|
||||
|
||||
public class VanillaBlockImpl implements BlockInterface {
|
||||
@Override
|
||||
public void removeBlock(Block block) {
|
||||
CustomBlock.remove(block.getLocation());
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeBlock(String id, Location location) {
|
||||
CustomBlock.place(id, location);
|
||||
location.getBlock().setType(Material.valueOf(id));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getID(Block block) {
|
||||
return TotemManager.BLOCKS.get(block.getType().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getID(Block block) {
|
||||
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
|
||||
return customBlock == null ? null : customBlock.getNamespacedID();
|
||||
public void replaceBlock(Location location, String id) {
|
||||
placeBlock(id, location);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.momirealms.customfishing.manager.LootManager;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CustomFishingItemHook implements ItemInterface {
|
||||
public class CustomFishingItemImpl implements ItemInterface {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class EcoItemHook {
|
||||
public class EcoItemRegister {
|
||||
|
||||
public static void registerItems() {
|
||||
// Rods
|
||||
@@ -5,7 +5,7 @@ import net.momirealms.customfishing.integration.ItemInterface;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemsAdderItemHook implements ItemInterface {
|
||||
public class ItemsAdderItemImpl implements ItemInterface {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -8,7 +8,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MMOItemsItemHook implements ItemInterface {
|
||||
public class MMOItemsItemImpl implements ItemInterface {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -6,11 +6,11 @@ import net.momirealms.customfishing.integration.ItemInterface;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MythicMobsItemHook implements ItemInterface {
|
||||
public class MythicMobsItemImpl implements ItemInterface {
|
||||
|
||||
private final ItemExecutor itemManager;
|
||||
|
||||
public MythicMobsItemHook() {
|
||||
public MythicMobsItemImpl() {
|
||||
this.itemManager = MythicBukkit.inst().getItemManager();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.momirealms.customfishing.integration.ItemInterface;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class OraxenItemHook implements ItemInterface {
|
||||
public class OraxenItemImpl implements ItemInterface {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -8,18 +8,18 @@ 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.integration.MobInterface;
|
||||
import net.momirealms.customfishing.object.MobVector;
|
||||
import net.momirealms.customfishing.object.loot.Mob;
|
||||
import net.momirealms.customfishing.object.loot.MobVector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MythicMobsMobHook implements MobInterface {
|
||||
public class MythicMobsMobImpl implements MobInterface {
|
||||
|
||||
private final MobManager mobManager;
|
||||
|
||||
public MythicMobsMobHook() {
|
||||
public MythicMobsMobImpl() {
|
||||
this.mobManager = MythicBukkit.inst().getMobManager();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.momirealms.customfishing.integration.papi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
package net.momirealms.customfishing.integration.season;
|
||||
|
||||
public class CustomCropsSeasonImpl {
|
||||
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
||||
import net.momirealms.customfishing.integration.SeasonInterface;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class CustomCropsSeasonImpl implements SeasonInterface {
|
||||
@Override
|
||||
public String getSeason(World world) {
|
||||
return SeasonUtils.getSeason(world).name();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import com.archyx.aureliumskills.skills.Skill;
|
||||
import net.momirealms.customfishing.integration.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AureliumsHook implements SkillInterface {
|
||||
public class AureliumsImpl implements SkillInterface {
|
||||
|
||||
private final Leveler leveler;
|
||||
private final Skill skill;
|
||||
|
||||
public AureliumsHook() {
|
||||
public AureliumsImpl() {
|
||||
leveler = AureliumAPI.getPlugin().getLeveler();
|
||||
skill = AureliumAPI.getPlugin().getSkillRegistry().getSkill("fishing");
|
||||
}
|
||||
@@ -22,11 +22,11 @@ import com.willfp.ecoskills.skills.Skills;
|
||||
import net.momirealms.customfishing.integration.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EcoSkillsHook implements SkillInterface {
|
||||
public class EcoSkillsImpl implements SkillInterface {
|
||||
|
||||
public EcoSkillsAPI ecoSkillsAPI;
|
||||
|
||||
public EcoSkillsHook() {
|
||||
public EcoSkillsImpl() {
|
||||
ecoSkillsAPI = EcoSkillsAPI.getInstance();
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JobsRebornHook implements SkillInterface {
|
||||
public class JobsRebornImpl implements SkillInterface {
|
||||
|
||||
private final PlayerManager playerManager;
|
||||
|
||||
public JobsRebornHook() {
|
||||
public JobsRebornImpl() {
|
||||
this.playerManager = Jobs.getPlayerManager();
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import net.momirealms.customfishing.integration.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MMOCoreHook implements SkillInterface {
|
||||
public class MMOCoreImpl implements SkillInterface {
|
||||
|
||||
private final Profession profession;
|
||||
private final PlayerDataManager playerDataManager;
|
||||
|
||||
public MMOCoreHook() {
|
||||
public MMOCoreImpl() {
|
||||
profession = MMOCore.plugin.professionManager.get("fishing");
|
||||
playerDataManager = MMOCore.plugin.dataProvider.getDataManager();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import net.momirealms.customfishing.integration.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class mcMMOHook implements SkillInterface {
|
||||
public class mcMMOImpl implements SkillInterface {
|
||||
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
@@ -1,20 +1,20 @@
|
||||
package net.momirealms.customfishing.listener;
|
||||
|
||||
import net.momirealms.customfishing.manager.FishingManager;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class InteractListener implements Listener {
|
||||
|
||||
private final FishingManager fishingManager;
|
||||
private final Function function;
|
||||
|
||||
public InteractListener(FishingManager fishingManager) {
|
||||
this.fishingManager = fishingManager;
|
||||
public InteractListener(Function function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
fishingManager.onInteract(event);
|
||||
function.onInteract(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.customfishing.listener;
|
||||
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.object.Bonus;
|
||||
import net.momirealms.customfishing.object.Item;
|
||||
import net.momirealms.customfishing.object.LeveledEnchantment;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.fishing.Bonus;
|
||||
import net.momirealms.customfishing.object.loot.Item;
|
||||
import net.momirealms.customfishing.object.loot.LeveledEnchantment;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import net.momirealms.customfishing.util.ItemStackUtil;
|
||||
@@ -131,7 +131,7 @@ public class BonusManager extends Function {
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + BAITITEMS.size() + " <gray>baits");
|
||||
}
|
||||
|
||||
private Bonus getBonus(YamlConfiguration config, String key) {
|
||||
public static Bonus getBonus(YamlConfiguration config, String key) {
|
||||
Bonus bonus = new Bonus();
|
||||
config.getConfigurationSection(key + ".modifier").getKeys(false).forEach(modifier -> {
|
||||
switch (modifier) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.competition.CompetitionGoal;
|
||||
import net.momirealms.customfishing.competition.CompetitionSchedule;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarOverlay;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.action.CommandActionImpl;
|
||||
import net.momirealms.customfishing.object.action.MessageActionImpl;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ConfigManager {
|
||||
needRodToFish = config.getBoolean("mechanics.need-special-rod.to-fish", false);
|
||||
rodLoseDurability = config.getBoolean("mechanics.rod-lose-durability", true);
|
||||
fishFinderCoolDown = config.getInt("mechanics.fishfinder-cooldown", 3000);
|
||||
enableCompetition = config.getBoolean("mechanics.fishing-competition", true);
|
||||
enableCompetition = config.getBoolean("mechanics.fishing-competition.enable", true);
|
||||
|
||||
priority = config.getString("other-settings.event-priority", "NORMAL").toUpperCase();
|
||||
disableJobsXp = config.getBoolean("other-settings.disable-JobsReborn-fishing-exp", false);
|
||||
@@ -97,7 +97,12 @@ public class ConfigManager {
|
||||
failureFadeStay = config.getInt("titles.failure.fade.stay", 30) * 50;
|
||||
failureFadeOut = config.getInt("titles.failure.fade.out", 10) * 50;
|
||||
|
||||
tryEnableJedis();
|
||||
useRedis = false;
|
||||
if (enableCompetition && config.getBoolean("mechanics.fishing-competition.redis", false)) {
|
||||
YamlConfiguration configuration = ConfigUtil.getConfig("database.yml");
|
||||
JedisUtil.initializeRedis(configuration);
|
||||
useRedis = true;
|
||||
}
|
||||
}
|
||||
public static List<World> getWorldsList() {
|
||||
if (whiteOrBlack) {
|
||||
@@ -109,13 +114,4 @@ public class ConfigManager {
|
||||
return worldList;
|
||||
}
|
||||
}
|
||||
|
||||
public static void tryEnableJedis(){
|
||||
YamlConfiguration configuration = ConfigUtil.getConfig("redis.yml");
|
||||
useRedis = false;
|
||||
if (configuration.getBoolean("redis.enable")){
|
||||
JedisUtil.initializeRedis(configuration);
|
||||
useRedis = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
|
||||
public class DataManager extends Function {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
super.unload();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.api.event.FishFinderEvent;
|
||||
import net.momirealms.customfishing.api.event.FishHookEvent;
|
||||
import net.momirealms.customfishing.api.event.FishResultEvent;
|
||||
@@ -17,8 +16,9 @@ import net.momirealms.customfishing.competition.Competition;
|
||||
import net.momirealms.customfishing.integration.MobInterface;
|
||||
import net.momirealms.customfishing.integration.item.McMMOTreasure;
|
||||
import net.momirealms.customfishing.listener.*;
|
||||
import net.momirealms.customfishing.object.*;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.fishing.*;
|
||||
import net.momirealms.customfishing.object.loot.DroppedItem;
|
||||
import net.momirealms.customfishing.object.loot.Loot;
|
||||
import net.momirealms.customfishing.object.loot.Mob;
|
||||
@@ -367,7 +367,7 @@ public class FishingManager extends Function {
|
||||
|
||||
dropItem(player, location, fishResultEvent.isDouble(), drop);
|
||||
for (ActionInterface action : droppedItem.getSuccessActions())
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
sendSuccessTitle(player, droppedItem.getNick());
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ public class FishingManager extends Function {
|
||||
|
||||
mobInterface.summon(player.getLocation(), location, mob);
|
||||
for (ActionInterface action : loot.getSuccessActions())
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
sendSuccessTitle(player, loot.getNick());
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ public class FishingManager extends Function {
|
||||
|
||||
if (!isVanilla && loot != null){
|
||||
for (ActionInterface action : loot.getFailureActions())
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
}
|
||||
|
||||
AdventureUtil.playerTitle(
|
||||
@@ -652,6 +652,7 @@ public class FishingManager extends Function {
|
||||
return available;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
ItemStack itemStack = event.getItem();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) return;
|
||||
@@ -739,7 +740,7 @@ public class FishingManager extends Function {
|
||||
|
||||
if (vanillaLoot.get(player) == null && loot != null){
|
||||
for (ActionInterface action : loot.getHookActions()) {
|
||||
action.doOn(player);
|
||||
action.doOn(player, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.integration.ItemInterface;
|
||||
import net.momirealms.customfishing.integration.MobInterface;
|
||||
import net.momirealms.customfishing.integration.SeasonInterface;
|
||||
import net.momirealms.customfishing.integration.SkillInterface;
|
||||
import net.momirealms.customfishing.helper.Log;
|
||||
import net.momirealms.customfishing.integration.*;
|
||||
import net.momirealms.customfishing.integration.antigrief.*;
|
||||
import net.momirealms.customfishing.integration.block.ItemsAdderBlockImpl;
|
||||
import net.momirealms.customfishing.integration.block.OraxenBlockImpl;
|
||||
import net.momirealms.customfishing.integration.block.VanillaBlockImpl;
|
||||
import net.momirealms.customfishing.integration.item.*;
|
||||
import net.momirealms.customfishing.integration.mob.MythicMobsMobHook;
|
||||
import net.momirealms.customfishing.integration.mob.MythicMobsMobImpl;
|
||||
import net.momirealms.customfishing.integration.papi.PlaceholderManager;
|
||||
import net.momirealms.customfishing.integration.season.CustomCropsSeasonImpl;
|
||||
import net.momirealms.customfishing.integration.season.RealisticSeasonsImpl;
|
||||
import net.momirealms.customfishing.integration.skill.*;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -29,7 +32,9 @@ public class IntegrationManager extends Function {
|
||||
private SkillInterface skillInterface;
|
||||
private ItemInterface[] itemInterfaces;
|
||||
private MobInterface mobInterface;
|
||||
private BlockInterface blockInterface;
|
||||
private PlaceholderManager placeholderManager;
|
||||
private AntiGriefInterface[] antiGriefs;
|
||||
|
||||
public IntegrationManager() {
|
||||
load();
|
||||
@@ -48,19 +53,24 @@ public class IntegrationManager extends Function {
|
||||
}
|
||||
|
||||
List<ItemInterface> itemInterfaceList = new ArrayList<>();
|
||||
itemInterfaceList.add(new CustomFishingItemHook());
|
||||
if (pluginManager.getPlugin("ItemsAdder") != null) itemInterfaceList.add(new ItemsAdderItemHook());
|
||||
if (pluginManager.getPlugin("Oraxen") != null) itemInterfaceList.add(new OraxenItemHook());
|
||||
if (pluginManager.getPlugin("MMOItems") != null) itemInterfaceList.add(new MMOItemsItemHook());
|
||||
itemInterfaceList.add(new CustomFishingItemImpl());
|
||||
if (pluginManager.getPlugin("ItemsAdder") != null) itemInterfaceList.add(new ItemsAdderItemImpl());
|
||||
if (pluginManager.getPlugin("Oraxen") != null) itemInterfaceList.add(new OraxenItemImpl());
|
||||
if (pluginManager.getPlugin("MMOItems") != null) itemInterfaceList.add(new MMOItemsItemImpl());
|
||||
if (pluginManager.getPlugin("MythicMobs") != null) {
|
||||
itemInterfaceList.add(new MythicMobsItemHook());
|
||||
this.mobInterface = new MythicMobsMobHook();
|
||||
itemInterfaceList.add(new MythicMobsItemImpl());
|
||||
this.mobInterface = new MythicMobsMobImpl();
|
||||
}
|
||||
this.itemInterfaces = itemInterfaceList.toArray(new ItemInterface[0]);
|
||||
|
||||
if (pluginManager.getPlugin("ItemsAdder") != null) {
|
||||
this.blockInterface = new ItemsAdderBlockImpl();
|
||||
} else if (pluginManager.getPlugin("Oraxen") != null) {
|
||||
this.blockInterface = new OraxenBlockImpl();
|
||||
} else this.blockInterface = new VanillaBlockImpl();
|
||||
|
||||
if (pluginManager.getPlugin("eco") != null) {
|
||||
EcoItemHook.registerItems();
|
||||
EcoItemRegister.registerItems();
|
||||
}
|
||||
|
||||
YamlConfiguration config = ConfigUtil.getConfig("config.yml");
|
||||
@@ -68,26 +78,68 @@ public class IntegrationManager extends Function {
|
||||
this.seasonInterface = new RealisticSeasonsImpl();
|
||||
hookMessage("RealisticSeasons");
|
||||
} else if (config.getBoolean("integration.CustomCrops", false) && pluginManager.getPlugin("CustomCrops") != null) {
|
||||
//TODO
|
||||
this.seasonInterface = null;
|
||||
this.seasonInterface = new CustomCropsSeasonImpl();
|
||||
hookMessage("CustomCrops");
|
||||
}
|
||||
if (config.getBoolean("integration.mcMMO", false) && Bukkit.getPluginManager().getPlugin("mcMMO") != null) {
|
||||
this.skillInterface = new mcMMOHook();
|
||||
this.skillInterface = new mcMMOImpl();
|
||||
hookMessage("mcMMO");
|
||||
} else if (config.getBoolean("integration.MMOCore", false) && Bukkit.getPluginManager().getPlugin("MMOCore") != null) {
|
||||
this.skillInterface = new MMOCoreHook();
|
||||
this.skillInterface = new MMOCoreImpl();
|
||||
hookMessage("MMOCore");
|
||||
} else if (config.getBoolean("integration.AureliumSkills", false) && Bukkit.getPluginManager().getPlugin("AureliumSkills") != null) {
|
||||
this.skillInterface = new AureliumsHook();
|
||||
this.skillInterface = new AureliumsImpl();
|
||||
hookMessage("AureliumSkills");
|
||||
} else if (config.getBoolean("integration.EcoSkills", false) && Bukkit.getPluginManager().getPlugin("EcoSkills") != null) {
|
||||
this.skillInterface = new EcoSkillsHook();
|
||||
this.skillInterface = new EcoSkillsImpl();
|
||||
hookMessage("EcoSkills");
|
||||
} else if (config.getBoolean("integration.JobsReborn", false) && Bukkit.getPluginManager().getPlugin("Jobs") != null) {
|
||||
this.skillInterface = new JobsRebornHook();
|
||||
this.skillInterface = new JobsRebornImpl();
|
||||
hookMessage("JobsReborn");
|
||||
}
|
||||
|
||||
List<AntiGriefInterface> antiGriefsList = new ArrayList<>();
|
||||
if (config.getBoolean("integration.Residence",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Residence") == null) Log.warn("Failed to initialize Residence!");
|
||||
else {antiGriefsList.add(new net.momirealms.customfishing.integration.antigrief.ResidenceHook());hookMessage("Residence");}
|
||||
}
|
||||
if (config.getBoolean("integration.Kingdoms",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Kingdoms") == null) Log.warn("Failed to initialize Kingdoms!");
|
||||
else {antiGriefsList.add(new KingdomsXHook());hookMessage("Kingdoms");}
|
||||
}
|
||||
if (config.getBoolean("integration.WorldGuard",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) Log.warn("Failed to initialize WorldGuard!");
|
||||
else {antiGriefsList.add(new WorldGuardHook());hookMessage("WorldGuard");}
|
||||
}
|
||||
if (config.getBoolean("integration.GriefDefender",false)){
|
||||
if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null) Log.warn("Failed to initialize GriefDefender!");
|
||||
else {antiGriefsList.add(new GriefDefenderHook());hookMessage("GriefDefender");}
|
||||
}
|
||||
if (config.getBoolean("integration.PlotSquared",false)){
|
||||
if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null) Log.warn("Failed to initialize PlotSquared!");
|
||||
else {antiGriefsList.add(new PlotSquaredHook());hookMessage("PlotSquared");}
|
||||
}
|
||||
if (config.getBoolean("integration.Towny",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Towny") == null) Log.warn("Failed to initialize Towny!");
|
||||
else {antiGriefsList.add(new TownyHook());hookMessage("Towny");}
|
||||
}
|
||||
if (config.getBoolean("integration.Lands",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Lands") == null) Log.warn("Failed to initialize Lands!");
|
||||
else {antiGriefsList.add(new LandsHook());hookMessage("Lands");}
|
||||
}
|
||||
if (config.getBoolean("integration.GriefPrevention",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("GriefPrevention") == null) Log.warn("Failed to initialize GriefPrevention!");
|
||||
else {antiGriefsList.add(new GriefPreventionHook());hookMessage("GriefPrevention");}
|
||||
}
|
||||
if (config.getBoolean("integration.CrashClaim",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("CrashClaim") == null) Log.warn("Failed to initialize CrashClaim!");
|
||||
else {antiGriefsList.add(new CrashClaimHook());hookMessage("CrashClaim");}
|
||||
}
|
||||
if (config.getBoolean("integration.BentoBox",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("BentoBox") == null) Log.warn("Failed to initialize BentoBox!");
|
||||
else {antiGriefsList.add(new BentoBoxHook());hookMessage("BentoBox");}
|
||||
}
|
||||
antiGriefs = antiGriefsList.toArray(new AntiGriefInterface[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,6 +148,7 @@ public class IntegrationManager extends Function {
|
||||
this.skillInterface = null;
|
||||
this.itemInterfaces = null;
|
||||
this.mobInterface = null;
|
||||
this.blockInterface = null;
|
||||
if (this.placeholderManager != null) {
|
||||
this.placeholderManager.unload();
|
||||
this.placeholderManager = null;
|
||||
@@ -122,11 +175,21 @@ public class IntegrationManager extends Function {
|
||||
return mobInterface;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BlockInterface getBlockInterface() {
|
||||
return blockInterface;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlaceholderManager getPlaceholderManager() {
|
||||
return placeholderManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AntiGriefInterface[] getAntiGriefs() {
|
||||
return antiGriefs;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack build(String key) {
|
||||
for (ItemInterface itemInterface : itemInterfaces) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.object.Layout;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.fishing.Layout;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.Function;
|
||||
import net.momirealms.customfishing.object.*;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.*;
|
||||
import net.momirealms.customfishing.object.loot.DroppedItem;
|
||||
import net.momirealms.customfishing.object.loot.Loot;
|
||||
import net.momirealms.customfishing.object.loot.Mob;
|
||||
import net.momirealms.customfishing.object.fishing.Difficulty;
|
||||
import net.momirealms.customfishing.object.fishing.Layout;
|
||||
import net.momirealms.customfishing.object.loot.*;
|
||||
import net.momirealms.customfishing.object.requirements.*;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ItemStackUtil;
|
||||
|
||||
@@ -1,9 +1,486 @@
|
||||
package net.momirealms.customfishing.manager;
|
||||
|
||||
import net.momirealms.customfishing.integration.BlockInterface;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.action.CommandActionImpl;
|
||||
import net.momirealms.customfishing.object.action.MessageActionImpl;
|
||||
import net.momirealms.customfishing.object.requirements.*;
|
||||
import net.momirealms.customfishing.object.totem.CorePos;
|
||||
import net.momirealms.customfishing.object.totem.FinalModel;
|
||||
import net.momirealms.customfishing.object.totem.OriginalModel;
|
||||
import net.momirealms.customfishing.object.totem.Totem;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import net.momirealms.customfishing.util.ConfigUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TotemManager {
|
||||
public class TotemManager extends Function {
|
||||
|
||||
public static HashMap<String, String> TOTEMS;
|
||||
public static HashMap<String, Totem> TOTEMS;
|
||||
public static HashMap<String, List<Totem>> CORES;
|
||||
public static HashMap<String, String> BLOCKS;
|
||||
public static HashMap<String, String> INVERTED;
|
||||
private final BlockInterface blockInterface;
|
||||
|
||||
public TotemManager(BlockInterface blockInterface) {
|
||||
this.blockInterface = blockInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
if (TOTEMS != null) TOTEMS.clear();
|
||||
if (CORES != null) CORES.clear();
|
||||
if (BLOCKS != null) BLOCKS.clear();
|
||||
if (INVERTED != null) INVERTED.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
TOTEMS = new HashMap<>();
|
||||
CORES = new HashMap<>();
|
||||
BLOCKS = new HashMap<>();
|
||||
INVERTED = new HashMap<>();
|
||||
|
||||
YamlConfiguration config = ConfigUtil.getConfig("totems.yml");
|
||||
for (String key : config.getKeys(false)) {
|
||||
List<String> cores = config.getStringList(key + ".core");
|
||||
List<String> flat = config.getStringList(key + ".layer.1");
|
||||
int length = flat.get(0).split("\\s+").length;
|
||||
int width = flat.size();
|
||||
int height = Objects.requireNonNull(config.getConfigurationSection(key + ".layer")).getKeys(false).size();
|
||||
CorePos corePos = null;
|
||||
OriginalModel originalModel = new OriginalModel(length, width, height);
|
||||
FinalModel finalModel = new FinalModel(length, width, height);
|
||||
for (int k = 0; k < height; k++) {
|
||||
List<String> layer = config.getStringList(key + ".layer." + (k+1));
|
||||
if (layer.size() != width) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Each layer should have the same size! Error exists in totem:" + key + " layer:" + (k + 1));
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < width; j++) {
|
||||
String[] args = layer.get(j).split("\\s+");
|
||||
if (args.length != length) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Each layer should have the same size! Error exists in totem:" + key + " layer:" + (k + 1) + " line:" + (k + 1));
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (args[i].startsWith("(") && args[i].endsWith(")")){
|
||||
String content = args[i].substring(1, args[i].length()-1);
|
||||
corePos = getCorePos(cores, corePos, originalModel, k, j, i, content);
|
||||
finalModel.setElement("*", i, j, k);
|
||||
}
|
||||
else if (args[i].contains(">")) {
|
||||
String before = StringUtils.split(args[i],">")[0];
|
||||
String after = StringUtils.split(args[i],">")[1];
|
||||
finalModel.setElement(after, i, j, k);
|
||||
corePos = getCorePos(cores, corePos, originalModel, k, j, i, before);
|
||||
}
|
||||
else {
|
||||
String[] elements = StringUtils.split(args[i], "|");
|
||||
originalModel.setElement(elements, i, j, k);
|
||||
for (String core : cores) {
|
||||
for (String element : elements) {
|
||||
if (element.equals(core)) {
|
||||
corePos = new CorePos(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(corePos == null) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomTotems] No core block set for totem:" + key);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
finalModel.setCorePos(corePos);
|
||||
originalModel.setCorePos(corePos);
|
||||
}
|
||||
|
||||
Totem totem = new Totem(
|
||||
originalModel,
|
||||
finalModel,
|
||||
config.getBoolean(key + ".require-item", false),
|
||||
config.getBoolean(key + ".consume-item", false),
|
||||
config.getInt(key + ".radius", 16),
|
||||
config.getInt(key + ".duration", 300),
|
||||
Particle.valueOf(config.getString(key + ".particle", "SPELL").toUpperCase()),
|
||||
BonusManager.getBonus(config, key)
|
||||
);
|
||||
|
||||
List<ActionInterface> actionList = new ArrayList<>();
|
||||
List<ActionInterface> nearActionList = new ArrayList<>();
|
||||
if (config.contains(key + ".action")) {
|
||||
for (String action : config.getConfigurationSection(key + ".action").getKeys(false)) {
|
||||
switch (action) {
|
||||
case "commands-activator" -> actionList.add(new CommandActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null));
|
||||
case "commands-nearby-players" -> nearActionList.add(new CommandActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null));
|
||||
case "messages-activator" -> actionList.add(new MessageActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null));
|
||||
case "messages-nearby-players" -> nearActionList.add(new MessageActionImpl(config.getStringList(key + ".action." + action).toArray(new String[0]), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
totem.setActivatorActions(actionList.toArray(new ActionInterface[0]));
|
||||
totem.setNearbyActions(nearActionList.toArray(new ActionInterface[0]));
|
||||
|
||||
if (config.contains(key + ".requirements")) {
|
||||
List<RequirementInterface> requirements = new ArrayList<>();
|
||||
config.getConfigurationSection(key + ".requirements").getKeys(false).forEach(requirement -> {
|
||||
switch (requirement){
|
||||
case "weather" -> requirements.add(new WeatherImpl(config.getStringList(key + ".requirements.weather")));
|
||||
case "ypos" -> requirements.add(new YPosImpl(config.getStringList(key + ".requirements.ypos")));
|
||||
case "season" -> requirements.add(new SeasonImpl(config.getStringList(key + ".requirements.season")));
|
||||
case "world" -> requirements.add(new WorldImpl(config.getStringList(key + ".requirements.world")));
|
||||
case "biome" -> requirements.add(new BiomeImpl(config.getStringList(key + ".requirements.biome")));
|
||||
case "permission" -> requirements.add(new PermissionImpl(config.getString(key + ".requirements.permission")));
|
||||
case "time" -> requirements.add(new TimeImpl(config.getStringList(key + ".requirements.time")));
|
||||
case "skill-level" -> requirements.add(new SkillLevelImpl(config.getInt(key + ".requirements.skill-level")));
|
||||
case "papi-condition" -> requirements.add(new CustomPapi(config.getConfigurationSection(key + ".requirements.papi-condition").getValues(false)));
|
||||
}
|
||||
});
|
||||
totem.setRequirements(requirements.toArray(new RequirementInterface[0]));
|
||||
}
|
||||
|
||||
TOTEMS.put(key, totem);
|
||||
|
||||
for (String core : cores) {
|
||||
if (CORES.get(core) == null){
|
||||
List<Totem> totems = new ArrayList<>();
|
||||
totems.add(totem);
|
||||
CORES.put(core, totems);
|
||||
}
|
||||
else {
|
||||
CORES.get(core).add(totem);
|
||||
}
|
||||
}
|
||||
}
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + TOTEMS.size() + " <gray>totems");
|
||||
}
|
||||
|
||||
private CorePos getCorePos(List<String> cores, CorePos corePos, OriginalModel originalModel, int k, int j, int i, String content) {
|
||||
String[] elements = StringUtils.split(content, "|");
|
||||
originalModel.setElement(elements, i, j, k);
|
||||
for (String core : cores) {
|
||||
for (String element : elements) {
|
||||
if (element.equals(core)) {
|
||||
corePos = new CorePos(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
return corePos;
|
||||
}
|
||||
|
||||
public int checkLocationModel(OriginalModel model, Location location){
|
||||
|
||||
CorePos corePos = model.getCorePos();
|
||||
int xOffset = corePos.getX();
|
||||
int yOffset = corePos.getY();
|
||||
int zOffset = corePos.getZ();
|
||||
|
||||
int height = model.getHeight();
|
||||
int length = model.getLength();
|
||||
int width = model.getWidth();
|
||||
|
||||
Location startLoc = location.clone().subtract(0, yOffset, 0);
|
||||
|
||||
Label_1:
|
||||
{
|
||||
for(int i = 0; i< height; i++) {
|
||||
Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(x, 0, z).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Label_2:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(xOffset, i, zOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(-x, 0, -z).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
Label_3:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-zOffset, i, xOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(z, 0, -x).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
Label_4:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(zOffset, i, -xOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(-z, 0, x).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
Label_5:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(z, 0, x).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_5;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
Label_6:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(zOffset, i, xOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(-z, 0, -x).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_6;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 6;
|
||||
}
|
||||
|
||||
Label_7:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-xOffset, i, zOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(x, 0, -z).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_7;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 7;
|
||||
}
|
||||
Label_8:
|
||||
{
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(xOffset, i, -zOffset);
|
||||
for (int z = 0; z < width; z++) {
|
||||
inner: for (int x = 0; x < length; x++) {
|
||||
String[] elements = model.getElement(x, z, i);
|
||||
String id = blockInterface.getID(loc.clone().add(-x, 0, z).getBlock());
|
||||
for (String element : elements) {
|
||||
if (element.equals("*")) continue inner;
|
||||
if (id == null) break;
|
||||
if (id.equals(element)) continue inner;
|
||||
}
|
||||
break Label_8;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public void removeModel(FinalModel model, Location location, int id) {
|
||||
|
||||
CorePos corePos = model.getCorePos();
|
||||
int xOffset = corePos.getX();
|
||||
int yOffset = corePos.getY();
|
||||
int zOffset = corePos.getZ();
|
||||
|
||||
int height = model.getHeight();
|
||||
int length = model.getLength();
|
||||
int width = model.getWidth();
|
||||
|
||||
Location startLoc = location.clone().subtract(0, yOffset, 0);
|
||||
|
||||
switch (id) {
|
||||
case 1:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(x, 0, z).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(x, 0, z), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(xOffset, i, zOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(-x, 0, -z).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(-x, 0, -z), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-zOffset, i, xOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(z, 0, -x).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(z, 0, -x), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(zOffset, i, -xOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(-z, 0, x).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(-z, 0, x), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(z, 0, x).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(z, 0, x), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(zOffset, i, xOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(-z, 0, -x).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(-z, 0, -x), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(-xOffset, i, zOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(x, 0, -z).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(x, 0, -z), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (int i = 0; i < height; i++) {
|
||||
Location loc = startLoc.clone().add(xOffset, i, -zOffset);
|
||||
for (int z = 0; z < width; z++)
|
||||
for (int x = 0; x < length; x++) {
|
||||
if (model.getElement(x, z, i) == null) {
|
||||
blockInterface.removeBlock(loc.clone().add(-x, 0, z).getBlock());
|
||||
}
|
||||
else if (!model.getElement(x, z, i).equals("*")){
|
||||
blockInterface.replaceBlock(loc.clone().add(-x, 0, z), model.getElement(x, z, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.customfishing;
|
||||
package net.momirealms.customfishing.object;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class Function {
|
||||
|
||||
@@ -19,4 +20,8 @@ public class Function {
|
||||
public void onJoin(Player player) {
|
||||
|
||||
}
|
||||
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,21 +27,14 @@ import java.util.List;
|
||||
|
||||
public class TextCache {
|
||||
|
||||
//所属玩家
|
||||
private final Player owner;
|
||||
//初始值
|
||||
private final String rawValue;
|
||||
//原始文字加工后的值
|
||||
private String originalValue;
|
||||
//最近一次替换值
|
||||
private String latestValue;
|
||||
//持有者占位符
|
||||
private String[] ownerPlaceholders;
|
||||
|
||||
public TextCache(Player owner, String rawValue) {
|
||||
this.owner = owner;
|
||||
this.rawValue = rawValue;
|
||||
analyze(this.rawValue);
|
||||
analyze(rawValue);
|
||||
}
|
||||
|
||||
private void analyze(String value) {
|
||||
@@ -56,15 +49,6 @@ public class TextCache {
|
||||
update();
|
||||
}
|
||||
|
||||
public String getRawValue() {
|
||||
return rawValue;
|
||||
}
|
||||
|
||||
public String updateAndGet() {
|
||||
update();
|
||||
return getLatestValue();
|
||||
}
|
||||
|
||||
public String getLatestValue() {
|
||||
return latestValue;
|
||||
}
|
||||
@@ -87,6 +71,7 @@ public class TextCache {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string = string.replace("{rank}", Competition.currentCompetition.getPlayerRank(owner))
|
||||
.replace("{time}", String.valueOf(Competition.currentCompetition.getRemainingTime()))
|
||||
.replace("{minute}", String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60))
|
||||
@@ -94,11 +79,11 @@ public class TextCache {
|
||||
.replace("{score}", String.format("%.1f", Competition.currentCompetition.getScore(owner)))
|
||||
.replace("{1st_score}", String.format("%.1f", Competition.currentCompetition.getFirstScore()))
|
||||
.replace("{1st_player}", Competition.currentCompetition.getFirstPlayer());
|
||||
|
||||
if (!latestValue.equals(string)) {
|
||||
latestValue = string;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.momirealms.customfishing.object.action;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ActionInterface {
|
||||
|
||||
void doOn(Player player);
|
||||
void doOn(Player player, @Nullable Player anotherPlayer);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public record CommandActionImpl(String[] commands, String nick) implements Actio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
public void doOn(Player player, @Nullable Player anotherPlayer) {
|
||||
for (String command : commands) {
|
||||
CustomFishing.plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
command.replace("{player}", player.getName())
|
||||
@@ -22,6 +22,7 @@ public record CommandActionImpl(String[] commands, String nick) implements Actio
|
||||
.replace("{z}", String.valueOf(player.getLocation().getBlockZ()))
|
||||
.replace("{loot}", nick)
|
||||
.replace("{world}", player.getWorld().getName())
|
||||
.replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.customfishing.object.action;
|
||||
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record MessageActionImpl(String[] messages, String nick) implements ActionInterface {
|
||||
|
||||
@@ -11,7 +12,7 @@ public record MessageActionImpl(String[] messages, String nick) implements Actio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
public void doOn(Player player, @Nullable Player anotherPlayer) {
|
||||
for (String message : messages) {
|
||||
AdventureUtil.playerMessage(player,
|
||||
message.replace("{player}", player.getName())
|
||||
@@ -19,7 +20,9 @@ public record MessageActionImpl(String[] messages, String nick) implements Actio
|
||||
.replace("{x}", String.valueOf(player.getLocation().getBlockX()))
|
||||
.replace("{y}", String.valueOf(player.getLocation().getBlockY()))
|
||||
.replace("{z}", String.valueOf(player.getLocation().getBlockZ()))
|
||||
.replace("{loot}", nick));
|
||||
.replace("{loot}", nick)
|
||||
.replace("{activator}", anotherPlayer == null ? "" : anotherPlayer.getName())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
public record SkillXPImpl(double amount) implements ActionInterface {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
public void doOn(Player player, Player another) {
|
||||
CustomFishing.plugin.getIntegrationManager().getSkillInterface().addXp(player, amount);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
||||
public record SoundActionImpl(String sound) implements ActionInterface {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
public void doOn(Player player, Player another) {
|
||||
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key(sound), 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
||||
public record VanillaXPImpl(int amount, boolean mending) implements ActionInterface {
|
||||
|
||||
@Override
|
||||
public void doOn(Player player) {
|
||||
public void doOn(Player player, Player another) {
|
||||
player.giveExp(amount, mending);
|
||||
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
public record Difficulty(int timer, int speed) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
public enum FishResult {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.integration.papi.PlaceholderManager;
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.FishingManager;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
public class Layout {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
public class Modifier {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.fishing;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
import net.momirealms.customfishing.object.Difficulty;
|
||||
import net.momirealms.customfishing.object.LeveledEnchantment;
|
||||
import net.momirealms.customfishing.object.fishing.Difficulty;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DroppedItem extends Loot{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
import net.momirealms.customfishing.object.Difficulty;
|
||||
import net.momirealms.customfishing.object.Layout;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.fishing.Difficulty;
|
||||
import net.momirealms.customfishing.object.fishing.Layout;
|
||||
import net.momirealms.customfishing.object.requirements.RequirementInterface;
|
||||
|
||||
public class Loot {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
import net.momirealms.customfishing.object.Difficulty;
|
||||
import net.momirealms.customfishing.object.MobVector;
|
||||
import net.momirealms.customfishing.object.fishing.Difficulty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Mob extends Loot{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.object.loot;
|
||||
|
||||
public record MobVector(double horizontal, double vertical) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
import net.momirealms.customfishing.object.requirements.papi.*;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
public record PermissionImpl(String permission) implements RequirementInterface {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
public interface RequirementInterface {
|
||||
boolean isConditionMet(FishingCondition fishingCondition);
|
||||
|
||||
@@ -19,7 +19,7 @@ package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.integration.SeasonInterface;
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
public record SkillLevelImpl(int level) implements RequirementInterface {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.object.requirements;
|
||||
|
||||
import net.momirealms.customfishing.object.FishingCondition;
|
||||
import net.momirealms.customfishing.object.fishing.FishingCondition;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,35 +17,49 @@
|
||||
|
||||
package net.momirealms.customfishing.object.totem;
|
||||
|
||||
import java.util.List;
|
||||
import net.momirealms.customfishing.object.action.ActionInterface;
|
||||
import net.momirealms.customfishing.object.fishing.Bonus;
|
||||
import net.momirealms.customfishing.object.requirements.RequirementInterface;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class Totem {
|
||||
|
||||
private final OriginalModel originalModel;
|
||||
private FinalModel finalModel;
|
||||
private List<String> commands;
|
||||
private List<String> messages;
|
||||
private final boolean cItem;
|
||||
private final boolean rItem;
|
||||
private RequirementInterface[] requirements;
|
||||
private final int radius;
|
||||
private final Particle particle;
|
||||
private final int duration;
|
||||
private final Bonus bonus;
|
||||
private ActionInterface[] activatorActions;
|
||||
private ActionInterface[] nearbyActions;
|
||||
|
||||
public Totem(OriginalModel originalModel, boolean rItem, boolean cItem) {
|
||||
public Totem(OriginalModel originalModel, FinalModel finalModel, boolean rItem, boolean cItem, int radius, int duration, Particle particle, Bonus bonus) {
|
||||
this.originalModel = originalModel;
|
||||
this.finalModel = finalModel;
|
||||
this.radius = radius;
|
||||
this.duration = duration;
|
||||
this.particle = particle;
|
||||
this.bonus = bonus;
|
||||
this.rItem = rItem;
|
||||
if (rItem) this.cItem = cItem;
|
||||
else this.cItem = false;
|
||||
}
|
||||
|
||||
public RequirementInterface[] getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
public void setRequirements(RequirementInterface[] requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public OriginalModel getOriginalModel() {
|
||||
return originalModel;
|
||||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(List<String> messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public FinalModel getFinalModel() {
|
||||
return finalModel;
|
||||
@@ -55,19 +69,43 @@ public class Totem {
|
||||
this.finalModel = finalModel;
|
||||
}
|
||||
|
||||
public void setCommands(List<String> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public boolean isrItem() {
|
||||
return rItem;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public boolean iscItem() {
|
||||
return cItem;
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public Particle getParticle() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public Bonus getBonus() {
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public ActionInterface[] getActivatorActions() {
|
||||
return activatorActions;
|
||||
}
|
||||
|
||||
public void setActivatorActions(ActionInterface[] activatorActions) {
|
||||
this.activatorActions = activatorActions;
|
||||
}
|
||||
|
||||
public ActionInterface[] getNearbyActions() {
|
||||
return nearbyActions;
|
||||
}
|
||||
|
||||
public void setNearbyActions(ActionInterface[] nearbyActions) {
|
||||
this.nearbyActions = nearbyActions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.helper.Log;
|
||||
import net.momirealms.customfishing.manager.ConfigManager;
|
||||
import net.momirealms.customfishing.manager.MessageManager;
|
||||
import net.momirealms.customfishing.object.Reflection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -7,9 +7,9 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.manager.BonusManager;
|
||||
import net.momirealms.customfishing.manager.LootManager;
|
||||
import net.momirealms.customfishing.object.Item;
|
||||
import net.momirealms.customfishing.object.LeveledEnchantment;
|
||||
import net.momirealms.customfishing.object.loot.DroppedItem;
|
||||
import net.momirealms.customfishing.object.loot.Item;
|
||||
import net.momirealms.customfishing.object.loot.LeveledEnchantment;
|
||||
import net.momirealms.customfishing.object.loot.Loot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -23,13 +23,13 @@ public class JedisUtil {
|
||||
jedisPoolConfig.setTestWhileIdle(true);
|
||||
jedisPoolConfig.setTimeBetweenEvictionRunsMillis(30000);
|
||||
jedisPoolConfig.setNumTestsPerEvictionRun(-1);
|
||||
jedisPoolConfig.setMinEvictableIdleTimeMillis(configuration.getInt("redis.MinEvictableIdleTimeMillis",1800000));
|
||||
jedisPoolConfig.setMaxTotal(configuration.getInt("redis.MaxTotal",8));
|
||||
jedisPoolConfig.setMaxIdle(configuration.getInt("redis.MaxIdle",8));
|
||||
jedisPoolConfig.setMinIdle(configuration.getInt("redis.MinIdle",1));
|
||||
jedisPoolConfig.setMinEvictableIdleTimeMillis(configuration.getInt("Redis.MinEvictableIdleTimeMillis",1800000));
|
||||
jedisPoolConfig.setMaxTotal(configuration.getInt("Redis.MaxTotal",8));
|
||||
jedisPoolConfig.setMaxIdle(configuration.getInt("Redis.MaxIdle",8));
|
||||
jedisPoolConfig.setMinIdle(configuration.getInt("Redis.MinIdle",1));
|
||||
jedisPoolConfig.setMaxWaitMillis(configuration.getInt("redis.MaxWaitMillis",30000));
|
||||
|
||||
jedisPool = new JedisPool(jedisPoolConfig, configuration.getString("redis.host","localhost"), configuration.getInt("redis.port",6379));
|
||||
jedisPool = new JedisPool(jedisPoolConfig, configuration.getString("Redis.host","localhost"), configuration.getInt("Redis.port",6379));
|
||||
|
||||
AdventureUtil.consoleMessage("[CustomFishing] <white>Redis Server Connected!");
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customfishing.object;
|
||||
package net.momirealms.customfishing.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -1,348 +0,0 @@
|
||||
///*
|
||||
// * 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.util;
|
||||
//
|
||||
//import net.momirealms.customfishing.object.totem.CorePos;
|
||||
//import net.momirealms.customfishing.object.totem.FinalModel;
|
||||
//import net.momirealms.customfishing.object.totem.OriginalModel;
|
||||
//import org.bukkit.Location;
|
||||
//
|
||||
//public class TotemUtil {
|
||||
//
|
||||
// public static int checkLocationModel(OriginalModel model, Location location){
|
||||
//
|
||||
// CorePos corePos = model.getCorePos();
|
||||
// int xOffset = corePos.getX();
|
||||
// int yOffset = corePos.getY();
|
||||
// int zOffset = corePos.getZ();
|
||||
//
|
||||
// int height = model.getHeight();
|
||||
// int length = model.getLength();
|
||||
// int width = model.getWidth();
|
||||
//
|
||||
// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测
|
||||
// Location startLoc = location.clone().subtract(0, yOffset, 0);
|
||||
//
|
||||
// Label_1:
|
||||
// {
|
||||
// for(int i = 0; i< height; i++) {
|
||||
// //起点定于左下角,向右上遍历
|
||||
// Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(x, 0, z));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// Label_2:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右上角,向左下遍历
|
||||
// Location loc = startLoc.clone().add(xOffset, i, zOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(-x, 0, -z));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_2;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 2;
|
||||
// }
|
||||
//
|
||||
// Label_3:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左上角,向右下遍历
|
||||
// Location loc = startLoc.clone().add(-zOffset, i, xOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(z, 0, -x));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_3;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// Label_4:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右下角,向左上遍历
|
||||
// Location loc = startLoc.clone().add(zOffset, i, -xOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(-z, 0, x));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_4;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 4;
|
||||
// }
|
||||
//
|
||||
// Label_5:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左下角(镜像),向上左遍历
|
||||
// Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(z, 0, x));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_5;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 5;
|
||||
// }
|
||||
//
|
||||
// Label_6:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右上角(镜像),向下左遍历
|
||||
// Location loc = startLoc.clone().add(zOffset, i, xOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(-z, 0, -x));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_6;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 6;
|
||||
// }
|
||||
//
|
||||
// Label_7:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左上角(镜像),向右下遍历
|
||||
// Location loc = startLoc.clone().add(-xOffset, i, zOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(x, 0, -z));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_7;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 7;
|
||||
// }
|
||||
// Label_8:
|
||||
// {
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右下角(镜像),向左上遍历
|
||||
// Location loc = startLoc.clone().add(xOffset, i, -zOffset);
|
||||
// for (int z = 0; z < width; z++) {
|
||||
// inner: for (int x = 0; x < length; x++) {
|
||||
// String[] elements = model.getElement(x, z, i);
|
||||
// String id = BlockUtil.getId(loc.clone().add(-x, 0, z));
|
||||
// for (String element : elements) {
|
||||
// if (element.equals("*")) continue inner;
|
||||
// if (id == null) break;
|
||||
// if (id.equals(element)) continue inner;
|
||||
// }
|
||||
// break Label_8;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 8;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static void removeModel(FinalModel model, Location location, int id) {
|
||||
//
|
||||
// CorePos corePos = model.getCorePos();
|
||||
// int xOffset = corePos.getX();
|
||||
// int yOffset = corePos.getY();
|
||||
// int zOffset = corePos.getZ();
|
||||
//
|
||||
// int height = model.getHeight();
|
||||
// int length = model.getLength();
|
||||
// int width = model.getWidth();
|
||||
//
|
||||
// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测
|
||||
// Location startLoc = location.clone().subtract(0, yOffset, 0);
|
||||
//
|
||||
// switch (id) {
|
||||
// case 1:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左下角,向右上遍历
|
||||
// Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(x, 0, z));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(x, 0, z), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 2:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右上角,向左下遍历
|
||||
// Location loc = startLoc.clone().add(xOffset, i, zOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(-x, 0, -z));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(-x, 0, -z), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 3:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左上角,向右下遍历
|
||||
// Location loc = startLoc.clone().add(-zOffset, i, xOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(z, 0, -x));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(z, 0, -x), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 4:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右下角,向左上遍历
|
||||
// Location loc = startLoc.clone().add(zOffset, i, -xOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(-z, 0, x));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(-z, 0, x), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 5:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左下角(镜像),向上左遍历
|
||||
// Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(z, 0, x));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(z, 0, x), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 6:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右上角(镜像),向下左遍历
|
||||
// Location loc = startLoc.clone().add(zOffset, i, xOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(-z, 0, -x));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(-z, 0, -x), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 7:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于左上角(镜像),向右下遍历
|
||||
// Location loc = startLoc.clone().add(-xOffset, i, zOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(x, 0, -z));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(x, 0, -z), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 8:
|
||||
// for (int i = 0; i < height; i++) {
|
||||
// //起点定于右下角(镜像),向左上遍历
|
||||
// Location loc = startLoc.clone().add(xOffset, i, -zOffset);
|
||||
// for (int z = 0; z < width; z++)
|
||||
// for (int x = 0; x < length; x++) {
|
||||
// if (model.getElement(x, z, i) == null) {
|
||||
// BlockUtil.remove(loc.clone().add(-x, 0, z));
|
||||
// }
|
||||
// else if (!model.getElement(x, z, i).equals("*")){
|
||||
// BlockUtil.replace(loc.clone().add(-x, 0, z), model.getElement(x, z, i));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user