mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2024-12-19 23:38:53 +08:00
新增支持1.21的合成台权限控制
This commit is contained in:
parent
49772fadc9
commit
9180a2a4e0
@ -1,13 +1,24 @@
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
}
|
||||
|
||||
group = "cn.lunadeer"
|
||||
version = "1.42.9-beta"
|
||||
version = "1.43.0-beta"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
// utf-8
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven("https://oss.sonatype.org/content/groups/public")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://jitpack.io")
|
||||
@ -17,6 +28,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
|
||||
|
||||
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:v2.6.2")
|
||||
compileOnly("us.dynmap:DynmapCoreAPI:3.4")
|
||||
|
||||
@ -24,11 +36,19 @@ dependencies {
|
||||
implementation("org.yaml:snakeyaml:2.0")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
tasks {
|
||||
processResources {
|
||||
// replace @version@ in plugin.yml with project version
|
||||
filesMatching("**/plugin.yml") {
|
||||
filter {
|
||||
it.replace("@version@", project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveBaseName.set(rootProject.name)
|
||||
archiveVersion.set(version.toString())
|
||||
shadowJar {
|
||||
archiveClassifier.set("")
|
||||
archiveVersion.set(project.version.toString())
|
||||
dependsOn(processResources)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.lunadeer.dominion;
|
||||
|
||||
import cn.lunadeer.dominion.events.EnvironmentEvents_1_20_1;
|
||||
import cn.lunadeer.dominion.events.PlayerEvents_1_20_1;
|
||||
import cn.lunadeer.dominion.events.EnvironmentEvents;
|
||||
import cn.lunadeer.dominion.events.PlayerEvents;
|
||||
import cn.lunadeer.dominion.events.SelectPointEvents;
|
||||
import cn.lunadeer.dominion.managers.ConfigManager;
|
||||
import cn.lunadeer.dominion.managers.DatabaseTables;
|
||||
@ -41,8 +41,8 @@ public final class Dominion extends JavaPlugin {
|
||||
AutoClean.run();
|
||||
Cache.instance = new Cache();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerEvents_1_20_1(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new EnvironmentEvents_1_20_1(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new EnvironmentEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new SelectPointEvents(), this);
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("dominion")).setExecutor(new Commands());
|
||||
|
||||
|
@ -10,7 +10,9 @@ import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
@ -21,7 +23,7 @@ import java.util.Objects;
|
||||
import static cn.lunadeer.dominion.events.Apis.checkFlag;
|
||||
import static org.bukkit.Material.FARMLAND;
|
||||
|
||||
public class EnvironmentEvents_1_20_1 implements Listener {
|
||||
public class EnvironmentEvents implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // creeper_explode
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
@ -81,8 +83,7 @@ public class EnvironmentEvents_1_20_1 implements Listener {
|
||||
return damager.getType() != EntityType.CREEPER
|
||||
&& damager.getType() != EntityType.WITHER_SKULL
|
||||
&& damager.getType() != EntityType.FIREBALL
|
||||
&& damager.getType().getTypeId() != 200;
|
||||
// 200 -> end_crystal
|
||||
&& damager.getType() != EntityType.END_CRYSTAL;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // dragon_break_block
|
||||
@ -147,8 +148,7 @@ public class EnvironmentEvents_1_20_1 implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // tnt_explode
|
||||
public void onTntExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
// 45 -> minecart_tnt, 20 -> primed_tnt
|
||||
if (entity.getType().getTypeId() != 45 && entity.getType().getTypeId() != 20) {
|
||||
if (entity.getType() != EntityType.TNT_MINECART && entity.getType() != EntityType.TNT) {
|
||||
return;
|
||||
}
|
||||
event.blockList().removeIf(block -> {
|
||||
@ -164,8 +164,7 @@ public class EnvironmentEvents_1_20_1 implements Listener {
|
||||
return;
|
||||
}
|
||||
Entity damager = event.getDamager();
|
||||
// 45 -> minecart_tnt, 20 -> primed_tnt
|
||||
if (entity.getType().getTypeId() != 45 && entity.getType().getTypeId() != 20) {
|
||||
if (entity.getType() != EntityType.TNT_MINECART && entity.getType() != EntityType.TNT) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());
|
@ -15,7 +15,10 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityMountEvent;
|
||||
import org.bukkit.event.entity.EntityPlaceEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
@ -29,7 +32,7 @@ import org.bukkit.material.Colorable;
|
||||
import static cn.lunadeer.dominion.events.Apis.checkFlag;
|
||||
import static cn.lunadeer.dominion.events.Apis.getInvDominion;
|
||||
|
||||
public class PlayerEvents_1_20_1 implements Listener {
|
||||
public class PlayerEvents implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player bukkitPlayer = event.getPlayer();
|
||||
@ -325,6 +328,19 @@ public class PlayerEvents_1_20_1 implements Listener {
|
||||
checkFlag(dom, Flag.CRAFT, bukkitPlayer, event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // crafter
|
||||
public void onCrafterOpen(InventoryOpenEvent event) {
|
||||
Inventory inv = event.getInventory();
|
||||
if (inv.getType() != InventoryType.CRAFTER) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getPlayer() instanceof Player bukkitPlayer)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = getInvDominion(bukkitPlayer, inv);
|
||||
checkFlag(dom, Flag.CRAFTER, bukkitPlayer, event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // comparer
|
||||
public void comparerChange(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||
@ -620,7 +636,7 @@ public class PlayerEvents_1_20_1 implements Listener {
|
||||
Teleport.doTeleportSafely(player, to).thenAccept((success) -> {
|
||||
if (!success) {
|
||||
Notification.warn(player, "传送失败,你将被传送到复活点");
|
||||
player.teleportAsync(player.getBedSpawnLocation() == null ?
|
||||
player.teleport(player.getBedSpawnLocation() == null ?
|
||||
player.getWorld().getSpawnLocation() :
|
||||
player.getBedSpawnLocation()
|
||||
, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
@ -1,30 +0,0 @@
|
||||
package cn.lunadeer.dominion.events;
|
||||
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.dtos.Flag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import static cn.lunadeer.dominion.events.Apis.checkFlag;
|
||||
import static cn.lunadeer.dominion.events.Apis.getInvDominion;
|
||||
|
||||
public class PlayerEvents_1_21 extends PlayerEvents_1_20_1 {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST) // crafter
|
||||
public void onCrafterOpen(InventoryOpenEvent event) {
|
||||
Inventory inv = event.getInventory();
|
||||
if (inv.getType() != InventoryType.CRAFTER) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getPlayer() instanceof Player bukkitPlayer)) {
|
||||
return;
|
||||
}
|
||||
DominionDTO dom = getInvDominion(bukkitPlayer, inv);
|
||||
checkFlag(dom, Flag.CRAFTER, bukkitPlayer, event);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
name: Dominion
|
||||
version: '${version}'
|
||||
version: @version@
|
||||
main: cn.lunadeer.dominion.Dominion
|
||||
api-version: '1.20'
|
||||
load: STARTUP
|
||||
|
Loading…
Reference in New Issue
Block a user