Merge branch 'development' into 'master'

Build-78

See merge request Songoda/fabledskyblock!19
This commit is contained in:
Esophose 2019-07-20 08:44:05 +00:00
commit 026dd9a7c0
14 changed files with 103 additions and 46 deletions

View File

@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
group 'com.songoda.fabledskyblock'
version 'Build-77'
version 'Build-78'
sourceCompatibility = 1.8
@ -50,9 +50,6 @@ dependencies {
shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0')
shade (group: 'commons-io', name: 'commons-io', version: '2.5')
// JetBrains Annotations
compile (group: 'org.jetbrains', name: 'annotations', version: '13.0')
// Songoda Updater
shade (group: 'com.songoda', name: 'songodaupdater', version: '1')

View File

@ -102,6 +102,12 @@ public class CoopCommand extends SubCommand {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Added.Message")
.replace("%player", targetPlayerName));
if (targetPlayer != null) {
messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Coop.AddedTarget.Message")
.replace("%player", player.getName()));
}
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}

View File

@ -182,7 +182,13 @@ public class Island {
save();
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(Bukkit.getServer().getPlayer(ownerUUID));
Player onlinePlayer = Bukkit.getServer().getPlayer(ownerUUID);
if (!skyblock.getPlayerDataManager().hasPlayerData(onlinePlayer)) {
skyblock.getPlayerDataManager().createPlayerData(onlinePlayer);
}
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(onlinePlayer);
playerData.setPlaytime(0);
playerData.setOwner(ownerUUID);
playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
@ -439,10 +445,12 @@ public class Island {
public void addCoopPlayer(UUID uuid) {
coopPlayers.add(uuid);
Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save);
}
public void removeCoopPlayer(UUID uuid) {
coopPlayers.remove(uuid);
Bukkit.getScheduler().runTaskAsynchronously(skyblock, this::save);
}
public boolean isCoopPlayer(UUID uuid) {

View File

@ -1402,10 +1402,6 @@ public class IslandManager {
if (islandLocation == null)
return false;
double size = island.getRadius();
if (size % 2 == 1)
size++;
return LocationUtil.isLocationAtLocationRadius(location.clone().add(0.5, 0, 0.5), islandLocation, size);
return LocationUtil.isLocationAtLocationRadius(location.clone().add(0.5, 0, 0.5), islandLocation, island.getRadius() + 1);
}
}

View File

@ -49,9 +49,7 @@ public class LeaderboardManager {
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Leaderboard.Exemptions.Enable");
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(),
Bukkit.getOfflinePlayer(ownerUUID),
"fabledskyblock.top.exempt"))
@ -93,21 +91,18 @@ public class LeaderboardManager {
switch (type) {
case Level:
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
Visit visit = visitManager.getIslands().get(ownerUUID);
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
}
break;
case Bank:
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
Visit visit = visitManager.getIslands().get(ownerUUID);
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long)visit.getBankBalance()));
}
case Votes:
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
Visit visit = visitManager.getIslands().get(ownerUUID);
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
}
@ -150,14 +145,9 @@ public class LeaderboardManager {
}
public Leaderboard getLeaderboardFromPosition(Leaderboard.Type type, int position) {
for (Leaderboard leaderboardPlayerList : leaderboardStorage) {
if (leaderboardPlayerList.getType() == type) {
if (leaderboardPlayerList.getPosition() == position) {
return leaderboardPlayerList;
}
}
}
for (Leaderboard leaderboardPlayerList : leaderboardStorage)
if (leaderboardPlayerList.getType() == type && leaderboardPlayerList.getPosition() == position)
return leaderboardPlayerList;
return null;
}

View File

@ -635,7 +635,7 @@ public class Block implements Listener {
if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) {
if (!skyblock.getIslandManager().hasSetting(block.getLocation(), IslandRole.Owner, "LeafDecay")) {
event.setCancelled(false);
event.setCancelled(true);
}
}
}

View File

@ -656,7 +656,8 @@ public class Entity implements Listener {
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getEntity() instanceof ArmorStand || event.getEntity() instanceof FallingBlock
if (event.getEntity() instanceof ArmorStand
|| event.getEntity() instanceof FallingBlock
|| event.getEntity() instanceof org.bukkit.entity.Item) {
return;
}

View File

@ -46,6 +46,7 @@ import me.goodandevil.skyblock.utils.structure.StructureUtil;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds;
import org.bukkit.material.Cauldron;
public class Interact implements Listener {
@ -109,6 +110,17 @@ public class Interact implements Listener {
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (block.getState() instanceof Cauldron) { // WildStacker stackables
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
}
@ -163,7 +175,8 @@ public class Interact implements Listener {
Location location = event.getClickedBlock().getLocation();
if (stackableManager.isStacked(location)) {
Stackable stackable = stackableManager.getStack(location, event.getMaterial());
stackable.addOne();
if (stackable != null)
stackable.addOne();
} else {
stackableManager.addStack(new Stackable(location, event.getMaterial()));
}
@ -185,8 +198,21 @@ public class Interact implements Listener {
}
level.setMaterialAmount(materials.name(), materialAmount + 1);
return;
}
if (block.getType() == Material.ANVIL) {
if (block.getType() == Materials.SWEET_BERRY_BUSH.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (block.getType() == Material.ANVIL) {
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
event.setCancelled(true);

View File

@ -64,7 +64,7 @@ public class WildStacker implements Listener {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getBarrel().getStackAmount());
level.setMaterialAmount(materials.name(), materialAmount + event.getBarrel().getStackAmount() - 1); // -1 because the Interact handler will always add +1
}
}
}
@ -100,7 +100,7 @@ public class WildStacker implements Listener {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount());
level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount() - 1); // -1 because the Interact handler will always add +1
}
}
}

View File

@ -217,7 +217,7 @@ public class Settings {
} else {
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(),
configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"), null, null, null,
null), 0, 9);
null), 0, 8);
nInv.addItem(nInv.createItem(Materials.OAK_SAPLING.parseItem(),
configLoad.getString("Menu.Settings.Categories.Item.Owner.Displayname"),
configLoad.getStringList("Menu.Settings.Categories.Item.Owner.Lore"), null, null, null), 6);

View File

@ -138,6 +138,30 @@ public class Upgrade {
upgrade.setEnabled(true);
}
if (playerDataManager.hasPlayerData(player)) {
me.goodandevil.skyblock.upgrade.Upgrade.Type upgradeType = ((Viewer) playerDataManager
.getPlayerData(player).getViewer()).getUpgrade();
boolean enabled = upgrade.isEnabled();
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
() -> {
Config config = fileManager.getConfig(new File(
skyblock.getDataFolder(), "upgrades.yml"));
FileConfiguration configLoad1 = config
.getFileConfiguration();
configLoad1.set(
"Upgrades." + upgradeType.name() + ".Enable",
enabled);
try {
configLoad1.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
});
}
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -226,21 +250,22 @@ public class Upgrade {
}
});
ItemStack potion = new ItemStack(Material.POTION);
ItemStack speedPotion = new ItemStack(Material.POTION);
ItemStack jumpPotion = new ItemStack(Material.POTION);
me.goodandevil.skyblock.upgrade.Upgrade upgrade;
int NMSVersion = NMSUtil.getVersionNumber();
if (NMSVersion > 12) {
PotionMeta pm = (PotionMeta) potion.getItemMeta();
PotionMeta pm = (PotionMeta) speedPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.SPEED));
potion.setItemMeta(pm);
speedPotion.setItemMeta(pm);
} else {
potion = new ItemStack(Material.POTION, 1, (short) 8194);
speedPotion = new ItemStack(Material.POTION, 1, (short) 8194);
}
upgrade = upgradeManager.getUpgrades(me.goodandevil.skyblock.upgrade.Upgrade.Type.Speed).get(0);
nInv.addItem(nInv.createItem(potion,
nInv.addItem(nInv.createItem(speedPotion,
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Speed.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Speed.Lore"),
@ -250,15 +275,15 @@ public class Upgrade {
null, new ItemFlag[] { ItemFlag.HIDE_POTION_EFFECTS }), 1);
if (NMSVersion > 12) {
PotionMeta pm = (PotionMeta) potion.getItemMeta();
PotionMeta pm = (PotionMeta) jumpPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.JUMP));
potion.setItemMeta(pm);
jumpPotion.setItemMeta(pm);
} else {
potion = new ItemStack(Material.POTION, 1, (short) 8203);
jumpPotion = new ItemStack(Material.POTION, 1, (short) 8203);
}
upgrade = upgradeManager.getUpgrades(me.goodandevil.skyblock.upgrade.Upgrade.Type.Jump).get(0);
nInv.addItem(nInv.createItem(potion,
nInv.addItem(nInv.createItem(jumpPotion,
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Jump.Lore"),

View File

@ -84,7 +84,7 @@ public class StackableManager {
public Stackable getStack(Location location, Material material) {
Stackable stackable = stacks.get(location);
if (stackable.getMaterial() == material)
if (stackable != null && stackable.getMaterial() == material)
return stacks.get(location);
else
return null;

View File

@ -17,7 +17,7 @@ public class SchematicUtil {
if (!Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
throw new IllegalStateException("Tried to generate an island using a schematic file without WorldEdit installed!");
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> {
Runnable pasteTask = () -> {
if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
try (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
@ -59,7 +59,13 @@ public class SchematicUtil {
e.printStackTrace();
}
}
});
};
if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit")) {
Bukkit.getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), pasteTask);
} else {
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), pasteTask);
}
return new Float[] { location.getYaw(), location.getPitch() };
}

View File

@ -325,6 +325,8 @@ Command:
Message: '&bSkyBlock &8| &cError&8: &eYou cannot coop yourself because you''re already a Member of the Island.'
Added:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have cooped &d%player&e.'
AddedTarget:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have been cooped on &d%player''s&e island.'
Banned:
Message: '&bSkyBlock &8| &cError&8: &eYou cannot coop a banned player.'
Permission: