Finished Building The Parts
This commit is contained in:
parent
dd77078ec0
commit
a49811f4fd
5 changed files with 60 additions and 11 deletions
|
@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class gPowerTest implements CommandExecutor{
|
||||
public class gPowerCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
@ -15,7 +15,7 @@ public class gPowerMemory {
|
|||
this.plugin = plugin;
|
||||
}
|
||||
//SHORT TERM MEMORY STORAGE
|
||||
Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
|
||||
public static Map<UUID, poweredPlayer> PlayerMap = new HashMap<UUID, poweredPlayer>();
|
||||
|
||||
//POWER ACTIVATION
|
||||
public void PowerUpPlayer(Player player, String colour){
|
||||
|
@ -57,7 +57,7 @@ public class gPowerMemory {
|
|||
}
|
||||
}
|
||||
//MEMORY UNIT
|
||||
class poweredPlayer{
|
||||
public class poweredPlayer{
|
||||
public UUID uuid;
|
||||
public String colour;
|
||||
public Boolean playerPowersActivated;
|
||||
|
@ -71,6 +71,8 @@ public class gPowerMemory {
|
|||
return "[UUID: "+ uuid.toString() + ", Colour: "+ colour+", IsActivated: "+playerPowersActivated + "]";
|
||||
}
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public void debug(String debugString){
|
||||
if (plugin.getServer().getPlayer("alisolarflare").isOnline() && debugMode == true){
|
||||
|
|
52
src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java
Normal file
52
src/alisolarflare/gpowers/listeners/gPowerApplyingTask.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package alisolarflare.gpowers.listeners;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import alisolarflare.AliPresents;
|
||||
import alisolarflare.gpowers.gPowerMemory;
|
||||
|
||||
public class gPowerApplyingTask extends BukkitRunnable{
|
||||
|
||||
private AliPresents plugin;
|
||||
|
||||
public gPowerApplyingTask(AliPresents plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
//REPEATS EVERY 5 SECONDS
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()){
|
||||
if(gPowerMemory.PlayerMap.containsKey(player.getUniqueId())){
|
||||
activatePower(player, gPowerMemory.PlayerMap.get(player.getUniqueId()).colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void activatePower(Player player, String colour) {
|
||||
if ((colour.startsWith("grey") || colour.startsWith("gra")) && (player.getWorld().getTime() > 12575 && player.getWorld().getTime() < 22925)){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1, true, false, Color.GRAY));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("r")){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("o")){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 100, 1, true, false, Color.GRAY));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("y") && player.getLocation().getBlock().getLightFromSky() == 15){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("g")){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LUCK, 100, 1, true, false, Color.GRAY));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("b")){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 1, true, false, Color.GRAY));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 100, 1, true, false, Color.GRAY));
|
||||
}else if (colour.startsWith("p")){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 100, 1, true, false, Color.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -6,12 +6,13 @@ import org.bukkit.scheduler.BukkitTask;
|
|||
import alisolarflare.AliPresents;
|
||||
|
||||
public class gPowerListener implements Listener{
|
||||
@SuppressWarnings("unused")
|
||||
private AliPresents plugin;
|
||||
public gPowerRepeatingTask powerRepeatingTask;
|
||||
public gPowerApplyingTask powerRepeatingTask;
|
||||
public BukkitTask bukkitTask;
|
||||
public gPowerListener(AliPresents plugin){
|
||||
this.plugin = plugin;
|
||||
this.powerRepeatingTask = new gPowerApplyingTask(this.plugin);
|
||||
bukkitTask = powerRepeatingTask.runTaskTimer(plugin, 5, 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package alisolarflare.gpowers.listeners;
|
||||
|
||||
public class gPowerRepeatingTask {
|
||||
//REPEATS EVERY 5 SECONDS
|
||||
|
||||
}
|
Loading…
Reference in a new issue