-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c5d875
commit bda7d75
Showing
3 changed files
with
55 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.lewmc.essence.utils; | ||
|
||
import net.lewmc.essence.Essence; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
/** | ||
* Manages player statistics. | ||
*/ | ||
public class StatsUtil { | ||
private final Player player; | ||
private final PermissionHandler permission; | ||
private final Essence plugin; | ||
|
||
public StatsUtil(Essence plugin, Player player, PermissionHandler permission) { | ||
this.plugin = plugin; | ||
this.player = player; | ||
this.permission = permission; | ||
} | ||
|
||
/** | ||
* Sets the player to be invisible. | ||
* @param isInvisible boolean - Should the player be invisible (true) or visible (false). | ||
* @return boolean - Was the operation successful? | ||
*/ | ||
public boolean invisible(boolean isInvisible) { | ||
if (this.permission.has("essence.admin.invisible")) { | ||
if (isInvisible) { | ||
this.player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1)); | ||
MessageUtil message = new MessageUtil(this.player, this.plugin); | ||
message.send("visibility", "invisible", new String[]{this.player.getName()}); | ||
} else { | ||
this.player.removePotionEffect(PotionEffectType.INVISIBILITY); | ||
MessageUtil message = new MessageUtil(this.player, this.plugin); | ||
message.send("visibility", "visible", new String[]{this.player.getName()}); | ||
} | ||
return true; | ||
} else { | ||
return this.permission.not(); | ||
} | ||
} | ||
} |