Skip to content

Commit 013e32e

Browse files
Fixed bugs
1 parent ec25db4 commit 013e32e

6 files changed

Lines changed: 22 additions & 13 deletions

File tree

src/main/java/me/general_breddok/blockdisplaycreator/data/manager/PersistentDataTypes.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public interface PersistentDataTypes {
204204

205205
PersistentDataType<String, UUID> UUID = PersistentDataTypeStore.newPersistentDataType(
206206
String.class,
207-
java.util.UUID.class,
207+
UUID.class,
208208
(complex, context) -> complex.toString(),
209209
(primitive, context) -> java.util.UUID.fromString(primitive)
210210
);
@@ -390,10 +390,21 @@ public interface PersistentDataTypes {
390390
CommandBundle.CommandSource commandSource = CommandBundle.CommandSource.CONSOLE;
391391
List<String> grantedCommandPermissions = new ArrayList<>();
392392

393-
ArrayList<?> commandList = (ArrayList<?>) primitive.getList("command");
393+
Object command = primitive.get("command");
394+
ArrayList<Object> commandList = null;
394395
ArrayList<?> grantedCommandPermissionList = (ArrayList<?>) primitive.getList("granted-command-permission");
395396
String commandSourceStr = primitive.getString("command-source");
396397

398+
if (command instanceof List) {
399+
commandList = (ArrayList<Object>) command;
400+
if (commandList.isEmpty()) {
401+
return null;
402+
}
403+
} else {
404+
commandList = new ArrayList<>();
405+
commandList.add(command);
406+
}
407+
397408
if (commandList != null) {
398409
commands = COMMAND_LIST.fromPrimitive(commandList, context);
399410
} else {

src/main/java/me/general_breddok/blockdisplaycreator/data/yaml/YamlData.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.google.common.reflect.TypeToken;
44
import me.general_breddok.blockdisplaycreator.data.BukkitData;
5-
import me.general_breddok.blockdisplaycreator.data.manager.ParameterizedClasses;
65
import me.general_breddok.blockdisplaycreator.data.exception.ConfigurationDataTypeMismatchException;
6+
import me.general_breddok.blockdisplaycreator.data.manager.ParameterizedClasses;
77
import me.general_breddok.blockdisplaycreator.data.manager.PersistentDataTypeManager;
88
import me.general_breddok.blockdisplaycreator.data.manager.PersistentDataTypeStore;
99
import me.general_breddok.blockdisplaycreator.data.manager.TypeTokens;
@@ -201,7 +201,6 @@ public C get(@NotNull String path) throws ConfigurationDataTypeMismatchException
201201
return null;
202202
}
203203

204-
205204
if (!(result instanceof String)) {
206205
if (result instanceof Number number) {
207206
if (NumberUtil.isNumberClass(primitiveType)) {
@@ -213,7 +212,7 @@ public C get(@NotNull String path) throws ConfigurationDataTypeMismatchException
213212
}
214213
}
215214

216-
if (!(result instanceof ArrayList<?>) && primitiveType.equals(ArrayList.class)) {
215+
if (!(result instanceof List<?>) && primitiveType.isAssignableFrom(List.class)) {
217216
List<Object> list = new ArrayList<>();
218217
list.add(result);
219218
result = list;

src/main/java/me/general_breddok/blockdisplaycreator/event/custom/block/CustomBlockInteractEvent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class CustomBlockInteractEvent extends CustomBlockPlayerEvent implements
2828
@NonFinal
2929
boolean cancelled = false;
3030
Interaction interactionEntity;
31-
@Nullable
3231
ConfiguredInteraction configuredInteraction;
3332
EquipmentSlot hand;
3433

@@ -45,7 +44,7 @@ public class CustomBlockInteractEvent extends CustomBlockPlayerEvent implements
4544

4645
public CustomBlockInteractEvent(@NotNull CustomBlock block, @NotNull Player player,
4746
@NotNull Interaction interactionEntity,
48-
@Nullable ConfiguredInteraction configuredInteraction,
47+
@NotNull ConfiguredInteraction configuredInteraction,
4948
@NotNull EquipmentSlot hand) {
5049
super(block, player);
5150
this.interactionEntity = interactionEntity;

src/main/java/me/general_breddok/blockdisplaycreator/listener/entity/EntityDamageByEntityListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
105105

106106
CustomBlockOption[] options = new CustomBlockOption[5];
107107

108-
if (player.getGameMode() != GameMode.CREATIVE || player.getGameMode() != GameMode.SPECTATOR) {
108+
if (!(player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)) {
109109
options[0] = CustomBlockBreakOption.DROP_ITEM;
110110
}
111111

src/main/java/me/general_breddok/blockdisplaycreator/listener/player/PlayerInteractEntityListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public void onPlayerInteractAtEntity(PlayerInteractEntityEvent event) {
9191

9292
ConfiguredInteraction configuredInteraction = customBlock.getConfiguredInteraction(interaction);
9393

94-
CustomBlockInteractEvent customBlockInteractEvent = new CustomBlockInteractEvent(customBlock, player, interaction, configuredInteraction, hand);
95-
96-
if (!EventUtil.call(customBlockInteractEvent)) {
94+
if (configuredInteraction == null) {
9795
return;
9896
}
9997

100-
if (configuredInteraction == null) {
98+
CustomBlockInteractEvent customBlockInteractEvent = new CustomBlockInteractEvent(customBlock, player, interaction, configuredInteraction, hand);
99+
100+
if (!EventUtil.call(customBlockInteractEvent)) {
101101
return;
102102
}
103103

src/main/java/me/general_breddok/blockdisplaycreator/listener/player/PlayerInteractListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
121121

122122
CustomBlock customBlock = customBlockService.placeBlock(abstractCustomBlock, blockLocation, customBlockRotation, player);
123123

124-
if (customBlock != null && player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR) {
124+
if (customBlock != null && !(player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR)) {
125125
item.setAmount(item.getAmount() - 1);
126126
}
127127
}

0 commit comments

Comments
 (0)