Added isPlayingSpleef() method to API. Also fixed a major bug with the
Death mercy system not properly dropping items in unloaded chunks.
This commit is contained in:
parent
e03eee1035
commit
b61abd62cf
Binary file not shown.
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public class SpleefManager {
|
|||||||
* Contains an array for every type of spleef game available
|
* Contains an array for every type of spleef game available
|
||||||
* along with a SpleefGame structure.
|
* along with a SpleefGame structure.
|
||||||
*/
|
*/
|
||||||
List<SpleefGame> spleef_game_list;
|
static List<SpleefGame> spleef_game_list;
|
||||||
TwosideKeeper plugin;
|
TwosideKeeper plugin;
|
||||||
public SpleefManager(TwosideKeeper plug) {
|
public SpleefManager(TwosideKeeper plug) {
|
||||||
plugin = plug;
|
plugin = plug;
|
||||||
@ -55,4 +56,13 @@ public class SpleefManager {
|
|||||||
spleef_game_list.get(i).Tick();
|
spleef_game_list.get(i).Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean playerIsPlayingSpleef(Player p) {
|
||||||
|
for (int i=0;i<spleef_game_list.size();i++) {
|
||||||
|
if (spleef_game_list.get(i).registered_players.contains(p)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1546,10 +1546,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
amounttotake = diff;
|
amounttotake = diff;
|
||||||
givePlayerBankMoney(p,-amounttotake);
|
givePlayerBankMoney(p,-amounttotake);
|
||||||
}
|
}
|
||||||
|
deathloc.getWorld().loadChunk(deathloc.getChunk());
|
||||||
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
|
||||||
if (p.getOpenInventory().getTopInventory().getItem(i)!=null &&
|
if (p.getOpenInventory().getTopInventory().getItem(i)!=null &&
|
||||||
p.getOpenInventory().getTopInventory().getItem(i).getType()!=Material.AIR) {
|
p.getOpenInventory().getTopInventory().getItem(i).getType()!=Material.AIR) {
|
||||||
deathloc.getWorld().dropItemNaturally(deathloc, p.getOpenInventory().getTopInventory().getItem(i));
|
deathloc.getWorld().dropItemNaturally(deathloc, p.getOpenInventory().getTopInventory().getItem(i));
|
||||||
|
log("Dropping "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" at Death location "+deathloc,3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeathManager.removeDeathStructure(p);
|
DeathManager.removeDeathStructure(p);
|
||||||
@ -1629,7 +1631,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
Player p = (Player)ev.getEntity();
|
Player p = (Player)ev.getEntity();
|
||||||
if (p.getFoodLevel()<ev.getFoodLevel()) {
|
if (p.getFoodLevel()<ev.getFoodLevel()) {
|
||||||
//If we are eating food, restore health.
|
//If we are eating food, restore health.
|
||||||
if (p.getHealth()<p.getMaxHealth()) {
|
if (p.getHealth()<p.getMaxHealth() && !p.isDead()) {
|
||||||
if (p.getHealth()+FOOD_HEAL_AMT>p.getMaxHealth()) {
|
if (p.getHealth()+FOOD_HEAL_AMT>p.getMaxHealth()) {
|
||||||
p.setHealth(p.getMaxHealth());
|
p.setHealth(p.getMaxHealth());
|
||||||
} else {
|
} else {
|
||||||
@ -3367,7 +3369,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
GenericFunctions.breakHardenedItem(item);
|
GenericFunctions.breakHardenedItem(item);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+item.getType().toString().replaceAll("_", " ")+ChatColor.DARK_RED+" has broken!");
|
p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.DARK_RED+" has broken!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4195,7 +4197,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.setMaxHealth(hp);
|
p.setMaxHealth(hp);
|
||||||
p.setHealth(p.getHealth());
|
if (!p.isDead()) {
|
||||||
|
p.setHealth(p.getHealth());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,11 @@ public final class TwosideKeeperAPI {
|
|||||||
return GenericFunctions.breakHardenedItem(i);
|
return GenericFunctions.breakHardenedItem(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Spleef COMMANDS.
|
||||||
|
public static boolean isPlayingSpleef(Player p) {
|
||||||
|
return SpleefManager.playerIsPlayingSpleef(p);
|
||||||
|
}
|
||||||
|
|
||||||
//Friendly Name COMMANDS.
|
//Friendly Name COMMANDS.
|
||||||
public static String getLocalizedItemName(ItemStack i) {
|
public static String getLocalizedItemName(ItemStack i) {
|
||||||
return GenericFunctions.UserFriendlyMaterialName(i);
|
return GenericFunctions.UserFriendlyMaterialName(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user