Moved items to items.yml config, closes #59

This commit is contained in:
Stijn Bannink 2023-08-13 19:25:19 +02:00
parent 6662f74d4f
commit 098ebeb5d7
6 changed files with 155 additions and 129 deletions

View file

@ -11,9 +11,7 @@ import tech.sbdevelopment.v10lift.listeners.BlockBreakListener;
import tech.sbdevelopment.v10lift.listeners.EntityDamageListener;
import tech.sbdevelopment.v10lift.listeners.PlayerInteractListener;
import tech.sbdevelopment.v10lift.listeners.SignChangeListener;
import tech.sbdevelopment.v10lift.managers.DBManager;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.managers.*;
import tech.sbdevelopment.v10lift.sbutils.ConfigUpdater;
import tech.sbdevelopment.v10lift.sbutils.UpdateManager;
import tech.sbdevelopment.v10lift.sbutils.YamlFile;
@ -29,6 +27,8 @@ public class V10LiftPlugin extends JavaPlugin {
private static DBManager dbManager;
@Getter
private static YamlFile messages;
@Getter
private static YamlFile items;
private static boolean vault = false;
@Override
@ -51,6 +51,12 @@ public class V10LiftPlugin extends JavaPlugin {
messages = new YamlFile("messages");
messages.loadDefaults();
//Load the items
items = new YamlFile("items");
items.loadDefaults();
AntiCopyBlockManager.init();
ForbiddenBlockManager.init();
//Load the database
dbManager = new DBManager("data");
try {

View file

@ -15,7 +15,9 @@ import org.bukkit.inventory.ItemStack;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.*;
import tech.sbdevelopment.v10lift.managers.AntiCopyBlockManager;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.ForbiddenBlockManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
@ -423,6 +425,9 @@ public class V10LiftCommand implements CommandExecutor {
e.printStackTrace();
}
AntiCopyBlockManager.reinit();
ForbiddenBlockManager.reinit();
ConfigUtil.sendMessage(sender, "Reload.Reloaded");
return true;
}

View file

@ -2,6 +2,7 @@ package tech.sbdevelopment.v10lift.managers;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import java.util.HashSet;
@ -11,93 +12,15 @@ import java.util.HashSet;
public class AntiCopyBlockManager {
private static final HashSet<XMaterial> antiCopy = new HashSet<>();
static {
//TODO Add more anti copy materials
//TODO Add to config
antiCopy.add(XMaterial.REDSTONE_TORCH);
antiCopy.add(XMaterial.REDSTONE_WALL_TORCH);
antiCopy.add(XMaterial.REPEATER);
antiCopy.add(XMaterial.COMPARATOR);
antiCopy.add(XMaterial.REDSTONE_WIRE);
antiCopy.add(XMaterial.ACACIA_BUTTON);
antiCopy.add(XMaterial.BIRCH_BUTTON);
antiCopy.add(XMaterial.DARK_OAK_BUTTON);
antiCopy.add(XMaterial.JUNGLE_BUTTON);
antiCopy.add(XMaterial.OAK_BUTTON);
antiCopy.add(XMaterial.SPRUCE_BUTTON);
antiCopy.add(XMaterial.STONE_BUTTON);
antiCopy.add(XMaterial.TORCH);
antiCopy.add(XMaterial.ACACIA_TRAPDOOR);
antiCopy.add(XMaterial.BIRCH_TRAPDOOR);
antiCopy.add(XMaterial.DARK_OAK_TRAPDOOR);
antiCopy.add(XMaterial.JUNGLE_TRAPDOOR);
antiCopy.add(XMaterial.OAK_TRAPDOOR);
antiCopy.add(XMaterial.SPRUCE_TRAPDOOR);
antiCopy.add(XMaterial.IRON_TRAPDOOR);
antiCopy.add(XMaterial.ACACIA_PRESSURE_PLATE);
antiCopy.add(XMaterial.BIRCH_PRESSURE_PLATE);
antiCopy.add(XMaterial.DARK_OAK_PRESSURE_PLATE);
antiCopy.add(XMaterial.JUNGLE_PRESSURE_PLATE);
antiCopy.add(XMaterial.OAK_PRESSURE_PLATE);
antiCopy.add(XMaterial.SPRUCE_PRESSURE_PLATE);
antiCopy.add(XMaterial.STONE_PRESSURE_PLATE);
antiCopy.add(XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE);
antiCopy.add(XMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE);
antiCopy.add(XMaterial.ACACIA_SIGN);
antiCopy.add(XMaterial.BIRCH_SIGN);
antiCopy.add(XMaterial.DARK_OAK_SIGN);
antiCopy.add(XMaterial.JUNGLE_SIGN);
antiCopy.add(XMaterial.OAK_SIGN);
antiCopy.add(XMaterial.SPRUCE_SIGN);
antiCopy.add(XMaterial.ACACIA_WALL_SIGN);
antiCopy.add(XMaterial.BIRCH_WALL_SIGN);
antiCopy.add(XMaterial.DARK_OAK_WALL_SIGN);
antiCopy.add(XMaterial.JUNGLE_WALL_SIGN);
antiCopy.add(XMaterial.OAK_WALL_SIGN);
antiCopy.add(XMaterial.SPRUCE_WALL_SIGN);
antiCopy.add(XMaterial.RAIL);
antiCopy.add(XMaterial.POWERED_RAIL);
antiCopy.add(XMaterial.DETECTOR_RAIL);
antiCopy.add(XMaterial.ACTIVATOR_RAIL);
antiCopy.add(XMaterial.LADDER);
public static void init() {
for (String mat : V10LiftPlugin.getItems().getFile().getStringList("AntiCopyMaterials")) {
antiCopy.add(XMaterial.matchXMaterial(mat).orElseThrow());
}
}
/* Causes duping */
antiCopy.add(XMaterial.WHITE_CARPET);
antiCopy.add(XMaterial.ORANGE_CARPET);
antiCopy.add(XMaterial.MAGENTA_CARPET);
antiCopy.add(XMaterial.LIGHT_BLUE_CARPET);
antiCopy.add(XMaterial.YELLOW_CARPET);
antiCopy.add(XMaterial.LIME_CARPET);
antiCopy.add(XMaterial.PINK_CARPET);
antiCopy.add(XMaterial.GRAY_CARPET);
antiCopy.add(XMaterial.LIGHT_GRAY_CARPET);
antiCopy.add(XMaterial.CYAN_CARPET);
antiCopy.add(XMaterial.PURPLE_CARPET);
antiCopy.add(XMaterial.BLUE_CARPET);
antiCopy.add(XMaterial.BROWN_CARPET);
antiCopy.add(XMaterial.GREEN_CARPET);
antiCopy.add(XMaterial.RED_CARPET);
antiCopy.add(XMaterial.BLACK_CARPET);
/* Because of datatypes */
antiCopy.add(XMaterial.BEEHIVE);
antiCopy.add(XMaterial.BELL);
antiCopy.add(XMaterial.BREWING_STAND);
antiCopy.add(XMaterial.BUBBLE_COLUMN);
antiCopy.add(XMaterial.CAKE);
antiCopy.add(XMaterial.CAMPFIRE);
antiCopy.add(XMaterial.COCOA);
antiCopy.add(XMaterial.COMMAND_BLOCK);
antiCopy.add(XMaterial.CHAIN_COMMAND_BLOCK);
antiCopy.add(XMaterial.REPEATING_COMMAND_BLOCK);
antiCopy.add(XMaterial.DAYLIGHT_DETECTOR);
antiCopy.add(XMaterial.DISPENSER);
antiCopy.add(XMaterial.END_PORTAL_FRAME);
antiCopy.add(XMaterial.FARMLAND);
antiCopy.add(XMaterial.FIRE);
antiCopy.add(XMaterial.FURNACE);
antiCopy.add(XMaterial.HOPPER);
antiCopy.add(XMaterial.JUKEBOX);
public static void reinit() {
antiCopy.clear();
init();
}
/**

View file

@ -2,6 +2,7 @@ package tech.sbdevelopment.v10lift.managers;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import java.util.HashSet;
@ -11,37 +12,15 @@ import java.util.HashSet;
public class ForbiddenBlockManager {
private static final HashSet<XMaterial> forbidden = new HashSet<>();
static {
//TODO Add more forbidden materials
//TODO Add to config
forbidden.add(XMaterial.BLACK_BED);
forbidden.add(XMaterial.BLUE_BED);
forbidden.add(XMaterial.BROWN_BED);
forbidden.add(XMaterial.CYAN_BED);
forbidden.add(XMaterial.GRAY_BED);
forbidden.add(XMaterial.GREEN_BED);
forbidden.add(XMaterial.LIGHT_BLUE_BED);
forbidden.add(XMaterial.LIGHT_GRAY_BED);
forbidden.add(XMaterial.LIME_BED);
forbidden.add(XMaterial.MAGENTA_BED);
forbidden.add(XMaterial.ORANGE_BED);
forbidden.add(XMaterial.PINK_BED);
forbidden.add(XMaterial.PURPLE_BED);
forbidden.add(XMaterial.RED_BED);
forbidden.add(XMaterial.WHITE_BED);
forbidden.add(XMaterial.YELLOW_BED);
forbidden.add(XMaterial.ACACIA_SAPLING);
forbidden.add(XMaterial.BAMBOO_SAPLING);
forbidden.add(XMaterial.BIRCH_SAPLING);
forbidden.add(XMaterial.DARK_OAK_SAPLING);
forbidden.add(XMaterial.JUNGLE_SAPLING);
forbidden.add(XMaterial.OAK_SAPLING);
forbidden.add(XMaterial.SPRUCE_SAPLING);
forbidden.add(XMaterial.TNT);
forbidden.add(XMaterial.PISTON);
forbidden.add(XMaterial.PISTON_HEAD);
forbidden.add(XMaterial.MOVING_PISTON);
forbidden.add(XMaterial.STICKY_PISTON);
public static void init() {
for (String mat : V10LiftPlugin.getItems().getFile().getStringList("ForbiddenMaterials")) {
forbidden.add(XMaterial.matchXMaterial(mat).orElseThrow());
}
}
public static void reinit() {
forbidden.clear();
init();
}
/**

View file

@ -1,4 +1,4 @@
#General sign texts
# Generic sign texts
SignText: "[v10lift]"
DefectText: "&kDefect!"
DisabledText: "&cDisabled"
@ -6,30 +6,30 @@ MaintenanceText: "&cMaintenance"
UpText: "&aup"
DownText: "&adown"
#The change for a lift to get defective. Disabled by default.
# The change for a lift to get defective. Disabled by default.
DefectRate: 0.0
#The repair item and amount required
# The repair item and amount required
RepairItem: REDSTONE
RepairAmount: 5
#The master repair item and amount required
# The master repair item and amount required
MasterRepairItem: DIAMOND
MasterRepairAmount: 10
#The default speed of a lift
# The default speed of a lift
DefaultSpeed: 16
#Create lifts with realistic mode enabled default?
# Create lifts with realistic mode enabled default?
DefaultRealistic: true
#The time for the door to close, in ticks. 20 ticks = 1 sec
# The time for the door to close, in ticks. 20 ticks = 1 sec
DoorCloseTime: 100
#Teleport with packets (no Bukkit events will be fired then)
# Teleport with packets (no Bukkit events will be fired then)
PacketTeleport: false
#The updater checker - It will check for new versions, and install automatically if found.
# The updater checker - It will check for new versions, and install automatically if found.
UpdateChecker:
Enabled: true
DownloadOnUpdate: true

View file

@ -0,0 +1,113 @@
# These items can't be added to an elevator cabin
ForbiddenMaterials:
- BLACK_BED
- BLUE_BED
- BROWN_BED
- CYAN_BED
- GRAY_BED
- GREEN_BED
- LIGHT_BLUE_BED
- LIGHT_GRAY_BED
- LIME_BED
- MAGENTA_BED
- ORANGE_BED
- PINK_BED
- PURPLE_BED
- RED_BED
- WHITE_BED
- YELLOW_BED
- ACACIA_SAPLING
- BAMBOO_SAPLING
- BIRCH_SAPLING
- DARK_OAK_SAPLING
- JUNGLE_SAPLING
- OAK_SAPLING
- SPRUCE_SAPLING
- TNT
- PISTON
- PISTON_HEAD
- MOVING_PISTON
- STICKY_PISTON
# These items won't be copied when the elevator is moving
AntiCopyMaterials:
- REDSTONE_TORCH
- REDSTONE_WALL_TORCH
- REPEATER
- COMPARATOR
- REDSTONE_WIRE
- ACACIA_BUTTON
- BIRCH_BUTTON
- DARK_OAK_BUTTON
- JUNGLE_BUTTON
- OAK_BUTTON
- SPRUCE_BUTTON
- STONE_BUTTON
- TORCH
- ACACIA_TRAPDOOR
- BIRCH_TRAPDOOR
- DARK_OAK_TRAPDOOR
- JUNGLE_TRAPDOOR
- OAK_TRAPDOOR
- SPRUCE_TRAPDOOR
- IRON_TRAPDOOR
- ACACIA_PRESSURE_PLATE
- BIRCH_PRESSURE_PLATE
- DARK_OAK_PRESSURE_PLATE
- JUNGLE_PRESSURE_PLATE
- OAK_PRESSURE_PLATE
- SPRUCE_PRESSURE_PLATE
- STONE_PRESSURE_PLATE
- HEAVY_WEIGHTED_PRESSURE_PLATE
- LIGHT_WEIGHTED_PRESSURE_PLATE
- ACACIA_SIGN
- BIRCH_SIGN
- DARK_OAK_SIGN
- JUNGLE_SIGN
- OAK_SIGN
- SPRUCE_SIGN
- ACACIA_WALL_SIGN
- BIRCH_WALL_SIGN
- DARK_OAK_WALL_SIGN
- JUNGLE_WALL_SIGN
- OAK_WALL_SIGN
- SPRUCE_WALL_SIGN
- RAIL
- POWERED_RAIL
- DETECTOR_RAIL
- ACTIVATOR_RAIL
- LADDER
- WHITE_CARPET
- ORANGE_CARPET
- MAGENTA_CARPET
- LIGHT_BLUE_CARPET
- YELLOW_CARPET
- LIME_CARPET
- PINK_CARPET
- GRAY_CARPET
- LIGHT_GRAY_CARPET
- CYAN_CARPET
- PURPLE_CARPET
- BLUE_CARPET
- BROWN_CARPET
- GREEN_CARPET
- RED_CARPET
- BLACK_CARPET
- BEEHIVE
- BELL
- BREWING_STAND
- BUBBLE_COLUMN
- CAKE
- CAMPFIRE
- COCOA
- COMMAND_BLOCK
- CHAIN_COMMAND_BLOCK
- REPEATING_COMMAND_BLOCK
- DAYLIGHT_DETECTOR
- DISPENSER
- END_PORTAL_FRAME
- FARMLAND
- FIRE
- FURNACE
- HOPPER
- JUKEBOX