{"action":"closed","issue":{"url":"https://api.github.com/repos/SpongePowered/SpongeCommon/issues/391","labels_url":"https://api.github.com/repos/SpongePowered/SpongeCommon/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeCommon/issues/391/comments","events_url":"https://api.github.com/repos/SpongePowered/SpongeCommon/issues/391/events","html_url":"https://github.com/SpongePowered/SpongeCommon/issues/391","id":124631127,"number":391,"title":"Invisibility API unforeseen consequences","user":{"login":"mbax","id":181668,"avatar_url":"https://avatars.githubusercontent.com/u/181668?v=3","gravatar_id":"","url":"https://api.github.com/users/mbax","html_url":"https://github.com/mbax","followers_url":"https://api.github.com/users/mbax/followers","following_url":"https://api.github.com/users/mbax/following{/other_user}","gists_url":"https://api.github.com/users/mbax/gists{/gist_id}","starred_url":"https://api.github.com/users/mbax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbax/subscriptions","organizations_url":"https://api.github.com/users/mbax/orgs","repos_url":"https://api.github.com/users/mbax/repos","events_url":"https://api.github.com/users/mbax/events{/privacy}","received_events_url":"https://api.github.com/users/mbax/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-03T06:10:50Z","updated_at":"2016-01-05T06:24:10Z","closed_at":"2016-01-05T06:24:10Z","body":"Pre-existing entities (including drops and tile entities like the ender crystal) become invisible at time of `player.offer(Keys.INVISIBLE, true);`. Entities that come into being while invisible remain visible until set back to visible. \r\n\r\nEntities that update (moving mobs, at the least) while in this invisible state will magically reappear as they move about.\r\n\r\nPlayers, however, do not reappear. The player with the INVISIBLE state cannot see other players even if these other players move, crouch, jump, or break blocks from my testing.\r\n\r\nI should have warned you to prepare for unforeseen consequences, meddling with visibility like this. \r\n![Unforeseen consequences indeed](http://i.imgur.com/upAqx8P.png)\r\n\r\nStarted with: `forge-1.8-11.14.4.1577-universal.jar` and only the test plugin.\r\n\r\nSponge output: \r\n```\r\n> sponge version\r\nSpongeMod: 1.8-1577-3.0.0-BETA-1000\r\nSpongeAPI: 3.0.0\r\n```\r\n\r\nComplete code from my tested command:\r\n```java\r\n/*\r\n * * Copyright (C) 2016 Matt Baxter http://kitteh.org\r\n *\r\n * Permission is hereby granted, free of charge, to any person\r\n * obtaining a copy of this software and associated documentation\r\n * files (the \"Software\"), to deal in the Software without\r\n * restriction, including without limitation the rights to use, copy,\r\n * modify, merge, publish, distribute, sublicense, and/or sell copies\r\n * of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be\r\n * included in all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r\n * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r\n * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\npackage org.kitteh.vanish;\r\n\r\nimport org.spongepowered.api.command.CommandException;\r\nimport org.spongepowered.api.command.CommandResult;\r\nimport org.spongepowered.api.command.CommandSource;\r\nimport org.spongepowered.api.command.args.CommandContext;\r\nimport org.spongepowered.api.command.spec.CommandExecutor;\r\nimport org.spongepowered.api.data.key.Keys;\r\nimport org.spongepowered.api.entity.living.player.Player;\r\nimport org.spongepowered.api.text.Text;\r\nimport org.spongepowered.api.text.format.TextColors;\r\n\r\nimport javax.annotation.Nonnull;\r\nimport java.util.Optional;\r\n\r\n/**\r\n * Vanish!\r\n */\r\nclass VanishCommand implements CommandExecutor {\r\n    @Nonnull\r\n    @Override\r\n    public CommandResult execute(@Nonnull CommandSource commandSource, @Nonnull CommandContext commandContext) throws CommandException {\r\n        if (!(commandSource instanceof Player)) {\r\n            return CommandResult.empty();\r\n        }\r\n        Player player = (Player) commandSource;\r\n        Optional<Boolean> invisible = player.get(Keys.INVISIBLE);\r\n        boolean wasVisible = invisible.orElse(false);\r\n        player.offer(Keys.INVISIBLE, !wasVisible);\r\n        player.sendMessage(Text.of(TextColors.AQUA, \"You are now \" + (wasVisible ? \"\" : \"in\") + \"visible\"));\r\n        return CommandResult.success();\r\n    }\r\n}\r\n```"}}