mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +01:00
Merge pull request #278 from taoneill/helmetProtection
Closes gh-242. Adding task to protect the helmet
This commit is contained in:
commit
aeeb458408
@ -26,6 +26,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.tommytony.war.*;
|
||||
import com.tommytony.war.jobs.HelmetProtectionTask;
|
||||
import com.tommytony.war.mappers.*;
|
||||
import com.tommytony.war.utils.*;
|
||||
|
||||
@ -144,6 +145,7 @@ public class War extends JavaPlugin {
|
||||
this.getDefaultReward().put( 0, new ItemStack(Material.CAKE, 1));
|
||||
|
||||
WarMapper.load();
|
||||
this.getServer().getScheduler().scheduleAsyncDelayedTask(this, new HelmetProtectionTask());
|
||||
this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.tommytony.war.jobs;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.TeamKind;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
/**
|
||||
* Sets the helmet again onto the players heads
|
||||
*
|
||||
* @author Tim Düsterhus
|
||||
*/
|
||||
public class HelmetProtectionTask implements Runnable {
|
||||
|
||||
/**
|
||||
* @see Runnable.run()
|
||||
*/
|
||||
public void run() {
|
||||
while (true) {
|
||||
for (Warzone zone : War.war.getWarzones()) {
|
||||
for (Team team : zone.getTeams()) {
|
||||
for (Player player : team.getPlayers()) {
|
||||
PlayerInventory playerInv = player.getInventory();
|
||||
if (zone.isBlockHeads()) {
|
||||
playerInv.setHelmet(new ItemStack(team.getKind().getMaterial(), 1, (short) 1, new Byte(team.getKind().getData())));
|
||||
} else {
|
||||
if (team.getKind() == TeamKind.GOLD) {
|
||||
playerInv.setHelmet(new ItemStack(Material.GOLD_HELMET));
|
||||
} else if (team.getKind() == TeamKind.DIAMOND) {
|
||||
playerInv.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
|
||||
} else if (team.getKind() == TeamKind.IRON) {
|
||||
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||
} else {
|
||||
playerInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep((War.war.isLoaded()) ? 500 : 10000));
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user