Schematics, bug fixes, island chat, placeholder, other stuff fixes

This commit is contained in:
Esophose 2019-05-10 18:01:37 -06:00
parent 904511f6c8
commit 6f00e98292
12 changed files with 121 additions and 100 deletions

View File

@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
group 'com.songoda.fabledskyblock'
version 'Build-74'
version 'Build-75'
sourceCompatibility = 1.8
@ -23,7 +23,7 @@ configurations {
dependencies {
// PlaceholderAPI
implementation (group: 'be.maximvdw', name: 'placeholderapi', version: '2.5.1')
implementation (group: 'me.clip', name: 'placeholderapi', version: '2.9.2')
implementation (group: 'me.clip', name: 'placeholderapi', version: '2.10.2')
// Vault
implementation (group: 'net.milkbowl', name: 'vault', version: '1.7.1')

View File

@ -14,7 +14,7 @@ public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
private String message, format;
public PlayerIslandChatEvent(Player player, Island island, String message, String format) {
super(player, island);
super(player, island, true);
this.message = message;
this.format = format;
}

View File

@ -44,6 +44,12 @@ public class UnlockCommand extends SubCommand {
return;
}
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + type + ".Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Disabled.Message").replace("%type%", type));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
Island island = islandManager.getIsland(player);
if (island == null) {

View File

@ -21,6 +21,7 @@ import me.goodandevil.skyblock.structure.StructureManager;
import me.goodandevil.skyblock.upgrade.Upgrade;
import me.goodandevil.skyblock.upgrade.UpgradeManager;
import me.goodandevil.skyblock.utils.player.OfflinePlayer;
import me.goodandevil.skyblock.utils.structure.SchematicUtil;
import me.goodandevil.skyblock.utils.structure.StructureUtil;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
@ -767,7 +768,7 @@ public class IslandManager {
direction = StructureUtil.pasteStructure(StructureUtil.loadStructure(structureFile),
island.getLocation(world, IslandEnvironment.Island), BlockDegreesType.ROTATE_360);
} else {
direction = StructureUtil.pasteSchematic(structureFile, island.getLocation(world, IslandEnvironment.Island));
direction = SchematicUtil.pasteSchematic(structureFile, island.getLocation(world, IslandEnvironment.Island));
}
org.bukkit.Location spawnLocation = island.getLocation(world, IslandEnvironment.Main).clone();

View File

@ -3,6 +3,8 @@ package me.goodandevil.skyblock.listeners;
import java.io.File;
import java.util.UUID;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
@ -39,6 +41,7 @@ public class Chat implements Listener {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
FileManager fileManager = skyblock.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
@ -84,11 +87,14 @@ public class Chat implements Listener {
if (!islandChatEvent.isCancelled()) {
for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
targetPlayer.sendMessage(ChatColor
.translateAlternateColorCodes('&',
messageManager.replaceMessage(targetPlayer,
islandChatEvent.getFormat().replace("%role", islandRole)
.replace("%player", player.getName())))
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())))
.replace("%message", islandChatEvent.getMessage());
targetPlayer.sendMessage(message);
}
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())
.replace("%message", islandChatEvent.getMessage()));
}
}

View File

@ -657,15 +657,13 @@ public class Entity implements Listener {
return;
}
if (!(event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.NATURAL)) {
if (event.getSpawnReason() != SpawnReason.NATURAL)
return;
}
LivingEntity livingEntity = event.getEntity();
if (livingEntity.hasMetadata("SkyBlock")) {
if (livingEntity.hasMetadata("SkyBlock"))
return;
}
if (skyblock.getWorldManager().isIslandWorld(livingEntity.getWorld())) {
if (!skyblock.getIslandManager().hasSetting(livingEntity.getLocation(), IslandRole.Owner, "NaturalMobSpawning")) {

View File

@ -865,12 +865,12 @@ public class Creator implements Listener {
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
() -> open(player), 1L);
} else {
if (fileManager.isFileExist(
new File(skyblock.getDataFolder().toString() + "/structures",
event1.getName()))) {
String fileName = event1.getName();
if (fileManager.isFileExist(new File(skyblock.getDataFolder().toString() + "/structures", fileName)) ||
fileManager.isFileExist(new File(skyblock.getDataFolder().toString() + "/schematics", fileName))) {
if (event.getClick() == ClickType.LEFT) {
Structure structure = structureManager.getStructure(name);
structure.setOverworldFile(event1.getName());
structure.setOverworldFile(fileName);
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(),
1.0F, 1.0F);
@ -883,10 +883,7 @@ public class Creator implements Listener {
FileConfiguration configLoad17 = config17
.getFileConfiguration();
configLoad17.set(
"Structures." + structure.getName()
+ ".File.Overworld",
event1.getName());
configLoad17.set("Structures." + structure.getName() + ".File.Overworld", fileName);
try {
configLoad17.save(config17.getFile());
@ -896,7 +893,7 @@ public class Creator implements Listener {
});
} else if (event.getClick() == ClickType.MIDDLE) {
Structure structure = structureManager.getStructure(name);
structure.setNetherFile(event1.getName());
structure.setNetherFile(fileName);
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(),
1.0F, 1.0F);
@ -910,7 +907,7 @@ public class Creator implements Listener {
.getFileConfiguration();
configLoad18.set("Structures." + structure.getName()
+ ".File.Nether", event1.getName());
+ ".File.Nether", fileName);
try {
configLoad18.save(config18.getFile());
@ -920,7 +917,7 @@ public class Creator implements Listener {
});
} else {
Structure structure = structureManager.getStructure(name);
structure.setEndFile(event1.getName());
structure.setEndFile(fileName);
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(),
1.0F, 1.0F);
@ -934,7 +931,7 @@ public class Creator implements Listener {
.getFileConfiguration();
configLoad19.set("Structures." + structure.getName()
+ ".File.End", event1.getName());
+ ".File.End", fileName);
try {
configLoad19.save(config19.getFile());

View File

@ -58,6 +58,8 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
List<Leaderboard> leaderboardBankPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Bank);
List<Leaderboard> leaderboardVotesPlayers = leaderboardManager.getLeaderboard(Leaderboard.Type.Votes);
if (identifier.equalsIgnoreCase("islands")) {
return "" + skyblock.getVisitManager().getIslands().size();
} else {
@ -83,12 +85,11 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
}
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Empty.Message"));
configLoad.getString("Placeholder.fabledskyblock_leaderboard_votes.Empty.Message"));
} else if (identifier.equalsIgnoreCase("leaderboard_bank_" + (i + 1))) {
if (i < leaderboardBankPlayers.size()) {
Leaderboard leaderboard = leaderboardBankPlayers.get(i);
Visit visit = leaderboard.getVisit();
IslandLevel level = visit.getLevel();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
@ -102,7 +103,7 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_leaderboard_bank.Non-empty.Message")
.replace("%position", "" + (i + 1)).replace("%player", islandOwnerName)
.replace("%balance", NumberUtil.formatNumberByDecimal(level.getLevel())));
.replace("%balance", NumberUtil.formatNumberByDecimal(visit.getBankBalance())));
}
return ChatColor.translateAlternateColorCodes('&',

View File

@ -0,0 +1,77 @@
package me.goodandevil.skyblock.utils.structure;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class SchematicUtil {
public static Float[] pasteSchematic(File schematicFile, org.bukkit.Location location) {
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(), () -> {
if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
try (ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
Clipboard clipboard = reader.read();
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(location.getWorld()), -1)) {
Operation operation = new ClipboardHolder(clipboard)
.createPaste(editSession)
.to(BlockVector3.at(location.getX(), location.getY(), location.getZ()))
.ignoreAirBlocks(true)
.build();
Operations.complete(operation);
} catch (Exception e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
} else { // WorldEdit 6 or earlier
// I don't want to use modules so reflection it is
// TODO: Cache this later
try {
Class<?> bukkitWorldClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitWorld");
Constructor bukkitWorldConstructor = bukkitWorldClass.getConstructor(World.class);
Class<?> editSessionClass = Class.forName("com.sk89q.worldedit.EditSession");
Class<?> localWorldClass = Class.forName("com.sk89q.worldedit.LocalWorld");
Constructor editSessionConstructor = editSessionClass.getConstructor(localWorldClass, int.class);
Class<?> cuboidClipboardClass = Class.forName("com.sk89q.worldedit.CuboidClipboard");
Method loadSchematicMethod = cuboidClipboardClass.getMethod("loadSchematic", File.class);
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.Vector");
Constructor vectorConstructor = vectorClass.getConstructor(double.class, double.class, double.class);
Method pasteMethod = cuboidClipboardClass.getMethod("paste", editSessionClass, vectorClass, boolean.class);
Object editSessionObj = editSessionConstructor.newInstance(bukkitWorldConstructor.newInstance(location.getWorld()), 999999999);
Object cuboidClipboardObj = loadSchematicMethod.invoke(null, schematicFile);
Object vectorObj = vectorConstructor.newInstance(location.getX(), location.getY(), location.getZ());
pasteMethod.invoke(cuboidClipboardObj, editSessionObj, vectorObj, true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
return new Float[] { location.getYaw(), location.getPitch() };
}
}

View File

@ -2,18 +2,6 @@ package me.goodandevil.skyblock.utils.structure;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
@ -193,64 +181,6 @@ public final class StructureUtil {
return new Float[] { yaw, pitch };
}
@SuppressWarnings("deprecation")
public static Float[] pasteSchematic(File schematicFile, org.bukkit.Location location) {
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(), () -> {
if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
try (ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
Clipboard clipboard = reader.read();
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(location.getWorld()), -1)) {
Operation operation = new ClipboardHolder(clipboard)
.createPaste(editSession)
.to(BlockVector3.at(location.getX(), location.getY(), location.getZ()))
.ignoreAirBlocks(true)
.build();
Operations.complete(operation);
} catch (WorldEditException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
} else { // WorldEdit 6 or earlier
// I don't want to use modules so reflection it is
// TODO: Cache this later
try {
Class<?> bukkitWorldClass = Class.forName("com.sk89q.worldedit.bukkit.BukkitWorld");
Constructor bukkitWorldConstructor = bukkitWorldClass.getConstructor(World.class);
Class<?> editSessionClass = Class.forName("com.sk89q.worldedit.EditSession");
Class<?> localWorldClass = Class.forName("com.sk89q.worldedit.LocalWorld");
Constructor editSessionConstructor = editSessionClass.getConstructor(localWorldClass, int.class);
Class<?> cuboidClipboardClass = Class.forName("com.sk89q.worldedit.CuboidClipboard");
Method loadSchematicMethod = cuboidClipboardClass.getMethod("loadSchematic", File.class);
Class<?> vectorClass = Class.forName("com.sk89q.worldedit.Vector");
Constructor vectorConstructor = vectorClass.getConstructor(double.class, double.class, double.class);
Method pasteMethod = cuboidClipboardClass.getMethod("paste", editSessionClass, vectorClass, boolean.class);
Object editSessionObj = editSessionConstructor.newInstance(bukkitWorldConstructor.newInstance(location.getWorld()), 999999999);
Object cuboidClipboardObj = loadSchematicMethod.invoke(null, schematicFile);
Object vectorObj = vectorConstructor.newInstance(location.getX(), location.getY(), location.getZ());
pasteMethod.invoke(cuboidClipboardObj, editSessionObj, vectorObj, true);
/*
EditSession es = new EditSession(new BukkitWorld(location.getWorld()), 999999999);
CuboidClipboard cc = CuboidClipboard.loadSchematic(schematicFile);
cc.paste(es, new Vector(location.getX(), location.getY(), location.getZ()), true);
*/
} catch (Exception e) {
e.printStackTrace();
}
}
});
return new Float[] { location.getYaw(), location.getPitch() };
}
public static ItemStack getTool() throws Exception {
SkyBlock skyblock = SkyBlock.getInstance();

View File

@ -64,6 +64,9 @@ Island:
Member:
# Max amount of players allowed to be in a team.
Capacity: 12
Chat:
# If island chat should be output to console
OutputToConsole: true
WorldBorder:
# Generates a worldborder around Islands.
# [!] WorldBorders will not show in Nether world due to centering bug
@ -273,4 +276,4 @@ Island:
Generator:
Enable: true
Stackable:
Enable: true
Enable: true

View File

@ -57,6 +57,8 @@ Command:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have successfully unlocked '&7The %type%&e'."
Unlocked:
Message: "&bSkyBlock &8| &cError&8: &eYou already unlocked '&7The %type%&e'."
Disabled:
Message: "&bSkyBlock &8| &cError&8: &e'&7The %type%&e' is disabled and cannot be unlocked."
Money:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have enough money to unlock that. The cost to unlock is &c$%cost%&e."
Info:
@ -464,7 +466,7 @@ Command:
Finished:
Message: "&aIsland level scan complete!"
NotOnIsland:
Message: "&bSkyBlock &8| &cError&8: &cYou cannot initiate an island scan without being on your island."
Message: "&bSkyBlock &8| &cError&8: &eYou cannot initiate an island level scan without being on your island."
Owner:
Yourself:
Message: "&bSkyBlock &8| &cError&8: &eYou are not an Island owner."