mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 02:35:21 +01:00
Removed unused imports.
Added configs.
This commit is contained in:
parent
92ceaff1d2
commit
87ab500706
27
config.yml
27
config.yml
@ -48,11 +48,12 @@ general:
|
||||
|
||||
### Database-related Settings ###
|
||||
database:
|
||||
# FLATFILE, MYSQL, SQLITE
|
||||
# FLATFILE, MYSQL
|
||||
type: FLATFILE
|
||||
|
||||
mysql: 0 #TODO
|
||||
sqlite: 0 #TODO
|
||||
port: 3306
|
||||
name: BSkyBlock
|
||||
username: username
|
||||
password: password
|
||||
|
||||
# How often the data will be saved to file in mins. Default is 5 minutes.
|
||||
# This helps prevent issues if the server crashes.
|
||||
@ -95,18 +96,16 @@ general:
|
||||
world:
|
||||
# Name of the world - if it does not exist then it will be generated.
|
||||
# It acts like a prefix for nether and end (e.g. BSkyBlock, BSkyBlock_nether, BSkyBlock_end)
|
||||
world-name: BSkyBlock
|
||||
world-name: BSkyBlock_world
|
||||
|
||||
# Distance between islands in blocks - NEVER change this mid-game.
|
||||
# Distance between islands in blocks IN CHUNKS (1 chunk = 16 blocks)
|
||||
# It is the same for every dimension : Overworld, Nether and End.
|
||||
# Values for a new world:
|
||||
# 400 - puts players distance enough that they usually cannot see each other
|
||||
# 200 - allows some expansion of the protected zone (recommended)
|
||||
# 110 - for compatibility with established worlds. Cozy.
|
||||
# 50 - minimum - not recommended
|
||||
# IF YOU ARE UPGRADING YOU MUST USE YOUR OLD VALUE EXACTLY (E.G.: 110), OR RESET YOUR WORLD
|
||||
# Value must be an even number (must end with 0, 2, 4, 6, 8)
|
||||
distance: 200
|
||||
# Recommended values for a new world:
|
||||
# 24 - puts players distance enough that they usually cannot see each other
|
||||
# 12 - allows some expansion of the protected zone (recommended)
|
||||
# 4 - minimum - not recommended
|
||||
# IF YOU ARE UPGRADING YOU MUST USE YOUR OLD VALUE EXACTLY (E.G.: 24), OR RESET YOUR WORLD
|
||||
distance-in-chunks: 24
|
||||
|
||||
# Default protection range (even number). Min = 0, Recommended = 100
|
||||
# Larger values will take longer to calculate the island level
|
||||
|
Binary file not shown.
@ -22,7 +22,6 @@ import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.managers.IslandsManager;
|
||||
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages;
|
||||
import us.tastybento.bskyblock.database.managers.PlayersManager;
|
||||
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
|
||||
import us.tastybento.bskyblock.generators.IslandWorld;
|
||||
import us.tastybento.bskyblock.listeners.JoinLeaveListener;
|
||||
import us.tastybento.bskyblock.listeners.NetherPortals;
|
||||
@ -64,15 +63,6 @@ public class BSkyBlock extends JavaPlugin{
|
||||
|
||||
// Load configuration and locales. If there are no errors, load the plugin.
|
||||
if(PluginConfig.loadPluginConfig(this)){
|
||||
// TEMP DEBUG DATABASE
|
||||
/*
|
||||
Settings.databaseType = DatabaseType.MYSQL;
|
||||
Settings.dbHost = "localhost";
|
||||
Settings.dbPort = 3306;
|
||||
Settings.dbName = "ASkyBlock";
|
||||
Settings.dbUsername = "username";
|
||||
Settings.dbPassword = "password";
|
||||
*/
|
||||
playersManager = new PlayersManager(this);
|
||||
islandsManager = new IslandsManager(this);
|
||||
// Only load metrics if set to true in config
|
||||
@ -101,51 +91,8 @@ public class BSkyBlock extends JavaPlugin{
|
||||
@Override
|
||||
public void run() {
|
||||
// Create the world if it does not exist
|
||||
// TODO: All these settings are placeholders and need to come from config.yml
|
||||
Settings.worldName = "BSkyBlock_world";
|
||||
Settings.createNether = true;
|
||||
Settings.createEnd = true;
|
||||
Settings.islandNether = true;
|
||||
Settings.islandEnd = false;
|
||||
Settings.limitedBlocks = new HashMap<String, Integer>();
|
||||
Settings.defaultWorldSettings = new HashMap<SettingsFlag, Boolean>();
|
||||
for (SettingsFlag flag: SettingsFlag.values()) {
|
||||
Settings.defaultWorldSettings.put(flag, false);
|
||||
}
|
||||
Settings.defaultWorldSettings.put(SettingsFlag.ANIMAL_SPAWN, true);
|
||||
Settings.defaultWorldSettings.put(SettingsFlag.MONSTER_SPAWN, true);
|
||||
new IslandWorld(plugin);
|
||||
|
||||
// Test: Create a random island and save it
|
||||
// TODO: ideally this should be in a test class!
|
||||
/*
|
||||
UUID owner = UUID.fromString("ddf561c5-72b6-4ec6-a7ea-8b50a893beb2");
|
||||
|
||||
Island island = islandsManager.createIsland(new Location(getServer().getWorld("world"),0,0,0,0,0), owner);
|
||||
// Add members
|
||||
Set<UUID> randomSet = new HashSet<UUID>();
|
||||
island.addMember(owner);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
randomSet.add(UUID.randomUUID());
|
||||
island.addMember(UUID.randomUUID());
|
||||
island.addToBanList(UUID.randomUUID());
|
||||
}
|
||||
island.setBanned(randomSet);
|
||||
island.setCoops(randomSet);
|
||||
island.setTrustees(randomSet);
|
||||
island.setMembers(randomSet);
|
||||
for (SettingsFlag flag: SettingsFlag.values()) {
|
||||
island.setFlag(flag, true);
|
||||
}
|
||||
island.setLocked(true);
|
||||
island.setName("new name");
|
||||
island.setPurgeProtected(true);
|
||||
islandsManager.save(false);
|
||||
|
||||
|
||||
getLogger().info("DEBUG: ************ Finished saving, now loading *************");
|
||||
|
||||
*/
|
||||
// Load islands from database
|
||||
islandsManager.load();
|
||||
|
||||
// Load schematics
|
||||
|
@ -22,7 +22,7 @@ public class NotSetup implements CommandExecutor{
|
||||
DIFFERENT_ISLAND_DISTANCE(0, 002),
|
||||
PROTECTION_RANGE_HIGHER_THAN_ISLAND_DISTANCE(1, 101),
|
||||
UNKNOWN_LANGUAGE(2, 201),
|
||||
NOT_EVEN_ISLAND_DISTANCE(2, 202),
|
||||
NOT_CHUNK_ISLAND_DISTANCE(2, 202),
|
||||
NOT_EVEN_PROTECTION_RANGE(2, 203),
|
||||
PURGE_ISLAND_LEVEL_TOO_LOW(3, 301),
|
||||
ISLAND_DISTANCE_TOO_LOW(3, 302),
|
||||
|
@ -4,6 +4,8 @@ import java.util.HashMap;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.config.NotSetup.ConfigError;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
|
||||
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
|
||||
|
||||
/**
|
||||
* Loads the plugin configuration and the locales.
|
||||
@ -19,13 +21,8 @@ public class PluginConfig {
|
||||
* If there were errors, it setups the commands as "NotSetup" and generates a debug for admins to fix their configuration.
|
||||
* @return true if there wasn't any error, otherwise false.
|
||||
*/
|
||||
public static boolean loadPluginConfig(BSkyBlock plugin){
|
||||
// Check if the config exists. It shouldn't happen, but the stack trace helps to know why.
|
||||
try{
|
||||
plugin.getConfig();
|
||||
} catch (Exception exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
public static boolean loadPluginConfig(BSkyBlock plugin) {
|
||||
plugin.saveDefaultConfig();
|
||||
|
||||
// Initialize the errors list
|
||||
HashMap<ConfigError, Object> errors = new HashMap<ConfigError, Object>();
|
||||
@ -51,7 +48,26 @@ public class PluginConfig {
|
||||
if(Settings.purgeMaxIslandLevel < 0) errors.put(ConfigError.PURGE_ISLAND_LEVEL_TOO_LOW, Settings.purgeMaxIslandLevel);
|
||||
Settings.purgeRemoveUserData = plugin.getConfig().getBoolean("general.purge.remove-user-data", false);
|
||||
|
||||
// TODO Database
|
||||
// Database
|
||||
String dbType = plugin.getConfig().getString("general.database.type","FLATFILE");
|
||||
boolean found = false;
|
||||
for (DatabaseType type: DatabaseType.values()) {
|
||||
if (type.name().equals(dbType.toUpperCase())) {
|
||||
Settings.databaseType = type;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
plugin.getLogger().severe("Database type not found! Using FLATFILE");
|
||||
Settings.databaseType = DatabaseType.FLATFILE;
|
||||
}
|
||||
Settings.dbHost = plugin.getConfig().getString("general.database.host", "localhost");
|
||||
Settings.dbPort = plugin.getConfig().getInt("general.database.port",3306);
|
||||
Settings.dbName = plugin.getConfig().getString("general.database.name", "BSkyBlock");
|
||||
Settings.dbUsername = plugin.getConfig().getString("general.database.username");
|
||||
Settings.dbPassword = plugin.getConfig().getString("general.database.password");
|
||||
|
||||
|
||||
Settings.recoverSuperFlat = plugin.getConfig().getBoolean("general.recover-super-flat", false);
|
||||
Settings.muteDeathMessages = plugin.getConfig().getBoolean("general.mute-death-messages", false);
|
||||
@ -65,14 +81,14 @@ public class PluginConfig {
|
||||
Settings.acidBlockedCommands = plugin.getConfig().getStringList("general.allow-teleport.acid-blocked-commands");
|
||||
|
||||
// ********************* World *********************
|
||||
Settings.worldName = plugin.getConfig().getString("world.world-name", "BSkyBlock");
|
||||
Settings.worldName = plugin.getConfig().getString("world.world-name", "BSkyBlock_world");
|
||||
//TODO check if it is the same than before
|
||||
|
||||
Settings.islandDistance = plugin.getConfig().getInt("world.distance", 200);
|
||||
// TODO check if it is the same than before
|
||||
if(Settings.islandDistance % 2 != 0) errors.put(ConfigError.NOT_EVEN_ISLAND_DISTANCE, Settings.islandDistance);
|
||||
if(Settings.islandDistance < 50) errors.put(ConfigError.ISLAND_DISTANCE_TOO_LOW, Settings.islandDistance);
|
||||
|
||||
int distance = plugin.getConfig().getInt("world.distance-in-chunks", 24);
|
||||
// TODO this is an arbitrary number
|
||||
Settings.islandDistance = distance * 16;
|
||||
if(distance < 50) errors.put(ConfigError.ISLAND_DISTANCE_TOO_LOW, Settings.islandDistance);
|
||||
|
||||
Settings.islandProtectionRange = plugin.getConfig().getInt("world.protection-range", 100);
|
||||
if(Settings.islandProtectionRange % 2 != 0) errors.put(ConfigError.NOT_EVEN_PROTECTION_RANGE, Settings.islandProtectionRange);
|
||||
if(Settings.islandProtectionRange < 0) errors.put(ConfigError.PROTECTION_RANGE_TOO_LOW, Settings.islandProtectionRange);
|
||||
@ -97,7 +113,17 @@ public class PluginConfig {
|
||||
if(Settings.netherSpawnRadius < 0) errors.put(ConfigError.NETHER_SPAWN_RADIUS_TOO_LOW, Settings.netherSpawnRadius);
|
||||
if(Settings.netherSpawnRadius > 100) errors.put(ConfigError.NETHER_SPAWN_RADIUS_TOO_HIGH, Settings.netherSpawnRadius);
|
||||
}
|
||||
|
||||
// TODO: add to config
|
||||
Settings.endGenerate = true;
|
||||
Settings.endIslands = false;
|
||||
Settings.limitedBlocks = new HashMap<String, Integer>();
|
||||
Settings.defaultWorldSettings = new HashMap<SettingsFlag, Boolean>();
|
||||
for (SettingsFlag flag: SettingsFlag.values()) {
|
||||
Settings.defaultWorldSettings.put(flag, false);
|
||||
}
|
||||
Settings.defaultWorldSettings.put(SettingsFlag.ANIMAL_SPAWN, true);
|
||||
Settings.defaultWorldSettings.put(SettingsFlag.MONSTER_SPAWN, true);
|
||||
|
||||
// Entities
|
||||
|
||||
//TODO end loading
|
||||
|
@ -199,15 +199,11 @@ public class Settings {
|
||||
public static String dbUsername;
|
||||
public static String dbPassword;
|
||||
|
||||
public static boolean createNether;
|
||||
|
||||
public static boolean useOwnGenerator;
|
||||
|
||||
public static boolean islandNether;
|
||||
public static boolean endGenerate;
|
||||
|
||||
public static boolean createEnd;
|
||||
|
||||
public static boolean islandEnd;
|
||||
public static boolean endIslands;
|
||||
public static boolean resetMoney;
|
||||
public static double acidDamage;
|
||||
public static int islandXOffset;
|
||||
|
@ -15,13 +15,15 @@
|
||||
package us.tastybento.bskyblock.config;
|
||||
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.enumeration;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.util.AbstractMap.SimpleImmutableEntry;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.enumeration;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -30,7 +32,6 @@ import java.util.Map.Entry;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
/**
|
||||
* An abstract class that handles insert/select-operations into/from a database
|
||||
|
@ -467,10 +467,10 @@ public class IslandsManager {
|
||||
if (loc.getWorld().equals(IslandWorld.getIslandWorld())) {
|
||||
return true;
|
||||
}
|
||||
if (Settings.islandNether && loc.getWorld().equals(IslandWorld.getNetherWorld())) {
|
||||
if (Settings.netherIslands && loc.getWorld().equals(IslandWorld.getNetherWorld())) {
|
||||
return true;
|
||||
}
|
||||
if (Settings.islandEnd && loc.getWorld().equals(IslandWorld.getEndWorld())) {
|
||||
if (Settings.endIslands && loc.getWorld().equals(IslandWorld.getEndWorld())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -538,7 +538,8 @@ public class IslandsManager {
|
||||
*/
|
||||
public boolean homeTeleport(final Player player, int number) {
|
||||
Location home = null;
|
||||
plugin.getLogger().info("home teleport called for #" + number);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("home teleport called for #" + number);
|
||||
home = getSafeHomeLocation(player.getUniqueId(), number);
|
||||
//plugin.getLogger().info("home get safe loc = " + home);
|
||||
// Check if the player is a passenger in a boat
|
||||
@ -553,12 +554,14 @@ public class IslandsManager {
|
||||
}
|
||||
}
|
||||
if (home == null) {
|
||||
plugin.getLogger().info("Fixing home location using safe spot teleport");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("Fixing home location using safe spot teleport");
|
||||
// Try to fix this teleport location and teleport the player if possible
|
||||
new SafeSpotTeleport(plugin, player, plugin.getPlayers().getHomeLocation(player.getUniqueId(), number), number);
|
||||
return true;
|
||||
}
|
||||
plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
|
||||
//home.getChunk().load();
|
||||
player.teleport(home);
|
||||
//player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
|
||||
@ -883,7 +886,7 @@ public class IslandsManager {
|
||||
//plugin.getLogger().info("DEBUG: pasting schematic " + schematic.getName() + " " + schematic.getPerm());
|
||||
//plugin.getLogger().info("DEBUG: nether world is " + BSkyBlock.getNetherWorld());
|
||||
// Paste the starting island. If it is a HELL biome, then we start in the Nether
|
||||
if (Settings.createNether && schematic.isInNether() && Settings.islandNether && IslandWorld.getNetherWorld() != null) {
|
||||
if (Settings.netherGenerate && schematic.isInNether() && Settings.netherIslands && IslandWorld.getNetherWorld() != null) {
|
||||
// Nether start
|
||||
// Paste the overworld if it exists
|
||||
if (!schematic.getPartnerName().isEmpty()) {
|
||||
@ -904,7 +907,7 @@ public class IslandsManager {
|
||||
//double diff = (System.nanoTime() - timer)/1000000;
|
||||
//plugin.getLogger().info("DEBUG: nano time = " + diff + " ms");
|
||||
//plugin.getLogger().info("DEBUG: pasted overworld");
|
||||
if (Settings.createNether && Settings.islandNether && IslandWorld.getNetherWorld() != null) {
|
||||
if (Settings.netherGenerate && Settings.netherIslands && IslandWorld.getNetherWorld() != null) {
|
||||
// Paste the other world schematic
|
||||
final Location netherLoc = next.toVector().toLocation(IslandWorld.getNetherWorld());
|
||||
if (schematic.getPartnerName().isEmpty()) {
|
||||
@ -1227,7 +1230,7 @@ public class IslandsManager {
|
||||
if (plugin.getPlayers().hasIsland(player.getUniqueId()) || plugin.getPlayers().inTeam(player.getUniqueId())) {
|
||||
islandTestLocations.add(plugin.getIslands().getIslandLocation(player.getUniqueId()));
|
||||
// If new Nether
|
||||
if (Settings.createNether && Settings.islandNether && IslandWorld.getNetherWorld() != null) {
|
||||
if (Settings.netherGenerate && Settings.netherIslands && IslandWorld.getNetherWorld() != null) {
|
||||
islandTestLocations.add(netherIsland(plugin.getIslands().getIslandLocation(player.getUniqueId())));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import us.tastybento.bskyblock.util.VaultHelper;
|
||||
|
||||
public class PlayersManager{
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
private BSkyBlock plugin;
|
||||
private BSBDatabase database;
|
||||
private AbstractDatabaseHandler<Players> handler;
|
||||
@ -608,7 +609,8 @@ public class PlayersManager{
|
||||
Players player = playerCache.get(playerUUID);
|
||||
try {
|
||||
handler.saveObject(player);
|
||||
plugin.getLogger().info("DEBUG: " + playerUUID + " saved");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: " + playerUUID + " saved");
|
||||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | SecurityException
|
||||
| InstantiationException | NoSuchMethodException
|
||||
@ -617,7 +619,8 @@ public class PlayersManager{
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().info("DEBUG: " + playerUUID + " is not in the cache to save");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: " + playerUUID + " is not in the cache to save");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ public class IslandWorld {
|
||||
islandWorld = WorldCreator.name(Settings.worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld())
|
||||
.createWorld();
|
||||
// Make the nether if it does not exist
|
||||
if (Settings.createNether) {
|
||||
if (Settings.netherGenerate) {
|
||||
if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) {
|
||||
Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether...");
|
||||
}
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
|
||||
} else {
|
||||
netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld())
|
||||
@ -45,11 +45,11 @@ public class IslandWorld {
|
||||
}
|
||||
}
|
||||
// Make the end if it does not exist
|
||||
if (Settings.createEnd) {
|
||||
if (Settings.endGenerate) {
|
||||
if (plugin.getServer().getWorld(Settings.worldName + "_the_end") == null) {
|
||||
Bukkit.getLogger().info("Creating " + plugin.getName() + "'s End World...");
|
||||
}
|
||||
if (!Settings.islandEnd) {
|
||||
if (!Settings.endIslands) {
|
||||
endWorld = WorldCreator.name(Settings.worldName + "_the_end").type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
|
||||
} else {
|
||||
endWorld = WorldCreator.name(Settings.worldName + "_the_end").type(WorldType.FLAT).generator(new ChunkGeneratorWorld())
|
||||
@ -70,13 +70,13 @@ public class IslandWorld {
|
||||
"mv modify set generator " + plugin.getName() + " " + Settings.worldName)) {
|
||||
Bukkit.getLogger().severe("Multiverse is out of date! - Upgrade to latest version!");
|
||||
}
|
||||
if (netherWorld != null && Settings.createNether && Settings.islandNether) {
|
||||
if (netherWorld != null && Settings.netherGenerate && Settings.netherIslands) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv import " + Settings.worldName + "_nether nether -g " + plugin.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv modify set generator " + plugin.getName() + " " + Settings.worldName + "_nether");
|
||||
}
|
||||
if (endWorld != null && Settings.createEnd && Settings.islandEnd) {
|
||||
if (endWorld != null && Settings.endGenerate && Settings.endIslands) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv import " + Settings.worldName + "_the_end end -g " + plugin.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
|
@ -42,7 +42,8 @@ public class JoinLeaveListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (plugin.getPlayers().isAKnownPlayer(playerUUID)) {
|
||||
plugin.getLogger().info("DEBUG: known player");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: known player");
|
||||
// Load player
|
||||
players.addPlayer(playerUUID);
|
||||
// Reset resets if the admin changes it to or from unlimited
|
||||
@ -82,10 +83,11 @@ public class JoinLeaveListener implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().info("DEBUG: not a known player");
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: not a known player");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
players.removeOnlinePlayer(event.getPlayer().getUniqueId());
|
||||
|
@ -45,7 +45,7 @@ public class NetherPortals implements Listener {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: nether portal entity " + event.getFrom().getBlock().getType());
|
||||
// If the nether is disabled then quit immediately
|
||||
if (!Settings.createNether || IslandWorld.getNetherWorld() == null) {
|
||||
if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() == null) {
|
||||
@ -73,7 +73,7 @@ public class NetherPortals implements Listener {
|
||||
return;
|
||||
}
|
||||
// No entities may pass with the old nether
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class NetherPortals implements Listener {
|
||||
plugin.getLogger().info("DEBUG: Player portal event - reason =" + event.getCause());
|
||||
UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
// If the nether is disabled then quit immediately
|
||||
if (!Settings.createNether || IslandWorld.getNetherWorld() == null) {
|
||||
if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
|
||||
return;
|
||||
}
|
||||
Location currentLocation = event.getFrom().clone();
|
||||
@ -159,7 +159,7 @@ public class NetherPortals implements Listener {
|
||||
if (home != null) {
|
||||
homeWorld = home.getWorld();
|
||||
}
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
// Legacy action
|
||||
if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
|
||||
// Going to Nether
|
||||
|
@ -134,7 +134,7 @@ public class IslandGuard implements Listener {
|
||||
if (loc.getWorld().equals(IslandWorld.getIslandWorld())) {
|
||||
return true;
|
||||
}
|
||||
if (Settings.createNether && Settings.islandNether && IslandWorld.getNetherWorld() != null && loc.getWorld().equals(IslandWorld.getNetherWorld())) {
|
||||
if (Settings.netherGenerate && Settings.netherIslands && IslandWorld.getNetherWorld() != null && loc.getWorld().equals(IslandWorld.getNetherWorld())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -44,7 +44,7 @@ public class NetherEvents implements Listener {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: nether portal entity " + event.getFrom().getBlock().getType());
|
||||
// If the nether is disabled then quit immediately
|
||||
if (!Settings.createNether || IslandWorld.getNetherWorld() == null) {
|
||||
if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() == null) {
|
||||
@ -72,7 +72,7 @@ public class NetherEvents implements Listener {
|
||||
return;
|
||||
}
|
||||
// No entities may pass with the old nether
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class NetherEvents implements Listener {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: " + e.getEventName());
|
||||
// plugin.getLogger().info("Block break");
|
||||
if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.islandNether)
|
||||
if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.netherIslands)
|
||||
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
|
||||
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
|
||||
return;
|
||||
@ -143,7 +143,7 @@ public class NetherEvents implements Listener {
|
||||
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: " + e.getEventName());
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|
||||
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
|
||||
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
|
||||
@ -160,7 +160,7 @@ public class NetherEvents implements Listener {
|
||||
public void onBucketEmpty(final PlayerBucketEmptyEvent e) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: " + e.getEventName());
|
||||
if (!Settings.islandNether) {
|
||||
if (!Settings.netherIslands) {
|
||||
if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|
||||
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
|
||||
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
|
||||
@ -180,7 +180,7 @@ public class NetherEvents implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onExplosion(final EntityExplodeEvent e) {
|
||||
if (Settings.islandNether) {
|
||||
if (Settings.netherIslands) {
|
||||
// Not used in the new nether
|
||||
return;
|
||||
}
|
||||
@ -214,7 +214,7 @@ public class NetherEvents implements Listener {
|
||||
if (!Settings.netherTrees) {
|
||||
return;
|
||||
}
|
||||
if (!Settings.createNether || IslandWorld.getNetherWorld() == null) {
|
||||
if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
|
||||
return;
|
||||
}
|
||||
// Check world
|
||||
|
@ -42,8 +42,6 @@ public class IslandBlock {
|
||||
private int z;
|
||||
private List<String> signText;
|
||||
private BannerBlock banner;
|
||||
private SkullBlock skull;
|
||||
private PotBlock pot;
|
||||
private EntityType spawnerBlockType;
|
||||
// Chest contents
|
||||
private HashMap<Byte,ItemStack> chestContents = new HashMap<Byte,ItemStack>();
|
||||
@ -202,8 +200,6 @@ public class IslandBlock {
|
||||
this.z = z;
|
||||
signText = null;
|
||||
banner = null;
|
||||
skull = null;
|
||||
pot = null;
|
||||
spawnerBlockType = null;
|
||||
chestContents = new HashMap<Byte,ItemStack>();
|
||||
}
|
||||
@ -262,19 +258,6 @@ public class IslandBlock {
|
||||
banner = new BannerBlock();
|
||||
banner.prep(map);
|
||||
}
|
||||
/**
|
||||
* Sets this block up with all the skull data required
|
||||
* @param map
|
||||
* @param dataValue
|
||||
*/
|
||||
public void setSkull(Map<String, Tag> map, int dataValue) {
|
||||
skull = new SkullBlock();
|
||||
skull.prep(map, dataValue);
|
||||
}
|
||||
public void setFlowerPot(Map<String, Tag> map){
|
||||
pot = new PotBlock();
|
||||
pot.prep(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the spawner type if this block is a spawner
|
||||
@ -542,10 +525,6 @@ public class IslandBlock {
|
||||
sign.update();
|
||||
} else if (banner != null) {
|
||||
banner.set(block);
|
||||
} else if (skull != null){
|
||||
skull.set(block);
|
||||
} else if (pot != null){
|
||||
pot.set(nms, block);
|
||||
} else if (spawnerBlockType != null) {
|
||||
if (block.getTypeId() != typeId) {
|
||||
block.setTypeId(typeId);
|
||||
|
@ -1,122 +0,0 @@
|
||||
package us.tastybento.bskyblock.schematics;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import us.tastybento.bskyblock.util.nms.NMSAbstraction;
|
||||
import us.tastybento.org.jnbt.IntTag;
|
||||
import us.tastybento.org.jnbt.StringTag;
|
||||
import us.tastybento.org.jnbt.Tag;
|
||||
|
||||
/**
|
||||
* This class describes pots and is used in schematic importing
|
||||
*
|
||||
* @author SpyL1nk
|
||||
*
|
||||
*/
|
||||
public class PotBlock {
|
||||
private Material potItem;
|
||||
private int potItemData;
|
||||
|
||||
private static HashMap<String, Material> potItemList;
|
||||
|
||||
static {
|
||||
potItemList = new HashMap<String, Material>();
|
||||
potItemList.put("", Material.AIR);
|
||||
potItemList.put("minecraft:red_flower", Material.RED_ROSE);
|
||||
potItemList.put("minecraft:yellow_flower", Material.YELLOW_FLOWER);
|
||||
potItemList.put("minecraft:sapling", Material.SAPLING);
|
||||
potItemList.put("minecraft:red_mushroom", Material.RED_MUSHROOM);
|
||||
potItemList.put("minecraft:brown_mushroom", Material.BROWN_MUSHROOM);
|
||||
potItemList.put("minecraft:cactus", Material.CACTUS);
|
||||
potItemList.put("minecraft:deadbush", Material.LONG_GRASS);
|
||||
potItemList.put("minecraft:tallgrass", Material.LONG_GRASS);
|
||||
}
|
||||
|
||||
public boolean set(NMSAbstraction nms, Block block) {
|
||||
if(potItem != Material.AIR){
|
||||
nms.setFlowerPotBlock(block, new ItemStack(potItem, 1,(short) potItemData));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean prep(Map<String, Tag> tileData) {
|
||||
// Initialize as default
|
||||
potItem = Material.AIR;
|
||||
potItemData = 0;
|
||||
try {
|
||||
if(tileData.containsKey("Item")){
|
||||
|
||||
// Get the item in the pot
|
||||
if (tileData.get("Item") instanceof IntTag) {
|
||||
// Item is a number, not a material
|
||||
int id = ((IntTag) tileData.get("Item")).getValue();
|
||||
potItem = Material.getMaterial(id);
|
||||
// Check it's a viable pot item
|
||||
if (!potItemList.containsValue(potItem)) {
|
||||
// No, so reset to AIR
|
||||
potItem = Material.AIR;
|
||||
}
|
||||
} else if (tileData.get("Item") instanceof StringTag) {
|
||||
// Item is a material
|
||||
String itemName = ((StringTag) tileData.get("Item")).getValue();
|
||||
if (potItemList.containsKey(itemName)){
|
||||
// Check it's a viable pot item
|
||||
if (potItemList.containsKey(itemName)) {
|
||||
potItem = potItemList.get(itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileData.containsKey("Data")){
|
||||
int dataTag = ((IntTag) tileData.get("Data")).getValue();
|
||||
// We should check data for each type of potItem
|
||||
if(potItem == Material.RED_ROSE){
|
||||
if(dataTag >= 0 && dataTag <= 8){
|
||||
potItemData = dataTag;
|
||||
} else {
|
||||
// Prevent hacks
|
||||
potItemData = 0;
|
||||
}
|
||||
} else if(potItem == Material.YELLOW_FLOWER ||
|
||||
potItem == Material.RED_MUSHROOM ||
|
||||
potItem == Material.BROWN_MUSHROOM ||
|
||||
potItem == Material.CACTUS){
|
||||
// Set to 0 anyway
|
||||
potItemData = 0;
|
||||
} else if(potItem == Material.SAPLING){
|
||||
if(dataTag >= 0 && dataTag <= 4){
|
||||
potItemData = dataTag;
|
||||
} else {
|
||||
// Prevent hacks
|
||||
potItemData = 0;
|
||||
}
|
||||
} else if(potItem == Material.LONG_GRASS){
|
||||
// Only 0 or 2
|
||||
if(dataTag == 0 || dataTag == 2){
|
||||
potItemData = dataTag;
|
||||
} else {
|
||||
potItemData = 0;
|
||||
}
|
||||
} else {
|
||||
// ERROR ?
|
||||
potItemData = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
potItemData = 0;
|
||||
}
|
||||
}
|
||||
//Bukkit.getLogger().info("Debug: flowerpot item = " + potItem.toString());
|
||||
//Bukkit.getLogger().info("Debug: flowerpot item data = " + potItemData);
|
||||
//Bukkit.getLogger().info("Debug: flowerpot materialdata = " + new MaterialData(potItem,(byte) potItemData).toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1165,12 +1165,6 @@ public class Schematic {
|
||||
if (block.getTypeId() == Material.STANDING_BANNER.getId()) {
|
||||
block.setBanner(tileEntitiesMap.get(new BlockVector(x, y, z)));
|
||||
}
|
||||
else if (block.getTypeId() == Material.SKULL.getId()) {
|
||||
block.setSkull(tileEntitiesMap.get(new BlockVector(x, y, z)), block.getData());
|
||||
}
|
||||
else if (block.getTypeId() == Material.FLOWER_POT.getId()) {
|
||||
block.setFlowerPot(tileEntitiesMap.get(new BlockVector(x, y, z)));
|
||||
}
|
||||
}
|
||||
// Monster spawner blocks
|
||||
if (block.getTypeId() == Material.MOB_SPAWNER.getId()) {
|
||||
|
@ -164,7 +164,7 @@ public class SchematicsMgr {
|
||||
if (schematic.isVisible()) {
|
||||
// Check if it's a nether island, but the nether is not enables
|
||||
if (schematic.getBiome().equals(Biome.HELL)) {
|
||||
if (Settings.createNether && IslandWorld.getNetherWorld() != null) {
|
||||
if (Settings.netherGenerate && IslandWorld.getNetherWorld() != null) {
|
||||
result.add(schematic);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,291 +0,0 @@
|
||||
package us.tastybento.bskyblock.schematics;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import us.tastybento.org.jnbt.ByteTag;
|
||||
import us.tastybento.org.jnbt.CompoundTag;
|
||||
import us.tastybento.org.jnbt.IntTag;
|
||||
import us.tastybento.org.jnbt.ListTag;
|
||||
import us.tastybento.org.jnbt.StringTag;
|
||||
import us.tastybento.org.jnbt.Tag;
|
||||
|
||||
/**
|
||||
* This class describes skulls and is used in schematic importing
|
||||
*
|
||||
* @author SpyL1nk
|
||||
*
|
||||
*/
|
||||
public class SkullBlock {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
private SkullType skullType;
|
||||
private String skullOwnerName;
|
||||
private String skullOwnerUUID;
|
||||
private BlockFace skullRotation;
|
||||
private int skullStanding;
|
||||
private String skullTextureValue = null;
|
||||
private String skullTextureSignature = null;
|
||||
|
||||
private static HashMap<Integer, SkullType> skullTypeList;
|
||||
private static HashMap<Integer, BlockFace> skullRotationList;
|
||||
|
||||
static {
|
||||
skullTypeList = new HashMap<Integer, SkullType>();
|
||||
skullTypeList.put(0, SkullType.SKELETON);
|
||||
skullTypeList.put(1, SkullType.WITHER);
|
||||
skullTypeList.put(2, SkullType.ZOMBIE);
|
||||
skullTypeList.put(3, SkullType.PLAYER);
|
||||
skullTypeList.put(4, SkullType.CREEPER);
|
||||
}
|
||||
|
||||
static {
|
||||
skullRotationList = new HashMap<Integer, BlockFace>();
|
||||
skullRotationList.put(0, BlockFace.NORTH);
|
||||
skullRotationList.put(1, BlockFace.NORTH_NORTH_EAST);
|
||||
skullRotationList.put(2, BlockFace.NORTH_EAST);
|
||||
skullRotationList.put(3, BlockFace.EAST_NORTH_EAST);
|
||||
skullRotationList.put(4, BlockFace.EAST);
|
||||
skullRotationList.put(5, BlockFace.EAST_SOUTH_EAST);
|
||||
skullRotationList.put(6, BlockFace.SOUTH_EAST);
|
||||
skullRotationList.put(7, BlockFace.SOUTH_SOUTH_EAST);
|
||||
skullRotationList.put(8, BlockFace.SOUTH);
|
||||
skullRotationList.put(9, BlockFace.SOUTH_SOUTH_WEST);
|
||||
skullRotationList.put(10, BlockFace.SOUTH_WEST);
|
||||
skullRotationList.put(11, BlockFace.WEST_SOUTH_WEST);
|
||||
skullRotationList.put(12, BlockFace.WEST);
|
||||
skullRotationList.put(13, BlockFace.WEST_NORTH_WEST);
|
||||
skullRotationList.put(14, BlockFace.NORTH_WEST);
|
||||
skullRotationList.put(15, BlockFace.NORTH_NORTH_WEST);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean set(Block block) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
if(skullOwnerName != null){
|
||||
skull.setOwner(skullOwnerName);
|
||||
}
|
||||
skull.setSkullType(skullType);
|
||||
skull.setRotation(skullRotation);
|
||||
skull.setRawData((byte) skullStanding);
|
||||
// Texture update
|
||||
if(skullTextureValue != null){
|
||||
setSkullWithNonPlayerProfile(skullTextureValue, skullTextureSignature, skullOwnerUUID, skullOwnerName, skull);
|
||||
}
|
||||
skull.update();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean prep(Map<String, Tag> tileData, int dataValue) {
|
||||
|
||||
try {
|
||||
// Take skull type
|
||||
if(tileData.containsKey("SkullType")){
|
||||
int skullTypeId = (int) ((ByteTag) tileData.get("SkullType")).getValue();
|
||||
//Bukkit.getLogger().info("DEBUG: skull type = " + skullTypeId);
|
||||
if(skullTypeList.containsKey(skullTypeId)){
|
||||
skullType = skullTypeList.get(skullTypeId);
|
||||
}
|
||||
else {
|
||||
// Prevent hacks, set to default skull type
|
||||
skullType = skullTypeList.get(0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
// Prevent hacks, set to defaut skull type
|
||||
skullType = skullTypeList.get(0);
|
||||
}
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull's data value = " + dataValue);
|
||||
// Data value 0 is actually unused for skulls, set to 2 to prevent hacks
|
||||
if(dataValue > 0 && dataValue < 6){
|
||||
|
||||
skullStanding = dataValue;
|
||||
|
||||
if(tileData.containsKey("Rot")){
|
||||
int skullRotId = (int) ((ByteTag) tileData.get("Rot")).getValue();
|
||||
//Bukkit.getLogger().info("DEBUG: skull's rotation byte = " + skullRotId);
|
||||
// Useful for skulls on the floor to insert rotation data
|
||||
if(skullRotationList.containsKey(skullStanding)){
|
||||
skullRotation = skullRotationList.get(skullRotId);
|
||||
}
|
||||
else{
|
||||
// Prevents hacks
|
||||
skullRotation = skullRotationList.get(0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
skullRotation = skullRotationList.get(0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
skullStanding = 2;
|
||||
|
||||
if(tileData.containsKey("Rot")){
|
||||
int skullRotId = ((IntTag) tileData.get("Rot")).getValue();
|
||||
//Bukkit.getLogger().info("DEBUG: skull's rotation byte = " + skullRotId);
|
||||
// Useful for skulls on the floor to insert rotation data
|
||||
if(skullRotationList.containsKey(skullStanding)){
|
||||
skullRotation = skullRotationList.get(skullRotId);
|
||||
}
|
||||
// Prevents hacks
|
||||
else{
|
||||
skullRotation = skullRotationList.get(0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
skullRotation = skullRotationList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Player Heads (skin, texture etc.)
|
||||
if(skullType == SkullType.PLAYER && tileData.containsKey("Owner")){
|
||||
|
||||
Map<String, Tag> skullOwner = ((CompoundTag) tileData.get("Owner")).getValue();
|
||||
|
||||
if(skullOwner.containsKey("Name")){
|
||||
skullOwnerName = ((StringTag) skullOwner.get("Name")).getValue();
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull owner's name = " + skullOwnerName);
|
||||
}
|
||||
|
||||
if(skullOwner.containsKey("Id")){
|
||||
skullOwnerUUID = ((StringTag) skullOwner.get("Id")).getValue();
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull owner's UUID = " + skullOwnerUUID);
|
||||
}
|
||||
|
||||
if(skullOwner.containsKey("Properties")){
|
||||
Map<String, Tag> skullOwnerProperties = ((CompoundTag) skullOwner.get("Properties")).getValue();
|
||||
|
||||
if(skullOwnerProperties.containsKey("textures")){
|
||||
|
||||
ListTag listTagTextures = (ListTag) skullOwnerProperties.get("textures");
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull texture's list = " + listTagTextures);
|
||||
|
||||
if(listTagTextures != null){
|
||||
|
||||
// Logicaly, textures should have only one entry ...
|
||||
Map<String, Tag> skullOwnerTextures = ((CompoundTag) listTagTextures.getValue().get(0)).getValue();
|
||||
|
||||
if(skullOwnerTextures.containsKey("Value")){
|
||||
skullTextureValue = ((StringTag) skullOwnerTextures.get("Value")).getValue();
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull texture's value = " + skullTextureValue);
|
||||
}
|
||||
if(skullOwnerTextures.containsKey("Signature")){
|
||||
skullTextureSignature = ((StringTag) skullOwnerTextures.get("Signature")).getValue();
|
||||
|
||||
//Bukkit.getLogger().info("DEBUG: skull's texture signature = " + skullTextureSignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Credits: GermanCoding
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setSkullWithNonPlayerProfile(String textureValue, String textureSignature, String ownerUUID, String ownerName, Skull skull) {
|
||||
if (skull.getType() != Material.SKULL)
|
||||
throw new IllegalArgumentException("Block must be a skull.");
|
||||
|
||||
skull.getWorld().refreshChunk(skull.getChunk().getX(), skull.getChunk().getZ());
|
||||
|
||||
|
||||
// Difference beetween NonPlayerSkin and PlayerSkin
|
||||
if(textureSignature != null){
|
||||
try {
|
||||
setSkullProfile(skull, getPlayerProfile(textureValue, textureSignature, ownerUUID, ownerName));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
setSkullProfile(skull, getNonPlayerProfile(textureValue, ownerUUID, ownerName));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//skull.getWorld().refreshChunk(skull.getChunk().getX(), skull.getChunk().getZ());
|
||||
}
|
||||
|
||||
// Credits: val59000 (THANK YOU VERY MUCH VAL59000 !)
|
||||
private static void setSkullProfile(Skull skull, GameProfile gameProfile) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
|
||||
Field profileField = null;
|
||||
try {
|
||||
profileField = skull.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(skull, gameProfile);
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Credits: dori99xd
|
||||
public static GameProfile getNonPlayerProfile(String textureValue, String ownerUUID, String ownerName) {
|
||||
// Create a new GameProfile with .schematic informations or with fake informations
|
||||
GameProfile newSkinProfile = new GameProfile(ownerUUID == null ? UUID.randomUUID() : UUID.fromString(ownerUUID),
|
||||
ownerName == null ? getRandomString(16) : null);
|
||||
|
||||
// Insert textures properties
|
||||
newSkinProfile.getProperties().put("textures", new Property("textures", textureValue));
|
||||
return newSkinProfile;
|
||||
}
|
||||
|
||||
// Credits: dori99xd
|
||||
public static GameProfile getPlayerProfile(String textureValue, String textureSignature, String ownerUUID, String ownerName) {
|
||||
// Create a new GameProfile with .schematic informations or with fake informations
|
||||
GameProfile newSkinProfile = new GameProfile( ownerUUID == null ? UUID.randomUUID() : UUID.fromString(ownerUUID),
|
||||
ownerName == null ? getRandomString(16) : null);
|
||||
|
||||
// Insert textures properties
|
||||
newSkinProfile.getProperties().put("textures", new Property("textures", textureValue, textureSignature));
|
||||
return newSkinProfile;
|
||||
}
|
||||
|
||||
// Credits: dori99xd
|
||||
public static String getRandomString(int length) {
|
||||
StringBuilder b = new StringBuilder(length);
|
||||
for(int j = 0; j < length; j++){
|
||||
b.append(chars.charAt(random.nextInt(chars.length())));
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ public class DeleteIslandBlocks {
|
||||
}
|
||||
if (regen) {
|
||||
world.regenerateChunk(x, z);
|
||||
if (Settings.islandNether && Settings.createNether) {
|
||||
if (Settings.netherIslands && Settings.netherGenerate) {
|
||||
if (world.equals(IslandWorld.getIslandWorld())) {
|
||||
IslandWorld.getNetherWorld().regenerateChunk(x, z);
|
||||
}
|
||||
@ -179,7 +179,7 @@ public class DeleteIslandBlocks {
|
||||
break;
|
||||
}
|
||||
// Nether, if it exists
|
||||
if (Settings.islandNether && Settings.createNether && y < IslandWorld.getNetherWorld().getMaxHeight() - 8) {
|
||||
if (Settings.netherIslands && Settings.netherGenerate && y < IslandWorld.getNetherWorld().getMaxHeight() - 8) {
|
||||
b = IslandWorld.getNetherWorld().getBlockAt(xCoord, y, zCoord);
|
||||
bt = b.getType();
|
||||
if (!b.equals(Material.AIR)) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package us.tastybento.bskyblock.util;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
/**
|
||||
* Helper class for Vault Economy and Permissions
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user