Skip to content

Commit

Permalink
Merge pull request #53 from TeamHRLive/development
Browse files Browse the repository at this point in the history
Fix island settings saving, heads in GUI menus, default island schematic
  • Loading branch information
ceze88 authored Sep 6, 2024
2 parents 09e5291 + 902b298 commit 774e5f1
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/craftaro/skyblock/island/Island.java
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ public synchronized void save() {

for (Entry<IslandRole, List<IslandPermission>> entry : this.islandPermissions.entrySet()) {
for (IslandPermission permission : entry.getValue()) {
configLoad.set("Settings." + entry.getKey().getFriendlyName() + "." + permission.getPermission().getName(), permission.getStatus());
configLoad.set("Settings." + entry.getKey().getFriendlyName().toUpperCase(Locale.US) + "." + permission.getPermission().getName(), permission.getStatus());
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/craftaro/skyblock/listeners/BlockListeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,23 @@ public void onBlockPlace(BlockPlaceEvent event) {
isObstructing = true;
}

// Specific check for beds
if (!isObstructing && event.getBlock().getState().getData() instanceof org.bukkit.material.Bed) {
// Specific check for beds using getBlockData() for versions 1.13 and above
if (!isObstructing && event.getBlock().getBlockData() instanceof org.bukkit.block.data.type.Bed && MajorServerVersion.isServerVersionAtLeast(MajorServerVersion.V1_13)) {
org.bukkit.block.data.type.Bed bedData = (org.bukkit.block.data.type.Bed) event.getBlock().getBlockData();
BlockFace bedDirection = bedData.getFacing();
org.bukkit.block.Block bedBlock = block.getRelative(bedDirection);
if (LocationUtil.isLocationAffectingIslandSpawn(bedBlock.getLocation(), island, world)) {
isObstructing = true;
}
} // Specific check for beds using getBlockData() for versions 1.12 and below
else if (MajorServerVersion.isServerVersionAtOrBelow(MajorServerVersion.V1_12)) {
if (!isObstructing && event.getBlock().getState().getData() instanceof org.bukkit.material.Bed){
BlockFace bedDirection = ((org.bukkit.material.Bed) event.getBlock().getState().getData()).getFacing();
org.bukkit.block.Block bedBlock = block.getRelative(bedDirection);
if (LocationUtil.isLocationAffectingIslandSpawn(bedBlock.getLocation(), island, world)) {
isObstructing = true;
}
}
}

if (isObstructing) {
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/craftaro/skyblock/listeners/EntityListeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,9 @@ public void onEntityDeath(EntityDeathEvent event) {
EntityEquipment equipment = livingEntity.getEquipment();
if (equipment != null) {
for (ItemStack item : event.getDrops()) {
if (item.equals(equipment.getHelmet()) || item.equals(equipment.getChestplate())
|| item.equals(equipment.getLeggings()) || item.equals(equipment.getBoots())
|| item.equals(equipment.getItemInMainHand()) || item.equals(equipment.getItemInOffHand())) {
if (item.isSimilar(equipment.getHelmet()) || item.isSimilar(equipment.getChestplate())
|| item.isSimilar(equipment.getLeggings()) || item.isSimilar(equipment.getBoots())
|| item.isSimilar(equipment.getItemInMainHand()) || item.isSimilar(equipment.getItemInOffHand())) {
dontMultiply.add(item);
}
}
Expand All @@ -607,12 +607,18 @@ public void onEntityDeath(EntityDeathEvent event) {
}
}

for (ItemStack is : event.getDrops()) {
for (ItemStack is2 : dontMultiply) {
if (!is2.isSimilar(is)) {
livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is);
// Only drop items that are not in the dontMultiply set
for (ItemStack item : event.getDrops()) {
boolean shouldDrop = true;
for (ItemStack dontMultiplyItem : dontMultiply) {
if (item.isSimilar(dontMultiplyItem)) {
shouldDrop = false;
break;
}
}
if (shouldDrop) {
livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), item);
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/craftaro/skyblock/menus/Leaderboard.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.craftaro.skyblock.menus;

import com.craftaro.core.utils.ItemUtils;
import com.craftaro.core.utils.NumberUtils;
import com.craftaro.core.utils.SkullItemCreator;
import com.craftaro.skyblock.SkyBlock;
Expand All @@ -11,9 +12,12 @@
import com.craftaro.skyblock.visit.Visit;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.third_party.com.cryptomorin.xseries.profiles.builder.XSkull;
import com.craftaro.third_party.com.cryptomorin.xseries.profiles.objects.Profileable;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Skull;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
Expand Down Expand Up @@ -290,9 +294,9 @@ public void open(Player player) {

ItemStack phead;
if (playerTexture.length >= 1 && playerTexture[0] != null) {
phead = SkullItemCreator.byTextureValue(playerTexture[0]);
phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply();
} else {
phead = SkullItemCreator.byUuid(visit.getOwnerUUID());
phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply();
}

nInv.addItem(
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/craftaro/skyblock/menus/Levelling.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void open(Player player) {
long value = testIslandMaterials.get(materialName);
Optional<XMaterial> materials = CompatibleMaterial.getMaterial(materialName);


if (!materials.isPresent()) {
continue;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/craftaro/skyblock/menus/Ownership.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.craftaro.skyblock.sound.SoundManager;
import com.craftaro.skyblock.utils.item.nInventoryUtil;
import com.craftaro.skyblock.utils.player.OfflinePlayer;
import com.craftaro.third_party.com.cryptomorin.xseries.profiles.builder.XSkull;
import com.craftaro.third_party.com.cryptomorin.xseries.profiles.objects.Profileable;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand Down Expand Up @@ -228,9 +230,9 @@ public void open(Player player) {

ItemStack phead;
if (playerTexture.length >= 1 && playerTexture[0] != null) {
phead = SkullItemCreator.byTextureValue(playerTexture[0]);
phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply();
} else {
phead = SkullItemCreator.byUuid(originalOwnerUUID);
phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply();
}

nInv.addItem(nInv.createItem(XMaterial.OAK_FENCE_GATE.parseItem(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/structures/default_1_20_5.structure

Large diffs are not rendered by default.

0 comments on commit 774e5f1

Please sign in to comment.