Merge branch 'development'

This commit is contained in:
Brianna 2020-05-01 05:40:45 -04:00
commit edcfd1b4f6
6 changed files with 192 additions and 214 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId> <artifactId>skyblock</artifactId>
<version>2.2.19</version> <version>2.2.11</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>

View File

@ -685,7 +685,8 @@ public class IslandManager {
banManager.createIsland(island.getOwnerUUID()); banManager.createIsland(island.getOwnerUUID());
} }
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())); Bukkit.getScheduler().runTask(skyblock, () ->
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())));
return island; return island;
} }

View File

@ -265,40 +265,7 @@ public class Block implements Listener {
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial() if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return; && event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client. updateLevel(island, blockLoc);
// BUG: Player can infinitely increase their level by placing a block at their
// feet.
// It doesn't take the block away but still increments the level.
// This doesn't happen in Spigot, but does happen in PaperSpigot due to a
// BlockPlaceEvent being incorrectly fired.
// The solution is to wait a tick to make sure that the block was actually
// placed.
// This shouldn't cause any issues besides the task number being increased
// insanely fast.
Bukkit.getScheduler().runTask(skyblock, () -> {
CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType());
if (material == null || material == CompatibleMaterial.AIR) return;
if (material == CompatibleMaterial.SPAWNER) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
return;
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
if (spawner != null)
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
}
long materialAmount = 0;
IslandLevel level = island.getLevel();
if (level.hasMaterial(material.name())) {
materialAmount = level.getMaterialAmount(material.name());
}
level.setMaterialAmount(material.name(), materialAmount + 1);
});
} }
@EventHandler @EventHandler
@ -363,6 +330,7 @@ public class Block implements Listener {
toBlockState.setData(genState.getData()); toBlockState.setData(genState.getData());
toBlockState.setType(genState.getType()); toBlockState.setType(genState.getType());
toBlockState.update(); toBlockState.update();
updateLevel(island, genState.getLocation());
return; return;
} }
} }
@ -588,6 +556,7 @@ public class Block implements Listener {
state.setType(genState.getType()); state.setType(genState.getType());
if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData()); if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData());
updateLevel(island, genState.getLocation());
return; return;
} }
} }
@ -672,4 +641,41 @@ public class Block implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
private void updateLevel(Island island, Location location) {
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client.
// BUG: Player can infinitely increase their level by placing a block at their
// feet.
// It doesn't take the block away but still increments the level.
// This doesn't happen in Spigot, but does happen in PaperSpigot due to a
// BlockPlaceEvent being incorrectly fired.
// The solution is to wait a tick to make sure that the block was actually
// placed.
// This shouldn't cause any issues besides the task number being increased
// insanely fast.
Bukkit.getScheduler().runTask(skyblock, () -> {
org.bukkit.block.Block block = location.getBlock();
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (material == null || material == CompatibleMaterial.AIR) return;
if (material == CompatibleMaterial.SPAWNER) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") || Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
return;
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
if (spawner != null)
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
}
long materialAmount = 0;
IslandLevel level = island.getLevel();
if (level.hasMaterial(material.name()))
materialAmount = level.getMaterialAmount(material.name());
level.setMaterialAmount(material.name(), materialAmount + 1);
});
}
} }

View File

@ -1,52 +1,32 @@
package com.songoda.skyblock.listeners; package com.songoda.skyblock.listeners;
import java.io.File;
import java.lang.reflect.Method;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.limit.impl.EntityLimitaton;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.upgrade.Upgrade;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.utils.world.entity.EntityUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.ElderGuardian;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Evoker;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Illager;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Mule;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Ravager; import org.bukkit.entity.*;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
@ -58,24 +38,9 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import com.songoda.skyblock.SkyBlock; import java.io.File;
import com.songoda.skyblock.config.FileManager; import java.lang.reflect.Method;
import com.songoda.skyblock.config.FileManager.Config; import java.util.*;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.limit.impl.EntityLimitaton;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.upgrade.Upgrade;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.utils.world.entity.EntityUtil;
import com.songoda.skyblock.world.WorldManager;
public class Entity implements Listener { public class Entity implements Listener {
@ -559,7 +524,8 @@ public class Entity implements Listener {
} }
if (event.getTo() != null && event.getTo() != Material.AIR) { if (event.getTo() != null && event.getTo() != Material.AIR) {
materials = CompatibleMaterial.getBlockMaterial(event.getTo());; materials = CompatibleMaterial.getBlockMaterial(event.getTo());
;
if (materials != null) { if (materials != null) {
long materialAmount = 0; long materialAmount = 0;
@ -639,7 +605,8 @@ public class Entity implements Listener {
} }
if (NMSUtil.getVersionNumber() > 9) { if (NMSUtil.getVersionNumber() > 9) {
if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian) return; if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian)
return;
} }
if (NMSUtil.getVersionNumber() > 10) { if (NMSUtil.getVersionNumber() > 10) {
@ -686,7 +653,8 @@ public class Entity implements Listener {
} }
for (ItemStack is : event.getDrops()) for (ItemStack is : event.getDrops())
if (!dontMultiply.contains(is)) livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is); if (!dontMultiply.contains(is))
livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is);
} }
} }
} }
@ -730,7 +698,8 @@ public class Entity implements Listener {
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (entity instanceof ArmorStand) return; if (entity instanceof ArmorStand) return;
if (entity.hasMetadata("SkyBlock")) return; // if (entity.hasMetadata("SkyBlock")) return;
// Doesn't appear this is ever set by our plugin and it is extremely intensive.
Location entityLocation = entity.getLocation(); Location entityLocation = entity.getLocation();

View File

@ -36,6 +36,7 @@ public class Join implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
Player player = event.getPlayer(); Player player = event.getPlayer();
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager(); ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
@ -146,5 +147,6 @@ public class Join implements Listener {
// Load Challenge // Load Challenge
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId()); SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(player.getUniqueId());
});
} }
} }

View File

@ -100,7 +100,7 @@ public class Portal implements Listener {
case Owner: case Owner:
case Member: case Member:
case Coop: case Coop:
spawnEnvironment = IslandEnvironment.Island; spawnEnvironment = IslandEnvironment.Main;
break; break;
default: default: