Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pvp enabled message showing to coop/trusted players even when they are not present on the island. #1885

Closed
bipedd opened this issue Dec 1, 2021 · 8 comments · Fixed by #1948
Assignees
Labels
Status: Done This issue has been completed or answered. This pull request has been merged. Type: Bug

Comments

@bipedd
Copy link

bipedd commented Dec 1, 2021

Expected behavior

The PvP enabled messages should only show when you teleport/enter the island that has PVP enabled.

Observed/Actual behavior

The message shows for trusted and cooped players even when they are not present on the island that PVP was enabled on. So if I am trusted on player 1's island but am at my own island, I still get that PVP-enabled message which can lead to confusion on if it's been enabled on your own island. Basically, the plugin isn't checking if cooped/trusted players are present on the island to then send the message to, it just sends it to them without checking.

Steps/models to reproduce

Need two accounts.

  1. Have account 1 make an island, then trust you.
  2. On account 2, go to your own island.
  3. On account 1 enable PVP.
  4. Check the chat of account 2.

BentoBox version

01.12 06:08:09 [Server] INFO Running PAPER 1.17.1.
01.12 06:08:09 [Server] INFO BentoBox version: 1.17.3
01.12 06:08:09 [Server] INFO Database: JSON
01.12 06:08:09 [Server] INFO Loaded Game Worlds:
01.12 06:08:09 [Server] INFO bskyblock_world (BSkyBlock): Overworld, Nether, The End
01.12 06:08:09 [Server] INFO Loaded Addons:
01.12 06:08:09 [Server] INFO Bank 1.3.2 (ENABLED)
01.12 06:08:09 [Server] INFO Biomes 1.14.0 (ENABLED)
01.12 06:08:09 [Server] INFO Border 3.2.0 (DISABLED)
01.12 06:08:09 [Server] INFO BSkyBlock 1.15.1 (ENABLED)
01.12 06:08:09 [Server] INFO Challenges 0.8.4 (ENABLED)
01.12 06:08:09 [Server] INFO Chat 1.1.4 (ENABLED)
01.12 06:08:09 [Server] INFO IslandFly 1.8.1 (ENABLED)
01.12 06:08:09 [Server] INFO Level 2.7.0 (ENABLED)
01.12 06:08:09 [Server] INFO MagicCobblestoneGenerator 2.3.0 (ENABLED)
01.12 06:08:09 [Server] INFO TwerkingForTrees 1.4.3 (ENABLED)
01.12 06:08:09 [Server] INFO Warps 1.10.2 (ENABLED)

Plugin list

No response

Other

No response

@BONNe
Copy link
Member

BONNe commented Dec 1, 2021

Can confirm:
https://github.com/BentoBoxWorld/BentoBox/blob/develop/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java#L229

I think this code could be adjusted to:

	@EventHandler(priority = EventPriority.NORMAL)
	public void onPVPFlagToggle(final FlagSettingChangeEvent e) {
		Flag flag = e.getEditedFlag();
		// Only care about PVP Flags
		if (Flags.PVP_OVERWORLD.equals(flag) || Flags.PVP_NETHER.equals(flag) || Flags.PVP_END.equals(flag)) {
			String message = "protection.flags." + flag.getID() + "." + (e.isSetTo() ? "enabled" : "disabled");
			// Send the message to players on the island
			e.getIsland().getPlayersOnIsland().forEach(player -> User.getInstance(player).sendMessage(message));
		}
	}

It will notify all players on the island about a flag change.

@bipedd
Copy link
Author

bipedd commented Dec 2, 2021

Can confirm:

https://github.com/BentoBoxWorld/BentoBox/blob/develop/src/main/java/world/bentobox/bentobox/listeners/flags/settings/PVPListener.java#L229

I think this code could be adjusted to:


	@EventHandler(priority = EventPriority.NORMAL)

	public void onPVPFlagToggle(final FlagSettingChangeEvent e) {

		Flag flag = e.getEditedFlag();

		// Only care about PVP Flags

		if (Flags.PVP_OVERWORLD.equals(flag) || Flags.PVP_NETHER.equals(flag) || Flags.PVP_END.equals(flag)) {

			String message = "protection.flags." + flag.getID() + "." + (e.isSetTo() ? "enabled" : "disabled");

			// Send the message to players on the island

			e.getIsland().getPlayersOnIsland().forEach(player -> User.getInstance(player).sendMessage(message));

		}

	}

It will notify all players on the island about a flag change.

Would that be added in a future update?

@bipedd
Copy link
Author

bipedd commented Dec 5, 2021

Any update?

@tastybento tastybento self-assigned this Dec 8, 2021
@tastybento tastybento added the Status: In progress Working on the issue. label Dec 8, 2021
@tastybento tastybento added Status: Done This issue has been completed or answered. This pull request has been merged. and removed Status: In progress Working on the issue. labels Dec 8, 2021
@tastybento
Copy link
Member

Done. It's in the latest BentoBox snapshot for 1.18 and also the one for 1.17.1

@bipedd
Copy link
Author

bipedd commented Dec 8, 2021

Done. It's in the latest BentoBox snapshot for 1.18 and also the one for 1.17.1

Thank you!

tastybento added a commit that referenced this issue Dec 13, 2021
* Update to Minecraft 1.18 (#1887)

* Make BlockEndDragon support custom max world height (#1888)

Use max world height instead of magic 255 value.

* Send PVP toggle messages only to on-island players.

#1885

* Add 1.18.1

Co-authored-by: BONNe <bonne@bonne.id.lv>
@bipedd
Copy link
Author

bipedd commented Mar 16, 2022

I'd like to re-open this issue due to me finding another issue that has the same subject:

Expected behavior
The PvP enabled messages should only show when you teleport/enter the island that has PVP enabled.

Observed/Actual behavior
When "block glitching" into a block while mining it, it spams the PVP-enabled message.

Steps/models to reproduce
Mine a block fast while also running into it.

BentoBox version
[03:08:59 INFO]: Running PAPER 1.18.1.
[03:08:59 INFO]: BentoBox version: 1.20.0
[03:08:59 INFO]: Database: JSON
[03:08:59 INFO]: Loaded Game Worlds:
[03:08:59 INFO]: bskyblock_world (BSkyBlock): Overworld, Nether, The End
[03:08:59 INFO]: Loaded Addons:
[03:08:59 INFO]: Bank 1.4.0 (ENABLED)
[03:08:59 INFO]: Biomes 1.14.0 (ENABLED)
[03:08:59 INFO]: BSkyBlock 1.15.2 (ENABLED)
[03:08:59 INFO]: Challenges 0.8.4 (ENABLED)
[03:08:59 INFO]: Chat 1.1.4 (ENABLED)
[03:08:59 INFO]: IslandFly 1.8.1 (ENABLED)
[03:08:59 INFO]: Level 2.9.0 (ENABLED)
[03:08:59 INFO]: MagicCobblestoneGenerator 2.3.0 (ENABLED)
[03:08:59 INFO]: TwerkingForTrees 1.4.3 (ENABLED)
[03:08:59 INFO]: Warps 1.11.1 (ENABLED)

Videos/images
https://user-images.githubusercontent.com/77213949/158532277-04c639d3-27ba-4185-be22-3c8a0484f8a7.mp4

Badlion.Client.2022.03.15.-.23.44.41.03.DVR_Trim.mp4

@bipedd
Copy link
Author

bipedd commented Mar 16, 2022

It seems to be happening every time I teleport back to the island. The issue is it shouldn't show even if I'm teleporting to a different spot on the island since I'm already on the island. In this video I was doing /top.
https://user-images.githubusercontent.com/77213949/158539373-bf824ebb-4943-48c6-ae30-3b5e660cfbbf.mp4

@BONNe
Copy link
Member

BONNe commented Mar 16, 2022

Yes, I notice that too... I will create a patch shortly :)

BONNe added a commit that referenced this issue Mar 16, 2022
If a player is teleporting on the same island in the same dimension, it keeps spamming that PVP is enabled in dimension. 
It should be enough with sending messages when the player teleports to the island.

Fixes #1885
BONNe added a commit that referenced this issue Mar 16, 2022
If a player is teleporting on the same island in the same dimension, it keeps spamming that PVP is enabled in dimension. 
It should be enough with sending messages when the player teleports to the island.

Fixes #1885
tastybento added a commit that referenced this issue Apr 17, 2022
* Version 1.20.1

* Added name of the addon causing the issue.

#1944

* Use world min-height for island bounding box.

* Fixes a bug when fallback could not use reusable

There was an issue in PanelItemTemplate that prevented fallback buttons to be "reusable" things.
The issue was that reusable items were not passed to the panel item reader.

* Adjusted test to try to avoid errors

* Fix for random test failures.

* Added 1.18.2 support

* Address unnecessary PVP reports on each teleport (#1948)

If a player is teleporting on the same island in the same dimension, it keeps spamming that PVP is enabled in dimension. 
It should be enough with sending messages when the player teleports to the island.

Fixes #1885

* Fixes bug with Safe Spot Teleport (#1951)

There was a bug that prevented finding a safe spot if all valid blocks were in height with the `startY` location.

Reported via discord.

* Fix Exception error reported by IDE

I am not sure why Eclipse is saying this is an error.

* Fix for kicking offline players

#1950

* Add an option in SafeSpotTeleport to cancel if fail (#1952)

There was no option to cancel teleportation if SafeSpotTeleport could not find a valid spot. This option could be used to avoid creating "backup" blocks in situations when teleportation is avoidable, f.e. visiting an island.

* Replace peplaceAll with replace

It does the same thing if the first argument is not a regex.

* Use constants for common strings

* Use constants for common strings

* Go back to replaceAll

This is required.

* Clearer paster (#1953)

* WIP - make easier to understand.

* Small refactor of paster to make it easier to understand

* Fix tabs to spaces. Sorry - new editor!

* Fix tabs to spaces

* Fix tab to spaces

* Improve team kick command (#1957)

The kick command has an unnecessary owner check. As command should be configurable by island owners, then limiting it to an owner is wrong.
Add a code that allows kicking only lower-ranked players.

Add message that shows who kicked from the island.
Add message that shows that rank does not allow to kick.

* Solve crashes with Addon#allLoaded call (#1959)

If some addon has code in Addon#allLoaded that crashes the call, then it did not disable addon as well as did not call allLoaded for every other addon that was left in the list.

This should be solved by adding an extra try-catch.

* using java 16 syntax (#1958)

* Fixes kick command (#1960)

PR #1957 broke kick command and noone could kick players from teams.
This should fix it.

* Fixes a bug with blueprint height (#1961)

Blueprint clipboard was preventing setting Y below 0 or above 255. 

The code was not adjusted to 1.18 changes.
Reported via discord.

* Fixes Lava Duplication Glitch (#1964)

Due to the fact, that Obsidian Scooping uses one tick delay to remove obsidian, a player with a bucket in hand and offhand duplicated lava. 
To avoid that, added an extra check that ignores the interact event if a player holds a bucket in both hands, and interacted hand is offhand.

Fixes #1963

* Fixes failures in obsidian cooping listener. (#1965)

Failures happened after implementing #1964

Co-authored-by: BONNe <bonne@bonne.id.lv>
Co-authored-by: Invvk <70810073+Invvk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Done This issue has been completed or answered. This pull request has been merged. Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants