Skip to content

Commit

Permalink
dismount a few ticks later and make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 18, 2024
1 parent 76d58ab commit 6a60c15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

public class AllayDupe extends AEFModule implements Listener {

private final boolean dismount;

public AllayDupe() {
super("dupe-preventions.allay-dupe");
config.addComment(configPath, """
Will prevent allays from entering vehicles to prevent a duplication exploit
confirmed working in 1.19.4.""");
this.dismount = config.getBoolean(configPath + ".dismount-premounted-allays", true);
}

@Override
Expand Down Expand Up @@ -47,7 +50,8 @@ private void onEntityPickupItem(EntityPickupItemEvent event) {

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
if (dismount)
event.getEntity().getScheduler().execute(plugin, event.getEntity()::leaveVehicle, null, 10);
}
}

Expand All @@ -57,7 +61,8 @@ private void onEntityDropItem(EntityDropItemEvent event) {

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
if (dismount)
event.getEntity().getScheduler().execute(plugin, event.getEntity()::leaveVehicle, null, 10);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

public class AllayDupe extends AEFModule implements Listener {

private final boolean dismount;

public AllayDupe() {
super("dupe-preventions.allay-dupe");
config.addComment(configPath,
"Will prevent allays from entering vehicles to prevent a duplication exploit\n" +
"confirmed working in 1.19.4.");
this.dismount = config.getBoolean(configPath + ".dismount-premounted-allays", true);
}

@Override
Expand Down Expand Up @@ -46,7 +49,8 @@ private void onEntityPickupItem(EntityPickupItemEvent event) {

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
if (dismount) plugin.getServer().getScheduler()
.scheduleSyncDelayedTask(plugin, () -> event.getEntity().leaveVehicle(), 10L);
}
}
}

0 comments on commit 6a60c15

Please sign in to comment.