Squashed commit of the following:

commit cb3e057dee1f2b29838ab654a526baac1baab7d6
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:43:57 2013 -0500

    1.4.00 release

commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:07:30 2013 -0500

    \r -> \n

commit b2ca22e0477c747143b0f08a28a096967ee6ffd7
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:53:56 2013 -0500

    Commented-out code shouldn't be done like that.

commit 92f131712cc671e3e616c14a22e22769ef6d6d0b
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:45:36 2013 -0500

    More things we missed.

commit 408b03766f6261a03a862a1ab7f5835772feda4a
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 23:20:13 2013 -0500

    Format: util through spout and backup lib

commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:50:08 2013 -0500

    The things we missed the first time through...

commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:05:29 2013 -0500

    Formatting: Skills

commit c097a6e188a7b760dd1b4389ed81dca417146b16
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:30:12 2013 -0500

    Organize imports.

commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:45 2013 -0500

    Fixed a missing fallthrough comment from ChatCommand

commit b4a76c9f022a2fd98bdd8f083accfea03becfd71
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:36 2013 -0500

    Formatting: datatypes.* through events.*

commit 3e57dd41d3265a7c8106c7eb026df926770a4d15
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:56:15 2013 -0500

    Fix issue with bad rebase

commit e8c8e06b2971555b7334e49128257e3af6f36892
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 17:35:32 2013 -0500

    Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and
    PlayerStat

commit 13ecf1cc41f377a12991e357ac10abdcda24d6de
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:31:43 2013 -0500

    Format: listeners.* through runnables.*

commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:13:57 2013 -0500

    Format PartyLockCommand

commit d50abed10bf94e1a88df3dc5cc07c259aea920ea
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 16:54:08 2013 -0500

    Format: base through config.*

commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:21:40 2013 -0500

    Example of using spaces to align like things

commit 534190cfe2481e466fe459d65628550458cc2993
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:12:19 2013 -0500

    Capitalization

commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:07:43 2013 -0500

    Updated readme, added standards.md

commit 5ec0df70fb82c527420a2f437f27f31bd758f884
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 14:42:16 2013 -0500

    Markdown was here, Creole is a loser

commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 13:46:24 2013 -0500

    Move MCStats shading to .metrics.mcstats

commit eb9d67e66b1659d6abd2397ecf403343cfeffdda
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 13:37:37 2013 -0500

    Move ALL the packages!

commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 12:37:12 2013 -0500

    /r/n -> /n
This commit is contained in:
NuclearW
2013-03-01 00:52:01 -05:00
parent 13111a8d1b
commit a542d6cf3e
263 changed files with 24364 additions and 23982 deletions

View File

@ -0,0 +1,40 @@
package com.gmail.nossr50.runnables.skills;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class AwardCombatXpTask implements Runnable {
private McMMOPlayer mcMMOPlayer;
private double baseXp;
private SkillType skillType;
private LivingEntity target;
private int baseHealth;
public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) {
this.mcMMOPlayer = mcMMOPlayer;
this.skillType = skillType;
this.baseXp = baseXp;
this.target = target;
baseHealth = target.getHealth();
}
@Override
public void run() {
int health = target.getHealth();
int damage = baseHealth - health;
// May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0) {
return;
}
// Don't reward the player for overkills
if (health < 0) {
damage += health;
}
mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp));
}
}

View File

@ -0,0 +1,109 @@
package com.gmail.nossr50.runnables.skills;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
public class BleedTimerTask implements Runnable {
private final static int MAX_BLEED_TICKS = 10;
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
@Override
public void run() {
for (Iterator<Entry<LivingEntity, Integer>> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext();) {
Entry<LivingEntity, Integer> entry = bleedIterator.next();
LivingEntity entity = entry.getKey();
if (entry.getValue() <= 0 || !entity.isValid()) {
bleedIterator.remove();
continue;
}
int damage = 0;
if (entity instanceof Player) {
damage = 1;
Player player = (Player) entity;
if (!player.isOnline()) {
continue;
}
// Never kill with Bleeding
if (player.getHealth() - damage > 0) {
CombatUtils.dealDamage(player, damage);
ParticleEffectUtils.playBleedEffect(entity);
}
entry.setValue(entry.getValue() - damage);
if (entry.getValue() <= 0) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
}
}
else {
damage = 2;
// Anticipate the entity's death to prevent CME because of our EntityDeathEvent listener
if (entity.getHealth() - damage > 0) {
entry.setValue(entry.getValue() - 1);
}
else {
bleedIterator.remove();
}
CombatUtils.dealDamage(entity, damage);
ParticleEffectUtils.playBleedEffect(entity);
}
}
}
/**
* Instantly Bleed out a LivingEntity
*
* @param entity LivingEntity to bleed out
*/
public static void bleedOut(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
CombatUtils.dealDamage(entity, bleedList.get(entity) * 2);
bleedList.remove(entity);
}
}
/**
* Remove a LivingEntity from the bleedList if it is in it
*
* @param entity LivingEntity to remove
*/
public static void remove(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
bleedList.remove(entity);
}
}
/**
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
int newTicks = ticks;
if (bleedList.containsKey(entity)) {
newTicks += bleedList.get(entity);
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
}
else {
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
}
}
}

View File

@ -0,0 +1,44 @@
package com.gmail.nossr50.runnables.skills;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillMonitorTask implements Runnable {
@Override
public void run() {
long curTime = System.currentTimeMillis();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Misc.isNPCEntity(player)) {
continue;
}
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
/*
* MONITOR SKILLS
*/
for (SkillType skill : SkillType.values()) {
if (skill.getTool() != null && skill.getAbility() != null) {
SkillUtils.monitorSkill(player, profile, curTime, skill);
}
}
/*
* COOLDOWN MONITORING
*/
for (AbilityType ability : AbilityType.values()) {
if (ability.getCooldown() > 0) {
SkillUtils.watchCooldown(player, profile, ability);
}
}
}
}
}

View File

@ -0,0 +1,46 @@
package com.gmail.nossr50.runnables.skills.herbalism;
import org.bukkit.CropState;
import org.bukkit.block.BlockState;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
public class GreenTerraTimerTask implements Runnable {
private BlockState blockState;
/**
* Convert plants affected by the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public GreenTerraTimerTask(BlockState blockState) {
this.blockState = blockState;
}
@Override
public void run() {
switch (blockState.getType()) {
case CROPS:
case CARROT:
case POTATO:
blockState.setRawData(CropState.MEDIUM.getData());
blockState.update(true);
return;
case NETHER_WARTS:
blockState.setRawData((byte) 0x2);
blockState.update(true);
return;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
plant.setSize(CocoaPlantSize.MEDIUM);
blockState.setData(plant);
blockState.update(true);
return;
default:
return;
}
}
}

View File

@ -0,0 +1,66 @@
package com.gmail.nossr50.runnables.skills.herbalism;
import org.bukkit.block.BlockState;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import com.gmail.nossr50.skills.herbalism.Herbalism;
public class GreenThumbTimerTask implements Runnable {
private BlockState blockState;
private int skillLevel;
/**
* Convert plants affected by the Green Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param skillLevel The player's Herbalism skill level
*/
public GreenThumbTimerTask(BlockState blockState, int skillLevel) {
this.blockState = blockState;
this.skillLevel = skillLevel;
}
@Override
public void run() {
int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
switch (blockState.getType()) {
case CROPS:
case CARROT:
case POTATO:
blockState.setRawData((byte) greenThumbStage);
blockState.update(true);
return;
case NETHER_WARTS:
if (greenThumbStage > 2) {
blockState.setRawData((byte) 0x2);
}
else if (greenThumbStage == 2) {
blockState.setRawData((byte) 0x1);
}
else {
blockState.setRawData((byte) 0x0);
}
blockState.update(true);
return;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
if (greenThumbStage > 1) {
plant.setSize(CocoaPlantSize.MEDIUM);
}
else {
plant.setSize(CocoaPlantSize.SMALL);
}
blockState.setData(plant);
blockState.update(true);
return;
default:
return;
}
}
}