Skip to content

Commit

Permalink
feat: introduce a fishing flag (#4343)
Browse files Browse the repository at this point in the history
* introduce fishing flag

* fixed typo in description

* added details to the flags description
  • Loading branch information
Tamikaschu committed Mar 2, 2024
1 parent 68701b6 commit 5344efd
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
Expand Up @@ -40,6 +40,7 @@
import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.plot.flag.implementations.BeaconEffectsFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.FishingFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
Expand Down Expand Up @@ -348,6 +349,11 @@ public void onProjectileLaunch(PlayerLaunchProjectileEvent event) {
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (entity.getType().equals(EntityType.FISHING_HOOK)) {
if (plot.getFlag(FishingFlag.class)) {
return;
}
}
if (!plot.getFlag(ProjectilesFlag.class)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
Expand Down
Expand Up @@ -28,12 +28,14 @@
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.flag.implementations.FishingFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.PlotFlagUtil;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
Expand Down Expand Up @@ -132,6 +134,11 @@ public void onProjectileLaunch(ProjectileLaunchEvent event) {
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (entity.getType().equals(EntityType.FISHING_HOOK)) {
if (plot.getFlag(FishingFlag.class)) {
return;
}
}
if (!plot.getFlag(ProjectilesFlag.class)) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
Expand Down Expand Up @@ -187,7 +194,8 @@ public void onProjectileHit(ProjectileHitEvent event) {
return;
}
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(
ProjectilesFlag.class)) {
ProjectilesFlag.class) || (entity.getType().equals(EntityType.FISHING_HOOK) && plot.getFlag(
FishingFlag.class))) {
return;
}
entity.remove();
Expand Down
Expand Up @@ -48,6 +48,7 @@
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
import com.plotsquared.core.plot.flag.implementations.FarewellFlag;
import com.plotsquared.core.plot.flag.implementations.FeedFlag;
import com.plotsquared.core.plot.flag.implementations.FishingFlag;
import com.plotsquared.core.plot.flag.implementations.FlyFlag;
import com.plotsquared.core.plot.flag.implementations.ForcefieldFlag;
import com.plotsquared.core.plot.flag.implementations.GamemodeFlag;
Expand Down Expand Up @@ -158,6 +159,7 @@ private GlobalFlagContainer() {
this.addFlag(EditSignFlag.EDIT_SIGN_FALSE);
this.addFlag(EntityChangeBlockFlag.ENTITY_CHANGE_BLOCK_FALSE);
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
this.addFlag(FishingFlag.FISHING_FALSE);
this.addFlag(ForcefieldFlag.FORCEFIELD_FALSE);
this.addFlag(GrassGrowFlag.GRASS_GROW_TRUE);
this.addFlag(HangingBreakFlag.HANGING_BREAK_FALSE);
Expand Down
@@ -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 FishingFlag extends BooleanFlag<FishingFlag> {

public static final FishingFlag FISHING_TRUE = new FishingFlag(true);
public static final FishingFlag FISHING_FALSE = new FishingFlag(false);

private FishingFlag(boolean value) {
super(value, TranslatableCaption.of("flags.flag_description_fishing"));
}

@Override
protected FishingFlag flagOf(@NonNull final Boolean value) {
return value ? FISHING_TRUE : FISHING_FALSE;
}

}
1 change: 1 addition & 0 deletions Core/src/main/resources/lang/messages_en.json
Expand Up @@ -559,6 +559,7 @@
"flags.flag_description_drop_protection": "<gray>Set to `true` to prevent dropped items from being picked up by non-members of the plot.</gray>",
"flags.flag_description_edit_sign": "<gray>Set to `true` to allow editing signs in the plot.</gray>",
"flags.flag_description_feed": "<gray>Specify an interval in seconds and an optional amount by which the players will be fed (amount is 1 by default).</gray>",
"flags.flag_description_fishing": "<gray>Set to `true` to allow guests to use a fishing rod in the plot.</gray>",
"flags.flag_description_forcefield": "<gray>Set to `true` to enable member forcefield in the plot.</gray>",
"flags.flag_description_grass_grow": "<gray>Set to `false` to prevent grass from growing within the plot.</gray>",
"flags.flag_description_hanging_break": "<gray>Set to `true` to allow guests to break hanging objects in the plot.</gray>",
Expand Down

0 comments on commit 5344efd

Please sign in to comment.