Added config.

This commit is contained in:
tastybento 2017-10-26 15:58:58 -07:00
parent 3e6507a654
commit 9dd66a0d1a
6 changed files with 104 additions and 420 deletions

View File

@ -1,305 +1,4 @@
# This file lists the values for various blocks that are used to calculate the
# island level. Level = total of all blocks in island boundary / 100.
# Players with the permission askyblock.island.multiplier.# will have their blocks
# multiplied in value by that amount.
# Underwater block multiplier
# If blocks are below sea-level, they can have a higher value. e.g. 2x
# Promotes under-water development if there is a sea. Value can be fractional.
underwater: 1.0
# Value of one island level. Default 100. Minimum value is 1.
levelcost: 100
# Cooldown between level requests in seconds
levelwait: 60
# Death penalty
# How many block values a player will lose per death.
# Default value of 100 means that for every death, the player will lose 1 level (if levelcost is 100)
# Set to zero to not use this feature
deathpenalty: 100
# Sum team deaths - if true, all the teams deaths are summed
# If false, only the leader's deaths counts
sumteamdeaths: false
# Max deaths
# If player dies more than this, it doesn't count anymore
# Stops players from getting into an impossible situation
maxdeaths: 10
# Reset deaths on island reset
islandresetdeathreset: true
# Reset deaths on team join
teamjoindeathreset: true
# This section lists the limits for any particular block. Blocks over this amount
# are not counted.
# Format:
# MATERIAL: limit or MATERIAL:DATA: limit.
# If DATA is used, there MUST be a corresponding block:data value in the blocks list.
# For example, if you limit Jungle Logs LOG:3, then there must be a value for LOG:3
# in the blocks section. If there is not, then LOG:3 would have no value.
limits:
COBBLESTONE: 10000
NETHERRACK: 1000
#LOG:3: 10
# This section lists the value of a block. Value must be an integer.
# Any blocks not listed will have a value of zero.
# Format is MATERIAL: value or MATERIAL:DATA: value.
blocks:
ACACIA_DOOR: 1
ACACIA_STAIRS: 1
ACACIA_FENCE: 1
ACACIA_FENCE_GATE: 1
ACACIA_STAIRS: 2
ACTIVATOR_RAIL: 10
AIR: 0
ANVIL: 10
ARMOR_STAND: 2
BANNER: 2
BEACON: 100
BED_BLOCK: 1
BEDROCK: 0
BEETROOT_BLOCK: 1
BIRCH_DOOR: 1
BIRCH_FENCE: 1
BIRCH_FENCE_GATE: 1
BIRCH_WOOD_STAIRS: 1
BLACK_GLAZED_TERRACOTTA: 1
BLACK_SHULKER_BOX: 1
BLUE_GLAZED_TERRACOTTA: 1
BLUE_SHULKER_BOX: 1
BOAT: 2
BOAT_ACACIA: 2
BOAT_BIRCH: 2
BOAT_DARK_OAK: 2
BOAT_JUNGLE: 2
BOAT_SPRUCE: 2
BONE_BLOCK: 1
BOOKSHELF: 5
BREWING_STAND: 20
BRICK: 5
BRICK_STAIRS: 5
BROWN_GLAZED_TERRACOTTA: 1
BROWN_SHULKER_BOX: 1
BURNING_FURNACE: 10
CACTUS: 1
CAKE_BLOCK: 1
CARPET: 1
CAULDRON: 10
CHEST: 2
CHORUS_FLOWER: 1
CHORUS_PLANT: 1
CLAY: 2
COAL_BLOCK: 9
COAL_ORE: 0
COBBLE_WALL: 1
COBBLESTONE: 1
COBBLESTONE_STAIRS: 1
COCOA: 1
CONCRETE: 1
CONCRETE_POWDER: 1
CYAN_GLAZED_TERRACOTTA: 1
CYAN_SHULKER_BOX: 1
DARK_OAK_DOOR: 1
DARK_OAK_FENCE: 1
DARK_OAK_FENCE_GATE: 1
DARK_OAK_STAIRS: 1
DAYLIGHT_DETECTOR: 10
DAYLIGHT_DETECTOR_INVERTED: 10
DEAD_BUSH: 1
DETECTOR_RAIL: 10
DIAMOND_BLOCK: 300
DIODE: 5
DIODE_BLOCK_OFF: 5
DIODE_BLOCK_ON: 5
DIRT: 2
DISPENSER: 5
DOUBLE_PLANT: 2
DOUBLE_STEP: 1
DOUBLE_STONE_SLAB2: 1
DRAGON_EGG: 150
DROPPER: 5
EMERALD_BLOCK: 150
EMERALD_ORE: 0
ENCHANTMENT_TABLE: 150
END_BRICKS: 2
ENDER_CHEST: 150
ENDER_PORTAL_FRAME: 0
ENDER_PORTAL: 0
ENDER_STONE: 2
EXPLOSIVE_MINECART: 10
FENCE: 1
FENCE_GATE: 1
FIRE: 0
FLOWER_POT: 5
FROSTED_ICE: 1
FURNACE: 10
GLASS: 2
GLOWSTONE: 1
GOLD_BLOCK: 150
GOLD_ORE: 0
GRASS: 5
GRASS_PATH: 5
GRAY_GLAZED_TERRACOTTA: 1
GRAY_SHULKER_BOX: 1
GRAVEL: 1
GREEN_GLAZED_TERRACOTTA: 1
GREEN_SHULKER_BOX: 1
HARD_CLAY: 2
HAY_BLOCK: 2
HOPPER: 10
HOPPER_MINECART: 20
HUGE_MUSHROOM_1: 1
HUGE_MUSHROOM_2: 1
ICE: 5
IRON_BLOCK: 10
IRON_DOOR_BLOCK: 5
IRON_FENCE: 5
IRON_ORE: 0
IRON_PLATE: 5
IRON_TRAPDOOR: 1
ITEM_FRAME: 2
JACK_O_LANTERN: 1
JUKEBOX: 10
JUNGLE_DOOR: 1
JUNGLE_FENCE: 1
JUNGLE_FENCE_GATE: 1
JUNGLE_WOOD_STAIRS: 1
LADDER: 1
LAPIS_BLOCK: 10
LAPIS_ORE: 0
LAVA: 0
LEAVES_2: 1
LEAVES: 1
LEVER: 1
LIGHT_BLUE_GLAZED_TERRACOTTA: 1
LIGHT_BLUE_SHULKER_BOX: 1
LIME_GLAZED_TERRACOTTA: 1
LIME_SHULKER_BOX: 1
LOG: 1
#Other log types - examples
#LOG:3: 2
LOG_2: 1
LONG_GRASS: 1
MAGENTA_GLAZED_TERRACOTTA: 1
MAGENTA_SHULKER_BOX: 1
MAGMA: 1
MELON_BLOCK: 1
MELON_STEM: 1
MINECART: 10
MOB_SPAWNER: 0
MOSSY_COBBLESTONE: 2
MYCEL: 5
NETHER_BRICK: 2
NETHER_BRICK_STAIRS: 2
NETHER_FENCE: 2
NETHER_STALK: 1
NETHER_WART_BLOCK: 2
NETHERRACK: 1
NOTE_BLOCK: 10
OBSERVER: 1
OBSIDIAN: 10
ORANGE_GLAZED_TERRACOTTA: 1
ORANGE_SHULKER_BOX: 1
PACKED_ICE: 5
PAINTING: 2
PINK_GLAZED_TERRACOTTA: 1
PINK_SHULKER_BOX: 1
PISTON_BASE: 2
PISTON_STICKY_BASE: 2
PORTAL: 0
POWERED_MINECART: 10
POWERED_RAIL: 10
PRISMARINE: 10
PUMPKIN_STEM: 1
PUMPKIN: 1
PURPLE_GLAZED_TERRACOTTA: 1
PURPLE_SHULKER_BOX: 1
PURPUR_BLOCK: 1
PURPUR_DOUBLE_SLAB: 1
PURPUR_PILLAR: 1
PURPUR_SLAB: 1
PURPUR_STAIRS: 1
QUARTZ_BLOCK: 1
QUARTZ_ORE: 0
QUARTZ_STAIRS: 1
QUARTZ: 1
RAILS: 1
RED_GLAZED_TERRACOTTA: 1
RED_MUSHROOM: 1
RED_NETHER_BRICK: 2
RED_ROSE: 1
RED_SANDSTONE: 1
RED_SANDSTONE_STAIRS: 1
RED_SHULKER_BOX: 1
REDSTONE_BLOCK: 10
REDSTONE_COMPARATOR_OFF: 10
REDSTONE_COMPARATOR_ON: 10
REDSTONE_COMPARATOR: 10
REDSTONE_LAMP_OFF: 10
REDSTONE_LAMP_ON: 10
REDSTONE_ORE: 0
REDSTONE_TORCH_OFF: 5
REDSTONE_TORCH_ON: 5
REDSTONE_WIRE: 1
SAND: 1
SANDSTONE: 1
SANDSTONE_STAIRS: 1
SEA_LANTERN: 1
SIGN_POST: 1
SILVER_GLAZED_TERRACOTTA: 1
SILVER_SHULKER_BOX: 1
SKULL: 10
SLIME_BLOCK: 10
SMOOTH_BRICK: 2
SMOOTH_STAIRS: 2
SNOW_BLOCK: 1
SOIL: 2
SOUL_SAND: 2
SPONGE: 10
SPRUCE_DOOR: 1
SPRUCE_FENCE: 1
SPRUCE_FENCE_GATE: 1
SPRUCE_WOOD_STAIRS: 1
STAINED_CLAY: 2
STAINED_GLASS: 2
STAINED_GLASS_PANE: 1
STATIONARY_LAVA: 0
STATIONARY_WATER: 0
STEP: 1
STONE: 1
STONE_BUTTON: 1
STONE_PLATE: 2
STORAGE_MINECART: 10
SUGAR_CANE_BLOCK: 1
THIN_GLASS: 1
TNT: 5
TORCH: 2
TRAP_DOOR: 5
TRAPPED_CHEST: 10
TRIPWIRE_HOOK: 2
TRIPWIRE: 2
VINE: 1
WALL_SIGN: 1
WATER_LILY: 5
WEB: 10
WHEAT: 1
WHITE_GLAZED_TERRACOTTA: 1
WHITE_SHULKER_BOX: 1
WOOD: 1
WOOD_BUTTON: 1
WOOD_DOOR: 1
WOOD_DOUBLE_STEP: 1
WOOD_PLATE: 1
WOOD_STAIRS: 1
WOOD_STEP: 1
WOODEN_DOOR: 1
WOOL: 1
WORKBENCH: 1
YELLOW_FLOWER: 1
YELLOW_GLAZED_TERRACOTTA: 1
YELLOW_SHULKER_BOX: 1
# Warp Restriction - needed levels to be able to create a warp
# 0 or negative values will disable this restriction
# 10 is default
warplevelrestriction: 10

View File

@ -43,23 +43,27 @@ public class Warp extends JavaPlugin {
}
// Local locales
localeManager = new LocaleManager(this);
// Start warp signs
warpSigns = new WarpSigns(this, bSkyBlock);
getServer().getPluginManager().registerEvents(warpSigns, this);
// Start the warp panel and register it for clicks
warpPanel = new WarpPanel(this);
getServer().getPluginManager().registerEvents(warpPanel, this);
// Register commands
new Commands(this);
// We have to wait for the worlds to load, so we do the rest 1 tick later
getServer().getScheduler().runTask(this, () -> {
// Start warp signs
warpSigns = new WarpSigns(this, bSkyBlock);
getServer().getPluginManager().registerEvents(warpSigns, this);
// Start the warp panel and register it for clicks
warpPanel = new WarpPanel(this);
getServer().getPluginManager().registerEvents(warpPanel, this);
// Register commands
new Commands(this);
});
// Done
}
@Override
public void onDisable(){
// Save the warps
warpSigns.saveWarpList();
if (warpSigns != null)
warpSigns.saveWarpList();
}
/**
* Get the locale for this player
* @param sender
@ -77,7 +81,7 @@ public class Warp extends JavaPlugin {
public BSBLocale getLocale(UUID uuid) {
return localeManager.getLocale(uuid);
}
/**
* @return default locale object
*/

View File

@ -25,9 +25,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import bskyblock.addin.warps.config.Settings;
import bskyblock.addin.warps.database.object.Warps;
import bskyblock.addin.warps.event.WarpCreateEvent;
import bskyblock.addin.warps.event.WarpInitiateEvent;
import bskyblock.addin.warps.event.WarpListEvent;
import bskyblock.addin.warps.event.WarpRemoveEvent;
import us.tastybento.bskyblock.BSkyBlock;
@ -96,7 +95,7 @@ public class WarpSigns extends AddonHelper implements Listener {
// Player removed sign
removeWarp(s.getLocation());
Bukkit.getPluginManager().callEvent(new WarpRemoveEvent(plugin, s.getLocation(), player.getUniqueId()));
} else if (player.isOp() || player.hasPermission(Settings.PERMPREFIX + "mod.removesign")) {
} else if (player.isOp() || player.hasPermission(us.tastybento.bskyblock.config.Settings.PERMPREFIX + "mod.removesign")) {
// Op or mod removed sign
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("warps.removed"));
removeWarp(s.getLocation());
@ -133,7 +132,7 @@ public class WarpSigns extends AddonHelper implements Listener {
if (title.equalsIgnoreCase(plugin.getLocale().get("warps.welcomeLine"))) {
//plugin.getLogger().info("DEBUG: Welcome sign detected");
// Welcome sign detected - check permissions
if (!(VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.addwarp"))) {
if (!(VaultHelper.hasPerm(player, us.tastybento.bskyblock.config.Settings.PERMPREFIX + "island.addwarp"))) {
Util.sendMessage(player, ChatColor.RED + plugin.getLocale(player.getUniqueId()).get("warps.error.no-permission"));
return;
}
@ -239,6 +238,9 @@ public class WarpSigns extends AddonHelper implements Listener {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (Entry<UUID, Location> en : warpList.entrySet()) {
plugin.getLogger().info("DEBUG: " + en.getKey() + " " + en.getValue());
}
Iterator<Entry<UUID, Location>> it = warpList.entrySet().iterator();
while (it.hasNext()) {
Entry<UUID, Location> en = it.next();
@ -280,7 +282,7 @@ public class WarpSigns extends AddonHelper implements Listener {
public void run() {
plugin.getWarpPanel().addWarp(playerUUID);
plugin.getWarpPanel().updatePanel();
Bukkit.getPluginManager().callEvent(new WarpCreateEvent(plugin, loc, playerUUID));
Bukkit.getPluginManager().callEvent(new WarpInitiateEvent(plugin, loc, playerUUID));
}});
return true;
}
@ -437,4 +439,5 @@ public class WarpSigns extends AddonHelper implements Listener {
return "";
}
}

View File

@ -1,95 +1,15 @@
package bskyblock.addin.warps.config;
import java.util.HashMap;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.material.MaterialData;
import bskyblock.addin.warps.Warp;
public class PluginConfig {
private static final boolean DEBUG = false;
/**
* Loads the various settings from the config.yml file into the plugin
*/
public PluginConfig(Warp plugin) {
plugin.saveDefaultConfig();
// Island level cool down time
Settings.levelWait = plugin.getConfig().getInt("levelwait", 60);
if (Settings.levelWait < 0) {
Settings.levelWait = 0;
}
// Get the under water multiplier
Settings.deathpenalty = plugin.getConfig().getInt("deathpenalty", 0);
Settings.sumTeamDeaths = plugin.getConfig().getBoolean("sumteamdeaths");
Settings.maxDeaths = plugin.getConfig().getInt("maxdeaths", 10);
Settings.islandResetDeathReset = plugin.getConfig().getBoolean("islandresetdeathreset", true);
Settings.teamJoinDeathReset = plugin.getConfig().getBoolean("teamjoindeathreset", true);
Settings.underWaterMultiplier = plugin.getConfig().getDouble("underwater", 1D);
Settings.levelCost = plugin.getConfig().getInt("levelcost", 100);
if (Settings.levelCost < 1) {
Settings.levelCost = 1;
plugin.getLogger().warning("levelcost in blockvalues.yml cannot be less than 1. Setting to 1.");
}
Settings.blockLimits = new HashMap<MaterialData, Integer>();
if (plugin.getConfig().isSet("limits")) {
for (String material : plugin.getConfig().getConfigurationSection("limits").getKeys(false)) {
try {
String[] split = material.split(":");
byte data = 0;
if (split.length>1) {
data = Byte.valueOf(split[1]);
}
Material mat;
if (StringUtils.isNumeric(split[0])) {
mat = Material.getMaterial(Integer.parseInt(split[0]));
} else {
mat = Material.valueOf(split[0].toUpperCase());
}
MaterialData materialData = new MaterialData(mat);
materialData.setData(data);
Settings.blockLimits.put(materialData, plugin.getConfig().getInt("limits." + material, 0));
if (DEBUG) {
plugin.getLogger().info("Maximum number of " + materialData + " will be " + Settings.blockLimits.get(materialData));
}
} catch (Exception e) {
plugin.getLogger().warning("Unknown material (" + material + ") in blockvalues.yml Limits section. Skipping...");
}
}
}
Settings.blockValues = new HashMap<MaterialData, Integer>();
if (plugin.getConfig().isSet("blocks")) {
for (String material : plugin.getConfig().getConfigurationSection("blocks").getKeys(false)) {
try {
String[] split = material.split(":");
byte data = 0;
if (split.length>1) {
data = Byte.valueOf(split[1]);
}
MaterialData materialData = null;
if (StringUtils.isNumeric(split[0])) {
materialData = new MaterialData(Integer.parseInt(split[0]));
} else {
materialData = new MaterialData(Material.valueOf(split[0].toUpperCase()));
}
materialData.setData(data);
Settings.blockValues.put(materialData, plugin.getConfig().getInt("blocks." + material, 0));
if (DEBUG) {
plugin.getLogger().info(materialData.toString() + " value = " + Settings.blockValues.get(materialData));
}
} catch (Exception e) {
// e.printStackTrace();
plugin.getLogger().warning("Unknown material (" + material + ") in blockvalues.yml blocks section. Skipping...");
}
}
} else {
plugin.getLogger().severe("No block values in blockvalues.yml! All island levels will be zero!");
}
Settings.warpLevelRestriction = plugin.getConfig().getInt("warplevelrestriction",10);
// All done
}
}

View File

@ -1,23 +1,6 @@
package bskyblock.addin.warps.config;
import java.util.HashMap;
import org.bukkit.material.MaterialData;
public class Settings {
public static String PERMPREFIX;
public static boolean sumTeamDeaths;
public static int seaHeight;
public static HashMap<MaterialData, Integer> blockLimits;
public static HashMap<MaterialData, Integer> blockValues;
public static double underWaterMultiplier;
public static int deathpenalty;
public static long levelCost;
public static Object defaultLanguage;
public static int levelWait;
public static int maxDeaths;
public static boolean islandResetDeathReset;
public static boolean teamJoinDeathReset;
public static int warpLevelRestriction;
}

View File

@ -0,0 +1,75 @@
package bskyblock.addin.warps.event;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import bskyblock.addin.warps.Warp;
/**
* This event is fired when a player tries to do a warp
* A Listener to this event can use it to get informations. e.g: broadcast something
*
* @author tastybento
*
*/
public class WarpInitiateEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Location warpLoc;
private final UUID player;
/**
* @param plugin
* @param warpLoc - where the player is warping to
* @param player - the UUID of the player
*/
public WarpInitiateEvent(Warp plugin, Location warpLoc, UUID player){
this.warpLoc = warpLoc;
this.player = player;
}
/**
* Get the location of the Warp
* @return created warp's location
*/
public Location getWarpLoc(){return this.warpLoc;}
/**
* Set a different location to where the player will go
* @param warpLoc
*/
public void setWarpLoc(Location warpLoc) {
this.warpLoc = warpLoc;
}
/**
* Get who is warping
* @return the warping player's uuid
*/
public UUID getPlayer(){return this.player;}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public boolean isCancelled() {
// TODO Auto-generated method stub
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}