This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
157 additions
and
20 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,18 @@ | ||
package bryangaming.code.api; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public interface EffectsModify { | ||
|
||
|
||
/** | ||
* Activate the effects according the rank that have the player. | ||
* | ||
* @param player The player that will activate his effects. | ||
* | ||
*/ | ||
|
||
static void giveEffectRank(Player player){ | ||
|
||
} | ||
} |
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,55 @@ | ||
package bryangaming.code.api; | ||
|
||
import bryangaming.code.Manager; | ||
import bryangaming.code.modules.CooldownMethod; | ||
import bryangaming.code.modules.MethodManager; | ||
import bryangaming.code.modules.PowerMethod; | ||
import bryangaming.code.modules.RankMethod; | ||
import bryangaming.code.modules.player.PlayerMessage; | ||
import bryangaming.code.registry.ConfigManager; | ||
import bryangaming.code.utils.Configuration; | ||
import org.bukkit.entity.Player; | ||
|
||
public class EffectsModifyImpl implements EffectsModify { | ||
|
||
private Manager manager; | ||
|
||
private static MethodManager methodManager; | ||
private static ConfigManager files; | ||
|
||
public EffectsModifyImpl(Manager manager){ | ||
this.manager = manager; | ||
methodManager = manager.getPlayerMethods(); | ||
files = manager.getFiles(); | ||
} | ||
|
||
|
||
public static void giveEffectRank(Player player){ | ||
|
||
RankMethod rankMethod = methodManager.getLoopMethod(); | ||
CooldownMethod cooldownMethod = methodManager.getCooldownMethod(); | ||
PowerMethod powerMethod = methodManager.getPowerMethod(); | ||
|
||
PlayerMessage playersender = methodManager.getSender(); | ||
|
||
Configuration config = files.getConfig(); | ||
Configuration messages = files.getMessages(); | ||
Configuration commands = files.getCommands(); | ||
|
||
if (cooldownMethod.playerIsInCooldown(player)) { | ||
playersender.sendMessage(player, messages.getString("error.cooldown.wait-time") | ||
.replace("%time%", cooldownMethod.getTextRankCooldown(player))); | ||
return; | ||
} | ||
|
||
if (rankMethod.getPlayerRank(player).equalsIgnoreCase("default") && config.getConfigurationSection("default") == null) { | ||
playersender.sendMessage(player, messages.getString("error.effects.empty-effects")); | ||
return; | ||
} | ||
|
||
powerMethod.setPower(player.getUniqueId()); | ||
playersender.sendMessage(player, commands.getString("commands.effects.status-on")); | ||
cooldownMethod.putCooldown(player, (System.currentTimeMillis() / 1000) + cooldownMethod.getRankCooldown(player)); | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/bryangaming/code/api/events/EnableEffectsEvent.java
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 bryangaming.code.api.events; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class EnableEffectsEvent extends Event implements Cancellable{ | ||
|
||
private final Player player; | ||
private boolean isCancelled; | ||
|
||
public EnableEffectsEvent(Player player){ | ||
this.player = player; | ||
this.isCancelled = false; | ||
} | ||
|
||
public Player getPlayer() { | ||
return player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return isCancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean isCancelled) { | ||
this.isCancelled = isCancelled; | ||
} | ||
|
||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
} |
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
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