mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-08-25 15:25:34 +02:00
Compare commits
2 Commits
fix/v7/spe
...
feat/v7/ge
Author | SHA1 | Date | |
---|---|---|---|
![]() |
91153e1b7b | ||
![]() |
4d8d5b3a9f |
@@ -47,6 +47,7 @@ import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
|||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@@ -157,14 +158,26 @@ public class ProjectileEventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileHit(ProjectileHitEvent event) {
|
public void onProjectileHit(ProjectileHitEvent event) {
|
||||||
Projectile entity = event.getEntity();
|
if (cancelProjectileHit(event.getEntity())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||||
|
if (cancelProjectileHit(event.getEgg())) {
|
||||||
|
event.setHatching(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean cancelProjectileHit(Projectile entity) {
|
||||||
Location location = BukkitUtil.adapt(entity.getLocation());
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
ProjectileSource shooter = entity.getShooter();
|
ProjectileSource shooter = entity.getShooter();
|
||||||
@@ -172,15 +185,14 @@ public class ProjectileEventListener implements Listener {
|
|||||||
if (!((Player) shooter).isOnline()) {
|
if (!((Player) shooter).isOnline()) {
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (plot.isAdded(((Player) shooter).getUniqueId()) || plot.getFlag(ProjectilesFlag.class)) {
|
if (plot.isAdded(((Player) shooter).getUniqueId()) || plot.getFlag(ProjectilesFlag.class)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true)) {
|
} else if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
|
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
@@ -189,38 +201,36 @@ public class ProjectileEventListener implements Listener {
|
|||||||
Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED
|
Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED
|
||||||
)) {
|
)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
|
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
|
||||||
ProjectilesFlag.class) || (entity instanceof FishHook && plot.getFlag(
|
ProjectilesFlag.class) || (entity instanceof FishHook && plot.getFlag(
|
||||||
FishingFlag.class))) {
|
FishingFlag.class))) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!(shooter instanceof Entity) && shooter != null) {
|
if (!(shooter instanceof Entity) && shooter != null) {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Location sLoc =
|
Location sLoc =
|
||||||
BukkitUtil.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
BukkitUtil.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||||
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Plot sPlot = area.getOwnedPlotAbs(sLoc);
|
Plot sPlot = area.getOwnedPlotAbs(sLoc);
|
||||||
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
|
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,6 @@ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "merge",
|
@CommandDeclaration(command = "merge",
|
||||||
aliases = "m",
|
aliases = "m",
|
||||||
@@ -117,11 +116,9 @@ public class Merge extends SubCommand {
|
|||||||
if (direction == null) {
|
if (direction == null) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||||
TagResolver.resolver(
|
TagResolver.resolver("value", Tag.inserting(Component.text(
|
||||||
"value", Tag.inserting(Component.text(
|
|
||||||
"/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]"
|
"/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]"
|
||||||
))
|
)))
|
||||||
)
|
|
||||||
);
|
);
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("help.direction"),
|
TranslatableCaption.of("help.direction"),
|
||||||
@@ -247,32 +244,28 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
if (!force) {
|
|
||||||
for (final UUID owner : uuids) {
|
for (final UUID owner : uuids) {
|
||||||
final PlotPlayer<?> accepter = PlotSquared.platform().playerManager().getPlayerIfExists(owner);
|
final PlotPlayer<?> accepter = PlotSquared.platform().playerManager().getPlayerIfExists(owner);
|
||||||
if (accepter == null) {
|
if (!force && accepter == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
isOnline = true;
|
isOnline = true;
|
||||||
final Direction dir = direction;
|
final Direction dir = direction;
|
||||||
Supplier<Boolean> run = () -> {
|
Runnable run = () -> {
|
||||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
|
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
|
||||||
if (plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain)) {
|
plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain);
|
||||||
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
|
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
|
||||||
if (plotPlayer == null) {
|
if (plotPlayer == null) {
|
||||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
|
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
|
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
|
||||||
if (this.econHandler.getMoney(player) < price) {
|
if (!force && this.econHandler.getMoney(player) < price) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
TranslatableCaption.of("economy.cannot_afford_merge"),
|
TranslatableCaption.of("economy.cannot_afford_merge"),
|
||||||
TagResolver.resolver(
|
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||||
"money",
|
|
||||||
Tag.inserting(Component.text(this.econHandler.format(price)))
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
this.econHandler.withdrawMoney(player, price);
|
this.econHandler.withdrawMoney(player, price);
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
@@ -282,14 +275,9 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||||
eventDispatcher.callPostMerge(player, plot);
|
eventDispatcher.callPostMerge(player, plot);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
if (hasConfirmation(player)) {
|
if (!force && hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(
|
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||||
accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
|
||||||
.deserialize(
|
.deserialize(
|
||||||
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player),
|
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player),
|
||||||
TagResolver.builder()
|
TagResolver.builder()
|
||||||
@@ -300,13 +288,10 @@ public class Merge extends SubCommand {
|
|||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
)),
|
)),
|
||||||
run::get
|
run
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return run.get();
|
run.run();
|
||||||
}
|
|
||||||
// find first
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (force || !isOnline) {
|
if (force || !isOnline) {
|
||||||
|
@@ -435,6 +435,11 @@ public class Settings extends Config {
|
|||||||
|
|
||||||
public static String SCHEMATICS = "schematics";
|
public static String SCHEMATICS = "schematics";
|
||||||
public static String TEMPLATES = "templates";
|
public static String TEMPLATES = "templates";
|
||||||
|
@Comment({"If schematics used for generation should be searched for in the path.schematics location",
|
||||||
|
" - This settings exists and is `false` by default for backwards compatibility.",
|
||||||
|
" - If false then generation schematics must be located in `schematics`",
|
||||||
|
" - Schematics must still always be under GEN_ROAD_SCHEMATIC/<world> etc."})
|
||||||
|
public static boolean USE_SCHEMATICS_PATH_FOR_GEN_SCHEMATICS = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -140,7 +140,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected PlotManager createManager() {
|
protected PlotManager createManager() {
|
||||||
return new HybridPlotManager(this, PlotSquared.platform().regionManager(),
|
return new HybridPlotManager(
|
||||||
|
this, PlotSquared.platform().regionManager(),
|
||||||
PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class)
|
PlotSquared.platform().injector().getInstance(ProgressSubscriberFactory.class)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -215,15 +216,16 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
|
|
||||||
// Try to determine root. This means that plot areas can have separate schematic
|
// Try to determine root. This means that plot areas can have separate schematic
|
||||||
// directories
|
// directories
|
||||||
|
String schematicFolder = Settings.Paths.USE_SCHEMATICS_PATH_FOR_GEN_SCHEMATICS ? Settings.Paths.SCHEMATICS : "schematics";
|
||||||
if (!(root =
|
if (!(root =
|
||||||
FileUtils.getFile(
|
FileUtils.getFile(
|
||||||
PlotSquared.platform().getDirectory(),
|
PlotSquared.platform().getDirectory(),
|
||||||
"schematics/GEN_ROAD_SCHEMATIC/" + this.getWorldName() + "/" + this.getId()
|
schematicFolder + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + this.getWorldName() + File.separator + this.getId()
|
||||||
))
|
))
|
||||||
.exists()) {
|
.exists()) {
|
||||||
root = FileUtils.getFile(
|
root = FileUtils.getFile(
|
||||||
PlotSquared.platform().getDirectory(),
|
PlotSquared.platform().getDirectory(),
|
||||||
"schematics/GEN_ROAD_SCHEMATIC/" + this.getWorldName()
|
schematicFolder + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + this.getWorldName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user