Added FallDamage option

This commit is contained in:
Fabrizio La Rosa 2020-06-13 00:03:56 +02:00
parent ab66bad6a5
commit 51daa0498d
7 changed files with 54 additions and 14 deletions

View File

@ -106,7 +106,10 @@ public class TeleportCommand extends SubCommand {
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
});
}
}

View File

@ -258,7 +258,9 @@ public class IslandManager {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
String biomeName = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase();
@ -1053,7 +1055,9 @@ public class IslandManager {
}
if(found){
player.teleport(locChecked);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cNessuna posizione sicura trovata!"));
}
@ -1086,7 +1090,9 @@ public class IslandManager {
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
});
List<String> islandWelcomeMessage = island.getMessage(IslandMessage.Welcome);

View File

@ -47,7 +47,9 @@ public class Death implements Listener {
if (configLoad.getBoolean("Island.Death.AutoRespawn")) {
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
player.spigot().respawn();
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
player.setFireTicks(0);
}, 1L);
}

View File

@ -60,7 +60,9 @@ public class Join implements Listener {
LocationUtil.teleportPlayerToSpawn(player);
} else if (configLoad.getBoolean("Island.Join.Island") && island != null) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
teleportedToIsland = true;
}

View File

@ -107,7 +107,9 @@ public class Move implements Listener {
if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) {
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
if (keepItemsOnDeath && configLoad.getBoolean("Island.Liquid.Teleport.Enable")) {
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
teleportPlayerToIslandSpawn(player, soundManager, island);
}
@ -134,8 +136,11 @@ public class Move implements Listener {
player.removePotionEffect(potionEffect.getType());
}
}
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
}
if (configLoad.getBoolean("Island.Void.Teleport.Island")) {
teleportPlayerToIslandSpawn(player, island);
@ -143,7 +148,9 @@ public class Move implements Listener {
LocationUtil.teleportPlayerToSpawn(player);
}
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
}
@ -151,7 +158,12 @@ public class Move implements Listener {
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) {
teleportPlayerToIslandSpawn(player, world, island);
player.setFallDistance(0.0F);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
.getString("Island.WorldBorder.Outside.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
@ -198,8 +210,14 @@ public class Move implements Listener {
private void teleportPlayerToIslandSpawn(Player player, SoundManager soundManager, Island island) {
teleportPlayerToIslandSpawn(player, island);
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}

View File

@ -134,7 +134,9 @@ public class Portal implements Listener {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
tick.setTick(1);
}
break;
@ -144,7 +146,9 @@ public class Portal implements Listener {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
tick.setTick(1);
}
break;
@ -153,7 +157,9 @@ public class Portal implements Listener {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
if(!configLoad.getBoolean("Island.Teleport.FallDamage")){
player.setFallDistance(0.0F);
}
tick.setTick(1);
break;
}

View File

@ -310,3 +310,6 @@ Island:
Challenge:
# Enable or disable challenges. Configuration for challenges are in challenges.yml file
Enable: true
Teleport:
# Enable or disable Fall damage
FallDamage: true