mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
Adding "windcharge" flag (1.21.1+)
This commit is contained in:
parent
5642061d6f
commit
3491ff6be3
@ -33,6 +33,7 @@ import com.plotsquared.bukkit.listener.BlockEventListener;
|
|||||||
import com.plotsquared.bukkit.listener.BlockEventListener117;
|
import com.plotsquared.bukkit.listener.BlockEventListener117;
|
||||||
import com.plotsquared.bukkit.listener.ChunkListener;
|
import com.plotsquared.bukkit.listener.ChunkListener;
|
||||||
import com.plotsquared.bukkit.listener.EntityEventListener;
|
import com.plotsquared.bukkit.listener.EntityEventListener;
|
||||||
|
import com.plotsquared.bukkit.listener.EntityEventListener1211;
|
||||||
import com.plotsquared.bukkit.listener.EntitySpawnListener;
|
import com.plotsquared.bukkit.listener.EntitySpawnListener;
|
||||||
import com.plotsquared.bukkit.listener.HighFreqBlockEventListener;
|
import com.plotsquared.bukkit.listener.HighFreqBlockEventListener;
|
||||||
import com.plotsquared.bukkit.listener.PaperListener;
|
import com.plotsquared.bukkit.listener.PaperListener;
|
||||||
@ -359,6 +360,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
if (Settings.Enabled_Components.EVENTS) {
|
if (Settings.Enabled_Components.EVENTS) {
|
||||||
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this);
|
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this);
|
||||||
|
if ((serverVersion()[1] == 21 && serverVersion()[2] >= 1) || serverVersion()[1] > 21) {
|
||||||
|
getServer().getPluginManager().registerEvents(injector().getInstance(EntityEventListener1211.class), this);
|
||||||
|
}
|
||||||
if ((serverVersion()[1] == 20 && serverVersion()[2] >= 1) || serverVersion()[1] > 20) {
|
if ((serverVersion()[1] == 20 && serverVersion()[2] >= 1) || serverVersion()[1] > 20) {
|
||||||
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener1201.class), this);
|
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener1201.class), this);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* PlotSquared, a land and world management plugin for Minecraft.
|
||||||
|
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
||||||
|
* Copyright (C) IntellectualSites team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.listener;
|
||||||
|
|
||||||
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import com.plotsquared.core.location.Location;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.flag.implementations.WindChargeFlag;
|
||||||
|
import com.plotsquared.core.util.PlotFlagUtil;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For events since 1.21.1
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public class EntityEventListener1211 implements Listener {
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onWindCharge(EntityExplodeEvent event) {
|
||||||
|
// TODO Use "ExplosionResult" for this check after building the plugin with 1.21.1+
|
||||||
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = location.getOwnedPlot();
|
||||||
|
if (plot == null) {
|
||||||
|
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, WindChargeFlag.class, false)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!plot.getFlag(WindChargeFlag.class)) {
|
||||||
|
plot.debug("Could not update blocks by wind charge because wind-charge = false");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -92,6 +92,7 @@ import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag;
|
import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
|
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
|
||||||
|
import com.plotsquared.core.plot.flag.implementations.WindChargeFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.PveFlag;
|
import com.plotsquared.core.plot.flag.implementations.PveFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.PvpFlag;
|
import com.plotsquared.core.plot.flag.implementations.PvpFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
|
||||||
@ -207,6 +208,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE);
|
this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE);
|
||||||
this.addFlag(VineGrowFlag.VINE_GROW_TRUE);
|
this.addFlag(VineGrowFlag.VINE_GROW_TRUE);
|
||||||
this.addFlag(ProjectilesFlag.PROJECTILES_FALSE);
|
this.addFlag(ProjectilesFlag.PROJECTILES_FALSE);
|
||||||
|
this.addFlag(WindChargeFlag.WIND_CHARGE_FALSE);
|
||||||
|
|
||||||
// Double flags
|
// Double flags
|
||||||
this.addFlag(PriceFlag.PRICE_NOT_BUYABLE);
|
this.addFlag(PriceFlag.PRICE_NOT_BUYABLE);
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* PlotSquared, a land and world management plugin for Minecraft.
|
||||||
|
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
||||||
|
* Copyright (C) IntellectualSites team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.plot.flag.implementations;
|
||||||
|
|
||||||
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
|
import com.plotsquared.core.plot.flag.types.BooleanFlag;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
public class WindChargeFlag extends BooleanFlag<WindChargeFlag> {
|
||||||
|
|
||||||
|
public static final WindChargeFlag WIND_CHARGE_TRUE = new WindChargeFlag(true);
|
||||||
|
public static final WindChargeFlag WIND_CHARGE_FALSE = new WindChargeFlag(false);
|
||||||
|
|
||||||
|
private WindChargeFlag(boolean value) {
|
||||||
|
super(value, TranslatableCaption.of("flags.flag_description_windcharge"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected WindChargeFlag flagOf(@NonNull Boolean value) {
|
||||||
|
return value ? WIND_CHARGE_TRUE : WIND_CHARGE_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -629,6 +629,7 @@
|
|||||||
"flags.flag_description_leaf_decay": "<gray>Set to `false` to prevent leaves from decaying.",
|
"flags.flag_description_leaf_decay": "<gray>Set to `false` to prevent leaves from decaying.",
|
||||||
"flags.flag_description_projectiles": "<gray>Prevents guests from shooting projectiles on the plot when set to false.</gray>",
|
"flags.flag_description_projectiles": "<gray>Prevents guests from shooting projectiles on the plot when set to false.</gray>",
|
||||||
"flags.flag_description_beacon_effect": "<gray>Enables beacon effects on the plot.</gray>",
|
"flags.flag_description_beacon_effect": "<gray>Enables beacon effects on the plot.</gray>",
|
||||||
|
"flags.flag_description_windcharge": "<gray>Enables Wind-Charge effects on the plot.</gray>",
|
||||||
"flags.flag_error_boolean": "Flag value must be a boolean (true | false).",
|
"flags.flag_error_boolean": "Flag value must be a boolean (true | false).",
|
||||||
"flags.flag_error_enum": "Must be one of: <list>",
|
"flags.flag_error_enum": "Must be one of: <list>",
|
||||||
"flags.flag_error_integer": "Flag value must be a whole positive number.",
|
"flags.flag_error_integer": "Flag value must be a whole positive number.",
|
||||||
|
Loading…
Reference in New Issue
Block a user