Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
tastybento 2018-04-27 09:21:03 +09:00
commit a2a23d0771
26 changed files with 378 additions and 159 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
*.iml
/target
/.DS_Store
/.idea

275
locales/vi-VN.yml Normal file
View File

@ -0,0 +1,275 @@
###########################################################################################
# Đây là 1 file YML, hãy cẩn thận khi chỉnh sửa, nên dùng trang web dể kiểm tra n #
# cái này http://yaml-online-parser.appspot.com #
###########################################################################################
### Credits ###
# tastybento: Người cung cấp bản YML gốc
# Poslovitch: Người cung cấp bản YML gốc
#
# Banbeucmas: Người dịch bản YML gốc
# This translation is adapted to version : [alpha-2]
banner:
- "RED"
- "CREEPER:YELLOW"
- "RHOMBUS_MIDDLE:YELLOW"
- "TRIANGLES_BOTTOM:RED"
- "SQUARE_BOTTOM_LEFT:RED"
- "SQUARE_BOTTOM_RIGHT:RED"
general:
deaths: "Chết"
unlimited: "Vô hạn"
success: "&aThành công!"
errors:
command-cancelled: "&cĐã hủy lệnh"
no-permission: "&cBạn không có quyền thực thi lệnh này."
use-in-game: "&cLệnh này chỉ dùng được trong game."
no-team: "&cBạn không ở trong 1 đội nào cả!"
no-island: "&cBạn không có đảo!"
player-has-no-island: "&cNgười chơi đó không có đảo!"
already-have-island: "&cBạn đã có đảo!"
no-safe-location: "&cKhông có địa điểm an toàn nào trên đảo!"
not-leader: "&cBạn không phải đội trưởng!"
not-in-team: "&cNgười chơi không có trong đội!"
offline-player: "&cNgười chơi đang offline hoặc không tồn tại."
unknown-player: "&cNgười chơi không tìm thấy!"
general: "&cLệnh chưa sẵn sàng - hãy liên hệ admin"
warp-not-safe: "&cCổng dịch chuyển không an toàn!"
wrong-world: "&cBạn đang không ở trong thế giới có thể làm được việc này!"
tips:
changing-ob-to-lava: "Đang chuyển Hắc Diện Thạch về Dung Nham, hãy cẩn thận"
commands:
help:
header: "&7=========== &c%bsb_plugin_name% &7==========="
syntax: "&b[usage] &a[parameters]&7: &e[description]"
end: "&7================================="
parameters: "[command]"
description: "help command"
admin:
help:
description: "xem lệnh dành cho admin"
parameters: ""
version:
description: "Hiện phiên bản %bsb_plugin_name% và các bổ sung"
setrange:
parameters: "[player] [range]"
description: "Đặt giới hạn đảo người chơi"
range-updated: "Giới hạn đảo đã chuyển sang [number]"
reload:
description: "Nạp lại plugin"
tp:
parameters: "[player]"
description: "Dịch chuyển đến đảo người chơi"
manual: "&cKhông tìm thấy cổng dịch chuyển an toàn! Hãy tp tới địa điểm &b[location] &cvà kiểm tra"
island:
about:
description: "hiện thông tin về %bsb_plugin_name%"
go:
parameters: "<home number>"
description: "dịch chuyển tới đảo"
teleport: "&aĐang dịch chuyển. &b/[label] help &ađể được giúp đỡ."
teleported: "&aĐã dịch chuyển bạn tới khu vực nhà số &e#[number]."
help:
description: "Các lệnh chính"
spawn:
description: "dịch chuyển ra spawn"
create:
description: "tạo đảo"
unable-create-island: "Không thể khởi tạo đảo, hãy liên hệ admin."
creating-island: "Đang tạo đảo..."
info:
description: "hiện thông tin đảo của bạn"
reset:
description: "làm lại đảo của bạn"
must-remove-members: "Hãy đuổi toàn bộ thành viên trước khi khởi tạo lại đảo (/island kick <người chơi>)."
sethome:
description: "đặt bị trí dịch chuyển cho /island"
must-be-on-your-island: "Bạn phải ở trên đảo của bạn!"
num-homes: "Số nhà có thể đặt từ 1 đến [max]."
home-set: "Đã đặt vị trí nhà tại địa điểm hiện tại của bạn."
parameters: "<home number>"
setname:
description: "đặt tên đảo"
name-too-short: "&cQuá ngắn. Giới hạn thấp nhất là [length] kí tự."
name-too-long: "&cQuá dài. Giới hạn tối đa là [length] kí tự."
parameters: "<name>"
resetname:
description: "làm lại tên đảo"
team:
description: "quản lý đội"
info:
description: "hiện thông tin chi tiết về đội"
invite:
description: "mới người chơi đến đảo"
invitation-sent: "Đã gửi lời mời tới [name]"
removing-invite: "Đang bỏ lời bời"
name-has-invited-you: "[name] đã mời bạn vào đảo."
to-accept-or-reject: "Ghi /island team accept để chấp nhận, hay /island team reject để từ chối"
you-will-lose-your-island: "&cCẢNH BÁO! Bạn sẽ mất đảo nếu chấp nhận"
errors:
cannot-invite-self: "&cBạn không thể mới chính mình"
cooldown: "&cBạn không thế mời người khác trong [time] giây"
island-is-full: "&cĐảo đã đầy, không thể mời thêm"
none-invited-you: "&cKhông ai mời bạn :c."
you-already-are-in-team: "&cBạn đã ở trong 1 đội!"
already-on-team: "&cNgười chơi đó đã ở trong 1 đội!"
invalid-invite: "&cLời mời vô hiệu, xin lỗi."
parameters: "<player>"
you-can-invite: "Bạn có thể mời thêm [number] người."
accept:
description: "chấp nhận lời mời"
you-joined-island: "&aBạn đã tham gia đảo! Sử dụng /[label] team info để biết thêm thông tin."
name-joined-your-island: "&a[name] đã vào đảo của bạn!"
reject:
description: "từ chối lời mời"
you-rejected-invite: "&aBạn đã từ chối lời mời vào đảo."
name-rejected-your-invite: "&c[name] đã từ chối lời mời của bạn!"
cancel:
description: "hủy lời mời hiện tại"
leave:
description: "rời đảo"
type-again: "&cGõ lệnh rời đảo 1 lần nữa để xác nhận"
left-your-island: "&c[player] đã rời đảo"
kick:
description: "loại bỏ 1 người chơi khỏi đảo"
parameters: "<player>"
type-again: "&cHãy đánh lệnh loại bỏ 1 lần nữa để xác nhận"
leader-kicked: "&cĐội trưởng đã đuổi bạn ra khỏi đội!"
demote:
description: "hạ cấp bậc người chơi"
parameters: "<player>"
failure: "&cNgười chơi không thể hạ cấp thêm nữa"
success: "Đã hạ cấp [name] đến bậc [rank]"
promote:
description: "thăng chức người chơi"
parameters: "<player>"
failure: "&cKhông thể thăng chức nữa!"
success: "Đã thăng chức [name] lên bậc [rank]"
setowner:
description: "chuyển quyền sở hữu đảo"
errors:
cant-transfer-to-yourself: "&cBạn không thể chuyển quyền sở hữu cho chính mình"
target-is-not-member: "&cNgười chơi đó không phải là người trong đội!"
name-is-the-owner: "&a[name] giờ là chủ đảo!"
parameters: "<player>"
you-are-the-owner: "&aBạn giờ là chủ đảo!"
ban:
description: "cấm 1 người chơi khỏi đảo"
parameters: "<player>"
unban:
description: "bỏ cấm 1 người chơi khỏi đảo"
parameters: "<player>"
banlist:
description: "những người chơi bị cấm"
lock:
description: "khóa/bỏ khóa khả năng truy cập đảo của bạn"
settings:
description: "hiện cài đặt đảo"
language:
description: "chọn ngôn ngữ"
parameters: "<language>"
ranks:
owner: "Chủ"
member: "Thành Viên"
coop: "Đối tác"
visitor: "Khách"
banned: "Bị cấm"
protection:
protected: "&cĐã bảo vệ đảo!"
flags:
ANVIL:
name: "Đe"
description: "Tắt/bật tương tác với Đe"
ARMOR_STAND:
name: "Giá để giáp"
description: "Tắt/bật tương tác với giá để giáp"
BEACON:
name: "Beacons"
description: "Tắt/bật tương tác với beacons"
BED:
name: "Giường"
description: "Tắt/bật tương tác với giường"
BREAK_BLOCKS:
name: "Phá khối"
description: "Tắt/bật khả năng phá khối"
BREEDING:
name: "Giao phối"
description: "Tắt/bật khả năng giao phối của dộng vật"
BREWING:
name: "Brewing stands"
description: "Tắt/bật tương tác với brewing stands"
BUCKET:
name: "Xô"
description: "Tắt/bật tương tác với xô"
COLLECT_WATER:
name: "Lấy nước"
description: |
Tắt/bật khả năng lấy nước bằng xô
COLLECT_LAVA:
name: "Lấy dung nham"
description: |
Tắt/bật khả năng lấy nước bằng xô
CHORUS_FRUIT:
name: "Chorus fruits"
description: "Toggle teleportation using Chorus fruits"
CRAFTING: "Use crafting table"
CROP_TRAMPLE: "Trample crops"
DOOR: "Use doors"
ELYTRA: "Use elytras"
ENCHANTING: "Use enchanting table"
ENTER_EXIT_MESSAGES: "Display entry and exit messages"
FIRE: "FIRE"
FIRE_EXTINGUISH: "FIRE_EXTINGUISH"
FIRE_SPREAD: "FIRE_SPREAD"
FURNACE: "FURNACE"
GATE: "GATE"
HURT_ANIMALS: "HURT_ANIMALS"
HURT_MONSTERS: "HURT_MONSTERS"
HURT_VILLAGERS: "HURT_VILLAGERS"
ITEM_DROP: "ITEM_DROP"
ITEM_PICKUP: "ITEM_PICKUP"
LEASH: "LEASH"
MILKING: "MILKING"
MOB_SPAWN: "MOB_SPAWN"
MONSTER_SPAWN: "MONSTER_SPAWN"
MOUNT_INVENTORY: "MOUNT_INVENTORY"
RIDING: "RIDING"
MUSIC: "MUSIC"
CHEST: "CHEST"
PLACE_BLOCKS: "PLACE_BLOCKS"
PORTAL: "PORTAL"
PRESSURE_PLATE: "PRESSURE_PLATE"
PVP_OVERWORLD: "PVP_OVERWORLD"
PVP_NETHER: "PVP_NETHER"
PVP_END: "PVP_END"
REDSTONE: "REDSTONE"
SPAWN_EGGS: "SPAWN_EGGS"
SHEARING: "SHEARING"
EGGS: "EGGS"
TRADING: "TRADING"
panel:
title: "Island flags"
flag-item:
name-layout: "&a[name]"
description-layout: |+
&a[description]
&7Allowed for: &f[rank]
help-item:
name: "&aNeed some help?"
island:
locked: "&cThis island is locked!"
new-island:
sign:
line0: "&1%bsb_plugin_name%"
line1: "[player]"
line2: "Đừng rơi"
line3: "Vui vẻ &c<3"

View File

@ -63,7 +63,6 @@ public class BSkyBlock extends JavaPlugin {
settings = new Settings();
// Load settings from config.yml. This will check if there are any issues with it too.
try {
//settings.saveSettings();
settings = settings.loadSettings();
} catch (Exception e) {
getLogger().severe("Settings could not be loaded " + e.getMessage());
@ -282,8 +281,6 @@ public class BSkyBlock extends JavaPlugin {
return notifier;
}
/**
* @return the headGetter
*/

View File

@ -1,8 +1,8 @@
package us.tastybento.bskyblock;
/**
* All the plugin constants are here
* @author Tastybento
* Contains the plugin constants.
* @author tastybento
*/
public class Constants {
// ----------------- Constants -----------------
@ -10,17 +10,7 @@ public class Constants {
public enum GameType {
BSKYBLOCK, ACIDISLAND, BOTH
}
/*
public static final GameType GAMETYPE = GameType.ACIDISLAND;
// The spawn command (Essentials spawn for example)
public static final String SPAWNCOMMAND = "spawn";
// Permission prefix
public static final String PERMPREFIX = "acidisland.";
// The island command
public static final String ISLANDCOMMAND = "ai";
// Admin command
public static final String ADMINCOMMAND = "acid";
*/
public static final GameType GAMETYPE = GameType.BSKYBLOCK;
// Permission prefix
public static final String PERMPREFIX = "bskyblock.";

View File

@ -404,7 +404,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
if (cmd.hasSubCommmands()) {
// Check if subcommands are visible to this sender
for (CompositeCommand subCommand: cmd.getSubCommands().values()) {
if ((sender instanceof Player)) {
if (sender instanceof Player) {
// Player
if (subCommand.getPermission().isEmpty() || sender.hasPermission(subCommand.getPermission())) {
// Permission is okay
@ -419,7 +419,8 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
}
}
}
String lastArg = (args.length != 0 ? args[args.length - 1] : "");
String lastArg = args.length != 0 ? args[args.length - 1] : "";
return Util.tabLimit(options, lastArg);
}

View File

@ -9,7 +9,7 @@ public abstract class PremadeEvent extends Event {
@Override
public HandlerList getHandlers() {
return handlers;
return getHandlerList();
}
public static HandlerList getHandlerList() {

View File

@ -14,7 +14,7 @@ public class EntityDamageByAcidEvent extends IslandBaseEvent {
private final Entity entity;
private double damage;
public enum Acid { RAIN, WATER };
public enum Acid { RAIN, WATER }
private final Acid cause;
public EntityDamageByAcidEvent(Island island, Entity entity, double damage, Acid cause) {

View File

@ -28,7 +28,7 @@ public class IslandEvent {
RESETTED,
UNLOCK,
UNKNOWN
};
}
public static IslandEventBuilder builder() {
return new IslandEventBuilder();

View File

@ -26,7 +26,7 @@ public class TeamEvent {
DELETE,
UNKNOWN,
UNINVITE
};
}
public static TeamEventBuilder builder() {
return new TeamEventBuilder();

View File

@ -99,10 +99,8 @@ public class Flag implements Comparable<Flag> {
} else if (!id.equals(other.id)) {
return false;
}
if (type != other.type) {
return false;
}
return true;
return type == other.type;
}
public PanelItem toPanelItem(User user) {

View File

@ -28,7 +28,6 @@ public class PanelItem {
public PanelItem(ItemStack icon, String name, List<String> description, boolean glow, ClickHandler clickHandler, boolean playerHead) {
this.icon = icon;
this.playerHead = playerHead;
setMeta();
// Get the meta
meta = icon.getItemMeta();
@ -48,11 +47,6 @@ public class PanelItem {
icon.setItemMeta(meta);
}
private void setMeta() {
// TODO Auto-generated method stub
}
public ItemStack getItem() {
return icon;
}
@ -117,7 +111,6 @@ public class PanelItem {
public void setHead(ItemStack itemStack) {
this.icon = itemStack;
setMeta();
// Get the meta
meta = icon.getItemMeta();
// Create the final item

View File

@ -16,7 +16,7 @@ public class Notifier {
/**
* Time in seconds before {@link #notificationCache} removes the entry related to the player.
*/
private final int NOTIFICATION_DELAY = 5;
private static final int NOTIFICATION_DELAY = 5;
private final LoadingCache<User, Notification> notificationCache = CacheBuilder.newBuilder()
.expireAfterAccess(NOTIFICATION_DELAY, TimeUnit.SECONDS)

View File

@ -50,7 +50,7 @@ public abstract class AbstractDatabaseHandler<T> {
* Loads all the records in this table and returns a list of them
* @return list of <T>
*/
public abstract List<T> loadObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException;
public abstract List<T> loadObjects() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException;
/**
* Creates a <T> filled with values from the corresponding
@ -58,20 +58,20 @@ public abstract class AbstractDatabaseHandler<T> {
* @param uniqueId - unique ID
* @return <T>
*/
public abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException;
public abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException;
/**
* Save T into the corresponding database
*
* @param instance that should be inserted into the database
*/
public abstract void saveObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException ;
public abstract void saveObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ;
/**
* Deletes the object with the unique id from the database
* @param instance
*/
public abstract void deleteObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException ;
public abstract void deleteObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ;
/**
* Checks if a key exists or not

View File

@ -21,12 +21,12 @@ public class ConfigHandler<T> extends FlatFileDatabaseHandler<T> {
super(plugin, type, databaseConnecter);
}
public void saveSettings(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException {
public void saveSettings(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException {
configFlag = true;
saveObject(instance);
}
public T loadSettings(String uniqueId, T dbConfig) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IntrospectionException {
public T loadSettings(String uniqueId, T dbConfig) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException {
if (dbConfig == null) {
return loadObject(uniqueId);
}

View File

@ -8,7 +8,7 @@ public class FlatFileDatabase extends BSBDbSetup{
@Override
public AbstractDatabaseHandler<?> getHandler(Class<?> type) {
return new FlatFileDatabaseHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance(), null));
return new FlatFileDatabaseHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance()));
}
/**
@ -17,7 +17,7 @@ public class FlatFileDatabase extends BSBDbSetup{
* @return - the config handler
*/
public AbstractDatabaseHandler<?> getConfig(Class<?> type) {
return new ConfigHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance(), null));
return new ConfigHandler<>(BSkyBlock.getInstance(), type, new FlatFileDatabaseConnecter(BSkyBlock.getInstance()));
}
}

View File

@ -27,7 +27,7 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter {
private File dataFolder;
public FlatFileDatabaseConnecter(Plugin plugin, DatabaseConnectionSettingsImpl databaseConnectionSettingsImpl) {
public FlatFileDatabaseConnecter(Plugin plugin) {
this.plugin = plugin;
dataFolder = new File(plugin.getDataFolder(), DATABASE_FOLDER_NAME);
}

View File

@ -194,13 +194,6 @@ public class Island implements DataObject {
return levelHandicap;
}
/**
* @return true if the island is locked, otherwise false
*/
public boolean getLocked(){
return locked;
}
/**
* @return the members
*/
@ -294,13 +287,6 @@ public class Island implements DataObject {
return members.getOrDefault(user.getUniqueId(), RanksManager.VISITOR_RANK);
}
/**
* @return true if the island is the spawn otherwise false
*/
public boolean getSpawn(){
return spawn;
}
public Location getSpawnPoint() {
return spawnPoint;
}
@ -326,10 +312,8 @@ public class Island implements DataObject {
if (holder.getType().equals(Material.BURNING_FURNACE)) {
result++;
}
} else if (material.toString().endsWith("BANNER")) {
if (holder.getType().toString().endsWith("BANNER")) {
result++;
}
} else if (material.toString().endsWith("BANNER") && holder.getType().toString().endsWith("BANNER")) {
result++;
} else if (material.equals(Material.WALL_SIGN) || material.equals(Material.SIGN_POST)) {
if (holder.getType().equals(Material.WALL_SIGN) || holder.getType().equals(Material.SIGN_POST)) {
result++;
@ -519,9 +503,7 @@ public class Island implements DataObject {
* Resets the flags to their default as set in config.yml for this island
*/
public void setFlagsDefaults(){
/*for(SettingsFlag flag : SettingsFlag.values()){
this.flags.put(flag, Settings.defaultIslandSettings.get(flag));
}*/ //TODO default flags
//TODO default flags
}
/**
@ -650,9 +632,7 @@ public class Island implements DataObject {
* Resets the flags to their default as set in config.yml for the spawn
*/
public void setSpawnFlagsDefaults(){
/*for(SettingsFlag flag : SettingsFlag.values()){
this.flags.put(flag, Settings.defaultSpawnSettings.get(flag));
}*/ //TODO default flags
//TODO default flags
}
public void setSpawnPoint(Location location) {

View File

@ -232,7 +232,6 @@ public class Players implements DataObject {
Date kickedDate = new Date(kickedList.get(location));
Calendar coolDownTime = Calendar.getInstance();
coolDownTime.setTime(kickedDate);
// coolDownTime.add(Calendar.HOUR_OF_DAY, Settings.inviteWait);
coolDownTime.add(Calendar.MINUTE, getPlugin().getSettings().getInviteWait());
// Add the invite cooldown period
Calendar timeNow = Calendar.getInstance();

View File

@ -40,13 +40,13 @@ public class IslandBuilder {
private Island island;
private World world;
private IslandType type = IslandType.ISLAND;
//private List<String> companionNames = new ArrayList<>();
private List<ItemStack> chestItems;
//private List<Entity> companions = new ArrayList<>();
private UUID playerUUID;
private String playerName;
private BSkyBlock plugin;
//TODO support companions?
public IslandBuilder(BSkyBlock plugin, Island island) {
this.plugin = plugin;
this.island = island;
@ -208,8 +208,6 @@ public class IslandBuilder {
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
world.generateTree(treeLoc, TreeType.ACACIA);
// Place the cow
//Location location = new Location(world, x, (islandHeight + 5), z - 2);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
@ -295,8 +293,6 @@ public class IslandBuilder {
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
world.generateTree(treeLoc, TreeType.TREE);
// Place the cow
//Location location = new Location(world, x, (islandHeight + 5), z - 2);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
@ -373,18 +369,11 @@ public class IslandBuilder {
// Add island items
y = islandHeight;
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
treeLoc.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT);
world.generateTree(treeLoc, TreeType.TREE);
// Place the cow
//Location location = new Location(world, x, (islandHeight + 5), z - 2);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);
// Place the chest - no need to use the safe spawn function
// because we
// know what this island looks like
// because we know what this island looks like
placeChest(x, islandHeight + 5, z + 1);
}
@ -456,12 +445,8 @@ public class IslandBuilder {
// Add island items
y = islandHeight;
// Add tree (natural)
Location treeLoc = new Location(world, x, y + 5D, z);
world.spawnEntity(treeLoc, EntityType.ENDER_CRYSTAL);
//world.generateTree(treeLoc, TreeType.TREE);
// Place the cow
//Location location = new Location(world, x, (islandHeight + 5), z - 2);
// Spawn an ender crystal
world.spawnEntity(new Location(world, x, y + 5D, z), EntityType.ENDER_CRYSTAL);
// Place a helpful sign in front of player
placeSign(x, islandHeight + 5, z + 3);

View File

@ -16,6 +16,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.user.User;
import java.util.ArrayList;
import java.util.List;
/**
* Enables changing of obsidian back into lava
* @author tastybento
@ -25,7 +28,6 @@ public class ObsidianToLava implements Listener {
private BSkyBlock plugin;
/**
* @param plugin
*/
@ -33,7 +35,6 @@ public class ObsidianToLava implements Listener {
this.plugin = plugin;
}
/**
* Enables changing of obsidian back into lava
*
@ -54,18 +55,14 @@ public class ObsidianToLava implements Listener {
if (plugin.getIslands().playerIsOnIsland(user)) {
// Look around to see if this is a lone obsidian block
Block b = e.getClickedBlock();
for (int x = -2; x <= 2; x++) {
for (int y = -2; y <= 2; y++) {
for (int z = -2; z <= 2; z++) {
Material testBlock = b.getWorld().getBlockAt(b.getX() + x, b.getY() + y, b.getZ() + z).getType();
if ((x != 0 || y != 0 || z != 0) && testBlock.equals(Material.OBSIDIAN)) {
// Do nothing special
return false;
}
}
for (Block testBlock : getBlocksAround(b)) {
if (testBlock.getType().equals(Material.OBSIDIAN)) {
// Do nothing special
return false;
}
}
user.sendMessage("general.tips.changing-ob-to-lava");
e.getItem().setType(Material.LAVA_BUCKET);
e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ITEM_BUCKET_FILL_LAVA, 1F, 1F);
@ -76,4 +73,20 @@ public class ObsidianToLava implements Listener {
return false;
}
private List<Block> getBlocksAround(Block b) {
List<Block> blocksAround = new ArrayList<>();
for (int x = -2; x <= 2; x++) {
for (int y = -2; y <= 2; y++) {
for (int z = -2; z <= 2; z++) {
blocksAround.add(b.getWorld().getBlockAt(b.getX() + x, b.getY() + y, b.getZ() + z));
}
}
}
// Remove the block at x = 0, y = 0 and z = 0 (which is the base block)
blocksAround.remove(b);
return blocksAround;
}
}

View File

@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffect;
import us.tastybento.bskyblock.api.flags.Flag;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.lists.Flags;
/**
* TODO: PVP is different to other flags - it's either allowed for everyone or not allowed for everyone. Currently owners can hit visitors.
@ -42,11 +43,11 @@ public class PVPListener extends AbstractFlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player) {
Flag flag = us.tastybento.bskyblock.lists.Flags.PVP_OVERWORLD;
Flag flag = Flags.PVP_OVERWORLD;
if (e.getEntity().getWorld().equals(getPlugin().getIslandWorldManager().getNetherWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_NETHER;
flag = Flags.PVP_NETHER;
} else if (e.getEntity().getWorld().equals(getPlugin().getIslandWorldManager().getEndWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_END;
flag = Flags.PVP_END;
}
respond(e, e.getDamager(), flag);
}
@ -72,11 +73,11 @@ public class PVPListener extends AbstractFlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFishing(PlayerFishEvent e) {
if (e.getCaught() != null && e.getCaught() instanceof Player) {
Flag flag = us.tastybento.bskyblock.lists.Flags.PVP_OVERWORLD;
Flag flag = Flags.PVP_OVERWORLD;
if (e.getCaught().getWorld().equals(getPlugin().getIslandWorldManager().getNetherWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_NETHER;
flag = Flags.PVP_NETHER;
} else if (e.getCaught().getWorld().equals(getPlugin().getIslandWorldManager().getEndWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_END;
flag = Flags.PVP_END;
}
if (checkIsland(e, e.getCaught().getLocation(), flag)) {
e.getHook().remove();
@ -91,11 +92,11 @@ public class PVPListener extends AbstractFlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onSplashPotionSplash(final PotionSplashEvent e) {
// Deduce the world
Flag flag = us.tastybento.bskyblock.lists.Flags.PVP_OVERWORLD;
Flag flag = Flags.PVP_OVERWORLD;
if (e.getPotion().getWorld().equals(getPlugin().getIslandWorldManager().getNetherWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_NETHER;
flag = Flags.PVP_NETHER;
} else if (e.getPotion().getWorld().equals(getPlugin().getIslandWorldManager().getEndWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_END;
flag = Flags.PVP_END;
}
// Try to get the thrower
@ -125,7 +126,7 @@ public class PVPListener extends AbstractFlagListener {
// Try to get the shooter
Projectile projectile = e.getEntity();
if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
UUID uuid = ((Player) projectile.getShooter()).getUniqueId();
// Store it and remove it when the effect is gone
thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> thrownPotions.remove(e.getAreaEffectCloud().getEntityId()), e.getAreaEffectCloud().getDuration());
@ -140,11 +141,11 @@ public class PVPListener extends AbstractFlagListener {
if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
// Deduce the world
Flag flag = us.tastybento.bskyblock.lists.Flags.PVP_OVERWORLD;
Flag flag = Flags.PVP_OVERWORLD;
if (e.getEntity().getWorld().equals(getPlugin().getIslandWorldManager().getNetherWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_NETHER;
flag = Flags.PVP_NETHER;
} else if (e.getEntity().getWorld().equals(getPlugin().getIslandWorldManager().getEndWorld())) {
flag = us.tastybento.bskyblock.lists.Flags.PVP_END;
flag = Flags.PVP_END;
}
UUID attacker = thrownPotions.get(e.getDamager().getEntityId());

View File

@ -68,7 +68,7 @@ public class FlyingMobEvents implements Listener {
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void mobSpawn(CreatureSpawnEvent e) {
public void onMobSpawn(CreatureSpawnEvent e) {
// Only cover withers in the island world
if (!Util.inWorld(e.getEntity())) {
return;
@ -81,7 +81,7 @@ public class FlyingMobEvents implements Listener {
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void mobExplosion(EntityExplodeEvent e) {
public void onMobExplosion(EntityExplodeEvent e) {
// Only cover in the island world
if (e.getEntity() == null || !Util.inWorld(e.getEntity())) {
return;
@ -100,7 +100,7 @@ public class FlyingMobEvents implements Listener {
* Deal with pre-explosions
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void witherExplode(ExplosionPrimeEvent e) {
public void onWitherExplode(ExplosionPrimeEvent e) {
// Only cover withers in the island world
if (!Util.inWorld(e.getEntity()) || e.getEntity() == null) {
return;
@ -115,7 +115,6 @@ public class FlyingMobEvents implements Listener {
e.setCancelled(true);
}
}
// Testing only e.setCancelled(true);
}
if (e.getEntityType() == EntityType.WITHER_SKULL) {
// Get shooter
@ -140,7 +139,7 @@ public class FlyingMobEvents implements Listener {
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void witherChangeBlocks(EntityChangeBlockEvent e) {
public void onWitherChangeBlocks(EntityChangeBlockEvent e) {
// Only cover withers in the island world
if (e.getEntityType() != EntityType.WITHER || !Util.inWorld(e.getEntity()) ) {
return;
@ -158,7 +157,7 @@ public class FlyingMobEvents implements Listener {
* Clean up the hashmap. It's probably not needed, but just in case.
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void mobDeath(EntityDeathEvent e) {
public void onMobDeath(EntityDeathEvent e) {
mobSpawnInfo.remove(e.getEntity());
}
}

View File

@ -117,12 +117,12 @@ public final class AddonsManager {
YamlConfiguration data = new YamlConfiguration();
data.load(reader);
// Load the addon
AddonClassLoader loader = new AddonClassLoader(this, data, f, this.getClass().getClassLoader());
AddonClassLoader addonClassLoader = new AddonClassLoader(this, data, f, this.getClass().getClassLoader());
// Add to the list of loaders
this.loader.add(loader);
loader.add(addonClassLoader);
// Get the addon itself
addon = loader.getAddon();
addon = addonClassLoader.getAddon();
// Initialize some settings
addon.setDataFolder(new File(f.getParent(), addon.getDescription().getName()));
addon.setAddonFile(f);
@ -163,12 +163,12 @@ public final class AddonsManager {
addons.forEach(addon -> {
addon.onDisable();
Bukkit.getPluginManager().callEvent(AddonEvent.builder().addon(addon).reason(AddonEvent.Reason.DISABLE).build());
System.out.println("Disabling " + addon.getDescription().getName() + "...");
plugin.getLogger().info("Disabling " + addon.getDescription().getName() + "...");
});
loader.forEach(loader -> {
loader.forEach(l -> {
try {
loader.close();
l.close();
} catch (IOException e) {
// Do nothing
}
@ -187,7 +187,6 @@ public final class AddonsManager {
this.loader = loader;
}
/**
* Finds a class by name that has been loaded by this loader
* Code copied from Bukkit JavaPluginLoader
@ -200,9 +199,9 @@ public final class AddonsManager {
if (cachedClass != null) {
return cachedClass;
} else {
for (AddonClassLoader loader : loader) {
for (AddonClassLoader l : loader) {
try {
cachedClass = loader.findClass(name, false);
cachedClass = l.findClass(name, false);
} catch (ClassNotFoundException cnfe) {}
if (cachedClass != null) {
return cachedClass;
@ -237,7 +236,7 @@ public final class AddonsManager {
* @return a list of files
- if the file cannot be read
*/
public List<String> listJarYamlFiles(JarFile jar, String folderPath) throws IOException {
public List<String> listJarYamlFiles(JarFile jar, String folderPath) {
List<String> result = new ArrayList<>();
/**

View File

@ -727,14 +727,12 @@ public class IslandsManager {
homeTeleport(player);
} else {
// Move player to spawn
Island spawn = getSpawn();
if (spawn != null) {
// go to island spawn
player.teleport(plugin.getIslandWorldManager().getIslandWorld().getSpawnLocation());
} else {
if (!player.performCommand(Constants.SPAWNCOMMAND)) {
plugin.getLogger().warning(()->
"During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry.");
plugin.getLogger().warning(()-> "During island deletion player " + player.getName() + " could not be sent to spawn so was dropped, sorry.");
}
}
}

View File

@ -59,10 +59,7 @@ public class LocalesManager {
// Describe the filter - we only want files that are correctly named
FilenameFilter ymlFilter = (dir, name) -> {
// Files must be 9 chars long
if (name.toLowerCase().endsWith(".yml") && name.length() == 9) {
return true;
}
return false;
return name.toLowerCase().endsWith(".yml") && name.length() == 9;
};
// Run through the files and store the locales

View File

@ -74,29 +74,24 @@ public class SafeSpotTeleport {
checking = true;
// Start a recurring task until done or cancelled
task = plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() {
@Override
public void run() {
List<ChunkSnapshot> chunkSnapshot = new ArrayList<>();
if (checking) {
Iterator<Pair<Integer, Integer>> it = chunksToScan.iterator();
if (!it.hasNext()) {
// Nothing left
tidyUp(entity, failureMessage);
return;
}
// Add chunk snapshots to the list
while (it.hasNext() && chunkSnapshot.size() < MAX_CHUNKS) {
Pair<Integer, Integer> pair = it.next();
chunkSnapshot.add(location.getWorld().getChunkAt(pair.x, pair.z).getChunkSnapshot());
it.remove();
}
// Move to next step
checking = false;
checkChunks(chunkSnapshot);
task = plugin.getServer().getScheduler().runTaskTimer(plugin, () -> {
List<ChunkSnapshot> chunkSnapshot = new ArrayList<>();
if (checking) {
Iterator<Pair<Integer, Integer>> it = chunksToScan.iterator();
if (!it.hasNext()) {
// Nothing left
tidyUp(entity, failureMessage);
return;
}
// Add chunk snapshots to the list
while (it.hasNext() && chunkSnapshot.size() < MAX_CHUNKS) {
Pair<Integer, Integer> pair = it.next();
chunkSnapshot.add(location.getWorld().getChunkAt(pair.x, pair.z).getChunkSnapshot());
it.remove();
}
// Move to next step
checking = false;
checkChunks(chunkSnapshot);
}
}, 0L, SPEED);
}
@ -119,8 +114,6 @@ public class SafeSpotTeleport {
/**
* Gets a set of chunk coords that will be scanned.
* @param entity
* @param location - the location
* @return
*/
private List<Pair<Integer, Integer>> getChunksToScan() {