mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Renamed/Organized a lot of stuff
This commit is contained in:
parent
af372064ed
commit
44a37b6181
@ -1,6 +1,9 @@
|
||||
Changelog:
|
||||
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code#
|
||||
Version 1.0
|
||||
Water changing Gravel to Clay removed
|
||||
Code Organized/Optimized further
|
||||
MySQL Support
|
||||
Taming Skill
|
||||
Leaderboards
|
||||
Players won't hand out XP if they died within the last 5 seconds
|
||||
|
586
mcMMO/com/gmail/nossr50/Combat.java
Normal file
586
mcMMO/com/gmail/nossr50/Combat.java
Normal file
@ -0,0 +1,586 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Axes;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Swords;
|
||||
|
||||
public class Combat {
|
||||
private static mcMMO plugin;
|
||||
public Combat(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
public static void combatChecks(EntityDamageEvent event){
|
||||
if(event.isCancelled() || event.getDamage() == 0)
|
||||
return;
|
||||
/*
|
||||
* OFFENSIVE CHECKS
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
||||
{
|
||||
//Declare Things
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
||||
Player attacker = (Player)((EntityDamageByEntityEvent) event).getDamager();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
//If there are any abilities to activate
|
||||
combatAbilityChecks(attacker, PPa);
|
||||
|
||||
//Modify the event damage if Attacker is Berserk
|
||||
if(PPa.getBerserkMode())
|
||||
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
||||
//Handle the combat interactions between the Player and the defending entity
|
||||
if(event.getEntity() instanceof Player)
|
||||
playerVersusPlayerChecks(eventb, attacker);
|
||||
if(event.getEntity() instanceof Animals)
|
||||
playerVersusAnimalsChecks(eventb, attacker);
|
||||
if(event.getEntity() instanceof Monster)
|
||||
playerVersusMonsterChecks(eventb, attacker);
|
||||
if(event.getEntity() instanceof Squid)
|
||||
playerVersusSquidChecks(eventb, attacker);
|
||||
|
||||
//Handle Ability Interactions
|
||||
if(PPa.getSkullSplitterMode() && m.isAxes(attacker.getItemInHand()))
|
||||
Axes.applyAoeDamage(attacker, eventb);
|
||||
if(PPa.getSerratedStrikesMode() && m.isSwords(attacker.getItemInHand()))
|
||||
Swords.applySerratedStrikes(attacker, eventb);
|
||||
}
|
||||
//Another offensive check for Archery
|
||||
if(event instanceof EntityDamageByProjectileEvent)
|
||||
archeryCheck((EntityDamageByProjectileEvent) event);
|
||||
|
||||
/*
|
||||
* DEFENSIVE CHECKS
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && event.getEntity() instanceof Player)
|
||||
{
|
||||
Player defender = (Player)event.getEntity();
|
||||
Swords.parryCheck((EntityDamageByEntityEvent) event, defender);
|
||||
Swords.counterAttackChecks(event);
|
||||
Acrobatics.dodgeChecks((EntityDamageByEntityEvent)event);
|
||||
}
|
||||
}
|
||||
|
||||
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa){
|
||||
//Check to see if any abilities need to be activated
|
||||
if(PPa.getAxePreparationMode())
|
||||
Skills.skullSplitterCheck(attacker, plugin);
|
||||
if(PPa.getSwordsPreparationMode())
|
||||
Skills.serratedStrikesActivationCheck(attacker, plugin);
|
||||
if(PPa.getFistsPreparationMode())
|
||||
Skills.berserkActivationCheck(attacker, plugin);
|
||||
}
|
||||
public static void playerVersusPlayerChecks(EntityDamageByEntityEvent event, Player attacker){
|
||||
Entity x = event.getEntity();
|
||||
if(x instanceof Player){
|
||||
if(LoadProperties.pvp == false){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
Player defender = (Player)x;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
/*
|
||||
* COMPATABILITY CHECKS (Stuff that wouldn't happen normally in basically...)
|
||||
*/
|
||||
if(Users.getProfile(defender) == null)
|
||||
Users.addUser(defender);
|
||||
if(attacker != null && defender != null && Users.getProfile(attacker).inParty() && Users.getProfile(defender).inParty()){
|
||||
if(Party.getInstance().inSameParty(defender, attacker)){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AXE CRITICAL CHECK
|
||||
*/
|
||||
axeCriticalCheck(attacker, event, x);
|
||||
if(!Config.getInstance().isBleedTracked(x)){
|
||||
Swords.bleedCheck(attacker, x);
|
||||
}
|
||||
if(defender != null && mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0){
|
||||
|
||||
//Bonus just for having unarmed
|
||||
int bonus = 2;
|
||||
if (PPa.getUnarmedInt() >= 250)
|
||||
bonus++;
|
||||
if (PPa.getUnarmedInt() >= 500)
|
||||
bonus++;
|
||||
event.setDamage(calculateDamage(event, bonus));
|
||||
|
||||
//PROC
|
||||
if(simulateUnarmedProc(attacker)){
|
||||
Location loc = defender.getLocation();
|
||||
if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0){
|
||||
attacker.sendMessage(ChatColor.DARK_RED+"You have hit with great force.");
|
||||
defender.sendMessage(ChatColor.DARK_RED+"You have been disarmed!");
|
||||
ItemStack item = defender.getItemInHand();
|
||||
if(item != null){
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
ItemStack itemx = null;
|
||||
defender.setItemInHand(itemx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* PVP XP
|
||||
*/
|
||||
if(attacker != null && defender != null && LoadProperties.pvpxp){
|
||||
if(PPd.inParty() && PPa.inParty() && Party.getInstance().inSameParty(attacker, defender))
|
||||
return;
|
||||
if(System.currentTimeMillis() >= PPd.getRespawnATS() + 5000 && defender.getHealth() >= 1){
|
||||
if(m.isAxes(attacker.getItemInHand()))
|
||||
PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier);
|
||||
if(m.isSwords(attacker.getItemInHand()))
|
||||
PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier);
|
||||
if(attacker.getItemInHand().getTypeId() == 0)
|
||||
PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* CHECK FOR LEVEL UPS
|
||||
*/
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
}
|
||||
public static void playerVersusSquidChecks(EntityDamageByEntityEvent event, Player attacker){
|
||||
Entity x = event.getEntity();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int type = attacker.getItemInHand().getTypeId();
|
||||
if(x instanceof Squid){
|
||||
if(!Config.getInstance().isBleedTracked(x)){
|
||||
Swords.bleedCheck(attacker, x);
|
||||
}
|
||||
Squid defender = (Squid)event.getEntity();
|
||||
if(m.isSwords(attacker.getItemInHand()) && defender.getHealth() > 0 && mcPermissions.getInstance().swords(attacker)){
|
||||
PPa.addSwordsXP(10 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
Skills.XpCheck(attacker);
|
||||
if(m.isAxes(attacker.getItemInHand())
|
||||
&& defender.getHealth() > 0
|
||||
&& mcPermissions.getInstance().axes(attacker)){
|
||||
PPa.addAxesXP(10 * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
||||
if(PPa.getAxesInt() >= 500){
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* UNARMED VS SQUID
|
||||
*/
|
||||
if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){
|
||||
if(defender.getHealth() <= 0)
|
||||
return;
|
||||
|
||||
//Bonus just for having unarmed
|
||||
int bonus = 2;
|
||||
if (PPa.getUnarmedInt() >= 250)
|
||||
bonus++;
|
||||
if (PPa.getUnarmedInt() >= 500)
|
||||
bonus++;
|
||||
event.setDamage(calculateDamage(event, bonus));
|
||||
|
||||
//XP
|
||||
if(defender.getHealth() != 0){
|
||||
PPa.addUnarmedXP(10 * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void playerVersusAnimalsChecks(EntityDamageByEntityEvent event, Player attacker){
|
||||
int type = attacker.getItemInHand().getTypeId();
|
||||
Entity x = event.getEntity();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(x instanceof Animals){
|
||||
if(!Config.getInstance().isBleedTracked(x)){
|
||||
Swords.bleedCheck(attacker, x);
|
||||
}
|
||||
Animals defender = (Animals)event.getEntity();
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
||||
if(defender.getHealth() <= 0)
|
||||
return;
|
||||
if(PPa.getAxesInt() >= 500){
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
}
|
||||
}
|
||||
if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){
|
||||
//Bonus just for having unarmed
|
||||
int bonus = 2;
|
||||
if (PPa.getUnarmedInt() >= 250)
|
||||
bonus++;
|
||||
if (PPa.getUnarmedInt() >= 500)
|
||||
bonus++;
|
||||
event.setDamage(calculateDamage(event, bonus));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void playerVersusMonsterChecks(EntityDamageByEntityEvent event, Player attacker){
|
||||
Entity x = event.getEntity();
|
||||
int type = attacker.getItemInHand().getTypeId();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(x instanceof Monster){
|
||||
/*
|
||||
* AXE PROC CHECKS
|
||||
*/
|
||||
axeCriticalCheck(attacker, event, x);
|
||||
if(!Config.getInstance().isBleedTracked(x)){
|
||||
Swords.bleedCheck(attacker, x);
|
||||
}
|
||||
Monster defender = (Monster)event.getEntity();
|
||||
if(m.isSwords(attacker.getItemInHand())
|
||||
&& defender.getHealth() > 0
|
||||
&& mcPermissions.getInstance().swords(attacker)){
|
||||
if(!Config.getInstance().isMobSpawnTracked(x)){
|
||||
if(x instanceof Creeper)
|
||||
PPa.addSwordsXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Spider)
|
||||
PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Skeleton)
|
||||
PPa.addSwordsXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Zombie)
|
||||
PPa.addSwordsXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof PigZombie)
|
||||
PPa.addSwordsXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
if(m.isAxes(attacker.getItemInHand())
|
||||
&& defender.getHealth() > 0
|
||||
&& mcPermissions.getInstance().axes(attacker)){
|
||||
if(!Config.getInstance().isMobSpawnTracked(x)){
|
||||
if(x instanceof Creeper)
|
||||
PPa.addAxesXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Spider)
|
||||
PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Skeleton)
|
||||
PPa.addAxesXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Zombie)
|
||||
PPa.addAxesXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof PigZombie)
|
||||
PPa.addAxesXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
/*
|
||||
* AXE DAMAGE SCALING && LOOT CHECKS
|
||||
*/
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
||||
if(PPa.getAxesInt() >= 500){
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
}
|
||||
}
|
||||
if(type == 0 && mcPermissions.getInstance().unarmed(attacker)){
|
||||
if(defender.getHealth() <= 0)
|
||||
return;
|
||||
|
||||
//Bonus just for having unarmed
|
||||
int bonus = 2;
|
||||
if (PPa.getUnarmedInt() >= 250)
|
||||
bonus++;
|
||||
if (PPa.getUnarmedInt() >= 500)
|
||||
bonus++;
|
||||
event.setDamage(calculateDamage(event, bonus));
|
||||
|
||||
//XP
|
||||
if(!Config.getInstance().isMobSpawnTracked(x)){
|
||||
if(x instanceof Creeper)
|
||||
PPa.addUnarmedXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Spider)
|
||||
PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Skeleton)
|
||||
PPa.addUnarmedXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Zombie)
|
||||
PPa.addUnarmedXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof PigZombie)
|
||||
PPa.addUnarmedXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void archeryCheck(EntityDamageByProjectileEvent event){
|
||||
Entity y = event.getDamager();
|
||||
Entity x = event.getEntity();
|
||||
if(event.getProjectile().toString().equals("CraftArrow") && x instanceof Player){
|
||||
Player defender = (Player)x;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(PPd == null)
|
||||
Users.addUser(defender);
|
||||
if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0){
|
||||
if(defender != null && PPd.getUnarmedInt() >= 1000){
|
||||
if(Math.random() * 1000 <= 500){
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(ChatColor.WHITE+"**ARROW DEFLECT**");
|
||||
return;
|
||||
}
|
||||
} else if(defender != null && Math.random() * 1000 <= (PPd.getUnarmedInt() / 2)){
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(ChatColor.WHITE+"**ARROW DEFLECT**");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If attacker is player
|
||||
*/
|
||||
if(y instanceof Player){
|
||||
Player attacker = (Player)y;
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(event.getProjectile().toString().equals("CraftArrow") && mcPermissions.getInstance().archery(attacker)){
|
||||
if(!Config.getInstance().isTracked(x) && event.getDamage() > 0){
|
||||
Config.getInstance().addArrowTrack(x, 0);
|
||||
if(attacker != null){
|
||||
if(Math.random() * 1000 <= PPa.getArcheryInt()){
|
||||
Config.getInstance().addArrowCount(x, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(event.getDamage() > 0){
|
||||
if(attacker != null){
|
||||
if(Math.random() * 1000 <= PPa.getArcheryInt()){
|
||||
Config.getInstance().addArrowCount(x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* IGNITION
|
||||
*/
|
||||
if(Math.random() * 100 >= 75){
|
||||
|
||||
int ignition = 20;
|
||||
if(PPa.getArcheryInt() >= 200)
|
||||
ignition+=20;
|
||||
if(PPa.getArcheryInt() >= 400)
|
||||
ignition+=20;
|
||||
if(PPa.getArcheryInt() >= 600)
|
||||
ignition+=20;
|
||||
if(PPa.getArcheryInt() >= 800)
|
||||
ignition+=20;
|
||||
if(PPa.getArcheryInt() >= 1000)
|
||||
ignition+=20;
|
||||
|
||||
if(x instanceof Player){
|
||||
Player Defender = (Player)x;
|
||||
if(!Party.getInstance().inSameParty(attacker, Defender)){
|
||||
event.getEntity().setFireTicks(ignition);
|
||||
attacker.sendMessage(ChatColor.RED+"**IGNITION**");
|
||||
Defender.sendMessage(ChatColor.DARK_RED+"You were struck by a burning arrow!");
|
||||
}
|
||||
} else {
|
||||
event.getEntity().setFireTicks(ignition);
|
||||
attacker.sendMessage(ChatColor.RED+"**IGNITION**");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Defender is Monster
|
||||
*/
|
||||
if(x instanceof Monster){
|
||||
/*
|
||||
* TRACK ARROWS USED AGAINST THE ENTITY
|
||||
*/
|
||||
if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250)
|
||||
event.setDamage(calculateDamage(event, 1));
|
||||
if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575)
|
||||
event.setDamage(calculateDamage(event, 2));
|
||||
if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725)
|
||||
event.setDamage(calculateDamage(event, 3));
|
||||
if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000)
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
if(PPa.getArcheryInt() >= 1000)
|
||||
event.setDamage(calculateDamage(event, 5));
|
||||
//XP
|
||||
if(!Config.getInstance().isMobSpawnTracked(x)){
|
||||
if(x instanceof Creeper)
|
||||
PPa.addArcheryXP((event.getDamage() * 4) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Spider)
|
||||
PPa.addArcheryXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Skeleton)
|
||||
PPa.addArcheryXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof Zombie)
|
||||
PPa.addArcheryXP((event.getDamage() * 2) * LoadProperties.xpGainMultiplier);
|
||||
if(x instanceof PigZombie)
|
||||
PPa.addArcheryXP((event.getDamage() * 3) * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Defender is Animals
|
||||
*/
|
||||
if(x instanceof Animals){
|
||||
if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250)
|
||||
event.setDamage(calculateDamage(event, 1));
|
||||
if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575)
|
||||
event.setDamage(calculateDamage(event, 2));
|
||||
if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725)
|
||||
event.setDamage(calculateDamage(event, 3));
|
||||
if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000)
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
if(PPa.getArcheryInt() >= 1000)
|
||||
event.setDamage(calculateDamage(event, 5));
|
||||
}
|
||||
/*
|
||||
* Defender is Squid
|
||||
*/
|
||||
if(x instanceof Squid){
|
||||
if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250)
|
||||
event.setDamage(calculateDamage(event, 1));
|
||||
if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575)
|
||||
event.setDamage(calculateDamage(event, 2));
|
||||
if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725)
|
||||
event.setDamage(calculateDamage(event, 3));
|
||||
if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000)
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
if(PPa.getArcheryInt() >= 1000)
|
||||
event.setDamage(calculateDamage(event, 5));
|
||||
}
|
||||
/*
|
||||
* Attacker is Player
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
if(LoadProperties.pvp == false){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Player defender = (Player)x;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
/*
|
||||
* Stuff for the daze proc
|
||||
*/
|
||||
if(PPa.inParty() && PPd.inParty()){
|
||||
if(Party.getInstance().inSameParty(defender, attacker)){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* PVP XP
|
||||
*/
|
||||
if(LoadProperties.pvpxp && !Party.getInstance().inSameParty(attacker, defender)){
|
||||
PPa.addArcheryXP((event.getDamage() * 3) * LoadProperties.pvpxprewardmodifier);
|
||||
}
|
||||
/*
|
||||
* DAZE PROC
|
||||
*/
|
||||
Location loc = defender.getLocation();
|
||||
if(Math.random() * 10 > 5){
|
||||
loc.setPitch(90);
|
||||
} else {
|
||||
loc.setPitch(-90);
|
||||
}
|
||||
if(PPa.getArcheryInt() >= 1000){
|
||||
if(Math.random() * 1000 <= 500){
|
||||
defender.teleportTo(loc);
|
||||
defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy.");
|
||||
attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed");
|
||||
}
|
||||
} else if(Math.random() * 2000 <= PPa.getArcheryInt()){
|
||||
defender.teleportTo(loc);
|
||||
defender.sendMessage(ChatColor.DARK_RED+"Touched Fuzzy. Felt Dizzy.");
|
||||
attacker.sendMessage("Target was "+ChatColor.DARK_RED+"Dazed");
|
||||
}
|
||||
|
||||
if(PPa.getArcheryInt() >= 50 && PPa.getArcheryInt() < 250)
|
||||
event.setDamage(calculateDamage(event, 1));
|
||||
if(PPa.getArcheryInt() >= 250 && PPa.getArcheryInt() < 575)
|
||||
event.setDamage(calculateDamage(event, 2));
|
||||
if(PPa.getArcheryInt() >= 575 && PPa.getArcheryInt() < 725)
|
||||
event.setDamage(calculateDamage(event, 3));
|
||||
if(PPa.getArcheryInt() >= 725 && PPa.getArcheryInt() < 1000)
|
||||
event.setDamage(calculateDamage(event, 4));
|
||||
if(PPa.getArcheryInt() >= 1000)
|
||||
event.setDamage(calculateDamage(event, 5));
|
||||
}
|
||||
}
|
||||
Skills.XpCheck(attacker);
|
||||
}
|
||||
}
|
||||
public static boolean simulateUnarmedProc(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(PP.getUnarmedInt() >= 1000){
|
||||
if(Math.random() * 4000 <= 1000){
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(Math.random() * 4000 <= PP.getUnarmedInt()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int calculateDamage(EntityDamageEvent event, int dmg){
|
||||
return event.getDamage() + dmg;
|
||||
}
|
||||
public static void dealDamage(Entity target, int dmg){
|
||||
if(target instanceof Player){
|
||||
((Player) target).damage(dmg);
|
||||
}
|
||||
if(target instanceof Animals){
|
||||
((Animals) target).damage(dmg);
|
||||
}
|
||||
if(target instanceof Monster){
|
||||
((Monster) target).damage(dmg);
|
||||
}
|
||||
}
|
||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Entity x){
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
||||
if(PPa.getAxesInt() >= 750){
|
||||
if(Math.random() * 1000 <= 750){
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||
}
|
||||
if(x instanceof Player){
|
||||
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
|
||||
} else {
|
||||
event.setDamage(event.getDamage() * 2);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||
}
|
||||
} else if(Math.random() * 1000 <= PPa.getAxesInt()){
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||
}
|
||||
if(x instanceof Player){
|
||||
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
|
||||
} else {
|
||||
event.setDamage(event.getDamage() * 2);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -12,6 +12,8 @@ import java.sql.PreparedStatement;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
|
||||
public class Database {
|
||||
|
||||
@ -28,7 +30,7 @@ public class Database {
|
||||
|
||||
// make the connection
|
||||
try {
|
||||
conn = DriverManager.getConnection("jdbc:mysql://" + mcLoadProperties.MySQLserverName + ":" + mcLoadProperties.MySQLport + "/" + mcLoadProperties.MySQLdbName + "?user=" + mcLoadProperties.MySQLuserName + "&password=" + mcLoadProperties.MySQLdbPass);
|
||||
conn = DriverManager.getConnection("jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass);
|
||||
} catch (SQLException ex) {
|
||||
// handle any errors
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
|
79
mcMMO/com/gmail/nossr50/Item.java
Normal file
79
mcMMO/com/gmail/nossr50/Item.java
Normal file
@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Item {
|
||||
|
||||
public static void itehecks(Player player, Plugin plugin){
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
if(inhand.getTypeId() == 288){
|
||||
chimaerawing(player, plugin);
|
||||
}
|
||||
}
|
||||
public static void chimaerawing(Player player, Plugin plugin){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack is = player.getItemInHand();
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == 288){
|
||||
if(Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing){
|
||||
Block derp = player.getLocation().getBlock();
|
||||
int y = derp.getY();
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 288){
|
||||
if(x.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing + 1){
|
||||
x.setAmount(x.getAmount() - LoadProperties.feathersConsumedByChimaeraWing);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
} else {
|
||||
x.setAmount(0);
|
||||
x.setTypeId(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(y < 127){
|
||||
y++;
|
||||
if(player != null){
|
||||
if(player.getLocation().getWorld().getBlockAt(block.getX(), y, block.getZ()).getType() != Material.AIR){
|
||||
player.sendMessage("**CHIMAERA WING FAILED!**");
|
||||
player.teleportTo(player.getLocation().getWorld().getBlockAt(block.getX(), (y - 1), block.getZ()).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(PP.getMySpawn(player) != null){
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
if(mySpawn != null && plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)) != null)
|
||||
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
|
||||
if(mySpawn != null){
|
||||
player.teleportTo(mySpawn);//Do it twice to prevent weird stuff
|
||||
player.teleportTo(mySpawn);
|
||||
}
|
||||
} else {
|
||||
player.teleportTo(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
player.sendMessage("**CHIMAERA WING**");
|
||||
} else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10) {
|
||||
player.sendMessage("You were injured recently and must wait to use this."
|
||||
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getRecentlyHurt(), 60)+"s)");
|
||||
} else if (is.getTypeId() == 288 && is.getAmount() <= 9){
|
||||
player.sendMessage("You need more of that to use it");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
244
mcMMO/com/gmail/nossr50/Leaderboard.java
Normal file
244
mcMMO/com/gmail/nossr50/Leaderboard.java
Normal file
@ -0,0 +1,244 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.Tree;
|
||||
|
||||
public class Leaderboard {
|
||||
static String location = "plugins/mcMMO/mcmmo.users";
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
/*
|
||||
* Read from the file
|
||||
*/
|
||||
public static void makeLeaderboards(){
|
||||
//Make Trees
|
||||
Tree Mining = new Tree();
|
||||
Tree WoodCutting = new Tree();
|
||||
Tree Herbalism = new Tree();
|
||||
Tree Excavation = new Tree();
|
||||
Tree Acrobatics = new Tree();
|
||||
Tree Repair = new Tree();
|
||||
Tree Swords = new Tree();
|
||||
Tree Axes = new Tree();
|
||||
Tree Archery = new Tree();
|
||||
Tree Unarmed = new Tree();
|
||||
Tree Taming = new Tree();
|
||||
Tree PowerLevel = new Tree();
|
||||
|
||||
//Add Data To Trees
|
||||
try {
|
||||
//Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
while((line = in.readLine()) != null)
|
||||
{
|
||||
|
||||
String[] character = line.split(":");
|
||||
String p = character[0];
|
||||
|
||||
|
||||
int Plvl = 0;
|
||||
|
||||
if(character.length > 1 && isInt(character[1]))
|
||||
{
|
||||
Mining.add(p, Integer.valueOf(character[1]));
|
||||
Plvl += Integer.valueOf(character[1]);
|
||||
}
|
||||
if(character.length > 5 && isInt(character[5])){
|
||||
WoodCutting.add(p, Integer.valueOf(character[5]));
|
||||
Plvl += Integer.valueOf(character[5]);
|
||||
}
|
||||
if(character.length > 7 && isInt(character[7])){
|
||||
Repair.add(p, Integer.valueOf(character[7]));
|
||||
Plvl += Integer.valueOf(character[7]);
|
||||
}
|
||||
if(character.length > 8 && isInt(character[8])){
|
||||
Unarmed.add(p, Integer.valueOf(character[8]));
|
||||
Plvl += Integer.valueOf(character[8]);
|
||||
}
|
||||
if(character.length > 9 && isInt(character[9])){
|
||||
Herbalism.add(p, Integer.valueOf(character[9]));
|
||||
Plvl += Integer.valueOf(character[9]);
|
||||
}
|
||||
if(character.length > 10 && isInt(character[10])){
|
||||
Excavation.add(p, Integer.valueOf(character[10]));
|
||||
Plvl += Integer.valueOf(character[10]);
|
||||
}
|
||||
if(character.length > 11 && isInt(character[11])){
|
||||
Archery.add(p, Integer.valueOf(character[11]));
|
||||
Plvl += Integer.valueOf(character[11]);
|
||||
}
|
||||
if(character.length > 12 && isInt(character[12])){
|
||||
Swords.add(p, Integer.valueOf(character[12]));
|
||||
Plvl += Integer.valueOf(character[12]);
|
||||
}
|
||||
if(character.length > 13 && isInt(character[13])){
|
||||
Axes.add(p, Integer.valueOf(character[13]));
|
||||
Plvl += Integer.valueOf(character[13]);
|
||||
}
|
||||
if(character.length > 14 && isInt(character[14])){
|
||||
Acrobatics.add(p, Integer.valueOf(character[14]));
|
||||
Plvl += Integer.valueOf(character[14]);
|
||||
}
|
||||
if(character.length > 24 && isInt(character[24])){
|
||||
Taming.add(p, Integer.valueOf(character[24]));
|
||||
Plvl += Integer.valueOf(character[24]);
|
||||
}
|
||||
|
||||
PowerLevel.add(p, Plvl);
|
||||
}
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading "
|
||||
+ location + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
//Write the leader board files
|
||||
leaderWrite(Mining.inOrder(), "mining");
|
||||
leaderWrite(WoodCutting.inOrder(), "woodcutting");
|
||||
leaderWrite(Repair.inOrder(), "repair");
|
||||
leaderWrite(Unarmed.inOrder(), "unarmed");
|
||||
leaderWrite(Herbalism.inOrder(), "herbalism");
|
||||
leaderWrite(Excavation.inOrder(), "excavation");
|
||||
leaderWrite(Archery.inOrder(), "archery");
|
||||
leaderWrite(Swords.inOrder(), "swords");
|
||||
leaderWrite(Axes.inOrder(), "axes");
|
||||
leaderWrite(Acrobatics.inOrder(), "acrobatics");
|
||||
leaderWrite(Taming.inOrder(), "taming");
|
||||
leaderWrite(PowerLevel.inOrder(), "powerlevel");
|
||||
}
|
||||
public static void leaderWrite(PlayerStat[] ps, String statName)
|
||||
{
|
||||
String theLocation = "plugins/mcMMO/" + statName + ".mcmmo";
|
||||
//CHECK IF THE FILE EXISTS
|
||||
File theDir = new File(theLocation);
|
||||
if(!theDir.exists()){
|
||||
//properties = new PropertiesFile(location);
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(theLocation);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while creating " + theLocation, e);
|
||||
} finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, "Exception while closing writer for " + theLocation, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
|
||||
//HERP
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
for(PlayerStat p : ps)
|
||||
{
|
||||
writer.append(p.name + ":" + p.statVal);
|
||||
writer.append("\r\n");
|
||||
}
|
||||
in.close();
|
||||
//Write the new file
|
||||
FileWriter out = new FileWriter(theLocation);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
}
|
||||
//Create/open the file
|
||||
//Loop through backward writing each player
|
||||
//Close the file
|
||||
}
|
||||
|
||||
public static String[] retrieveInfo(String statName, int pagenumber){
|
||||
String theLocation = "plugins/mcMMO/" + statName + ".mcmmo";
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
|
||||
int destination = (pagenumber - 1) * 10; //How many lines to skip through
|
||||
int x = 0; //how many lines we've gone through
|
||||
int y = 0; //going through the lines
|
||||
String line = "";
|
||||
String[] info = new String[10]; //what to return
|
||||
while((line = in.readLine()) != null && y < 10)
|
||||
{
|
||||
x++;
|
||||
if(x >= destination && y < 10){
|
||||
info[y] = line.toString();
|
||||
y++;
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
return info;
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading "
|
||||
+ theLocation + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
return null; //Shouldn't get here
|
||||
}
|
||||
public static void updateLeaderboard(PlayerStat ps, String statName){
|
||||
if(LoadProperties.useMySQL)
|
||||
return;
|
||||
String theLocation = "plugins/mcMMO/" + statName + ".mcmmo";
|
||||
try {
|
||||
//Open the file
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
Boolean inserted = false;
|
||||
//While not at the end of the file
|
||||
while((line = in.readLine()) != null)
|
||||
{
|
||||
//Insert the player into the line before it finds a smaller one
|
||||
if(Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted)
|
||||
{
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
|
||||
inserted = true;
|
||||
}
|
||||
//Write anything that isn't the player already in the file so we remove the duplicate
|
||||
if(!line.split(":")[0].equalsIgnoreCase(ps.name))
|
||||
{
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(!inserted)
|
||||
{
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
|
||||
}
|
||||
|
||||
in.close();
|
||||
//Write the new file
|
||||
FileWriter out = new FileWriter(theLocation);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
}
|
||||
public static boolean isInt(String string){
|
||||
try {
|
||||
int x = Integer.parseInt(string);
|
||||
}
|
||||
catch(NumberFormatException nFE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
95
mcMMO/com/gmail/nossr50/Users.java
Normal file
95
mcMMO/com/gmail/nossr50/Users.java
Normal file
@ -0,0 +1,95 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Users {
|
||||
private static volatile Users instance;
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
String location = "plugins/mcMMO/mcmmo.users";
|
||||
|
||||
//public static ArrayList<PlayerProfile> players;
|
||||
public static HashMap<Player, PlayerProfile> players = new HashMap<Player, PlayerProfile>();
|
||||
private Properties properties = new Properties();
|
||||
|
||||
//To load
|
||||
public void load() throws IOException {
|
||||
properties.load(new FileInputStream(location));
|
||||
}
|
||||
//To save
|
||||
public void save() {
|
||||
try {
|
||||
properties.store(new FileOutputStream(location), null);
|
||||
}catch(IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadUsers(){
|
||||
File theDir = new File(location);
|
||||
if(!theDir.exists()){
|
||||
//properties = new PropertiesFile(location);
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(location);
|
||||
writer.write("#Storage place for user information\r\n");
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
||||
} finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//properties = new PropertiesFile(location);
|
||||
try {
|
||||
load();
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, "Exception while loading " + location, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addUser(Player player){
|
||||
players.put(player, new PlayerProfile(player));
|
||||
}
|
||||
|
||||
|
||||
public static void removeUser(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PP.save();
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
public static PlayerProfile getProfile(Player player){
|
||||
return players.get(player);
|
||||
}
|
||||
|
||||
public static Users getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Users();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public static void getRow(){
|
||||
|
||||
}
|
||||
|
||||
}
|
174
mcMMO/com/gmail/nossr50/config/Config.java
Normal file
174
mcMMO/com/gmail/nossr50/config/Config.java
Normal file
@ -0,0 +1,174 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class Config {
|
||||
private static volatile Config instance;
|
||||
String location = "mcmmo.properties";
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
static ArrayList<String> adminChatList = new ArrayList<String>();
|
||||
static ArrayList<Block> blockWatchList = new ArrayList<Block>();
|
||||
static ArrayList<Block> treeFeller = new ArrayList<Block>();
|
||||
static ArrayList<String> partyChatList = new ArrayList<String>();
|
||||
static ArrayList<String> godModeList = new ArrayList<String>();
|
||||
HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
static ArrayList<Entity> bleedTracker = new ArrayList<Entity>();
|
||||
static ArrayList<Entity> mobSpawnTracker = new ArrayList<Entity>();
|
||||
|
||||
/*
|
||||
* The Bleed Que Stuff
|
||||
*/
|
||||
public Entity[] bleedQue = new Entity[20];
|
||||
public int bleedQuePos = 0;
|
||||
|
||||
public void addToBleedQue(Entity entity){
|
||||
//Assign entity to empty position
|
||||
bleedQue[bleedQuePos] = entity;
|
||||
//Move position up by 1 increment
|
||||
bleedQuePos++;
|
||||
|
||||
//Check if array is full
|
||||
if(bleedQuePos >= bleedQue.length){
|
||||
//Create new temporary array
|
||||
Entity[] temp = new Entity[bleedQue.length*2];
|
||||
//Copy data from bleedQue to temporary array
|
||||
System.arraycopy(bleedQue, 0, temp, 0, bleedQue.length);
|
||||
//Point bleedQue to new array
|
||||
bleedQue = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public Entity[] getBleedQue(){return bleedQue;}
|
||||
|
||||
public void clearBleedQue(){
|
||||
bleedQue = new Entity[bleedQue.length];
|
||||
setBleedQuePos(0);
|
||||
}
|
||||
public void setBleedQuePos(int x){bleedQuePos = x;}
|
||||
|
||||
/*
|
||||
* The Bleed Removal Que Stuff
|
||||
*/
|
||||
|
||||
public Entity[] bleedRemovalQue = new Entity[20];
|
||||
public int bleedRemovalQuePos = 0;
|
||||
|
||||
public void addToBleedRemovalQue(Entity entity){
|
||||
//Assign entity to empty position
|
||||
bleedRemovalQue[bleedRemovalQuePos] = entity;
|
||||
//Move position up by 1 increment
|
||||
bleedRemovalQuePos++;
|
||||
|
||||
//Check if array is full
|
||||
if(bleedRemovalQuePos >= bleedRemovalQue.length){
|
||||
//Create new temporary array
|
||||
Entity[] temp = new Entity[bleedRemovalQue.length*2];
|
||||
//Copy data from bleedRemovalQue to temporary array
|
||||
System.arraycopy(bleedRemovalQue, 0, temp, 0, bleedRemovalQue.length);
|
||||
//Point bleedRemovalQue to new array
|
||||
bleedRemovalQue = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public Entity[] getBleedRemovalQue(){return bleedRemovalQue;}
|
||||
|
||||
public void clearBleedRemovalQue(){
|
||||
bleedQue = new Entity[bleedRemovalQue.length];
|
||||
setBleedQuePos(0);
|
||||
}
|
||||
public void setBleedRemovalQuePos(int x){bleedRemovalQuePos = x;}
|
||||
|
||||
|
||||
public boolean isBlockWatched(Block block) {return blockWatchList.contains(block);}
|
||||
public boolean isTreeFellerWatched(Block block) {return treeFeller.contains(block);}
|
||||
public ArrayList<Block> getTreeFeller() {return treeFeller;}
|
||||
public void removeBlockWatch(Block block) {blockWatchList.remove(blockWatchList.indexOf(block));}
|
||||
public void addBlockWatch(Block block) {blockWatchList.add(block);}
|
||||
public void removeTreeFeller(Block block) {treeFeller.remove(treeFeller.indexOf(block));}
|
||||
public void addTreeFeller(Block block) {treeFeller.add(block);}
|
||||
public void addBleedTrack(Entity entity) {bleedTracker.add(entity);}
|
||||
public void addMobSpawnTrack(Entity entity) {mobSpawnTracker.add(entity);}
|
||||
public void removeMobSpawnTrack(Entity entity) {mobSpawnTracker.remove(entity);}
|
||||
public ArrayList<Entity> getBleedTracked() {return bleedTracker;}
|
||||
public void addArrowTrack(Entity entity, Integer arrowcount) {arrowTracker.put(entity, arrowcount);}
|
||||
public Integer getArrowCount(Entity entity) {return arrowTracker.get(entity);}
|
||||
public void removeArrowTracked(Entity entity){
|
||||
if(arrowTracker.containsKey(entity)){
|
||||
arrowTracker.remove(entity);
|
||||
}
|
||||
}
|
||||
public void removeBleedTrack(Entity entity){
|
||||
bleedTracker.remove(entity);
|
||||
}
|
||||
public void clearTreeFeller(){
|
||||
treeFeller.clear();
|
||||
}
|
||||
public void setBleedCount(Entity entity, Integer newvalue){
|
||||
bleedTracker.add(entity);
|
||||
}
|
||||
public void addArrowCount(Entity entity, Integer newvalue) {
|
||||
arrowTracker.put(entity, arrowTracker.get(entity) + newvalue);
|
||||
}
|
||||
public boolean isTracked(Entity entity) {
|
||||
if(arrowTracker.containsKey(entity)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isMobSpawnTracked(Entity entity) {
|
||||
if(mobSpawnTracker.contains(entity)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isBleedTracked(Entity entity) {
|
||||
if(bleedTracker.contains(entity)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
|
||||
public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
|
||||
public boolean isGodModeToggled(String playerName) {return godModeList.contains(playerName);}
|
||||
public void removeGodModeToggled(String playerName) {godModeList.remove(godModeList.indexOf(playerName));}
|
||||
public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
|
||||
public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
|
||||
public void addGodModeToggled(String playerName) {godModeList.add(playerName);}
|
||||
public void addPartyToggled(String playerName) {partyChatList.add(playerName);}
|
||||
public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
|
||||
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public void toggleAdminChat(String playerName){
|
||||
if(isAdminToggled(playerName)){
|
||||
removeAdminToggled(playerName);
|
||||
} else {
|
||||
addAdminToggled(playerName);
|
||||
}
|
||||
}
|
||||
public void toggleGodMode(String playerName){
|
||||
if(isGodModeToggled(playerName)){
|
||||
removeGodModeToggled(playerName);
|
||||
} else {
|
||||
addGodModeToggled(playerName);
|
||||
}
|
||||
}
|
||||
public void togglePartyChat(String playerName){
|
||||
if(isPartyToggled(playerName)){
|
||||
removePartyToggled(playerName);
|
||||
} else {
|
||||
addPartyToggled(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
116
mcMMO/com/gmail/nossr50/config/LoadProperties.java
Normal file
116
mcMMO/com/gmail/nossr50/config/LoadProperties.java
Normal file
@ -0,0 +1,116 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class LoadProperties {
|
||||
public static Boolean useMySQL, cocoabeans, archeryFireRateLimit, mushrooms, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, woodcuttingrequiresaxe, pvp, eggs, apples, myspawnclearsinventory, cake, music, diamond, glowstone, slowsand, sulphur, netherrack, bones, coal, clay, anvilmessages;
|
||||
public static String MySQLuserName, MySQLserverName, MySQLdbName, MySQLdbPass, mctop, addxp, mcability, mcmmo, mcc, mcrefresh, mcitem, mcgod, stats, mmoedit, ptp, party, myspawn, setmyspawn, whois, invite, accept, clearmyspawn;
|
||||
public static int MySQLport, xpGainMultiplier, superBreakerCooldown, greenTerraCooldown, gigaDrillBreakerCooldown, treeFellerCooldown, berserkCooldown, serratedStrikeCooldown, skullSplitterCooldown, abilityDurabilityLoss, feathersConsumedByChimaeraWing, pvpxprewardmodifier, repairdiamondlevel, globalxpmodifier, tamingxpmodifier, miningxpmodifier, repairxpmodifier, woodcuttingxpmodifier, unarmedxpmodifier, herbalismxpmodifier, excavationxpmodifier, archeryxpmodifier, swordsxpmodifier, axesxpmodifier, acrobaticsxpmodifier;
|
||||
|
||||
public static void loadMain(){
|
||||
String propertiesFile = mcMMO.maindirectory + "mcmmo.properties";
|
||||
mcProperties properties = new mcProperties(propertiesFile);
|
||||
properties.load();
|
||||
|
||||
/*
|
||||
* COOLDOWN CONTROL
|
||||
*/
|
||||
greenTerraCooldown = properties.getInteger("greenTerraCooldown", 240);
|
||||
superBreakerCooldown = properties.getInteger("superBreakerCooldown", 240);
|
||||
gigaDrillBreakerCooldown = properties.getInteger("gigaDrillBreakerCooldown", 240);
|
||||
treeFellerCooldown = properties.getInteger("treeFellerCooldown", 240);
|
||||
berserkCooldown = properties.getInteger("berserkCooldown", 240);
|
||||
serratedStrikeCooldown = properties.getInteger("serratedStrikeCooldown", 240);
|
||||
skullSplitterCooldown = properties.getInteger("skullSplitterCooldown", 240);
|
||||
|
||||
/*
|
||||
* MySQL Stuff
|
||||
*/
|
||||
|
||||
MySQLserverName = properties.getString("MySQLServer", "ipofserver");
|
||||
MySQLdbPass = properties.getString("MySQLdbPass", "defaultdbpass");
|
||||
MySQLdbName = properties.getString("MySQLdbName", "defaultdbname");
|
||||
MySQLuserName = properties.getString("MySQLuserName", "defaultusername");
|
||||
MySQLport = properties.getInteger("MySQLport", 3306);
|
||||
useMySQL = properties.getBoolean("mysql", false);
|
||||
|
||||
/*
|
||||
* OTHER
|
||||
*/
|
||||
|
||||
archeryFireRateLimit = properties.getBoolean("archeryFireRateLimit", true);
|
||||
myspawnclearsinventory = properties.getBoolean("mySpawnClearsInventory", true);
|
||||
xpGainMultiplier = properties.getInteger("xpGainMultiplier", 1);
|
||||
toolsLoseDurabilityFromAbilities = properties.getBoolean("toolsLoseDurabilityFromAbilities", true);
|
||||
abilityDurabilityLoss = properties.getInteger("abilityDurabilityLoss", 2);
|
||||
feathersConsumedByChimaeraWing = properties.getInteger("feathersConsumedByChimaeraWing", 10);
|
||||
pvpxp = properties.getBoolean("pvpGivesXP", true);
|
||||
pvpxprewardmodifier = properties.getInteger("pvpXpRewardModifier", 1);
|
||||
miningrequirespickaxe = properties.getBoolean("miningRequiresPickaxe", true);
|
||||
woodcuttingrequiresaxe = properties.getBoolean("woodcuttingRequiresAxe", true);
|
||||
repairdiamondlevel = properties.getInteger("repairDiamondLevel", 50);
|
||||
/*
|
||||
* EXPERIENCE RATE MODIFIER
|
||||
*/
|
||||
globalxpmodifier = properties.getInteger("globalXpModifier", 1);
|
||||
tamingxpmodifier = properties.getInteger("tamingXpModifier", 2);
|
||||
miningxpmodifier = properties.getInteger("miningXpModifier", 2);
|
||||
repairxpmodifier = properties.getInteger("repairXpModifier", 2);
|
||||
woodcuttingxpmodifier = properties.getInteger("woodcuttingXpModifier", 2);
|
||||
unarmedxpmodifier = properties.getInteger("unarmedXpModifier", 2);
|
||||
herbalismxpmodifier = properties.getInteger("herbalismXpModifier", 2);
|
||||
excavationxpmodifier = properties.getInteger("excavationXpModifier", 2);
|
||||
archeryxpmodifier = properties.getInteger("archeryXpModifier", 2);
|
||||
swordsxpmodifier = properties.getInteger("swordsXpModifier", 2);
|
||||
axesxpmodifier = properties.getInteger("axesXpModifier", 2);
|
||||
acrobaticsxpmodifier = properties.getInteger("acrobaticsXpModifier", 2);
|
||||
/*
|
||||
* TOGGLE CLAY
|
||||
*/
|
||||
clay = properties.getBoolean("gravelToClay", true);
|
||||
/*
|
||||
* ANVIL MESSAGES
|
||||
*/
|
||||
anvilmessages = properties.getBoolean("anvilMessages", true);
|
||||
/*
|
||||
* EXCAVATION LOOT TOGGLES
|
||||
*/
|
||||
cocoabeans = properties.getBoolean("canExcavateCocoaBeans", true);
|
||||
mushrooms = properties.getBoolean("canExcavateMushrooms", true);
|
||||
glowstone = properties.getBoolean("canExcavateGlowstone", true);
|
||||
pvp = properties.getBoolean("pvp", true);
|
||||
eggs = properties.getBoolean("canExcavateEggs", true);
|
||||
apples = properties.getBoolean("canExcavateApples", true);
|
||||
cake = properties.getBoolean("canExcavateCake", true);
|
||||
music = properties.getBoolean("canExcavateMusic", true);
|
||||
diamond = properties.getBoolean("canExcavateDiamond", true);
|
||||
slowsand = properties.getBoolean("canExcavateSlowSand", true);
|
||||
sulphur = properties.getBoolean("canExcavateSulphur", true);
|
||||
netherrack = properties.getBoolean("canExcavateNetherrack", true);
|
||||
bones = properties.getBoolean("canExcavateBones", true);
|
||||
|
||||
/*
|
||||
* CUSTOM COMMANDS
|
||||
*/
|
||||
mctop = properties.getString("/mctop", "mctop");
|
||||
addxp = properties.getString("/addxp", "addxp");
|
||||
mcability = properties.getString("/mcability", "mcability");
|
||||
mcrefresh = properties.getString("/mcrefresh", "mcrefresh");
|
||||
mcitem = properties.getString("/mcitem", "mcitem");
|
||||
mcmmo = properties.getString("/mcmmo", "mcmmo");
|
||||
mcc = properties.getString("/mcc", "mcc");
|
||||
mcgod = properties.getString("/mcgod", "mcgod");
|
||||
stats = properties.getString("/stats", "stats");
|
||||
mmoedit = properties.getString("/mmoedit", "mmoedit");
|
||||
ptp = properties.getString("/ptp", "ptp");
|
||||
party = properties.getString("/party", "party");
|
||||
myspawn = properties.getString("/myspawn", "myspawn");
|
||||
setmyspawn = properties.getString("/setmyspawn", "setmyspawn");
|
||||
whois = properties.getString("/whois", "whois");
|
||||
invite = properties.getString("/invite", "invite");
|
||||
accept = properties.getString("/accept", "accept");
|
||||
clearmyspawn = properties.getString("/clearmyspawn", "clearmyspawn");
|
||||
properties.save("==McMMO Configuration==\r\nYou can turn off excavation loot tables by turning the option to false\r\nYou can customize mcMMOs command names by modifying them here as well\r\nThis is an early version of the configuration file, eventually you'll be able to customize messages from mcMMO and XP gains");
|
||||
//herp derp
|
||||
}
|
||||
}
|
64
mcMMO/com/gmail/nossr50/config/mcProperties.java
Normal file
64
mcMMO/com/gmail/nossr50/config/mcProperties.java
Normal file
@ -0,0 +1,64 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class mcProperties extends Properties{
|
||||
//private static volatile mcProperties instance;
|
||||
private String fileName;
|
||||
public mcProperties(String file) {
|
||||
this.fileName = file;
|
||||
}
|
||||
public void load() {
|
||||
File file = new File(this.fileName);
|
||||
if(file.exists()) {
|
||||
try {
|
||||
load(new FileInputStream(this.fileName));
|
||||
} catch (IOException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public void save(String start){
|
||||
try{
|
||||
store(new FileOutputStream(this.fileName), start);
|
||||
} catch (IOException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
public int getInteger(String key, int value){
|
||||
if(containsKey(key)){
|
||||
return Integer.parseInt(getProperty(key));
|
||||
}
|
||||
put(key, String.valueOf(value));
|
||||
return value;
|
||||
}
|
||||
public String getString(String key, String value){
|
||||
if(containsKey(key)){
|
||||
return getProperty(key);
|
||||
}
|
||||
put(key, value);
|
||||
return value;
|
||||
}
|
||||
public Boolean getBoolean(String key, boolean value) {
|
||||
if (containsKey(key)) {
|
||||
String boolString = getProperty(key);
|
||||
return (boolString.length() > 0)
|
||||
&& (boolString.toLowerCase().charAt(0) == 't');
|
||||
}
|
||||
put(key, value ? "true" : "false");
|
||||
return value;
|
||||
}
|
||||
public double getDouble(String key, double value) {
|
||||
if (containsKey(key)) {
|
||||
return Double.parseDouble(getProperty(key));
|
||||
}
|
||||
|
||||
put(key, String.valueOf(value));
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
@ -16,9 +16,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Database;
|
||||
import com.gmail.nossr50.mcLoadProperties;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcSkills;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public class PlayerProfile
|
||||
public PlayerProfile(Player player)
|
||||
{
|
||||
|
||||
if (mcLoadProperties.useMySQL) {
|
||||
if (LoadProperties.useMySQL) {
|
||||
// if usemysql load from database
|
||||
if(!loadMySQL(player)) {
|
||||
addMySQLPlayer(player);
|
||||
@ -208,11 +208,13 @@ public class PlayerProfile
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
// if we are using mysql save to database
|
||||
if (mcLoadProperties.useMySQL) {
|
||||
if (LoadProperties.useMySQL) {
|
||||
mcMMO.database.Write("UPDATE users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
|
||||
mcMMO.database.Write("UPDATE spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid);
|
||||
mcMMO.database.Write("UPDATE skills SET "
|
||||
+" taming = "+taming
|
||||
+", mining = "+mining
|
||||
+", repair = "+repair
|
||||
+", woodcutting = "+woodcutting
|
||||
+", unarmed = "+unarmed
|
||||
+", herbalism = "+herbalism
|
||||
@ -224,6 +226,8 @@ public class PlayerProfile
|
||||
+" WHERE user_id = "+this.userid);
|
||||
mcMMO.database.Write("UPDATE experience SET "
|
||||
+" taming = "+tamingXP
|
||||
+", mining = "+miningXP
|
||||
+", repair = "+repairXP
|
||||
+", woodcutting = "+woodCuttingXP
|
||||
+", unarmed = "+unarmedXP
|
||||
+", herbalism = "+herbalismXP
|
||||
@ -1520,7 +1524,7 @@ public class PlayerProfile
|
||||
axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue);
|
||||
}
|
||||
save();
|
||||
mcSkills.XpCheck(thisplayer);
|
||||
Skills.XpCheck(thisplayer);
|
||||
}
|
||||
public void modifyskill(int newvalue, String skillname){
|
||||
if(skillname.toLowerCase().equals("taming")){
|
||||
@ -1573,37 +1577,37 @@ public class PlayerProfile
|
||||
}
|
||||
public Integer getXpToLevel(String skillname){
|
||||
if(skillname.equals("taming")){
|
||||
return ((getTamingInt() + 50) * mcLoadProperties.tamingxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getTamingInt() + 50) * LoadProperties.tamingxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("mining")){
|
||||
return ((getMiningInt() + 50) * mcLoadProperties.miningxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getMiningInt() + 50) * LoadProperties.miningxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("woodcutting")){
|
||||
return ((getWoodCuttingInt() + 50) * mcLoadProperties.woodcuttingxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getWoodCuttingInt() + 50) * LoadProperties.woodcuttingxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("repair")){
|
||||
return ((getRepairInt() + 50) * mcLoadProperties.repairxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getRepairInt() + 50) * LoadProperties.repairxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("herbalism")){
|
||||
return ((getHerbalismInt() + 50) * mcLoadProperties.herbalismxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getHerbalismInt() + 50) * LoadProperties.herbalismxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("acrobatics")){
|
||||
return ((getAcrobaticsInt() + 50) * mcLoadProperties.acrobaticsxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getAcrobaticsInt() + 50) * LoadProperties.acrobaticsxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("swords")){
|
||||
return ((getSwordsInt() + 50) * mcLoadProperties.swordsxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getSwordsInt() + 50) * LoadProperties.swordsxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("archery")){
|
||||
return ((getArcheryInt() + 50) * mcLoadProperties.archeryxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getArcheryInt() + 50) * LoadProperties.archeryxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("unarmed")){
|
||||
return ((getUnarmedInt() + 50) * mcLoadProperties.unarmedxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getUnarmedInt() + 50) * LoadProperties.unarmedxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("excavation")){
|
||||
return ((getExcavationInt() + 50) * mcLoadProperties.excavationxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getExcavationInt() + 50) * LoadProperties.excavationxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
}
|
||||
if(skillname.equals("axes")){
|
||||
return ((getAxesInt() + 50) * mcLoadProperties.axesxpmodifier) * mcLoadProperties.globalxpmodifier;
|
||||
return ((getAxesInt() + 50) * LoadProperties.axesxpmodifier) * LoadProperties.globalxpmodifier;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
6
mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java
Normal file
6
mcMMO/com/gmail/nossr50/datatypes/PlayerStat.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public class PlayerStat {
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
}
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class Tree {
|
||||
|
||||
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class TreeNode {
|
||||
TreeNode left = null
|
||||
|
685
mcMMO/com/gmail/nossr50/m.java
Normal file
685
mcMMO/com/gmail/nossr50/m.java
Normal file
@ -0,0 +1,685 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.datatypes.*;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
import com.gmail.nossr50.party.*;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
|
||||
public class m {
|
||||
/*
|
||||
* I'm storing my functions/methods in here in an unorganized manner. Spheal with it.
|
||||
*/
|
||||
private static mcMMO plugin;
|
||||
private static mcMMO pluginx;
|
||||
public m(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public static boolean shouldBeWatched(Block block){
|
||||
int id = block.getTypeId();
|
||||
if(id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPowerLevel(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int x = 0;
|
||||
if(mcPermissions.getInstance().mining(player))
|
||||
x+=PP.getMiningInt();
|
||||
if(mcPermissions.getInstance().woodcutting(player))
|
||||
x+=PP.getWoodCuttingInt();
|
||||
if(mcPermissions.getInstance().unarmed(player))
|
||||
x+=PP.getUnarmedInt();
|
||||
if(mcPermissions.getInstance().herbalism(player))
|
||||
x+=PP.getHerbalismInt();
|
||||
if(mcPermissions.getInstance().excavation(player))
|
||||
x+=PP.getExcavationInt();
|
||||
if(mcPermissions.getInstance().archery(player))
|
||||
x+=PP.getArcheryInt();
|
||||
if(mcPermissions.getInstance().swords(player))
|
||||
x+=PP.getSwordsInt();
|
||||
if(mcPermissions.getInstance().axes(player))
|
||||
x+=PP.getAxesInt();
|
||||
if(mcPermissions.getInstance().acrobatics(player))
|
||||
x+=PP.getAcrobaticsInt();
|
||||
if(mcPermissions.getInstance().repair(player))
|
||||
x+=PP.getRepairInt();
|
||||
return x;
|
||||
}
|
||||
public static boolean blockBreakSimulate(Block block, Player player, Plugin plugin){
|
||||
|
||||
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
|
||||
if(block != null && plugin != null && player != null){
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled())
|
||||
{
|
||||
return true; //Return true if not cancelled
|
||||
} else {
|
||||
return false; //Return false if cancelled
|
||||
}
|
||||
} else {
|
||||
return false; //Return false if something went wrong
|
||||
}
|
||||
}
|
||||
|
||||
public static void damageTool(Player player, short damage){
|
||||
if(player.getItemInHand().getTypeId() == 0)
|
||||
return;
|
||||
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + damage));
|
||||
if(player.getItemInHand().getDurability() >= getMaxDurability(getTier(player), player.getItemInHand())){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == player.getItemInHand().getTypeId() && x.getDurability() == player.getItemInHand().getDurability()){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean hasArrows(Player player){
|
||||
for(ItemStack x : player.getInventory().getContents()){
|
||||
if(x.getTypeId() == 262)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void addArrows(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 262){
|
||||
if(x.getAmount() >= 1 && x.getAmount() < 64){
|
||||
x.setAmount(x.getAmount() + 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Integer getTier(Player player){
|
||||
int i = player.getItemInHand().getTypeId();
|
||||
if(i == 268 || i == 269 || i == 270 || i == 271 || i == 290){
|
||||
return 1; //WOOD
|
||||
} else if (i == 272 || i == 273 || i == 274 || i == 275 || i == 291){
|
||||
return 2; //STONE
|
||||
} else if (i == 256 || i == 257 || i == 258 || i == 267 || i == 292){
|
||||
return 3; //IRON
|
||||
} else if (i == 283 || i == 284 || i == 285 || i == 286 || i == 294){
|
||||
return 1; //GOLD
|
||||
} else if (i == 276 || i == 277 || i == 278 || i == 279 || i == 293){
|
||||
return 4; //DIAMOND
|
||||
} else {
|
||||
return 1; //UNRECOGNIZED
|
||||
}
|
||||
}
|
||||
public static Integer getMaxDurability(Integer tier, ItemStack item){
|
||||
int id = item.getTypeId();
|
||||
if(tier == 1){
|
||||
if((id == 276 || id == 277 || id == 278 || id == 279 || id == 293)){
|
||||
return 33;
|
||||
} else {
|
||||
return 60;
|
||||
}
|
||||
} else if (tier == 2){
|
||||
return 132;
|
||||
} else if (tier == 3){
|
||||
return 251;
|
||||
} else if (tier == 4){
|
||||
return 1562;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public static double getDistance(Location loca, Location locb)
|
||||
{
|
||||
return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2)
|
||||
+ Math.pow(loca.getZ() - locb.getZ(), 2));
|
||||
}
|
||||
public static boolean abilityBlockCheck(Block block){
|
||||
int i = block.getTypeId();
|
||||
if(i == 68 || i == 355 || i == 26 || i == 323 || i == 25 || i == 54 || i == 69 || i == 92 || i == 77 || i == 58 || i == 61 || i == 62 || i == 42 || i == 71 || i == 64 || i == 84 || i == 324 || i == 330){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static boolean isBlockAround(Location loc, Integer radius, Integer typeid){
|
||||
Block blockx = loc.getBlock();
|
||||
int ox = blockx.getX();
|
||||
int oy = blockx.getY();
|
||||
int oz = blockx.getZ();
|
||||
for (int cx = -radius; cx <= radius; cx++) {
|
||||
for (int cy = -radius; cy <= radius; cy++) {
|
||||
for (int cz = -radius; cz <= radius; cz++) {
|
||||
Block block = loc.getWorld().getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
//If block is block
|
||||
if (block.getTypeId() == typeid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isPvpEnabled(){
|
||||
String propertyName = "pvp";
|
||||
FileReader fr = null;
|
||||
try {
|
||||
fr = new FileReader("server.properties");
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
String property;
|
||||
String s = null;
|
||||
try {
|
||||
while((s=br.readLine()) .indexOf(propertyName)==-1);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
property = s.split("=")[1];
|
||||
try {
|
||||
fr.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(property.toLowerCase().equals("true")){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static Integer calculateHealth(Integer health, Integer newvalue){
|
||||
if((health + newvalue) > 20){
|
||||
return 20;
|
||||
} else {
|
||||
return health+newvalue;
|
||||
}
|
||||
}
|
||||
public Integer calculateMinusHealth(Integer health, Integer newvalue){
|
||||
if((health - newvalue) < 1){
|
||||
return 0;
|
||||
} else {
|
||||
return health-newvalue;
|
||||
}
|
||||
}
|
||||
public static Integer getHealth(Entity entity){
|
||||
if(entity instanceof Monster){
|
||||
Monster monster = (Monster)entity;
|
||||
return monster.getHealth();
|
||||
} else if (entity instanceof Animals){
|
||||
Animals animals = (Animals)entity;
|
||||
return animals.getHealth();
|
||||
} else if (entity instanceof Player){
|
||||
Player player = (Player)entity;
|
||||
return player.getHealth();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public static boolean isInt(String string){
|
||||
try {
|
||||
int x = Integer.parseInt(string);
|
||||
}
|
||||
catch(NumberFormatException nFE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static void mcDropItem(Location loc, int id){
|
||||
if(loc != null){
|
||||
Material mat = Material.getMaterial(id);
|
||||
byte damage = 0;
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSwords(ItemStack is){
|
||||
if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isHoe(ItemStack is){
|
||||
int id = is.getTypeId();
|
||||
if(id == 290 || id == 291 || id == 292 || id == 293 || id == 294){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isShovel(ItemStack is){
|
||||
if(is.getTypeId() == 269 || is.getTypeId() == 273 || is.getTypeId() == 277 || is.getTypeId() == 284 || is.getTypeId() == 256){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isAxes(ItemStack is){
|
||||
if(is.getTypeId() == 271 || is.getTypeId() == 258 || is.getTypeId() == 286 || is.getTypeId() == 279 || is.getTypeId() == 275){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isMiningPick(ItemStack is){
|
||||
if(is.getTypeId() == 270 || is.getTypeId() == 274 || is.getTypeId() == 285 || is.getTypeId() == 257 || is.getTypeId() == 278){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isGold(ItemStack is){
|
||||
int i = is.getTypeId();
|
||||
if(i == 283 || i == 284 || i == 285 || i == 286 || i == 294 || i == 314 || i == 315 || i == 316 || i == 317){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void mmoHelpCheck(String[] split, Player player, PlayerChatEvent event){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(split[0].equalsIgnoreCase("/woodcutting")){
|
||||
event.setCancelled(true);
|
||||
float skillvalue = (float)PP.getWoodCuttingInt();
|
||||
int ticks = 2;
|
||||
int x = PP.getWoodCuttingInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"WOODCUTTING"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Chopping down trees");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Tree Feller (ABILITY): "+ChatColor.GREEN+"Make trees explode");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Double Drops: "+ChatColor.YELLOW+ChatColor.GREEN+"Double the normal loot");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Double Drop Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Tree Feller Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/archery")){
|
||||
event.setCancelled(true);
|
||||
Integer rank = 0;
|
||||
if(PP.getArcheryInt() >= 50)
|
||||
rank++;
|
||||
if(PP.getArcheryInt() >= 250)
|
||||
rank++;
|
||||
if(PP.getArcheryInt() >= 575)
|
||||
rank++;
|
||||
if(PP.getArcheryInt() >= 725)
|
||||
rank++;
|
||||
if(PP.getArcheryInt() >= 1000)
|
||||
rank++;
|
||||
float skillvalue = (float)PP.getArcheryInt();
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
|
||||
int ignition = 20;
|
||||
if(PP.getArcheryInt() >= 200)
|
||||
ignition+=20;
|
||||
if(PP.getArcheryInt() >= 400)
|
||||
ignition+=20;
|
||||
if(PP.getArcheryInt() >= 600)
|
||||
ignition+=20;
|
||||
if(PP.getArcheryInt() >= 800)
|
||||
ignition+=20;
|
||||
if(PP.getArcheryInt() >= 1000)
|
||||
ignition+=20;
|
||||
|
||||
String percentagedaze;
|
||||
if(PP.getArcheryInt() < 1000){
|
||||
percentagedaze = String.valueOf((skillvalue / 2000) * 100);
|
||||
} else {
|
||||
percentagedaze = "50";
|
||||
}
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"ARCHERY"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Attacking Monsters");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Ignition: "+ChatColor.GREEN+"25% Chance Enemies will ignite");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Daze (Players): "+ChatColor.GREEN+"Disorients foes");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Damage+: "+ChatColor.GREEN+"Modifies Damage");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Arrow Retrieval: "+ChatColor.GREEN+"Chance to retrieve arrows from corpses");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Chance to Daze: "+ChatColor.YELLOW+percentagedaze+"%");
|
||||
player.sendMessage(ChatColor.RED+"Chance to Retrieve Arrows: "+ChatColor.YELLOW+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Length of Ignition: "+ChatColor.YELLOW+(ignition / 20)+" seconds");
|
||||
player.sendMessage(ChatColor.RED+"Damage+ (Rank"+rank+"): Bonus "+rank+" damage");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/axes")){
|
||||
event.setCancelled(true);
|
||||
String percentage;
|
||||
float skillvalue = (float)PP.getAxesInt();
|
||||
if(PP.getAxesInt() < 750){
|
||||
percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
} else {
|
||||
percentage = "75";
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getAxesInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"AXES"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Attacking Monsters");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Skull Splitter (ABILITY): "+ChatColor.GREEN+"Deal AoE Damage");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Critical Strikes: "+ChatColor.GREEN+"Double Damage");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Axe Mastery (500 SKILL): "+ChatColor.GREEN+"Modifies Damage");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Chance to crtically strike: "+ChatColor.YELLOW+percentage+"%");
|
||||
if(PP.getAxesInt() < 500){
|
||||
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (AXEMASTERY)");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"Axe Mastery:"+ChatColor.YELLOW+" Bonus 4 damage");
|
||||
}
|
||||
player.sendMessage(ChatColor.RED+"Skull Splitter Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/swords")){
|
||||
event.setCancelled(true);
|
||||
int bleedrank = 2;
|
||||
String percentage, parrypercentage = null, counterattackpercentage;
|
||||
float skillvalue = (float)PP.getSwordsInt();
|
||||
if(PP.getSwordsInt() < 750){
|
||||
percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
} else {
|
||||
percentage = "75";
|
||||
}
|
||||
if(skillvalue >= 750)
|
||||
bleedrank+=1;
|
||||
|
||||
if(PP.getSwordsInt() <= 900){
|
||||
parrypercentage = String.valueOf((skillvalue / 3000) * 100);
|
||||
} else {
|
||||
parrypercentage = "30";
|
||||
}
|
||||
|
||||
if(PP.getSwordsInt() <= 600){
|
||||
counterattackpercentage = String.valueOf((skillvalue / 2000) * 100);
|
||||
} else {
|
||||
counterattackpercentage = "30";
|
||||
}
|
||||
|
||||
int ticks = 2;
|
||||
int x = PP.getSwordsInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"SWORDS"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Attacking Monsters");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Counter Attack: "+ChatColor.GREEN+"Reflect 50% of damage taken");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Serrated Strikes (ABILITY): "+ChatColor.GREEN+"25% DMG AoE, Bleed+ AoE");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"Serrated Strikes Bleed+: "+ChatColor.GREEN+"5 Tick Bleed");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Parrying: "+ChatColor.GREEN+"Negates Damage");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Bleed: "+ChatColor.GREEN+"Apply a bleed DoT");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Counter Attack Chance: "+ChatColor.YELLOW+counterattackpercentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Bleed Length: "+ChatColor.YELLOW+bleedrank+" ticks");
|
||||
player.sendMessage(ChatColor.GRAY+"NOTE: "+ChatColor.YELLOW+"1 Tick happens every 2 seconds");
|
||||
player.sendMessage(ChatColor.RED+"Bleed Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Parry Chance: "+ChatColor.YELLOW+parrypercentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Serrated Strikes Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/acrobatics")){
|
||||
event.setCancelled(true);
|
||||
String dodgepercentage;
|
||||
float skillvalue = (float)PP.getAcrobaticsInt();
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
String gracepercentage = String.valueOf(((skillvalue / 1000) * 100) * 2);
|
||||
if(PP.getAcrobaticsInt() <= 800){
|
||||
dodgepercentage = String.valueOf((skillvalue / 4000 * 100));
|
||||
} else {
|
||||
dodgepercentage = "20";
|
||||
}
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"ACROBATICS"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Falling");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Roll: "+ChatColor.GREEN+"Reduces or Negates damage");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Graceful Roll: "+ChatColor.GREEN+"Twice as effective as Roll");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Dodge: "+ChatColor.GREEN+"Reduce damage by half");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Roll Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Graceful Roll Chance: "+ChatColor.YELLOW+gracepercentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Dodge Chance: "+ChatColor.YELLOW+dodgepercentage+"%");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/mining")){
|
||||
float skillvalue = (float)PP.getMiningInt();
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
int ticks = 2;
|
||||
int x = PP.getMiningInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"MINING"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Mining Stone & Ore");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Super Breaker (ABILITY): "+ChatColor.GREEN+"Speed+, Triple Drop Chance");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Double Drops: "+ChatColor.GREEN+"Double the normal loot");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Double Drop Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Super Breaker Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/repair")){
|
||||
float skillvalue = (float)PP.getRepairInt();
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
String repairmastery = String.valueOf((skillvalue / 500) * 100);
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"REPAIR"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Repairing");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Repair: "+ChatColor.GREEN+"Repair Iron Tools & Armor");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Repair Mastery: "+ChatColor.GREEN+"Increased repair amount");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Super Repair: "+ChatColor.GREEN+"Double effectiveness");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Diamond Repair ("+LoadProperties.repairdiamondlevel+"+ SKILL): "+ChatColor.GREEN+"Repair Diamond Tools & Armor");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Repair Mastery: "+ChatColor.YELLOW+"Extra "+repairmastery+"% durability restored");
|
||||
player.sendMessage(ChatColor.RED+"Super Repair Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/unarmed")){
|
||||
event.setCancelled(true);
|
||||
String percentage, arrowpercentage;
|
||||
float skillvalue = (float)PP.getUnarmedInt();
|
||||
|
||||
if(PP.getUnarmedInt() < 1000){
|
||||
percentage = String.valueOf((skillvalue / 4000) * 100);
|
||||
} else {
|
||||
percentage = "25";
|
||||
}
|
||||
|
||||
if(PP.getUnarmedInt() < 1000){
|
||||
arrowpercentage = String.valueOf(((skillvalue / 1000) * 100) / 2);
|
||||
} else {
|
||||
arrowpercentage = "50";
|
||||
}
|
||||
|
||||
|
||||
int ticks = 2;
|
||||
int x = PP.getUnarmedInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"UNARMED"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Attacking Monsters");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Berserk (ABILITY): "+ChatColor.GREEN+"+50% DMG, Breaks weak materials");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Disarm (Players): "+ChatColor.GREEN+"Drops the foes item held in hand");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Unarmed Mastery: "+ChatColor.GREEN+"Large Damage Upgrade");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Unarmed Apprentice: "+ChatColor.GREEN+"Damage Upgrade");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Arrow Deflect: "+ChatColor.GREEN+"Deflect arrows");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Arrow Deflect Chance: "+ChatColor.YELLOW+arrowpercentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Disarm Chance: "+ChatColor.YELLOW+percentage+"%");
|
||||
if(PP.getUnarmedInt() < 250){
|
||||
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 250+ SKILL (UNARMED APPRENTICE)");
|
||||
} else if(PP.getUnarmedInt() >= 250 && PP.getUnarmedInt() < 500){
|
||||
player.sendMessage(ChatColor.RED+"Unarmed Apprentice: "+ChatColor.YELLOW+"Damage Upgrade");
|
||||
player.sendMessage(ChatColor.GRAY+"LOCKED UNTIL 500+ SKILL (UNARMED MASTERY)");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"Unarmed Mastery: "+ChatColor.YELLOW+"Large Damage Upgrade");
|
||||
}
|
||||
player.sendMessage(ChatColor.RED+"Berserk Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/herbalism")){
|
||||
event.setCancelled(true);
|
||||
int rank = 0;
|
||||
if(PP.getHerbalismInt() >= 50)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 150)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 250)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 350)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 450)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 550)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 650)
|
||||
rank++;
|
||||
if (PP.getHerbalismInt() >= 750)
|
||||
rank++;
|
||||
int bonus = 0;
|
||||
if(PP.getHerbalismInt() >= 200)
|
||||
bonus++;
|
||||
if(PP.getHerbalismInt() >= 400)
|
||||
bonus++;
|
||||
if(PP.getHerbalismInt() >= 600)
|
||||
bonus++;
|
||||
|
||||
int ticks = 2;
|
||||
int x = PP.getHerbalismInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
float skillvalue = (float)PP.getHerbalismInt();
|
||||
String percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
String gpercentage = String.valueOf((skillvalue / 1500) * 100);
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"HERBALISM"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Harvesting Herbs");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Green Terra (ABILITY): "+ChatColor.GREEN+"Spread the Terra, 3x Drops");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Green Thumb (Wheat): "+ChatColor.GREEN+"Auto-Plants wheat when harvesting");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Green Thumb (Cobble): "+ChatColor.GREEN+"Cobblestone -> Mossy w/ Seeds");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Food+: "+ChatColor.GREEN+"Modifies health received from bread/stew");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Double Drops (All Herbs): "+ChatColor.GREEN+"Double the normal loot");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Green Terra Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
player.sendMessage(ChatColor.RED+"Green Thumb Chance: "+gpercentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Green Thumb Stage: Wheat grows in stage "+bonus);
|
||||
player.sendMessage(ChatColor.RED+"Double Drop Chance: "+percentage+"%");
|
||||
player.sendMessage(ChatColor.RED+"Food+ (Rank"+rank+"): Bonus "+rank+" healing");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/excavation")){
|
||||
event.setCancelled(true);
|
||||
int ticks = 2;
|
||||
int x = PP.getExcavationInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"EXCAVATION"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Digging and finding treasures");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Giga Drill Breaker (ABILITY): "+ChatColor.GREEN+"3x Drop Rate, 3x EXP, +Speed");
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Treasure Hunter: "+ChatColor.GREEN+"Ability to dig for treasure");
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"YOUR STATS"+ChatColor.RED+"[]---");
|
||||
player.sendMessage(ChatColor.RED+"Giga Drill Breaker Length: "+ChatColor.YELLOW+ticks+"s");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcmmo)){
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----");
|
||||
player.sendMessage(ChatColor.YELLOW+"mMO is an RPG server mod for minecraft.");
|
||||
player.sendMessage(ChatColor.YELLOW+"There are many skills added by mMO to minecraft.");
|
||||
player.sendMessage(ChatColor.YELLOW+"They can do anything from giving a chance");
|
||||
player.sendMessage(ChatColor.YELLOW+"for double drops to letting you break materials instantly.");
|
||||
player.sendMessage(ChatColor.YELLOW+"For example, by harvesting logs from trees you will gain");
|
||||
player.sendMessage(ChatColor.YELLOW+"Woodcutting xp and once you have enough xp you will gain");
|
||||
player.sendMessage(ChatColor.YELLOW+"a skill level in Woodcutting. By raising this skill you will");
|
||||
player.sendMessage(ChatColor.YELLOW+"be able to receive benefits like "+ChatColor.RED+"double drops");
|
||||
player.sendMessage(ChatColor.YELLOW+"and increase the effects of the "+ChatColor.RED+"\"Tree Felling\""+ChatColor.YELLOW+" ability.");
|
||||
player.sendMessage(ChatColor.YELLOW+"mMO has abilities related to the skill, skills normally");
|
||||
player.sendMessage(ChatColor.YELLOW+"provide passive bonuses but they also have activated");
|
||||
player.sendMessage(ChatColor.YELLOW+"abilities too. Each ability is activated by holding");
|
||||
player.sendMessage(ChatColor.YELLOW+"the appropriate tool and "+ChatColor.RED+"right clicking.");
|
||||
player.sendMessage(ChatColor.YELLOW+"For example, if you hold a Mining Pick and right click");
|
||||
player.sendMessage(ChatColor.YELLOW+"you will ready your Pickaxe, attack mining materials");
|
||||
player.sendMessage(ChatColor.YELLOW+"and then "+ChatColor.RED+"Super Breaker "+ChatColor.YELLOW+"will activate.");
|
||||
player.sendMessage(ChatColor.GREEN+"Find out mMO commands with "+ChatColor.DARK_AQUA+"/"+LoadProperties.mcc);
|
||||
player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcc)){
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mMO Commands"+ChatColor.RED+"[]---");
|
||||
player.sendMessage("/"+LoadProperties.stats+ChatColor.RED+" - View your mMO stats");
|
||||
if(mcPermissions.getInstance().party(player)){
|
||||
player.sendMessage(ChatColor.GREEN+"--PARTY COMMANDS--");
|
||||
player.sendMessage("/"+LoadProperties.party+" [party name] "+ChatColor.RED+"- Create/Join designated party");
|
||||
player.sendMessage("/"+LoadProperties.party+" q "+ChatColor.RED+"- Leave your current party");
|
||||
if(mcPermissions.getInstance().partyChat(player))
|
||||
player.sendMessage("/p "+ChatColor.RED+" - Toggle Party Chat");
|
||||
player.sendMessage("/"+LoadProperties.invite+" [player name] "+ChatColor.RED+"- Send party invite");
|
||||
player.sendMessage("/"+LoadProperties.accept+" "+ChatColor.RED+"- Accept party invite");
|
||||
if(mcPermissions.getInstance().partyTeleport(player))
|
||||
player.sendMessage("/"+LoadProperties.ptp+" [party member name] "+ChatColor.RED+"- Teleport to party member");
|
||||
}
|
||||
if(mcPermissions.getInstance().mySpawn(player)){
|
||||
player.sendMessage(ChatColor.GREEN+"--MYSPAWN COMMANDS--");
|
||||
player.sendMessage("/"+LoadProperties.myspawn+" "+ChatColor.RED+"- Clears inventory & teleports to myspawn");
|
||||
player.sendMessage("/"+LoadProperties.clearmyspawn+" "+ChatColor.RED+"- Clears your MySpawn");
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"--OTHER COMMANDS--");
|
||||
player.sendMessage("/mctop <skillname> <page> "+ChatColor.RED+"- Leaderboards");
|
||||
if(mcPermissions.getInstance().mcAbility(player))
|
||||
player.sendMessage("/"+LoadProperties.mcability+ChatColor.RED+" - Toggle ability activation with right click");
|
||||
if(mcPermissions.getInstance().adminChat(player)){
|
||||
player.sendMessage("/a "+ChatColor.RED+"- Toggle admin chat");
|
||||
}
|
||||
if(mcPermissions.getInstance().whois(player))
|
||||
player.sendMessage("/"+LoadProperties.whois+" [playername] "+ChatColor.RED+"- View detailed player info");
|
||||
if(mcPermissions.getInstance().mmoedit(player)){
|
||||
//player.sendMessage("/"+LoadProperties.mmoedit+" [skill] [newvalue] "+ChatColor.RED+"Modify the designated skill value");
|
||||
player.sendMessage("/"+LoadProperties.mmoedit+" [playername] [skill] [newvalue] "+ChatColor.RED+"- Modify target");
|
||||
}
|
||||
if(mcPermissions.getInstance().mcgod(player))
|
||||
player.sendMessage("/"+LoadProperties.mcgod+ChatColor.RED+" - God Mode");
|
||||
player.sendMessage("/[skillname] "+ChatColor.RED+" View detailed information about a skill");
|
||||
player.sendMessage("/"+LoadProperties.mcmmo+" "+ChatColor.RED+"- Read brief mod description");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -13,6 +15,11 @@ import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.datatypes.*;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
import com.gmail.nossr50.party.*;
|
||||
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
|
||||
|
||||
@ -32,19 +39,19 @@ public class mcBlockListener extends BlockListener {
|
||||
else {
|
||||
block = event.getBlock();
|
||||
}
|
||||
if(player != null && mcm.shouldBeWatched(block)){
|
||||
if(player != null && m.shouldBeWatched(block)){
|
||||
if(block.getTypeId() != 17)
|
||||
block.setData((byte) 5); //Change the byte
|
||||
if(block.getTypeId() == 17 || block.getTypeId() == 91 || block.getTypeId() == 86)
|
||||
mcConfig.getInstance().addBlockWatch(block);
|
||||
Config.getInstance().addBlockWatch(block);
|
||||
}
|
||||
if(block.getTypeId() == 42 && mcLoadProperties.anvilmessages)
|
||||
if(block.getTypeId() == 42 && LoadProperties.anvilmessages)
|
||||
event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor.");
|
||||
}
|
||||
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Block block = event.getBlock();
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
if(event.isCancelled())
|
||||
@ -54,18 +61,18 @@ public class mcBlockListener extends BlockListener {
|
||||
/*
|
||||
* Check if the Timer is doing its job
|
||||
*/
|
||||
mcSkills.monitorSkills(player);
|
||||
Skills.monitorSkills(player);
|
||||
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && block.getTypeId() == 59 && block.getData() == (byte) 0x07){
|
||||
mcHerbalism.greenTerraCheck(player, block, plugin);
|
||||
Herbalism.greenTerraCheck(player, block, plugin);
|
||||
}
|
||||
//Wheat && Triple drops
|
||||
if(PP.getGreenTerraMode() && mcHerbalism.canBeGreenTerra(block)){
|
||||
mcHerbalism.herbalismProcCheck(block, player, event);
|
||||
mcHerbalism.greenTerraWheat(player, block, event);
|
||||
if(PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(block)){
|
||||
Herbalism.herbalismProcCheck(block, player, event);
|
||||
Herbalism.greenTerraWheat(player, block, event);
|
||||
}
|
||||
|
||||
|
||||
@ -73,11 +80,11 @@ public class mcBlockListener extends BlockListener {
|
||||
* MINING
|
||||
*/
|
||||
if(mcPermissions.getInstance().mining(player)){
|
||||
if(mcLoadProperties.miningrequirespickaxe){
|
||||
if(mcm.isMiningPick(inhand))
|
||||
mcMining.miningBlockCheck(player, block);
|
||||
if(LoadProperties.miningrequirespickaxe){
|
||||
if(m.isMiningPick(inhand))
|
||||
Mining.miningBlockCheck(player, block);
|
||||
} else {
|
||||
mcMining.miningBlockCheck(player, block);
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -85,20 +92,20 @@ public class mcBlockListener extends BlockListener {
|
||||
*/
|
||||
|
||||
if(player != null && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player)){
|
||||
if(mcLoadProperties.woodcuttingrequiresaxe){
|
||||
if(mcm.isAxes(inhand)){
|
||||
if(!mcConfig.getInstance().isBlockWatched(block)){
|
||||
mcWoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addWoodcuttingXP(7 * mcLoadProperties.xpGainMultiplier);
|
||||
if(LoadProperties.woodcuttingrequiresaxe){
|
||||
if(m.isAxes(inhand)){
|
||||
if(!Config.getInstance().isBlockWatched(block)){
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addWoodcuttingXP(7 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(block.getData() != 5){
|
||||
mcWoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addWoodcuttingXP(7 * mcLoadProperties.xpGainMultiplier);
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
PP.addWoodcuttingXP(7 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
}
|
||||
mcSkills.XpCheck(player);
|
||||
Skills.XpCheck(player);
|
||||
|
||||
/*
|
||||
* IF PLAYER IS USING TREEFELLER
|
||||
@ -106,10 +113,10 @@ public class mcBlockListener extends BlockListener {
|
||||
if(mcPermissions.getInstance().woodCuttingAbility(player)
|
||||
&& PP.getTreeFellerMode()
|
||||
&& block.getTypeId() == 17
|
||||
&& mcm.blockBreakSimulate(block, player, plugin)){
|
||||
&& m.blockBreakSimulate(block, player, plugin)){
|
||||
|
||||
mcWoodCutting.treeFeller(block, player);
|
||||
for(Block blockx : mcConfig.getInstance().getTreeFeller()){
|
||||
WoodCutting.treeFeller(block, player);
|
||||
for(Block blockx : Config.getInstance().getTreeFeller()){
|
||||
if(blockx != null){
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
byte type = 0;
|
||||
@ -119,8 +126,8 @@ public class mcBlockListener extends BlockListener {
|
||||
if(blockx.getTypeId() == 17){
|
||||
blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item);
|
||||
//XP WOODCUTTING
|
||||
if(!mcConfig.getInstance().isBlockWatched(block)){
|
||||
mcWoodCutting.woodCuttingProcCheck(player, blockx);
|
||||
if(!Config.getInstance().isBlockWatched(block)){
|
||||
WoodCutting.woodCuttingProcCheck(player, blockx);
|
||||
PP.addWoodcuttingXP(7);
|
||||
}
|
||||
}
|
||||
@ -133,24 +140,24 @@ public class mcBlockListener extends BlockListener {
|
||||
blockx.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
if(mcLoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss);
|
||||
mcConfig.getInstance().clearTreeFeller();
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
Config.getInstance().clearTreeFeller();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
if(mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
|
||||
mcExcavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && mcHerbalism.canBeGreenTerra(block)){
|
||||
mcHerbalism.greenTerraCheck(player, block, plugin);
|
||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(block)){
|
||||
Herbalism.greenTerraCheck(player, block, plugin);
|
||||
}
|
||||
if(mcPermissions.getInstance().herbalism(player) && block.getData() != (byte) 5)
|
||||
mcHerbalism.herbalismProcCheck(block, player, event);
|
||||
Herbalism.herbalismProcCheck(block, player, event);
|
||||
|
||||
//Change the byte back when broken
|
||||
if(block.getData() == 5)
|
||||
@ -160,66 +167,64 @@ public class mcBlockListener extends BlockListener {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
if(player.isOp())
|
||||
player.sendMessage("mcMMO DEBUG: Byte: "+block.getData()+", ID: "+block.getTypeId());
|
||||
/*
|
||||
* Check if the Timer is doing its job
|
||||
*/
|
||||
mcSkills.monitorSkills(player);
|
||||
Skills.monitorSkills(player);
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if(PP.getHoePreparationMode() && mcHerbalism.canBeGreenTerra(block))
|
||||
mcHerbalism.greenTerraCheck(player, block, plugin);
|
||||
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
|
||||
Herbalism.greenTerraCheck(player, block, plugin);
|
||||
if(PP.getAxePreparationMode() && block.getTypeId() == 17)
|
||||
mcWoodCutting.treeFellerCheck(player, block, plugin);
|
||||
WoodCutting.treeFellerCheck(player, block, plugin);
|
||||
if(PP.getPickaxePreparationMode())
|
||||
mcMining.superBreakerCheck(player, block, plugin);
|
||||
if(PP.getShovelPreparationMode() && mcExcavation.canBeGigaDrillBroken(block))
|
||||
mcExcavation.gigaDrillBreakerActivationCheck(player, block, plugin);
|
||||
if(PP.getFistsPreparationMode() && mcExcavation.canBeGigaDrillBroken(block))
|
||||
mcSkills.berserkActivationCheck(player, plugin);
|
||||
Mining.superBreakerCheck(player, block, plugin);
|
||||
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
|
||||
Excavation.gigaDrillBreakerActivationCheck(player, block, plugin);
|
||||
if(PP.getFistsPreparationMode() && Excavation.canBeGigaDrillBroken(block))
|
||||
Skills.berserkActivationCheck(player, plugin);
|
||||
/*
|
||||
* GREEN TERRA STUFF
|
||||
*/
|
||||
if(PP.getGreenTerraMode() && mcPermissions.getInstance().herbalismAbility(player) && PP.getGreenTerraMode()){
|
||||
mcHerbalism.greenTerra(player, block);
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
|
||||
/*
|
||||
* GIGA DRILL BREAKER CHECKS
|
||||
*/
|
||||
if(PP.getGigaDrillBreakerMode()
|
||||
&& mcm.blockBreakSimulate(block, player, plugin)
|
||||
&& mcExcavation.canBeGigaDrillBroken(block)
|
||||
&& mcm.isShovel(inhand)){
|
||||
&& m.blockBreakSimulate(block, player, plugin)
|
||||
&& Excavation.canBeGigaDrillBroken(block)
|
||||
&& m.isShovel(inhand)){
|
||||
|
||||
if(mcm.getTier(player) >= 2)
|
||||
mcExcavation.excavationProcCheck(block, player);
|
||||
if(mcm.getTier(player) >= 3)
|
||||
mcExcavation.excavationProcCheck(block, player);
|
||||
if(mcm.getTier(player) >= 4)
|
||||
mcExcavation.excavationProcCheck(block, player);
|
||||
if(m.getTier(player) >= 2)
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
if(m.getTier(player) >= 3)
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
if(m.getTier(player) >= 4)
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
if(block.getTypeId() == 2)
|
||||
mat = Material.DIRT;
|
||||
byte type = block.getData();
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
|
||||
block.setType(Material.AIR);
|
||||
if(mcLoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
mcm.damageTool(player, (short) mcLoadProperties.abilityDurabilityLoss);
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
}
|
||||
/*
|
||||
* BERSERK MODE CHECKS
|
||||
*/
|
||||
if(PP.getBerserkMode()
|
||||
&& mcm.blockBreakSimulate(block, player, plugin)
|
||||
&& m.blockBreakSimulate(block, player, plugin)
|
||||
&& player.getItemInHand().getTypeId() == 0
|
||||
&& mcExcavation.canBeGigaDrillBroken(block)){
|
||||
&& Excavation.canBeGigaDrillBroken(block)){
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
if(block.getTypeId() == 2)
|
||||
mat = Material.DIRT;
|
||||
@ -233,49 +238,24 @@ public class mcBlockListener extends BlockListener {
|
||||
* SUPER BREAKER CHECKS
|
||||
*/
|
||||
if(PP.getSuperBreakerMode()
|
||||
&& mcMining.canBeSuperBroken(block)
|
||||
&& mcm.blockBreakSimulate(block, player, plugin)){
|
||||
&& Mining.canBeSuperBroken(block)
|
||||
&& m.blockBreakSimulate(block, player, plugin)){
|
||||
|
||||
if(mcLoadProperties.miningrequirespickaxe){
|
||||
if(mcm.isMiningPick(inhand))
|
||||
mcMining.SuperBreakerBlockCheck(player, block);
|
||||
if(LoadProperties.miningrequirespickaxe){
|
||||
if(m.isMiningPick(inhand))
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
} else {
|
||||
mcMining.SuperBreakerBlockCheck(player, block);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
//Code borrowed from WorldGuard by sk89q
|
||||
World world = event.getBlock().getWorld();
|
||||
int radius = 1;
|
||||
Block blockFrom = event.getBlock();
|
||||
Block blockTo = event.getToBlock();
|
||||
|
||||
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||
|
||||
int ox = blockTo.getX();
|
||||
int oy = blockTo.getY();
|
||||
int oz = blockTo.getZ();
|
||||
|
||||
if(blockTo.getTypeId() == 9 || blockTo.getTypeId() == 8)
|
||||
return;
|
||||
|
||||
if(mcLoadProperties.clay){
|
||||
for (int cx = -radius; cx <= radius; cx++) {
|
||||
for (int cy = -radius; cy <= radius; cy++) {
|
||||
for (int cz = -radius; cz <= radius; cz++) {
|
||||
Block block = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
//If block is block
|
||||
if (isWater == true && block.getType() == Material.GRAVEL){
|
||||
//Change
|
||||
block.setType(Material.CLAY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m.shouldBeWatched(blockFrom) && blockFrom.getData() == (byte)5){
|
||||
blockTo.setData((byte)5);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,14 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
|
||||
|
||||
public class mcEntityListener extends EntityListener {
|
||||
@ -36,8 +43,8 @@ public class mcEntityListener extends EntityListener {
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
Location loc = event.getLocation();
|
||||
Entity spawnee = event.getEntity();
|
||||
if(mcm.isBlockAround(loc, 5, 52)){
|
||||
mcConfig.getInstance().addMobSpawnTrack(spawnee);
|
||||
if(m.isBlockAround(loc, 5, 52)){
|
||||
Config.getInstance().addMobSpawnTrack(spawnee);
|
||||
}
|
||||
}
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
@ -46,233 +53,82 @@ public class mcEntityListener extends EntityListener {
|
||||
/*
|
||||
* CHECK FOR INVULNERABILITY
|
||||
*/
|
||||
if(event.getEntity() instanceof Player){
|
||||
Player defender = (Player)event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(defender != null && Config.getInstance().isGodModeToggled(defender.getName()))
|
||||
event.setCancelled(true);
|
||||
if(PPd == null)
|
||||
Users.addUser(defender);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof CraftEntity){
|
||||
CraftEntity cEntity = (CraftEntity)event.getEntity();
|
||||
if(cEntity.getHandle() instanceof EntityLiving){
|
||||
EntityLiving entityliving = (EntityLiving)cEntity.getHandle();
|
||||
if(entityliving.noDamageTicks < entityliving.maxNoDamageTicks/2.0F){
|
||||
Entity x = event.getEntity();
|
||||
DamageCause type = event.getCause();
|
||||
/*
|
||||
* ACROBATICS
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
Location loc = player.getLocation();
|
||||
int xx = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
if(type == DamageCause.FALL){
|
||||
mcAcrobatics.getInstance().acrobaticsCheck(player, event, loc, xx, y, z);
|
||||
}
|
||||
}
|
||||
CraftEntity cEntity = (CraftEntity)event.getEntity();
|
||||
if(cEntity.getHandle() instanceof EntityLiving)
|
||||
{
|
||||
EntityLiving entityliving = (EntityLiving)cEntity.getHandle();
|
||||
if(entityliving.noDamageTicks < entityliving.maxNoDamageTicks/2.0F)
|
||||
{
|
||||
Entity x = event.getEntity();
|
||||
DamageCause type = event.getCause();
|
||||
/*
|
||||
* ACROBATICS
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
if(type == DamageCause.FALL){
|
||||
Acrobatics.acrobaticsCheck(player, event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Entity Damage by Entity checks
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && event.getDamage() >= 1){
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
||||
Entity e = eventb.getEntity(); //Defender
|
||||
Entity f = eventb.getDamager(); //Attacker
|
||||
/*
|
||||
* DEFENDER PROC/GODMODE CHECKS
|
||||
*/
|
||||
if(e instanceof Player){
|
||||
Player defender = (Player)e;
|
||||
PlayerProfile PPd = mcUsers.getProfile(defender);
|
||||
if(defender != null && mcConfig.getInstance().isGodModeToggled(defender.getName()))
|
||||
event.setCancelled(true);
|
||||
if(PPd == null)
|
||||
mcUsers.addUser(defender);
|
||||
/*
|
||||
* PARRYING CHECK, CHECK TO SEE IF ITS A SUCCESSFUL PARRY OR NOT
|
||||
*/
|
||||
mcCombat.parryCheck(defender, eventb, f);
|
||||
}
|
||||
|
||||
/*
|
||||
* ARCHERY CHECKS
|
||||
*/
|
||||
if(!event.isCancelled() && event instanceof EntityDamageByProjectileEvent && event.getDamage() >= 1){
|
||||
EntityDamageByProjectileEvent c = (EntityDamageByProjectileEvent)event;
|
||||
mcCombat.archeryCheck(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* CHECK FOR PVP INTERACTIONS
|
||||
*/
|
||||
if(f instanceof Player && e instanceof Player && !mcLoadProperties.pvp)
|
||||
event.setCancelled(true);
|
||||
|
||||
/*
|
||||
* IF ATTACKER IS PLAYER
|
||||
*/
|
||||
if(f instanceof Player && !event.isCancelled()){
|
||||
//((Player) f).sendMessage("DEBUG: EntityDamageByEntity cast correctly!");
|
||||
int typeid = ((Player) f).getItemInHand().getTypeId();
|
||||
Player attacker = (Player)f;
|
||||
/*
|
||||
* Check if the Timer is doing its job
|
||||
*/
|
||||
mcSkills.monitorSkills(attacker);
|
||||
|
||||
PlayerProfile PPa = mcUsers.getProfile(attacker);
|
||||
/*
|
||||
* ACTIVATE ABILITIES
|
||||
*/
|
||||
if(PPa.getAxePreparationMode())
|
||||
mcSkills.skullSplitterCheck(attacker, plugin);
|
||||
if(PPa.getSwordsPreparationMode())
|
||||
mcSkills.serratedStrikesActivationCheck(attacker, plugin);
|
||||
if(PPa.getFistsPreparationMode())
|
||||
mcSkills.berserkActivationCheck(attacker, plugin);
|
||||
/*
|
||||
* BERSERK DAMAGE MODIFIER
|
||||
*/
|
||||
if(PPa.getBerserkMode())
|
||||
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
||||
/*
|
||||
* Player versus Monster checks, this handles all skill damage modifiers and any procs.
|
||||
*/
|
||||
mcCombat.playerVersusMonsterChecks(eventb, attacker, e, typeid);
|
||||
/*
|
||||
* Player versus Squid checks, this handles all skill damage modifiers and any procs.
|
||||
*/
|
||||
mcCombat.playerVersusSquidChecks(eventb, attacker, e, typeid);
|
||||
/*
|
||||
* Player versus Player checks, these checks make sure players are not in the same party, etc. They also check for any procs from skills and handle damage modifiers.
|
||||
*/
|
||||
if(mcm.isPvpEnabled())
|
||||
mcCombat.playerVersusPlayerChecks(e, attacker, eventb);
|
||||
/*
|
||||
* Player versus Animals checks, these checks handle any skill modifiers or procs
|
||||
*/
|
||||
mcCombat.playerVersusAnimalsChecks(e, attacker, eventb, typeid);
|
||||
/*
|
||||
* This will do AOE damage from the axes ability
|
||||
*/
|
||||
|
||||
if(!event.isCancelled() && PPa.getSkullSplitterMode() && mcm.isAxes(attacker.getItemInHand())){
|
||||
mcCombat.applyAoeDamage(attacker, eventb, x);
|
||||
}
|
||||
if(!event.isCancelled() && PPa.getSerratedStrikesMode() && mcm.isSwords(attacker.getItemInHand())){
|
||||
mcCombat.applySerratedStrikes(attacker, eventb, x);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* DODGE / COUNTERATTACK CHECKS
|
||||
*/
|
||||
if(e instanceof Player){
|
||||
Player defender = (Player)e;
|
||||
PlayerProfile PPd = mcUsers.getProfile(defender);
|
||||
if(f instanceof Player){
|
||||
Player attacker = (Player)f;
|
||||
if(mcParty.getInstance().inSameParty(defender, attacker)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* COUNTER ATTACK STUFF
|
||||
*/
|
||||
if(mcPermissions.getInstance().swords(defender)
|
||||
&& mcm.isSwords(defender.getItemInHand())){
|
||||
boolean isArrow = false;
|
||||
if (event instanceof EntityDamageByProjectileEvent) {
|
||||
final EntityDamageByProjectileEvent realEvent =
|
||||
(EntityDamageByProjectileEvent) event;
|
||||
isArrow = (realEvent.getProjectile() instanceof Arrow);
|
||||
}
|
||||
if(isArrow == false){
|
||||
//defender.sendMessage("isArrow ="+isArrow);
|
||||
if(PPd.getSwordsInt() >= 600){
|
||||
if(Math.random() * 2000 <= 600){
|
||||
mcCombat.dealDamage(f, event.getDamage() / 2);
|
||||
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
|
||||
if(f instanceof Player)
|
||||
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
|
||||
}
|
||||
} else if (Math.random() * 2000 <= PPd.getSwordsInt()){
|
||||
mcCombat.dealDamage(f, event.getDamage() / 2);
|
||||
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
|
||||
if(f instanceof Player)
|
||||
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
|
||||
/*
|
||||
* Entity Damage by Entity checks
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
||||
{
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
||||
Entity f = eventb.getDamager();
|
||||
Entity e = event.getEntity();
|
||||
/*
|
||||
* PARTY CHECKS
|
||||
*/
|
||||
if(event.getEntity() instanceof Player && f instanceof Player)
|
||||
{
|
||||
Player defender = (Player)e;
|
||||
Player attacker = (Player)f;
|
||||
if(Party.getInstance().inSameParty(defender, attacker))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* DODGE STUFF
|
||||
*/
|
||||
if(mcPermissions.getInstance().acrobatics(defender)){
|
||||
if(PPd.getAcrobaticsInt() <= 800){
|
||||
if(Math.random() * 4000 <= PPd.getAcrobaticsInt()){
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addAcrobaticsXP(event.getDamage() * 12);
|
||||
mcSkills.XpCheck(defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to do minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
} else if(Math.random() * 4000 <= 800) {
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addAcrobaticsXP(event.getDamage() * 12);
|
||||
mcSkills.XpCheck(defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to do minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TAMING STUFF
|
||||
*/
|
||||
if(f instanceof Wolf){
|
||||
Wolf theWolf = (Wolf)f;
|
||||
if(mcTaming.hasOwner(theWolf, plugin) && mcTaming.getInstance().getOwner(theWolf, plugin) != null){
|
||||
Player wolfMaster = mcTaming.getInstance().getOwner(theWolf, plugin);
|
||||
if(!event.isCancelled()){
|
||||
mcUsers.getProfile(wolfMaster).addXpToSkill(event.getDamage(), "Taming");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check to see if the defender took damage so we can apply recently hurt
|
||||
*/
|
||||
if(x instanceof Player && !event.isCancelled()){
|
||||
Player herpderp = (Player)x;
|
||||
mcUsers.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
Combat.combatChecks(event);
|
||||
}
|
||||
/*
|
||||
* Check to see if the defender took damage so we can apply recently hurt
|
||||
*/
|
||||
if(event.getEntity() instanceof Player && !event.isCancelled() && event.getDamage() >= 1)
|
||||
{
|
||||
Player herpderp = (Player)event.getEntity();
|
||||
Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
Entity x = event.getEntity();
|
||||
x.setFireTicks(0);
|
||||
|
||||
//Remove bleed track
|
||||
if(mcConfig.getInstance().isBleedTracked(x))
|
||||
mcConfig.getInstance().addToBleedRemovalQue(x);
|
||||
if(Config.getInstance().isBleedTracked(x))
|
||||
Config.getInstance().addToBleedRemovalQue(x);
|
||||
|
||||
mcSkills.arrowRetrievalCheck(x);
|
||||
if(mcConfig.getInstance().isMobSpawnTracked(x)){
|
||||
mcConfig.getInstance().removeMobSpawnTrack(x);
|
||||
Skills.arrowRetrievalCheck(x);
|
||||
if(Config.getInstance().isMobSpawnTracked(x)){
|
||||
Config.getInstance().removeMobSpawnTrack(x);
|
||||
}
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
mcUsers.getProfile(player).setBleedTicks(0);
|
||||
Users.getProfile(player).setBleedTicks(0);
|
||||
}
|
||||
}
|
||||
public boolean isPlayer(Entity entity){
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.datatypes.*;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
import com.gmail.nossr50.party.*;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.nijiko.Messaging;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
@ -34,7 +38,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
static String maindirectory = "plugins/mcMMO/";
|
||||
public static String maindirectory = "plugins/mcMMO/";
|
||||
static File Properties = new File(maindirectory + "mcmmo.properties");
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final mcPlayerListener playerListener = new mcPlayerListener(this);
|
||||
@ -47,7 +51,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public static Database database = null;
|
||||
|
||||
public void onEnable() {
|
||||
mcMMO_Timer.schedule(new mcTimer(this), 0, (long)(1000));
|
||||
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000));
|
||||
new File(maindirectory).mkdir();
|
||||
|
||||
if(!Properties.exists()){
|
||||
@ -73,10 +77,10 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
//Load the file
|
||||
mcLoadProperties.loadMain();
|
||||
mcUsers.getInstance().loadUsers();
|
||||
LoadProperties.loadMain();
|
||||
Users.getInstance().loadUsers();
|
||||
for(Player player : getServer().getOnlinePlayers()){
|
||||
mcUsers.addUser(player);
|
||||
Users.addUser(player);
|
||||
}
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||
@ -98,12 +102,12 @@ public class mcMMO extends JavaPlugin {
|
||||
mcPermissions.initialize(getServer());
|
||||
mcLoadMySQL();
|
||||
|
||||
mcLeaderboard.makeLeaderboards(); //Make the leaderboards
|
||||
Leaderboard.makeLeaderboards(); //Make the leaderboards
|
||||
System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
}
|
||||
|
||||
private void mcLoadMySQL() {
|
||||
if (mcLoadProperties.useMySQL) {
|
||||
if (LoadProperties.useMySQL) {
|
||||
// create database object
|
||||
database = new Database();
|
||||
}
|
||||
@ -121,15 +125,15 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
public boolean isPartyChatToggled(Player player){
|
||||
if(mcConfig.getInstance().isPartyToggled(player.getName())){
|
||||
if(Config.getInstance().isPartyToggled(player.getName())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean inSameParty(Player playera, Player playerb){
|
||||
if(mcUsers.getProfile(playera).inParty() && mcUsers.getProfile(playerb).inParty()){
|
||||
if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){
|
||||
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()){
|
||||
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -139,12 +143,12 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
public void addXp(Player player, String skillname, Integer newvalue){
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PP.addXpToSkill(newvalue, skillname);
|
||||
mcSkills.XpCheck(player);
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
public void modifySkill(Player player, String skillname, Integer newvalue){
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PP.modifyskill(newvalue, skillname);
|
||||
}
|
||||
public ArrayList<String> getParties(){
|
||||
@ -173,15 +177,15 @@ public class mcMMO extends JavaPlugin {
|
||||
return parties;
|
||||
}
|
||||
public static String getPartyName(Player player){
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.getParty();
|
||||
}
|
||||
public static boolean inParty(Player player){
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.inParty();
|
||||
}
|
||||
public boolean isAdminChatToggled(Player player){
|
||||
if(mcConfig.getInstance().isAdminToggled(player.getName())){
|
||||
if(Config.getInstance().isAdminToggled(player.getName())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -19,7 +19,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
|
||||
public class mcPlayerListener extends PlayerListener {
|
||||
@ -34,7 +40,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player != null){
|
||||
PP.setRespawnATS(System.currentTimeMillis());
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
@ -66,30 +72,30 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
mcUsers.addUser(player);
|
||||
Users.addUser(player);
|
||||
}
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
mcUsers.removeUser(event.getPlayer());
|
||||
Users.removeUser(event.getPlayer());
|
||||
}
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(mcPermissions.getInstance().motd(player)){
|
||||
player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+mcLoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
|
||||
player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
|
||||
player.sendMessage(ChatColor.BLUE +"This server is running MMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
|
||||
player.sendMessage(ChatColor.GREEN+"http://mmo.wikia.com"+ChatColor.BLUE+" - MMO Wiki");
|
||||
player.sendMessage(ChatColor.DARK_RED+"ATTN: YOUR STATS WILL BE BACK TO NORMAL SHORTLY, WE ARE USING MySQL NOW AND I HAVE TO WRITE A MYSQL QUERY TO UPDATE YOUR STATS!");
|
||||
}
|
||||
}
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
//Archery Nerf
|
||||
if(player.getItemInHand().getTypeId() == 261 && mcLoadProperties.archeryFireRateLimit){
|
||||
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit){
|
||||
if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){
|
||||
/*
|
||||
if(mcm.hasArrows(player))
|
||||
mcm.addArrows(player);
|
||||
if(m.hasArrows(player))
|
||||
m.addArrows(player);
|
||||
*/
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
@ -112,22 +118,22 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
if(block != null && player != null && mcPermissions.getInstance().repair(player) && event.getClickedBlock().getTypeId() == 42){
|
||||
mcRepair.repairCheck(player, is, event.getClickedBlock());
|
||||
Repair.repairCheck(player, is, event.getClickedBlock());
|
||||
}
|
||||
|
||||
if(mcm.abilityBlockCheck(block))
|
||||
if(m.abilityBlockCheck(block))
|
||||
{
|
||||
if(block != null && mcm.isHoe(player.getItemInHand()) && block.getTypeId() != 3 && block.getTypeId() != 2 && block.getTypeId() != 60){
|
||||
mcSkills.hoeReadinessCheck(player);
|
||||
if(block != null && m.isHoe(player.getItemInHand()) && block.getTypeId() != 3 && block.getTypeId() != 2 && block.getTypeId() != 60){
|
||||
Skills.hoeReadinessCheck(player);
|
||||
}
|
||||
mcSkills.abilityActivationCheck(player);
|
||||
Skills.abilityActivationCheck(player);
|
||||
}
|
||||
|
||||
//GREEN THUMB
|
||||
if(block != null && (block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT) && player.getItemInHand().getType() == Material.SEEDS){
|
||||
boolean pass = false;
|
||||
if(mcHerbalism.hasSeeds(player)){
|
||||
mcHerbalism.removeSeeds(player);
|
||||
if(Herbalism.hasSeeds(player)){
|
||||
Herbalism.removeSeeds(player);
|
||||
if(block.getType() == Material.COBBLESTONE && Math.random() * 1500 <= PP.getHerbalismInt()){
|
||||
player.sendMessage(ChatColor.GREEN+"**GREEN THUMB**");
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
@ -145,35 +151,35 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
if(action == Action.RIGHT_CLICK_AIR){
|
||||
mcSkills.hoeReadinessCheck(player);
|
||||
mcSkills.abilityActivationCheck(player);
|
||||
Skills.hoeReadinessCheck(player);
|
||||
Skills.abilityActivationCheck(player);
|
||||
|
||||
/*
|
||||
* HERBALISM MODIFIERS
|
||||
*/
|
||||
if(mcPermissions.getInstance().herbalism(player)){
|
||||
mcHerbalism.breadCheck(player, player.getItemInHand());
|
||||
mcHerbalism.stewCheck(player, player.getItemInHand());
|
||||
Herbalism.breadCheck(player, player.getItemInHand());
|
||||
Herbalism.stewCheck(player, player.getItemInHand());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* ITEM CHECKS
|
||||
*/
|
||||
if(action == Action.RIGHT_CLICK_AIR)
|
||||
mcItem.itemChecks(player, plugin);
|
||||
Item.itehecks(player, plugin);
|
||||
if(action == Action.RIGHT_CLICK_BLOCK){
|
||||
if(mcm.abilityBlockCheck(event.getClickedBlock()))
|
||||
mcItem.itemChecks(player, plugin);
|
||||
if(m.abilityBlockCheck(event.getClickedBlock()))
|
||||
Item.itehecks(player, plugin);
|
||||
}
|
||||
}
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
String[] split = event.getMessage().split(" ");
|
||||
String playerName = player.getName();
|
||||
//Check if the command is an mcMMO related help command
|
||||
mcm.mcmmoHelpCheck(split, player, event);
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcability)){
|
||||
//Check if the command is an MMO related help command
|
||||
m.mmoHelpCheck(split, player, event);
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+LoadProperties.mcability)){
|
||||
event.setCancelled(true);
|
||||
if(PP.getAbilityUse()){
|
||||
player.sendMessage("Ability use toggled off");
|
||||
@ -187,17 +193,17 @@ public class mcPlayerListener extends PlayerListener {
|
||||
* LEADER BOARD COMMAND
|
||||
*/
|
||||
|
||||
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.mctop)){
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.mctop)){
|
||||
event.setCancelled(true);
|
||||
//Format: /mctop <skillname> <pagenumber>
|
||||
//Format: /top <skillname> <pagenumber>
|
||||
|
||||
/*
|
||||
* POWER LEVEL INFO RETRIEVAL
|
||||
*/
|
||||
if(split.length == 1){
|
||||
int p = 1;
|
||||
String[] info = mcLeaderboard.retrieveInfo("powerlevel", p);
|
||||
player.sendMessage(ChatColor.YELLOW+"--mcMMO"+ChatColor.BLUE+" Power Level "+ChatColor.YELLOW+"Leaderboard--");
|
||||
String[] info = Leaderboard.retrieveInfo("powerlevel", p);
|
||||
player.sendMessage(ChatColor.YELLOW+"--MMO"+ChatColor.BLUE+" Power Level "+ChatColor.YELLOW+"Leaderboard--");
|
||||
int n = 1 * p; //Position
|
||||
for(String x : info){
|
||||
if(x != null){
|
||||
@ -211,11 +217,11 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(split.length >= 2 && mcLeaderboard.isInt(split[1])){
|
||||
if(split.length >= 2 && Leaderboard.isInt(split[1])){
|
||||
int p = 1;
|
||||
//Grab page value if specified
|
||||
if(split.length >= 2){
|
||||
if(mcLeaderboard.isInt(split[1])){
|
||||
if(Leaderboard.isInt(split[1])){
|
||||
p = Integer.valueOf(split[1]);
|
||||
}
|
||||
}
|
||||
@ -225,8 +231,8 @@ public class mcPlayerListener extends PlayerListener {
|
||||
pt += (pt * 10);
|
||||
pt = 10;
|
||||
}
|
||||
String[] info = mcLeaderboard.retrieveInfo("powerlevel", p);
|
||||
player.sendMessage("--mcMMO Power Level Leaderboard--");
|
||||
String[] info = Leaderboard.retrieveInfo("powerlevel", p);
|
||||
player.sendMessage("--MMO Power Level Leaderboard--");
|
||||
int n = 1 * pt; //Position
|
||||
for(String x : info){
|
||||
if(x != null){
|
||||
@ -243,11 +249,11 @@ public class mcPlayerListener extends PlayerListener {
|
||||
/*
|
||||
* SKILL SPECIFIED INFO RETRIEVAL
|
||||
*/
|
||||
if(split.length >= 2 && mcSkills.isSkill(split[1])){
|
||||
if(split.length >= 2 && Skills.isSkill(split[1])){
|
||||
int p = 1;
|
||||
//Grab page value if specified
|
||||
if(split.length >= 3){
|
||||
if(mcLeaderboard.isInt(split[2])){
|
||||
if(Leaderboard.isInt(split[2])){
|
||||
p = Integer.valueOf(split[2]);
|
||||
}
|
||||
}
|
||||
@ -261,8 +267,8 @@ public class mcPlayerListener extends PlayerListener {
|
||||
String remainder = split[1].substring(1); // Get remainder of word.
|
||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||
|
||||
String[] info = mcLeaderboard.retrieveInfo(split[1].toLowerCase(), p);
|
||||
player.sendMessage(ChatColor.YELLOW+"--mcMMO "+ChatColor.BLUE+capitalized+ChatColor.YELLOW+" Leaderboard--");
|
||||
String[] info = Leaderboard.retrieveInfo(split[1].toLowerCase(), p);
|
||||
player.sendMessage(ChatColor.YELLOW+"--MMO "+ChatColor.BLUE+capitalized+ChatColor.YELLOW+" Leaderboard--");
|
||||
int n = 1 * pt; //Position
|
||||
for(String x : info){
|
||||
if(x != null){
|
||||
@ -289,10 +295,10 @@ public class mcPlayerListener extends PlayerListener {
|
||||
PP.togglePartyChatOnly();
|
||||
}
|
||||
*/
|
||||
if(mcPermissions.getInstance().mcAbility(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcrefresh)){
|
||||
if(mcPermissions.getInstance().mcAbility(player) && split[0].equalsIgnoreCase("/"+LoadProperties.mcrefresh)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().mcrefresh(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(split.length >= 2 && isPlayer(split[1])){
|
||||
@ -342,27 +348,27 @@ public class mcPlayerListener extends PlayerListener {
|
||||
|
||||
player.sendMessage(ChatColor.GREEN+"**ABILITIES REFRESHED!**");
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.mcitem)){
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcitem)){
|
||||
|
||||
}
|
||||
/*
|
||||
* GODMODE COMMAND
|
||||
*/
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mcgod)){
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+LoadProperties.mcgod)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().mcgod(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(mcConfig.getInstance().isGodModeToggled(playerName)){
|
||||
player.sendMessage(ChatColor.YELLOW+"mcMMO Godmode Disabled");
|
||||
mcConfig.getInstance().toggleGodMode(playerName);
|
||||
if(Config.getInstance().isGodModeToggled(playerName)){
|
||||
player.sendMessage(ChatColor.YELLOW+"MMO Godmode Disabled");
|
||||
Config.getInstance().toggleGodMode(playerName);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW+"mcMMO Godmode Enabled");
|
||||
mcConfig.getInstance().toggleGodMode(playerName);
|
||||
player.sendMessage(ChatColor.YELLOW+"MMO Godmode Enabled");
|
||||
Config.getInstance().toggleGodMode(playerName);
|
||||
}
|
||||
}
|
||||
if(mcPermissions.getInstance().mySpawn(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.clearmyspawn)){
|
||||
if(mcPermissions.getInstance().mySpawn(player) && split[0].equalsIgnoreCase("/"+LoadProperties.clearmyspawn)){
|
||||
event.setCancelled(true);
|
||||
double x = plugin.getServer().getWorlds().get(0).getSpawnLocation().getX();
|
||||
double y = plugin.getServer().getWorlds().get(0).getSpawnLocation().getY();
|
||||
@ -371,73 +377,73 @@ public class mcPlayerListener extends PlayerListener {
|
||||
PP.setMySpawn(x, y, z, worldname);
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Myspawn is now cleared.");
|
||||
}
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.mmoedit)){
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+LoadProperties.mmoedit)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().mmoedit(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(split.length < 3){
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.mmoedit+" playername skillname newvalue");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.mmoedit+" playername skillname newvalue");
|
||||
return;
|
||||
}
|
||||
if(split.length == 4){
|
||||
if(isPlayer(split[1]) && mcm.isInt(split[3]) && mcSkills.isSkill(split[2])){
|
||||
if(isPlayer(split[1]) && m.isInt(split[3]) && Skills.isSkill(split[2])){
|
||||
int newvalue = Integer.valueOf(split[3]);
|
||||
mcUsers.getProfile(getPlayer(split[1])).modifyskill(newvalue, split[2]);
|
||||
Users.getProfile(getPlayer(split[1])).modifyskill(newvalue, split[2]);
|
||||
player.sendMessage(ChatColor.RED+split[2]+" has been modified.");
|
||||
}
|
||||
}
|
||||
else if(split.length == 3){
|
||||
if(mcm.isInt(split[2]) && mcSkills.isSkill(split[1])){
|
||||
if(m.isInt(split[2]) && Skills.isSkill(split[1])){
|
||||
int newvalue = Integer.valueOf(split[2]);
|
||||
PP.modifyskill(newvalue, split[1]);
|
||||
player.sendMessage(ChatColor.RED+split[1]+" has been modified.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.mmoedit+" playername skillname newvalue");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.mmoedit+" playername skillname newvalue");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* ADD EXPERIENCE COMMAND
|
||||
*/
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+mcLoadProperties.addxp)){
|
||||
if(mcPermissions.permissionsEnabled && split[0].equalsIgnoreCase("/"+LoadProperties.addxp)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().mmoedit(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(split.length < 3){
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.addxp+" playername skillname xp");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
||||
return;
|
||||
}
|
||||
if(split.length == 4){
|
||||
if(isPlayer(split[1]) && mcm.isInt(split[3]) && mcSkills.isSkill(split[2])){
|
||||
if(isPlayer(split[1]) && m.isInt(split[3]) && Skills.isSkill(split[2])){
|
||||
int newvalue = Integer.valueOf(split[3]);
|
||||
mcUsers.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2]);
|
||||
Users.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2]);
|
||||
getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!");
|
||||
player.sendMessage(ChatColor.RED+split[2]+" has been modified.");
|
||||
}
|
||||
}
|
||||
else if(split.length == 3){
|
||||
if(mcm.isInt(split[2]) && mcSkills.isSkill(split[1])){
|
||||
if(m.isInt(split[2]) && Skills.isSkill(split[1])){
|
||||
int newvalue = Integer.valueOf(split[2]);
|
||||
PP.addXpToSkill(newvalue, split[1]);
|
||||
player.sendMessage(ChatColor.RED+split[1]+" has been modified.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.addxp+" playername skillname xp");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
||||
}
|
||||
}
|
||||
|
||||
if(PP.inParty() && split[0].equalsIgnoreCase("/"+mcLoadProperties.ptp)){
|
||||
if(PP.inParty() && split[0].equalsIgnoreCase("/"+LoadProperties.ptp)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().partyTeleport(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(split.length < 2){
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.ptp+" <playername>");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.ptp+" <playername>");
|
||||
return;
|
||||
}
|
||||
if(!isPlayer(split[1])){
|
||||
@ -445,7 +451,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
if(isPlayer(split[1])){
|
||||
Player target = getPlayer(split[1]);
|
||||
PlayerProfile PPt = mcUsers.getProfile(target);
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
if(PP.getParty().equals(PPt.getParty())){
|
||||
player.teleportTo(target);
|
||||
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
|
||||
@ -456,16 +462,16 @@ public class mcPlayerListener extends PlayerListener {
|
||||
/*
|
||||
* WHOIS COMMAND
|
||||
*/
|
||||
if((player.isOp() || mcPermissions.getInstance().whois(player)) && split[0].equalsIgnoreCase("/"+mcLoadProperties.whois)){
|
||||
if((player.isOp() || mcPermissions.getInstance().whois(player)) && split[0].equalsIgnoreCase("/"+LoadProperties.whois)){
|
||||
event.setCancelled(true);
|
||||
if(split.length < 2){
|
||||
player.sendMessage(ChatColor.RED + "Proper usage is /"+mcLoadProperties.whois+" <playername>");
|
||||
player.sendMessage(ChatColor.RED + "Proper usage is /"+LoadProperties.whois+" <playername>");
|
||||
return;
|
||||
}
|
||||
//if split[1] is a player
|
||||
if(isPlayer(split[1])){
|
||||
Player target = getPlayer(split[1]);
|
||||
PlayerProfile PPt = mcUsers.getProfile(target);
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
double x,y,z;
|
||||
x = target.getLocation().getX();
|
||||
y = target.getLocation().getY();
|
||||
@ -476,7 +482,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
player.sendMessage("Party: "+PPt.getParty());
|
||||
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
|
||||
player.sendMessage("OP: " + target.isOp());
|
||||
player.sendMessage(ChatColor.GREEN+"mcMMO Stats for "+ChatColor.YELLOW+target.getName());
|
||||
player.sendMessage(ChatColor.GREEN+"MMO Stats for "+ChatColor.YELLOW+target.getName());
|
||||
if(mcPermissions.getInstance().taming(target))
|
||||
player.sendMessage(ChatColor.YELLOW + "Taming Skill: " + ChatColor.GREEN + PPt.getTaming()+ChatColor.DARK_AQUA
|
||||
+ " XP("+PPt.getTamingXP()
|
||||
@ -521,7 +527,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + PPt.getAcrobatics()+ChatColor.DARK_AQUA
|
||||
+ " XP("+PPt.getAcrobaticsXP()
|
||||
+"/"+PPt.getXpToLevel("acrobatics")+")");
|
||||
player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getPowerLevel(target)));
|
||||
player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(m.getPowerLevel(target)));
|
||||
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
|
||||
player.sendMessage("X: "+x);
|
||||
player.sendMessage("Y: "+y);
|
||||
@ -531,9 +537,9 @@ public class mcPlayerListener extends PlayerListener {
|
||||
/*
|
||||
* STATS COMMAND
|
||||
*/
|
||||
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.stats)){
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.stats)){
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.GREEN + "Your mcMMO Stats");
|
||||
player.sendMessage(ChatColor.GREEN + "Your MMO Stats");
|
||||
if(mcPermissions.getInstance().permissionsEnabled)
|
||||
player.sendMessage(ChatColor.DARK_GRAY+"If you don't have access to a skill it will not be shown here.");
|
||||
|
||||
@ -581,51 +587,51 @@ public class mcPlayerListener extends PlayerListener {
|
||||
player.sendMessage(ChatColor.YELLOW + "Acrobatics Skill: " + ChatColor.GREEN + PP.getAcrobatics()+ChatColor.DARK_AQUA
|
||||
+ " XP("+PP.getAcrobaticsXP()
|
||||
+"/"+PP.getXpToLevel("acrobatics")+")");
|
||||
player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(mcm.getPowerLevel(player)));
|
||||
player.sendMessage(ChatColor.DARK_RED+"POWER LEVEL: "+ChatColor.GREEN+(m.getPowerLevel(player)));
|
||||
}
|
||||
//Invite Command
|
||||
if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.invite)){
|
||||
if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+LoadProperties.invite)){
|
||||
event.setCancelled(true);
|
||||
if(!PP.inParty()){
|
||||
player.sendMessage(ChatColor.RED+"You are not in a party.");
|
||||
return;
|
||||
}
|
||||
if(split.length < 2){
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+mcLoadProperties.invite+" <playername>");
|
||||
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.invite+" <playername>");
|
||||
return;
|
||||
}
|
||||
if(PP.inParty() && split.length >= 2 && isPlayer(split[1])){
|
||||
Player target = getPlayer(split[1]);
|
||||
PlayerProfile PPt = mcUsers.getProfile(target);
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
PPt.modifyInvite(PP.getParty());
|
||||
player.sendMessage(ChatColor.GREEN+"Invite sent successfully");
|
||||
target.sendMessage(ChatColor.RED+"ALERT: "+ChatColor.GREEN+"You have received a party invite for "+PPt.getInvite()+" from "+player.getName());
|
||||
target.sendMessage(ChatColor.YELLOW+"Type "+ChatColor.GREEN+"/"+mcLoadProperties.accept+ChatColor.YELLOW+" to accept the invite");
|
||||
target.sendMessage(ChatColor.YELLOW+"Type "+ChatColor.GREEN+"/"+LoadProperties.accept+ChatColor.YELLOW+" to accept the invite");
|
||||
}
|
||||
}
|
||||
//Accept invite
|
||||
if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+mcLoadProperties.accept)){
|
||||
if(mcPermissions.getInstance().party(player) && split[0].equalsIgnoreCase("/"+LoadProperties.accept)){
|
||||
event.setCancelled(true);
|
||||
if(PP.hasPartyInvite()){
|
||||
if(PP.inParty()){
|
||||
mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
Party.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
}
|
||||
PP.acceptInvite();
|
||||
mcParty.getInstance().informPartyMembers(player, getPlayersOnline());
|
||||
Party.getInstance().informPartyMembers(player, getPlayersOnline());
|
||||
player.sendMessage(ChatColor.GREEN+"Invite accepted. You have joined party ("+PP.getParty()+")");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"You have no invites at this time");
|
||||
}
|
||||
}
|
||||
//Party command
|
||||
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.party)){
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.party)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().party(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(split.length == 1 && !PP.inParty()){
|
||||
player.sendMessage("Proper usage is "+"/"+mcLoadProperties.party+" <name> or 'q' to quit");
|
||||
player.sendMessage("Proper usage is "+"/"+LoadProperties.party+" <name> or 'q' to quit");
|
||||
return;
|
||||
}
|
||||
if(split.length == 1 && PP.inParty()){
|
||||
@ -633,12 +639,12 @@ public class mcPlayerListener extends PlayerListener {
|
||||
int x = 0;
|
||||
for(Player p : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(PP.getParty().equals(mcUsers.getProfile(p).getParty())){
|
||||
if(p != null && x+1 >= mcParty.getInstance().partyCount(player, getPlayersOnline())){
|
||||
if(PP.getParty().equals(Users.getProfile(p).getParty())){
|
||||
if(p != null && x+1 >= Party.getInstance().partyCount(player, getPlayersOnline())){
|
||||
tempList+= p.getName();
|
||||
x++;
|
||||
}
|
||||
if(p != null && x < mcParty.getInstance().partyCount(player, getPlayersOnline())){
|
||||
if(p != null && x < Party.getInstance().partyCount(player, getPlayersOnline())){
|
||||
tempList+= p.getName() +", ";
|
||||
x++;
|
||||
}
|
||||
@ -648,29 +654,29 @@ public class mcPlayerListener extends PlayerListener {
|
||||
player.sendMessage(ChatColor.GREEN + "Party Members ("+ChatColor.WHITE+tempList+ChatColor.GREEN+")");
|
||||
}
|
||||
if(split.length > 1 && split[1].equals("q") && PP.inParty()){
|
||||
mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
Party.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
PP.removeParty();
|
||||
player.sendMessage(ChatColor.RED + "You have left that party");
|
||||
return;
|
||||
}
|
||||
if(split.length >= 2){
|
||||
if(PP.inParty())
|
||||
mcParty.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
Party.getInstance().informPartyMembersQuit(player, getPlayersOnline());
|
||||
PP.setParty(split[1]);
|
||||
player.sendMessage("Joined Party: " + split[1]);
|
||||
mcParty.getInstance().informPartyMembers(player, getPlayersOnline());
|
||||
Party.getInstance().informPartyMembers(player, getPlayersOnline());
|
||||
}
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/p")){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().party(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(mcConfig.getInstance().isAdminToggled(player.getName()))
|
||||
mcConfig.getInstance().toggleAdminChat(playerName);
|
||||
mcConfig.getInstance().togglePartyChat(playerName);
|
||||
if(mcConfig.getInstance().isPartyToggled(playerName)){
|
||||
if(Config.getInstance().isAdminToggled(player.getName()))
|
||||
Config.getInstance().toggleAdminChat(playerName);
|
||||
Config.getInstance().togglePartyChat(playerName);
|
||||
if(Config.getInstance().isPartyToggled(playerName)){
|
||||
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
|
||||
@ -678,14 +684,14 @@ public class mcPlayerListener extends PlayerListener {
|
||||
}
|
||||
if(split[0].equalsIgnoreCase("/a") && (player.isOp() || mcPermissions.getInstance().adminChat(player))){
|
||||
if(!mcPermissions.getInstance().adminChat(player) && !player.isOp()){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
if(mcConfig.getInstance().isPartyToggled(player.getName()))
|
||||
mcConfig.getInstance().togglePartyChat(playerName);
|
||||
mcConfig.getInstance().toggleAdminChat(playerName);
|
||||
if(mcConfig.getInstance().isAdminToggled(playerName)){
|
||||
if(Config.getInstance().isPartyToggled(player.getName()))
|
||||
Config.getInstance().togglePartyChat(playerName);
|
||||
Config.getInstance().toggleAdminChat(playerName);
|
||||
if(Config.getInstance().isAdminToggled(playerName)){
|
||||
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
|
||||
@ -694,10 +700,10 @@ public class mcPlayerListener extends PlayerListener {
|
||||
/*
|
||||
* MYSPAWN
|
||||
*/
|
||||
if(split[0].equalsIgnoreCase("/"+mcLoadProperties.myspawn)){
|
||||
if(split[0].equalsIgnoreCase("/"+LoadProperties.myspawn)){
|
||||
event.setCancelled(true);
|
||||
if(!mcPermissions.getInstance().mySpawn(player)){
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO]"+ChatColor.DARK_RED +" Insufficient permissions.");
|
||||
player.sendMessage(ChatColor.YELLOW+"[MMO]"+ChatColor.DARK_RED +" Insufficient mcPermissions.");
|
||||
return;
|
||||
}
|
||||
if(System.currentTimeMillis() < PP.getMySpawnATS() + 3600000){
|
||||
@ -719,20 +725,20 @@ public class mcPlayerListener extends PlayerListener {
|
||||
if(PP.getMySpawn(player) != null){
|
||||
player.setHealth(20);
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
//player.sendMessage("mcMMO DEBUG CODE 1");
|
||||
//player.sendMessage("MMO DEBUG CODE 1");
|
||||
if(PP.getMySpawnWorld(plugin) != null && !PP.getMySpawnWorld(plugin).equals("")){
|
||||
mySpawn.setWorld(plugin.getServer().getWorld(PP.getMySpawnWorld(plugin)));
|
||||
//player.sendMessage("mcMMO DEBUG CODE 2");
|
||||
//player.sendMessage("MMO DEBUG CODE 2");
|
||||
} else {
|
||||
//player.sendMessage("mcMMO DEBUG CODE 5");
|
||||
//player.sendMessage("MMO DEBUG CODE 5");
|
||||
mySpawn.setWorld(plugin.getServer().getWorlds().get(0));
|
||||
}
|
||||
//player.sendMessage("mcMMO DEBUG CODE 3");
|
||||
//player.sendMessage("MMO DEBUG CODE 3");
|
||||
player.teleportTo(mySpawn); //It's done twice because teleporting from one world to another is weird
|
||||
player.teleportTo(mySpawn);
|
||||
//Two lines of teleporting to prevent a bug when players try teleporting from one world to another bringing them to that worlds spawn at first.
|
||||
//player.sendMessage("mcMMO DEBUG CODE 4");
|
||||
if(mcLoadProperties.myspawnclearsinventory)
|
||||
//player.sendMessage("MMO DEBUG CODE 4");
|
||||
if(LoadProperties.myspawnclearsinventory)
|
||||
player.sendMessage("Traveled to your MySpawn");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"Configure your myspawn first with a bed.");
|
||||
@ -743,22 +749,22 @@ public class mcPlayerListener extends PlayerListener {
|
||||
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
String x = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") ";
|
||||
String y = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} ";
|
||||
if(mcConfig.getInstance().isPartyToggled(player.getName())){
|
||||
if(Config.getInstance().isPartyToggled(player.getName())){
|
||||
event.setCancelled(true);
|
||||
log.log(Level.INFO, "[P]("+PP.getParty()+")"+"<"+player.getName()+"> "+event.getMessage());
|
||||
for(Player herp : plugin.getServer().getOnlinePlayers()){
|
||||
if(mcUsers.getProfile(herp).inParty()){
|
||||
if(mcParty.getInstance().inSameParty(herp, player)){
|
||||
if(Users.getProfile(herp).inParty()){
|
||||
if(Party.getInstance().inSameParty(herp, player)){
|
||||
herp.sendMessage(x+event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if((player.isOp() || mcPermissions.getInstance().adminChat(player)) && mcConfig.getInstance().isAdminToggled(player.getName())){
|
||||
if((player.isOp() || mcPermissions.getInstance().adminChat(player)) && Config.getInstance().isAdminToggled(player.getName())){
|
||||
log.log(Level.INFO, "[A]"+"<"+player.getName()+"> "+event.getMessage());
|
||||
event.setCancelled(true);
|
||||
for(Player herp : plugin.getServer().getOnlinePlayers()){
|
||||
@ -771,7 +777,7 @@ public class mcPlayerListener extends PlayerListener {
|
||||
/*
|
||||
* Remove from normal chat if toggled
|
||||
for(Player z : event.getRecipients()){
|
||||
if(mcUsers.getProfile(z.getName()).getPartyChatOnlyToggle() == true)
|
||||
if(Users.getProfile(z.getName()).getPartyChatOnlyToggle() == true)
|
||||
event.getRecipients().remove(z);
|
||||
}
|
||||
*/
|
||||
|
@ -6,6 +6,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Swords;
|
||||
|
||||
|
||||
public class mcTimer extends TimerTask{
|
||||
@ -19,19 +21,19 @@ public class mcTimer extends TimerTask{
|
||||
public void run() {
|
||||
Player[] playerlist = plugin.getServer().getOnlinePlayers();
|
||||
for(Player player : playerlist){
|
||||
PlayerProfile PP = mcUsers.getProfile(player);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player == null)
|
||||
continue;
|
||||
if(PP == null)
|
||||
mcUsers.addUser(player);
|
||||
Users.addUser(player);
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
mcSkills.monitorSkills(player);
|
||||
Skills.monitorSkills(player);
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
mcSkills.watchCooldowns(player);
|
||||
Skills.watchCooldowns(player);
|
||||
|
||||
/*
|
||||
* PLAYER BLEED MONITORING
|
||||
@ -45,23 +47,23 @@ public class mcTimer extends TimerTask{
|
||||
if(thecount == 10 || thecount == 20 || thecount == 30 || thecount == 40){
|
||||
if(player != null &&
|
||||
player.getHealth() > 0 && player.getHealth() < 20
|
||||
&& mcm.getPowerLevel(player) >= 1000){
|
||||
player.setHealth(mcm.calculateHealth(player.getHealth(), 1));
|
||||
&& m.getPowerLevel(player) >= 1000){
|
||||
player.setHealth(m.calculateHealth(player.getHealth(), 1));
|
||||
}
|
||||
}
|
||||
if(thecount == 20 || thecount == 40){
|
||||
if(player != null &&
|
||||
player.getHealth() > 0 && player.getHealth() < 20
|
||||
&& mcm.getPowerLevel(player) >= 500
|
||||
&& mcm.getPowerLevel(player) < 1000){
|
||||
player.setHealth(mcm.calculateHealth(player.getHealth(), 1));
|
||||
&& m.getPowerLevel(player) >= 500
|
||||
&& m.getPowerLevel(player) < 1000){
|
||||
player.setHealth(m.calculateHealth(player.getHealth(), 1));
|
||||
}
|
||||
}
|
||||
if(thecount == 40){
|
||||
if(player != null &&
|
||||
player.getHealth() > 0 && player.getHealth() < 20
|
||||
&& mcm.getPowerLevel(player) < 500){
|
||||
player.setHealth(mcm.calculateHealth(player.getHealth(), 1));
|
||||
&& m.getPowerLevel(player) < 500){
|
||||
player.setHealth(m.calculateHealth(player.getHealth(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +73,7 @@ public class mcTimer extends TimerTask{
|
||||
* NON-PLAYER BLEED MONITORING
|
||||
*/
|
||||
if(thecount % 2 == 0)
|
||||
mcCombat.bleedSimulate();
|
||||
Swords.bleedSimulate();
|
||||
|
||||
if(thecount < 40){
|
||||
thecount++;
|
||||
|
71
mcMMO/com/gmail/nossr50/party/Party.java
Normal file
71
mcMMO/com/gmail/nossr50/party/Party.java
Normal file
@ -0,0 +1,71 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
|
||||
public class Party {
|
||||
private static mcMMO plugin;
|
||||
public Party(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
private static volatile Party instance;
|
||||
public static Party getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Party(plugin);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public boolean inSameParty(Player playera, Player playerb){
|
||||
if(Users.getProfile(playera) == null || Users.getProfile(playerb) == null){
|
||||
Users.addUser(playera);
|
||||
Users.addUser(playerb);
|
||||
}
|
||||
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()){
|
||||
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int partyCount(Player player, Player[] players){
|
||||
int x = 0;
|
||||
for(Player hurrdurr : players){
|
||||
if(player != null && hurrdurr != null){
|
||||
if(Users.getProfile(player).getParty().equals(Users.getProfile(hurrdurr).getParty()))
|
||||
x++;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
public void informPartyMembers(Player player, Player[] players){
|
||||
int x = 0;
|
||||
for(Player p : players){
|
||||
if(player != null && p != null){
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void informPartyMembersQuit(Player player, Player[] players){
|
||||
int x = 0;
|
||||
for(Player p : players){
|
||||
if(player != null && p != null){
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
|
||||
p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
84
mcMMO/com/gmail/nossr50/skills/Acrobatics.java
Normal file
84
mcMMO/com/gmail/nossr50/skills/Acrobatics.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Acrobatics {
|
||||
public static void acrobaticsCheck(Player player, EntityDamageEvent event){
|
||||
if(player != null && mcPermissions.getInstance().acrobatics(player)){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int acrovar = PP.getAcrobaticsInt();
|
||||
if(player.isSneaking())
|
||||
acrovar = acrovar * 2;
|
||||
if(Math.random() * 1000 <= acrovar && !event.isCancelled()){
|
||||
int threshold = 7;
|
||||
if(player.isSneaking())
|
||||
threshold = 14;
|
||||
int newDamage = event.getDamage() - threshold;
|
||||
if(newDamage < 0)
|
||||
newDamage = 0;
|
||||
/*
|
||||
* Check for death
|
||||
*/
|
||||
if(player.getHealth() - newDamage >= 1){
|
||||
if(!event.isCancelled())
|
||||
PP.addAcrobaticsXP((event.getDamage() * 8) * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(player);
|
||||
event.setDamage(newDamage);
|
||||
if(event.getDamage() <= 0)
|
||||
event.setCancelled(true);
|
||||
if(player.isSneaking()){
|
||||
player.sendMessage(ChatColor.GREEN+"**GRACEFUL ROLL**");
|
||||
} else {
|
||||
player.sendMessage("**ROLL**");
|
||||
}
|
||||
}
|
||||
} else if (!event.isCancelled()){
|
||||
if(player.getHealth() - event.getDamage() >= 1){
|
||||
PP.addAcrobaticsXP((event.getDamage() * 12) * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void dodgeChecks(EntityDamageByEntityEvent event){
|
||||
Player defender = (Player) event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if(mcPermissions.getInstance().acrobatics(defender)){
|
||||
if(PPd.getAcrobaticsInt() <= 800){
|
||||
if(Math.random() * 4000 <= PPd.getAcrobaticsInt()){
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addAcrobaticsXP(event.getDamage() * 12);
|
||||
Skills.XpCheck(defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to do minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
} else if(Math.random() * 4000 <= 800) {
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addAcrobaticsXP(event.getDamage() * 12);
|
||||
Skills.XpCheck(defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to deal minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
mcMMO/com/gmail/nossr50/skills/Archery.java
Normal file
5
mcMMO/com/gmail/nossr50/skills/Archery.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
public class Archery {
|
||||
|
||||
}
|
47
mcMMO/com/gmail/nossr50/skills/Axes.java
Normal file
47
mcMMO/com/gmail/nossr50/skills/Axes.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class Axes {
|
||||
public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event){
|
||||
int targets = 0;
|
||||
Entity x = event.getEntity();
|
||||
targets = m.getTier(attacker);
|
||||
for(Entity derp : x.getWorld().getEntities()){
|
||||
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5){
|
||||
if(derp instanceof Player){
|
||||
Player target = (Player)derp;
|
||||
if(Party.getInstance().inSameParty(attacker, target))
|
||||
continue;
|
||||
if(!target.getName().equals(attacker.getName()) && targets >= 1){
|
||||
target.damage(event.getDamage() / 2);
|
||||
target.sendMessage(ChatColor.DARK_RED+"Struck by CLEAVE!");
|
||||
targets--;
|
||||
}
|
||||
}
|
||||
if(derp instanceof Monster && targets >= 1){
|
||||
Monster target = (Monster)derp;
|
||||
target.damage(event.getDamage() / 2);
|
||||
targets--;
|
||||
}
|
||||
if(derp instanceof Wolf){
|
||||
continue;
|
||||
}
|
||||
if(derp instanceof Animals && targets >= 1){
|
||||
Animals target = (Animals)derp;
|
||||
target.damage(event.getDamage() / 2);
|
||||
targets--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
207
mcMMO/com/gmail/nossr50/skills/Excavation.java
Normal file
207
mcMMO/com/gmail/nossr50/skills/Excavation.java
Normal file
@ -0,0 +1,207 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Excavation {
|
||||
private static mcMMO plugin;
|
||||
public Excavation(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
public static void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isShovel(player.getItemInHand())){
|
||||
if(block != null){
|
||||
if(!m.abilityBlockCheck(block))
|
||||
return;
|
||||
}
|
||||
if(PP.getShovelPreparationMode()){
|
||||
PP.setShovelPreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getExcavationInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerCooldown() == 0){
|
||||
player.sendMessage(ChatColor.GREEN+"**GIGA DRILL BREAKER ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Giga Drill Breaker!");
|
||||
}
|
||||
PP.setGigaDrillBreakerTicks(ticks * 1000);
|
||||
PP.setGigaDrillBreakerActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setGigaDrillBreakerMode(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static boolean canBeGigaDrillBroken(Block block){
|
||||
int i = block.getTypeId();
|
||||
if(i == 2||i == 3||i == 12||i == 13){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void excavationProcCheck(Block block, Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int type = block.getTypeId();
|
||||
Location loc = block.getLocation();
|
||||
ItemStack is = null;
|
||||
Material mat = null;
|
||||
if(block.getData() == (byte) 5){
|
||||
return;
|
||||
}
|
||||
if(type == 2){
|
||||
if(PP.getExcavationInt() > 250){
|
||||
//CHANCE TO GET EGGS
|
||||
if(LoadProperties.eggs == true && Math.random() * 100 > 99){
|
||||
PP.addExcavationXP(10 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(344);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
//CHANCE TO GET APPLES
|
||||
if(LoadProperties.apples == true && Math.random() * 100 > 99){
|
||||
PP.addExcavationXP(10 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(260);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
//DIRT SAND OR GRAVEL
|
||||
if(type == 3 || type == 13 || type == 2 || type == 12){
|
||||
PP.addExcavationXP(4 * LoadProperties.xpGainMultiplier);
|
||||
if(PP.getExcavationInt() > 750){
|
||||
//CHANCE TO GET CAKE
|
||||
if(LoadProperties.cake == true && Math.random() * 2000 > 1999){
|
||||
PP.addExcavationXP(300 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(354);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(PP.getExcavationInt() > 350){
|
||||
//CHANCE TO GET DIAMOND
|
||||
if(LoadProperties.diamond == true && Math.random() * 750 > 749){
|
||||
PP.addExcavationXP(100 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(264);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
if(PP.getExcavationInt() > 250){
|
||||
//CHANCE TO GET YELLOW MUSIC
|
||||
if(LoadProperties.music == true && Math.random() * 2000 > 1999){
|
||||
PP.addExcavationXP(300 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(2256);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
|
||||
}
|
||||
if(PP.getExcavationInt() > 350){
|
||||
//CHANCE TO GET GREEN MUSIC
|
||||
if(LoadProperties.music == true && Math.random() * 2000 > 1999){
|
||||
PP.addExcavationXP(300 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(2257);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
//SAND
|
||||
if(type == 12){
|
||||
//CHANCE TO GET GLOWSTONE
|
||||
if(LoadProperties.glowstone == true && PP.getExcavationInt() > 50 && Math.random() * 100 > 95){
|
||||
PP.addExcavationXP(8 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(348);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
//CHANCE TO GET SLOWSAND
|
||||
if(LoadProperties.slowsand == true && PP.getExcavationInt() > 650 && Math.random() * 200 > 199){
|
||||
PP.addExcavationXP(8 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(88);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
//GRASS OR DIRT
|
||||
if(type == 2 || type == 3){
|
||||
if(PP.getExcavationInt() > 50){
|
||||
//CHANCE FOR COCOA BEANS
|
||||
if(LoadProperties.eggs == true && Math.random() * 75 > 74){
|
||||
PP.addExcavationXP(10 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(351);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
is.setDurability((byte) 3); //COCOA
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
//CHANCE FOR SHROOMS
|
||||
if(LoadProperties.mushrooms == true && PP.getExcavationInt() > 500 && Math.random() * 200 > 199){
|
||||
PP.addExcavationXP(8 * LoadProperties.xpGainMultiplier);
|
||||
if(Math.random() * 10 > 5){
|
||||
mat = Material.getMaterial(39);
|
||||
} else {
|
||||
mat = Material.getMaterial(40);
|
||||
}
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
//CHANCE TO GET GLOWSTONE
|
||||
if(LoadProperties.glowstone == true && PP.getExcavationInt() > 25 && Math.random() * 100 > 95){
|
||||
PP.addExcavationXP(8 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(348);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
//GRAVEL
|
||||
if(type == 13){
|
||||
//CHANCE TO GET NETHERRACK
|
||||
if(LoadProperties.netherrack == true && PP.getExcavationInt() > 850 && Math.random() * 200 > 199){
|
||||
PP.addExcavationXP(3 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(87);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
//CHANCE TO GET SULPHUR
|
||||
if(LoadProperties.sulphur == true && PP.getExcavationInt() > 75){
|
||||
if(Math.random() * 10 > 9){
|
||||
PP.addExcavationXP(3 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(289);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
//CHANCE TO GET BONES
|
||||
if(LoadProperties.bones == true && PP.getExcavationInt() > 175){
|
||||
if(Math.random() * 10 > 9){
|
||||
PP.addExcavationXP(3 * LoadProperties.xpGainMultiplier);
|
||||
mat = Material.getMaterial(352);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
}
|
266
mcMMO/com/gmail/nossr50/skills/Herbalism.java
Normal file
266
mcMMO/com/gmail/nossr50/skills/Herbalism.java
Normal file
@ -0,0 +1,266 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Herbalism {
|
||||
private static mcMMO plugin;
|
||||
public Herbalism(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public static void greenTerraWheat(Player player, Block block, BlockBreakEvent event){
|
||||
if(block.getType() == Material.WHEAT && block.getData() == (byte) 0x07){
|
||||
event.setCancelled(true);
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Material mat = Material.getMaterial(296);
|
||||
Location loc = block.getLocation();
|
||||
ItemStack is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
PP.addHerbalismXP(5 * LoadProperties.xpGainMultiplier);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
herbalismProcCheck(block, player, event);
|
||||
herbalismProcCheck(block, player, event);
|
||||
block.setData((byte) 0x03);
|
||||
}
|
||||
}
|
||||
public static void greenTerra(Player player, Block block){
|
||||
if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT){
|
||||
if(!hasSeeds(player))
|
||||
player.sendMessage("You need more seeds to spread Green Terra");
|
||||
if(hasSeeds(player) && block.getType() != Material.WHEAT){
|
||||
removeSeeds(player);
|
||||
if(block.getType() == Material.DIRT)
|
||||
block.setType(Material.GRASS);
|
||||
if(block.getType() == Material.COBBLESTONE)
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Boolean canBeGreenTerra(Block block){
|
||||
int t = block.getTypeId();
|
||||
if(t == 4 || t == 3 || t == 59 || t == 81 || t == 83 || t == 91 || t == 86 || t == 39 || t == 46 || t == 37 || t == 38){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean hasSeeds(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 295){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static void removeSeeds(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 295){
|
||||
if(x.getAmount() == 1){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
} else{
|
||||
x.setAmount(x.getAmount() - 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void greenTerraCheck(Player player, Block block, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isHoe(player.getItemInHand())){
|
||||
if(block != null){
|
||||
if(!m.abilityBlockCheck(block))
|
||||
return;
|
||||
}
|
||||
if(PP.getHoePreparationMode()){
|
||||
PP.setHoePreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getHerbalismInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getGreenTerraMode() && Skills.cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown)){
|
||||
player.sendMessage(ChatColor.GREEN+"**GREEN TERRA ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Green Terra!");
|
||||
}
|
||||
PP.setGreenTerraTicks(ticks * 1000);
|
||||
PP.setGreenTerraActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setGreenTerraMode(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void herbalismProcCheck(Block block, Player player, BlockBreakEvent event){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int type = block.getTypeId();
|
||||
Location loc = block.getLocation();
|
||||
ItemStack is = null;
|
||||
Material mat = null;
|
||||
|
||||
if(Config.getInstance().isBlockWatched(block)){
|
||||
return;
|
||||
}
|
||||
if(type == 59 && block.getData() == (byte) 0x7){
|
||||
mat = Material.getMaterial(296);
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
PP.addHerbalismXP(5 * LoadProperties.xpGainMultiplier);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
//GREEN THUMB
|
||||
if(Math.random() * 1500 <= PP.getHerbalismInt()){
|
||||
event.setCancelled(true);
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
|
||||
block.setData((byte) 0x1); //Change it to first stage
|
||||
|
||||
//Setup the bonuses
|
||||
int bonus = 0;
|
||||
if(PP.getHerbalismInt() >= 200)
|
||||
bonus++;
|
||||
if(PP.getHerbalismInt() >= 400)
|
||||
bonus++;
|
||||
if(PP.getHerbalismInt() >= 600)
|
||||
bonus++;
|
||||
|
||||
//Change wheat to be whatever stage based on the bonus
|
||||
if(bonus == 1)
|
||||
block.setData((byte) 0x2);
|
||||
if(bonus == 2)
|
||||
block.setData((byte) 0x3);
|
||||
if(bonus == 3)
|
||||
block.setData((byte) 0x4);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We need to check not-wheat stuff for if it was placed by the player or not
|
||||
*/
|
||||
if(block.getData() != (byte) 5){
|
||||
//Cactus
|
||||
if(type == 81){
|
||||
mat = Material.getMaterial(block.getTypeId());
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
//Sugar Canes
|
||||
if(type == 83){
|
||||
is = new ItemStack(Material.SUGAR_CANE, 1, (byte)0, (byte)0);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
PP.addHerbalismXP(3 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
//Pumpkins
|
||||
if((type == 91 || type == 86) && !Config.getInstance().isBlockWatched(block)){
|
||||
mat = Material.getMaterial(block.getTypeId());
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
PP.addHerbalismXP(55 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
//Mushroom
|
||||
if(type == 39 || type == 40){
|
||||
mat = Material.getMaterial(block.getTypeId());
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
PP.addHerbalismXP(40 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
//Flower
|
||||
if(type == 37 || type == 38){
|
||||
mat = Material.getMaterial(block.getTypeId());
|
||||
is = new ItemStack(mat, 1, (byte)0, (byte)0);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getHerbalismInt()){
|
||||
loc.getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
PP.addHerbalismXP(10 * LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
}
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
public static void breadCheck(Player player, ItemStack is){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(is.getTypeId() == 297){
|
||||
if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){
|
||||
player.setHealth(player.getHealth() + 1);
|
||||
} else if (PP.getHerbalismInt() >= 150 && PP.getHerbalismInt() < 250){
|
||||
player.setHealth(player.getHealth() + 2);
|
||||
} else if (PP.getHerbalismInt() >= 250 && PP.getHerbalismInt() < 350){
|
||||
player.setHealth(player.getHealth() + 3);
|
||||
} else if (PP.getHerbalismInt() >= 350 && PP.getHerbalismInt() < 450){
|
||||
player.setHealth(player.getHealth() + 4);
|
||||
} else if (PP.getHerbalismInt() >= 450 && PP.getHerbalismInt() < 550){
|
||||
player.setHealth(player.getHealth() + 5);
|
||||
} else if (PP.getHerbalismInt() >= 550 && PP.getHerbalismInt() < 650){
|
||||
player.setHealth(player.getHealth() + 6);
|
||||
} else if (PP.getHerbalismInt() >= 650 && PP.getHerbalismInt() < 750){
|
||||
player.setHealth(player.getHealth() + 7);
|
||||
} else if (PP.getHerbalismInt() >= 750){
|
||||
player.setHealth(player.getHealth() + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void stewCheck(Player player, ItemStack is){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(is.getTypeId() == 282){
|
||||
if(PP.getHerbalismInt() >= 50 && PP.getHerbalismInt() < 150){
|
||||
player.setHealth(player.getHealth() + 1);
|
||||
} else if (PP.getHerbalismInt() >= 150 && PP.getHerbalismInt() < 250){
|
||||
player.setHealth(player.getHealth() + 2);
|
||||
} else if (PP.getHerbalismInt() >= 250 && PP.getHerbalismInt() < 350){
|
||||
player.setHealth(player.getHealth() + 3);
|
||||
} else if (PP.getHerbalismInt() >= 350 && PP.getHerbalismInt() < 450){
|
||||
player.setHealth(player.getHealth() + 4);
|
||||
} else if (PP.getHerbalismInt() >= 450 && PP.getHerbalismInt() < 550){
|
||||
player.setHealth(player.getHealth() + 5);
|
||||
} else if (PP.getHerbalismInt() >= 550 && PP.getHerbalismInt() < 650){
|
||||
player.setHealth(player.getHealth() + 6);
|
||||
} else if (PP.getHerbalismInt() >= 650 && PP.getHerbalismInt() < 750){
|
||||
player.setHealth(player.getHealth() + 7);
|
||||
} else if (PP.getHerbalismInt() >= 750){
|
||||
player.setHealth(player.getHealth() + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
322
mcMMO/com/gmail/nossr50/skills/Mining.java
Normal file
322
mcMMO/com/gmail/nossr50/skills/Mining.java
Normal file
@ -0,0 +1,322 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Mining {
|
||||
private static mcMMO plugin;
|
||||
public Mining(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public static void superBreakerCheck(Player player, Block block, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isMiningPick(player.getItemInHand())){
|
||||
if(block != null){
|
||||
if(!m.abilityBlockCheck(block))
|
||||
return;
|
||||
}
|
||||
if(PP.getPickaxePreparationMode()){
|
||||
PP.setPickaxePreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getMiningInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getSuperBreakerMode() && Skills.cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)){
|
||||
player.sendMessage(ChatColor.GREEN+"**SUPER BREAKER ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Super Breaker!");
|
||||
}
|
||||
PP.setSuperBreakerTicks(ticks * 1000);
|
||||
PP.setSuperBreakerActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setSuperBreakerMode(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void blockProcSimulate(Block block){
|
||||
Location loc = block.getLocation();
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
byte damage = 0;
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
if(block.getTypeId() == 89){
|
||||
mat = Material.getMaterial(348);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
if(block.getTypeId() == 73 || block.getTypeId() == 74){
|
||||
mat = Material.getMaterial(331);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
if(Math.random() * 10 > 5){
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
if(block.getTypeId() == 21){
|
||||
mat = Material.getMaterial(351);
|
||||
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
if(block.getTypeId() == 56){
|
||||
mat = Material.getMaterial(264);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
if(block.getTypeId() == 1){
|
||||
mat = Material.getMaterial(4);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
if(block.getTypeId() == 16){
|
||||
mat = Material.getMaterial(263);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
public static void blockProcCheck(Block block, Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getMiningInt()){
|
||||
blockProcSimulate(block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void miningBlockCheck(Player player, Block block){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(Config.getInstance().isBlockWatched(block) || block.getData() == (byte) 5)
|
||||
return;
|
||||
int xp = 0;
|
||||
if(block.getTypeId() == 1 || block.getTypeId() == 24){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//OBSIDIAN
|
||||
if(block.getTypeId() == 49){
|
||||
xp += 15;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//NETHERRACK
|
||||
if(block.getTypeId() == 87){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//GLOWSTONE
|
||||
if(block.getTypeId() == 89){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//COAL
|
||||
if(block.getTypeId() == 16){
|
||||
xp += 10;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//GOLD
|
||||
if(block.getTypeId() == 14){
|
||||
xp += 35;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//DIAMOND
|
||||
if(block.getTypeId() == 56){
|
||||
xp += 75;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//IRON
|
||||
if(block.getTypeId() == 15){
|
||||
xp += 25;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//REDSTONE
|
||||
if(block.getTypeId() == 73 || block.getTypeId() == 74){
|
||||
xp += 15;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
//LAPUS
|
||||
if(block.getTypeId() == 21){
|
||||
xp += 40;
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
PP.addMiningXP(xp * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
/*
|
||||
* Handling SuperBreaker stuff
|
||||
*/
|
||||
public static Boolean canBeSuperBroken(Block block){
|
||||
int t = block.getTypeId();
|
||||
if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void SuperBreakerBlockCheck(Player player, Block block){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
Location loc = block.getLocation();
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
int xp = 0;
|
||||
byte damage = 0;
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
if(block.getTypeId() == 1 || block.getTypeId() == 24){
|
||||
if(!Config.getInstance().isBlockWatched(block) && block.getData() != (byte) 5){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
if(block.getTypeId() == 1){
|
||||
mat = Material.COBBLESTONE;
|
||||
} else {
|
||||
mat = Material.SANDSTONE;
|
||||
}
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//NETHERRACK
|
||||
if(block.getTypeId() == 87){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(87);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//GLOWSTONE
|
||||
if(block.getTypeId() == 89){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 3;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(348);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//COAL
|
||||
if(block.getTypeId() == 16){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 10;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(263);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//GOLD
|
||||
if(block.getTypeId() == 14 && m.getTier(player) >= 3){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 35;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//OBSIDIAN
|
||||
if(block.getTypeId() == 49 && m.getTier(player) >= 4){
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) 104);
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 15;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(49);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//DIAMOND
|
||||
if(block.getTypeId() == 56 && m.getTier(player) >= 3){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 75;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(264);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//IRON
|
||||
if(block.getTypeId() == 15 && m.getTier(player) >= 2){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 25;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//REDSTONE
|
||||
if((block.getTypeId() == 73 || block.getTypeId() == 74) && m.getTier(player) >= 4){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 15;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(331);
|
||||
item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
if(Math.random() * 10 > 5){
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
//LAPUS
|
||||
if(block.getTypeId() == 21 && m.getTier(player) >= 3){
|
||||
if(!Config.getInstance().isBlockWatched(block)&& block.getData() != (byte) 5){
|
||||
xp += 40;
|
||||
blockProcCheck(block, player);
|
||||
blockProcCheck(block, player);
|
||||
}
|
||||
mat = Material.getMaterial(351);
|
||||
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
if(block.getData() != (byte) 5)
|
||||
PP.addMiningXP(xp * LoadProperties.xpGainMultiplier);
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
}
|
434
mcMMO/com/gmail/nossr50/skills/Repair.java
Normal file
434
mcMMO/com/gmail/nossr50/skills/Repair.java
Normal file
@ -0,0 +1,434 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Repair {
|
||||
private static mcMMO plugin;
|
||||
public Repair(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
private static volatile Repair instance;
|
||||
|
||||
public static void repairCheck(Player player, ItemStack is, Block block){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
short durabilityBefore = player.getItemInHand().getDurability();
|
||||
short durabilityAfter = 0;
|
||||
short dif = 0;
|
||||
if(block != null
|
||||
&& mcPermissions.repair(player)){
|
||||
if(player.getItemInHand().getDurability() > 0 && player.getItemInHand().getAmount() < 2){
|
||||
/*
|
||||
* ARMOR
|
||||
*/
|
||||
if(isArmor(is)){
|
||||
/*
|
||||
* DIAMOND ARMOR
|
||||
*/
|
||||
if(isDiamondArmor(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){
|
||||
removeDiamond(player);
|
||||
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter));
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
dif = (short) (dif * 6); //Boost XP
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
} else if (isIronArmor(is) && hasIron(player)){
|
||||
/*
|
||||
* IRON ARMOR
|
||||
*/
|
||||
removeIron(player);
|
||||
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
dif = (short) (dif * 2); //Boost XP
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
//GOLD ARMOR
|
||||
} else if (isGoldArmor(is) && hasGold(player)){
|
||||
removeGold(player);
|
||||
player.getItemInHand().setDurability(getArmorRepairAmount(is, player));
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
dif = (short) (dif * 4); //Boost XP of Gold to around Iron
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
} else {
|
||||
needMoreVespeneGas(is, player);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TOOLS
|
||||
*/
|
||||
if(isTools(is)){
|
||||
/*
|
||||
* IRON TOOLS
|
||||
*/
|
||||
if(isIronTools(is) && hasIron(player)){
|
||||
removeIron(player);
|
||||
/*
|
||||
* Repair Durability and calculate dif
|
||||
*/
|
||||
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
if(m.isShovel(is))
|
||||
dif = (short) (dif / 3);
|
||||
if(m.isSwords(is))
|
||||
dif = (short) (dif / 2);
|
||||
if(m.isHoe(is))
|
||||
dif = (short) (dif / 2);
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
} else if (isDiamondTools(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
|
||||
/*
|
||||
* DIAMOND TOOLS
|
||||
*/
|
||||
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
|
||||
removeDiamond(player);
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
if(m.isShovel(is))
|
||||
dif = (short) (dif / 3);
|
||||
if(m.isSwords(is))
|
||||
dif = (short) (dif / 2);
|
||||
if(m.isHoe(is))
|
||||
dif = (short) (dif / 2);
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
} else if(isGoldTools(is) && hasGold(player)){
|
||||
player.getItemInHand().setDurability(getToolRepairAmount(is, player));
|
||||
removeGold(player);
|
||||
durabilityAfter = player.getItemInHand().getDurability();
|
||||
dif = (short) (durabilityBefore - durabilityAfter);
|
||||
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
|
||||
if(m.isShovel(is))
|
||||
dif = (short) (dif / 3);
|
||||
if(m.isSwords(is))
|
||||
dif = (short) (dif / 2);
|
||||
if(m.isHoe(is))
|
||||
dif = (short) (dif / 2);
|
||||
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
|
||||
} else {
|
||||
needMoreVespeneGas(is, player);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage("That is at full durability.");
|
||||
}
|
||||
player.updateInventory();
|
||||
/*
|
||||
* GIVE SKILL IF THERE IS ENOUGH XP
|
||||
*/
|
||||
Skills.XpCheck(player);
|
||||
}
|
||||
}
|
||||
public static boolean isArmor(ItemStack is){
|
||||
if(is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 ||
|
||||
is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 ||
|
||||
is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isGoldArmor(ItemStack is){
|
||||
if(is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isIronArmor(ItemStack is){
|
||||
if(is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isDiamondArmor(ItemStack is){
|
||||
if(is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isTools(ItemStack is){
|
||||
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON
|
||||
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND
|
||||
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284) //GOLD
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isGoldTools(ItemStack is){
|
||||
if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isIronTools(ItemStack is){
|
||||
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDiamondTools(ItemStack is){
|
||||
if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void removeIron(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 265){
|
||||
if(x.getAmount() == 1){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
} else{
|
||||
x.setAmount(x.getAmount() - 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void removeGold(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 266){
|
||||
if(x.getAmount() == 1){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
} else{
|
||||
x.setAmount(x.getAmount() - 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void removeDiamond(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 264){
|
||||
if(x.getAmount() == 1){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
} else{
|
||||
x.setAmount(x.getAmount() - 1);
|
||||
player.getInventory().setContents(inventory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean hasGold(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 266){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean hasDiamond(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 264){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean hasIron(Player player){
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == 265){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static short repairCalculate(Player player, short durability, short ramt){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
float bonus = (PP.getRepairInt() / 500);
|
||||
bonus = (ramt * bonus);
|
||||
ramt = ramt+=bonus;
|
||||
if(checkPlayerProcRepair(player)){
|
||||
ramt = (short) (ramt * 2);
|
||||
}
|
||||
durability-=ramt;
|
||||
if(durability < 0){
|
||||
durability = 0;
|
||||
}
|
||||
return durability;
|
||||
}
|
||||
public static short getToolRepairAmount(ItemStack is, Player player){
|
||||
short durability = is.getDurability();
|
||||
short ramt = 0;
|
||||
switch(is.getTypeId())
|
||||
{
|
||||
//GOLD SHOVEL
|
||||
case 284:
|
||||
ramt = 33;
|
||||
break;
|
||||
//IRON SHOVEL
|
||||
case 256:
|
||||
ramt = 251;
|
||||
break;
|
||||
//DIAMOND SHOVEL
|
||||
case 277:
|
||||
ramt = 1562;
|
||||
break;
|
||||
//IRON PICK
|
||||
case 257:
|
||||
ramt = 84;
|
||||
break;
|
||||
//IRON AXE
|
||||
case 258:
|
||||
ramt = 84;
|
||||
break;
|
||||
//IRON SWORD
|
||||
case 267:
|
||||
ramt = 126;
|
||||
break;
|
||||
//IRON HOE
|
||||
case 292:
|
||||
ramt = 126;
|
||||
break;
|
||||
//DIAMOND SWORD
|
||||
case 276:
|
||||
ramt = 781;
|
||||
break;
|
||||
//DIAMOND PICK
|
||||
case 278:
|
||||
ramt = 521;
|
||||
break;
|
||||
//DIAMOND AXE
|
||||
case 279:
|
||||
ramt = 521;
|
||||
break;
|
||||
//DIAMOND HOE
|
||||
case 293:
|
||||
ramt = 781;
|
||||
break;
|
||||
//GOLD SWORD
|
||||
case 283:
|
||||
ramt = 17;
|
||||
break;
|
||||
//GOLD PICK
|
||||
case 285:
|
||||
ramt = 11;
|
||||
break;
|
||||
//GOLD AXE
|
||||
case 286:
|
||||
ramt = 11;
|
||||
break;
|
||||
//GOLD HOE
|
||||
case 294:
|
||||
ramt = 17;
|
||||
break;
|
||||
}
|
||||
return repairCalculate(player, durability, ramt);
|
||||
}
|
||||
//This determines how much we repair
|
||||
public static short getArmorRepairAmount(ItemStack is, Player player){
|
||||
short durability = is.getDurability();
|
||||
short ramt = 0;
|
||||
switch(is.getTypeId())
|
||||
{
|
||||
case 306:
|
||||
ramt = 27;
|
||||
break;
|
||||
case 310:
|
||||
ramt = 55;
|
||||
break;
|
||||
case 307:
|
||||
ramt = 24;
|
||||
break;
|
||||
case 311:
|
||||
ramt = 48;
|
||||
break;
|
||||
case 308:
|
||||
ramt = 27;
|
||||
break;
|
||||
case 312:
|
||||
ramt = 53;
|
||||
break;
|
||||
case 309:
|
||||
ramt = 40;
|
||||
break;
|
||||
case 313:
|
||||
ramt = 80;
|
||||
break;
|
||||
case 314:
|
||||
ramt = 13;
|
||||
break;
|
||||
case 315:
|
||||
ramt = 12;
|
||||
break;
|
||||
case 316:
|
||||
ramt = 14;
|
||||
break;
|
||||
case 317:
|
||||
ramt = 20;
|
||||
break;
|
||||
}
|
||||
if(durability < 0)
|
||||
durability = 0;
|
||||
return repairCalculate(player, durability, ramt);
|
||||
}
|
||||
public static void needMoreVespeneGas(ItemStack is, Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){
|
||||
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
|
||||
} else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player) || isGoldTools(is) && !hasGold(player)){
|
||||
if(isDiamondTools(is) && !hasDiamond(player))
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
|
||||
if(isIronTools(is) && !hasIron(player))
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
|
||||
//herp
|
||||
if(isGoldTools(is) && !hasGold(player))
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
|
||||
} else if (isDiamondArmor(is) && !hasDiamond(player)){
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
|
||||
} else if (isIronArmor(is) && !hasIron(player)){
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
|
||||
} else if (isGoldArmor(is) && !hasGold(player)){
|
||||
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
|
||||
} else if (is.getAmount() > 1)
|
||||
player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items");
|
||||
}
|
||||
public static boolean checkPlayerProcRepair(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getRepairInt()){
|
||||
player.sendMessage(ChatColor.GRAY + "That felt easy.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
649
mcMMO/com/gmail/nossr50/skills/Skills.java
Normal file
649
mcMMO/com/gmail/nossr50/skills/Skills.java
Normal file
@ -0,0 +1,649 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Leaderboard;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
|
||||
public class Skills {
|
||||
private static mcMMO plugin;
|
||||
public Skills(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
private static volatile Skills instance;
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
public void updateSQLfromFile(Player player){
|
||||
|
||||
}
|
||||
public static boolean cooldownOver(Player player, long oldTime, int cooldown){
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if(currentTime - oldTime >= (cooldown * 1000)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean hasArrows(Player player){
|
||||
for(ItemStack x : player.getInventory().getContents()){
|
||||
if (x.getTypeId() == 262){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void addArrows(Player player){
|
||||
for(ItemStack x : player.getInventory().getContents()){
|
||||
if (x.getTypeId() == 262){
|
||||
x.setAmount(x.getAmount() + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown){
|
||||
long currentTime = System.currentTimeMillis();
|
||||
int x = 0;
|
||||
while(currentTime < deactivatedTimeStamp + (cooldown * 1000)){
|
||||
currentTime += 1000;
|
||||
x++;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
public static void watchCooldowns(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - PP.getGreenTerraDeactivatedTimeStamp() >= (LoadProperties.greenTerraCooldown * 1000)){
|
||||
PP.setGreenTerraInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Green Terra "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getTreeFellerInformed() && System.currentTimeMillis() - PP.getTreeFellerDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setTreeFellerInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Tree Feller "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getSuperBreakerInformed() && System.currentTimeMillis() - PP.getSuperBreakerDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setSuperBreakerInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Super Breaker "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getSerratedStrikesInformed() && System.currentTimeMillis() - PP.getSerratedStrikesDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setSerratedStrikesInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Serrated Strikes "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getBerserkInformed() && System.currentTimeMillis() - PP.getBerserkDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setBerserkInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Berserk "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getSkullSplitterInformed() && System.currentTimeMillis() - PP.getSkullSplitterDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setSkullSplitterInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Skull Splitter "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
if(!PP.getGigaDrillBreakerInformed() && System.currentTimeMillis() - PP.getGigaDrillBreakerDeactivatedTimeStamp() >= (LoadProperties.berserkCooldown * 1000)){
|
||||
PP.setGigaDrillBreakerInformed(true);
|
||||
player.sendMessage(ChatColor.GREEN+"Your "+ChatColor.YELLOW+"Giga Drill Breaker "+ChatColor.GREEN+"ability is refreshed!");
|
||||
}
|
||||
}
|
||||
public static void hoeReadinessCheck(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(mcPermissions.getInstance().herbalismAbility(player) && m.isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){
|
||||
if(!PP.getGreenTerraMode() && !cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown)+"s)");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR HOE**");
|
||||
PP.setHoePreparationATS(System.currentTimeMillis());
|
||||
PP.setHoePreparationMode(true);
|
||||
}
|
||||
}
|
||||
public static void abilityActivationCheck(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(!PP.getAbilityUse())
|
||||
return;
|
||||
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode()){
|
||||
if(!PP.getSuperBreakerMode() && !cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)+"s)");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR PICKAXE**");
|
||||
PP.setPickaxePreparationATS(System.currentTimeMillis());
|
||||
PP.setPickaxePreparationMode(true);
|
||||
}
|
||||
if(mcPermissions.getInstance().excavationAbility(player) && m.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode()){
|
||||
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getGigaDrillBreakerDeactivatedTimeStamp(), LoadProperties.gigaDrillBreakerCooldown)+"s)");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR SHOVEL**");
|
||||
PP.setShovelPreparationATS(System.currentTimeMillis());
|
||||
PP.setShovelPreparationMode(true);
|
||||
}
|
||||
if(mcPermissions.getInstance().swordsAbility(player) && m.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode()){
|
||||
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSerratedStrikesDeactivatedTimeStamp(), LoadProperties.serratedStrikeCooldown)+"s)");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR SWORD**");
|
||||
PP.setSwordsPreparationATS(System.currentTimeMillis());
|
||||
PP.setSwordsPreparationMode(true);
|
||||
}
|
||||
if(mcPermissions.getInstance().unarmedAbility(player) && player.getItemInHand().getTypeId() == 0 && !PP.getFistsPreparationMode()){
|
||||
if(!PP.getBerserkMode() && !cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)+"s)");
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR FISTS**");
|
||||
PP.setFistsPreparationATS(System.currentTimeMillis());
|
||||
PP.setFistsPreparationMode(true);
|
||||
}
|
||||
if((mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().woodcutting(player)) && !PP.getAxePreparationMode()){
|
||||
if(m.isAxes(player.getItemInHand())){
|
||||
player.sendMessage(ChatColor.GREEN+"**YOU READY YOUR AXE**");
|
||||
PP.setAxePreparationATS(System.currentTimeMillis());
|
||||
PP.setAxePreparationMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void serratedStrikesActivationCheck(Player player, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isSwords(player.getItemInHand())){
|
||||
if(PP.getSwordsPreparationMode()){
|
||||
PP.setSwordsPreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getSwordsInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getSerratedStrikesMode() && PP.getSerratedStrikesCooldown() == 0){
|
||||
player.sendMessage(ChatColor.GREEN+"**SERRATED STRIKES ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Serrated Strikes!");
|
||||
}
|
||||
PP.setSerratedStrikesTicks((ticks * 2) * 1000);
|
||||
PP.setSerratedStrikesActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setSerratedStrikesMode(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static void berserkActivationCheck(Player player, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player.getItemInHand().getTypeId() == 0){
|
||||
if(PP.getFistsPreparationMode()){
|
||||
PP.setFistsPreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getUnarmedInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getBerserkMode() && cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)){
|
||||
player.sendMessage(ChatColor.GREEN+"**BERSERK ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Berserk!");
|
||||
}
|
||||
PP.setBerserkTicks(ticks * 1000);
|
||||
PP.setBerserkActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setBerserkMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void skullSplitterCheck(Player player, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){
|
||||
/*
|
||||
* CHECK FOR AXE PREP MODE
|
||||
*/
|
||||
if(PP.getAxePreparationMode()){
|
||||
PP.setAxePreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getAxesInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getSkullSplitterMode() && cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){
|
||||
player.sendMessage(ChatColor.GREEN+"**SKULL SPLITTER ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Skull Splitter!");
|
||||
}
|
||||
PP.setSkullSplitterTicks(ticks * 1000);
|
||||
PP.setSkullSplitterActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setSkullSplitterMode(true);
|
||||
}
|
||||
if(!PP.getSkullSplitterMode() && !cooldownOver(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, PP.getSkullSplitterDeactivatedTimeStamp(), LoadProperties.skullSplitterCooldown)+"s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void monitorSkills(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(PP == null)
|
||||
Users.addUser(player);
|
||||
if(PP.getHoePreparationMode() && System.currentTimeMillis() - PP.getHoePreparationATS() >= 4000){
|
||||
PP.setHoePreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR HOE**");
|
||||
}
|
||||
if(PP.getAxePreparationMode() && System.currentTimeMillis() - PP.getAxePreparationATS() >= 4000){
|
||||
PP.setAxePreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR AXE**");
|
||||
}
|
||||
if(PP.getPickaxePreparationMode() && System.currentTimeMillis() - PP.getPickaxePreparationATS() >= 4000){
|
||||
PP.setPickaxePreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR PICKAXE**");
|
||||
}
|
||||
if(PP.getSwordsPreparationMode() && System.currentTimeMillis() - PP.getSwordsPreparationATS() >= 4000){
|
||||
PP.setSwordsPreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR SWORD**");
|
||||
}
|
||||
if(PP.getFistsPreparationMode() && System.currentTimeMillis() - PP.getFistsPreparationATS() >= 4000){
|
||||
PP.setFistsPreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR FISTS**");
|
||||
}
|
||||
if(PP.getShovelPreparationMode() && System.currentTimeMillis() - PP.getShovelPreparationATS() >= 4000){
|
||||
PP.setShovelPreparationMode(false);
|
||||
player.sendMessage(ChatColor.GRAY+"**YOU LOWER YOUR SHOVEL**");
|
||||
}
|
||||
/*
|
||||
* HERBALISM ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().herbalismAbility(player)){
|
||||
if(PP.getGreenTerraMode() && PP.getGreenTerraActivatedTimeStamp() + PP.getGreenTerraTicks() <= System.currentTimeMillis()){
|
||||
PP.setGreenTerraMode(false);
|
||||
PP.setGreenTerraInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Green Terra has worn off**");
|
||||
PP.setGreenTerraDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AXES ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().axesAbility(player)){
|
||||
if(PP.getSkullSplitterMode() && PP.getSkullSplitterActivatedTimeStamp() + PP.getSkullSplitterTicks() <= System.currentTimeMillis()){
|
||||
PP.setSkullSplitterMode(false);
|
||||
PP.setSkullSplitterInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Skull Splitter has worn off**");
|
||||
PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WOODCUTTING ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().woodCuttingAbility(player)){
|
||||
if(PP.getTreeFellerMode() && PP.getTreeFellerActivatedTimeStamp() + PP.getTreeFellerTicks() <= System.currentTimeMillis()){
|
||||
PP.setTreeFellerMode(false);
|
||||
PP.setTreeFellerInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Tree Feller has worn off**");
|
||||
PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* MINING ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().miningAbility(player)){
|
||||
if(PP.getSuperBreakerMode() && PP.getSuperBreakerActivatedTimeStamp() + PP.getSuperBreakerTicks() <= System.currentTimeMillis()){
|
||||
PP.setSuperBreakerMode(false);
|
||||
PP.setSuperBreakerInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Super Breaker has worn off**");
|
||||
PP.setSuperBreakerDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* EXCAVATION ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().excavationAbility(player)){
|
||||
if(PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerActivatedTimeStamp() + PP.getGigaDrillBreakerTicks() <= System.currentTimeMillis()){
|
||||
PP.setGigaDrillBreakerMode(false);
|
||||
PP.setGigaDrillBreakerInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Giga Drill Breaker has worn off**");
|
||||
PP.setGigaDrillBreakerDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* SWORDS ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().swordsAbility(player)){
|
||||
if(PP.getSerratedStrikesMode() && PP.getSerratedStrikesActivatedTimeStamp() + PP.getSerratedStrikesTicks() <= System.currentTimeMillis()){
|
||||
PP.setSerratedStrikesMode(false);
|
||||
PP.setSerratedStrikesInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Serrated Strikes has worn off**");
|
||||
PP.setSerratedStrikesDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* UNARMED ABILITY
|
||||
*/
|
||||
if(mcPermissions.getInstance().unarmedAbility(player)){
|
||||
if(PP.getBerserkMode() && PP.getBerserkActivatedTimeStamp() + PP.getBerserkTicks() <= System.currentTimeMillis()){
|
||||
PP.setBerserkMode(false);
|
||||
PP.setBerserkInformed(false);
|
||||
player.sendMessage(ChatColor.RED+"**Berserk has worn off**");
|
||||
PP.setBerserkDeactivatedTimeStamp(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void XpCheck(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
/*
|
||||
* TAMING
|
||||
*/
|
||||
if(player != null && PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
|
||||
int skillups = 0;
|
||||
while(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
|
||||
skillups++;
|
||||
PP.removeTamingXP(PP.getXpToLevel("taming"));
|
||||
PP.skillUpTaming(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getTamingInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "taming");
|
||||
if(player != null && PP.getTaming() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+skillups+"."+" Total ("+PP.getTaming()+")");
|
||||
}
|
||||
/*
|
||||
* ACROBATICS
|
||||
*/
|
||||
if(player != null && PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
|
||||
int skillups = 0;
|
||||
while(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
|
||||
skillups++;
|
||||
PP.removeAcrobaticsXP(PP.getXpToLevel("acrobatics"));
|
||||
PP.skillUpAcrobatics(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getAcrobaticsInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "acrobatics");
|
||||
|
||||
if(player != null && PP.getAcrobatics() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+PP.getAcrobatics()+")");
|
||||
}
|
||||
/*
|
||||
* ARCHERY
|
||||
*/
|
||||
if(PP.getArcheryXPInt() >= PP.getXpToLevel("archery")){
|
||||
int skillups = 0;
|
||||
while(PP.getArcheryXPInt() >= PP.getXpToLevel("archery")){
|
||||
skillups++;
|
||||
PP.removeArcheryXP(PP.getXpToLevel("archery"));
|
||||
PP.skillUpArchery(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getArcheryInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "archery");
|
||||
|
||||
if(player != null && PP.getArchery() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+PP.getArchery()+")");
|
||||
}
|
||||
/*
|
||||
* SWORDS
|
||||
*/
|
||||
if(PP.getSwordsXPInt() >= PP.getXpToLevel("swords")){
|
||||
int skillups = 0;
|
||||
while(PP.getSwordsXPInt() >= PP.getXpToLevel("swords")){
|
||||
skillups++;
|
||||
PP.removeSwordsXP(PP.getXpToLevel("swords"));
|
||||
PP.skillUpSwords(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getSwordsInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "swords");
|
||||
|
||||
if(player != null && PP.getSwords() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+PP.getSwords()+")");
|
||||
}
|
||||
/*
|
||||
* AXES
|
||||
*/
|
||||
if(PP.getAxesXPInt() >= PP.getXpToLevel("axes")){
|
||||
int skillups = 0;
|
||||
while(PP.getAxesXPInt() >= PP.getXpToLevel("axes")){
|
||||
skillups++;
|
||||
PP.removeAxesXP(PP.getXpToLevel("axes"));
|
||||
PP.skillUpAxes(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getAxesInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "axes");
|
||||
|
||||
if(player != null && PP.getAxes() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+PP.getAxes()+")");
|
||||
}
|
||||
/*
|
||||
* UNARMED
|
||||
*/
|
||||
if(PP.getUnarmedXPInt() >= PP.getXpToLevel("unarmed")){
|
||||
int skillups = 0;
|
||||
while(PP.getUnarmedXPInt() >= PP.getXpToLevel("unarmed")){
|
||||
skillups++;
|
||||
PP.removeUnarmedXP(PP.getXpToLevel("unarmed"));
|
||||
PP.skillUpUnarmed(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getUnarmedInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "unarmed");
|
||||
|
||||
if(player != null && PP.getUnarmed() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+PP.getUnarmed()+")");
|
||||
}
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
if(PP.getHerbalismXPInt() >= PP.getXpToLevel("herbalism")){
|
||||
int skillups = 0;
|
||||
while(PP.getHerbalismXPInt() >= PP.getXpToLevel("herbalism")){
|
||||
skillups++;
|
||||
PP.removeHerbalismXP(PP.getXpToLevel("herbalism"));
|
||||
PP.skillUpHerbalism(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getHerbalismInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "herbalism");
|
||||
|
||||
if(player != null && PP.getHerbalism() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+PP.getHerbalism()+")");
|
||||
}
|
||||
/*
|
||||
* MINING
|
||||
*/
|
||||
if(player != null && PP.getMiningXPInt() >= PP.getXpToLevel("mining")){
|
||||
int skillups = 0;
|
||||
while(PP.getMiningXPInt() >= PP.getXpToLevel("mining")){
|
||||
skillups++;
|
||||
PP.removeMiningXP(PP.getXpToLevel("mining"));
|
||||
PP.skillUpMining(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getMiningInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "mining");
|
||||
|
||||
if(player != null && PP.getMining() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+PP.getMining()+")");
|
||||
}
|
||||
/*
|
||||
* WOODCUTTING
|
||||
*/
|
||||
if(player != null && PP.getWoodCuttingXPInt() >= PP.getXpToLevel("woodcutting")){
|
||||
int skillups = 0;
|
||||
while(PP.getWoodCuttingXPInt() >= PP.getXpToLevel("woodcutting")){
|
||||
skillups++;
|
||||
PP.removeWoodCuttingXP(PP.getXpToLevel("woodcutting"));
|
||||
PP.skillUpWoodCutting(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getWoodCuttingInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "woodcutting");
|
||||
|
||||
if(player != null && PP.getWoodCutting() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+PP.getWoodCutting()+")");
|
||||
}
|
||||
/*
|
||||
* REPAIR
|
||||
*/
|
||||
if(PP.getRepairXPInt() >= PP.getXpToLevel("repair")){
|
||||
int skillups = 0;
|
||||
while(PP.getRepairXPInt() >= PP.getXpToLevel("repair")){
|
||||
skillups++;
|
||||
PP.removeRepairXP(PP.getXpToLevel("repair"));
|
||||
PP.skillUpRepair(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getRepairInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "repair");
|
||||
|
||||
if(player != null && PP.getRepair() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+PP.getRepair()+")");
|
||||
}
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
if(PP.getExcavationXPInt() >= PP.getXpToLevel("excavation")){
|
||||
int skillups = 0;
|
||||
while(PP.getExcavationXPInt() >= PP.getXpToLevel("excavation")){
|
||||
skillups++;
|
||||
PP.removeExcavationXP(PP.getXpToLevel("excavation"));
|
||||
PP.skillUpExcavation(1);
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = PP.getExcavationInt();
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "excavation");
|
||||
|
||||
if(player != null && PP.getExcavation() != null)
|
||||
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+PP.getExcavation()+")");
|
||||
}
|
||||
/*
|
||||
* Leaderboard updating stuff
|
||||
*/
|
||||
PlayerStat ps = new PlayerStat();
|
||||
ps.statVal = m.getPowerLevel(player);
|
||||
ps.name = player.getName();
|
||||
Leaderboard.updateLeaderboard(ps, "powerlevel");
|
||||
}
|
||||
public static boolean isSkill(String skillname){
|
||||
skillname = skillname.toLowerCase();
|
||||
if(skillname.equals("all")){
|
||||
return true;
|
||||
}
|
||||
if(skillname.equals("taming")){
|
||||
return true;
|
||||
}
|
||||
if(skillname.equals("mining")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("woodcutting")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("excavation")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("repair")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("herbalism")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("acrobatics")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("swords")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("archery")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("unarmed")){
|
||||
return true;
|
||||
}
|
||||
else if(skillname.equals("axes")){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void arrowRetrievalCheck(Entity entity){
|
||||
if(Config.getInstance().isTracked(entity)){
|
||||
Integer x = 0;
|
||||
while(x < Config.getInstance().getArrowCount(entity)){
|
||||
m.mcDropItem(entity.getLocation(), 262);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
Config.getInstance().removeArrowTracked(entity);
|
||||
}
|
||||
}
|
179
mcMMO/com/gmail/nossr50/skills/Swords.java
Normal file
179
mcMMO/com/gmail/nossr50/skills/Swords.java
Normal file
@ -0,0 +1,179 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class Swords {
|
||||
|
||||
public static void bleedCheck(Player attacker, Entity x){
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(mcPermissions.getInstance().swords(attacker) && m.isSwords(attacker.getItemInHand())){
|
||||
if(PPa.getSwordsInt() >= 750){
|
||||
if(Math.random() * 1000 >= 750){
|
||||
if(!(x instanceof Player))
|
||||
Config.getInstance().addToBleedQue(x);
|
||||
if(x instanceof Player){
|
||||
Player target = (Player)x;
|
||||
Users.getProfile(target).addBleedTicks(3);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
||||
}
|
||||
} else if (Math.random() * 1000 <= PPa.getSwordsInt()){
|
||||
if(!(x instanceof Player))
|
||||
Config.getInstance().addToBleedQue(x);
|
||||
if(x instanceof Player){
|
||||
Player target = (Player)x;
|
||||
Users.getProfile(target).addBleedTicks(2);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event){
|
||||
int targets = 0;
|
||||
Entity x = event.getEntity();
|
||||
targets = m.getTier(attacker);
|
||||
for(Entity derp : x.getWorld().getEntities()){
|
||||
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5){
|
||||
if(derp instanceof Player){
|
||||
Player target = (Player)derp;
|
||||
if(Party.getInstance().inSameParty(attacker, target))
|
||||
continue;
|
||||
if(!target.getName().equals(attacker.getName()) && targets >= 1){
|
||||
target.damage(event.getDamage() / 4);
|
||||
target.sendMessage(ChatColor.DARK_RED+"Struck by Serrated Strikes!");
|
||||
Users.getProfile(target).addBleedTicks(5);
|
||||
targets--;
|
||||
}
|
||||
}
|
||||
if(derp instanceof Monster && targets >= 1){
|
||||
if(!Config.getInstance().isBleedTracked(derp))
|
||||
Config.getInstance().addToBleedQue(x);
|
||||
Monster target = (Monster)derp;
|
||||
target.damage(event.getDamage() / 4);
|
||||
targets--;
|
||||
}
|
||||
if(derp instanceof Wolf){
|
||||
continue;
|
||||
}
|
||||
if(derp instanceof Animals && targets >= 1){
|
||||
if(!Config.getInstance().isBleedTracked(derp))
|
||||
Config.getInstance().addToBleedQue(x);
|
||||
Animals target = (Animals)derp;
|
||||
target.damage(event.getDamage() / 4);
|
||||
targets--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void parryCheck(EntityDamageByEntityEvent event, Player defender){
|
||||
Entity y = event.getDamager();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(defender != null && m.isSwords(defender.getItemInHand())
|
||||
&& mcPermissions.getInstance().swords(defender)){
|
||||
if(PPd.getSwordsInt() >= 900){
|
||||
if(Math.random() * 3000 <= 900){
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(ChatColor.GREEN+"**PARRIED**");
|
||||
defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1));
|
||||
if(y instanceof Player){
|
||||
Player attacker = (Player)y;
|
||||
attacker.sendMessage(ChatColor.GREEN+"**PARRIED**");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(Math.random() * 3000 <= PPd.getSwordsInt()){
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*");
|
||||
defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1));
|
||||
if(y instanceof Player){
|
||||
Player attacker = (Player)y;
|
||||
attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void counterAttackChecks(EntityDamageEvent event){
|
||||
//Don't want to counter attack arrows
|
||||
if(event instanceof EntityDamageByProjectileEvent)
|
||||
return;
|
||||
if(event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
Entity f = ((EntityDamageByEntityEvent) event).getDamager();
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player defender = (Player)event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(PPd.getSwordsInt() >= 600)
|
||||
{
|
||||
if(Math.random() * 2000 <= 600)
|
||||
{
|
||||
Combat.dealDamage(f, event.getDamage() / 2);
|
||||
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
|
||||
if(f instanceof Player)
|
||||
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
|
||||
}
|
||||
}
|
||||
else if (Math.random() * 2000 <= PPd.getSwordsInt())
|
||||
{
|
||||
Combat.dealDamage(f, event.getDamage() / 2);
|
||||
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
|
||||
if(f instanceof Player)
|
||||
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void bleedSimulate(){
|
||||
|
||||
//Add items from Que list to BleedTrack list
|
||||
for(Entity x : Config.getInstance().getBleedQue()){
|
||||
Config.getInstance().addBleedTrack(x);
|
||||
}
|
||||
//Clear list
|
||||
Config.getInstance().clearBleedQue();
|
||||
|
||||
//Cleanup any dead entities from the list
|
||||
for(Entity x : Config.getInstance().getBleedRemovalQue()){
|
||||
Config.getInstance().removeBleedTrack(x);
|
||||
}
|
||||
|
||||
//Clear bleed removal list
|
||||
Config.getInstance().clearBleedRemovalQue();
|
||||
|
||||
//Bleed monsters/animals
|
||||
for(Entity x : Config.getInstance().getBleedTracked()){
|
||||
if(x == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(m.getHealth(x) <= 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(x instanceof Animals){
|
||||
((Animals) x).damage(2);
|
||||
}
|
||||
|
||||
if(x instanceof Monster){((Monster) x).damage(2);}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
mcMMO/com/gmail/nossr50/skills/Taming.java
Normal file
38
mcMMO/com/gmail/nossr50/skills/Taming.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import net.minecraft.server.EntityWolf;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftWolf;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Taming {
|
||||
public static String getOwnerName(Entity theWolf){
|
||||
CraftWolf cWolf = (CraftWolf)theWolf;
|
||||
EntityWolf eWolf = (EntityWolf)cWolf.getHandle();
|
||||
|
||||
String playerName = eWolf.v();
|
||||
return playerName;
|
||||
}
|
||||
public static boolean hasOwner(Entity theWolf, Plugin pluginx){
|
||||
for(Player x : pluginx.getServer().getOnlinePlayers()){
|
||||
if(x != null && x.getName().equals(getOwnerName(theWolf))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Player getOwner(Entity theWolf, Plugin pluginx){
|
||||
for(Player x : pluginx.getServer().getOnlinePlayers()){
|
||||
if(x != null && x.getName().equals(getOwnerName(theWolf))){
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Taming getInstance() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
5
mcMMO/com/gmail/nossr50/skills/Unarmed.java
Normal file
5
mcMMO/com/gmail/nossr50/skills/Unarmed.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
public class Unarmed {
|
||||
|
||||
}
|
141
mcMMO/com/gmail/nossr50/skills/WoodCutting.java
Normal file
141
mcMMO/com/gmail/nossr50/skills/WoodCutting.java
Normal file
@ -0,0 +1,141 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.config.*;
|
||||
|
||||
|
||||
public class WoodCutting {
|
||||
static int w = 0;
|
||||
private static boolean isdone = false;
|
||||
private static mcMMO plugin;
|
||||
public WoodCutting(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public static void woodCuttingProcCheck(Player player, Block block){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
byte type = block.getData();
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
if(player != null){
|
||||
if(Math.random() * 1000 <= PP.getWoodCuttingInt()){
|
||||
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
|
||||
block.getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void treeFellerCheck(Player player, Block block, Plugin pluginx){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isAxes(player.getItemInHand())){
|
||||
if(block != null){
|
||||
if(!m.abilityBlockCheck(block))
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* CHECK FOR AXE PREP MODE
|
||||
*/
|
||||
if(PP.getAxePreparationMode()){
|
||||
PP.setAxePreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getWoodCuttingInt();
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){
|
||||
player.sendMessage(ChatColor.GREEN+"**TREE FELLING ACTIVATED**");
|
||||
for(Player y : pluginx.getServer().getOnlinePlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Tree Feller!");
|
||||
}
|
||||
PP.setTreeFellerTicks(ticks * 1000);
|
||||
PP.setTreeFellerActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setTreeFellerMode(true);
|
||||
}
|
||||
if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)){
|
||||
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
|
||||
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)+"s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void treeFeller(Block block, Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int radius = 1;
|
||||
if(PP.getWoodCuttingXPInt() >= 500)
|
||||
radius++;
|
||||
if(PP.getWoodCuttingXPInt() >= 950)
|
||||
radius++;
|
||||
ArrayList<Block> blocklist = new ArrayList<Block>();
|
||||
ArrayList<Block> toAdd = new ArrayList<Block>();
|
||||
if(block != null)
|
||||
blocklist.add(block);
|
||||
while(isdone == false){
|
||||
addBlocksToTreeFelling(blocklist, toAdd, radius);
|
||||
}
|
||||
//This needs to be a hashmap too!
|
||||
isdone = false;
|
||||
/*
|
||||
* Add blocks from the temporary 'toAdd' array list into the 'treeFeller' array list
|
||||
* We use this temporary list to prevent concurrent modification exceptions
|
||||
*/
|
||||
for(Block x : toAdd){
|
||||
if(!Config.getInstance().isTreeFellerWatched(x))
|
||||
Config.getInstance().addTreeFeller(x);
|
||||
}
|
||||
toAdd.clear();
|
||||
}
|
||||
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius){
|
||||
int u = 0;
|
||||
for (Block x : blocklist){
|
||||
u++;
|
||||
if(toAdd.contains(x))
|
||||
continue;
|
||||
w = 0;
|
||||
Location loc = x.getLocation();
|
||||
int vx = x.getX();
|
||||
int vy = x.getY();
|
||||
int vz = x.getZ();
|
||||
|
||||
/*
|
||||
* Run through the blocks around the broken block to see if they qualify to be 'felled'
|
||||
*/
|
||||
for (int cx = -radius; cx <= radius; cx++) {
|
||||
for (int cy = -radius; cy <= radius; cy++) {
|
||||
for (int cz = -radius; cz <= radius; cz++) {
|
||||
Block blocktarget = loc.getWorld().getBlockAt(vx + cx, vy + cy, vz + cz);
|
||||
if (!blocklist.contains(blocktarget) && !toAdd.contains(blocktarget) && (blocktarget.getTypeId() == 17 || blocktarget.getTypeId() == 18)) {
|
||||
toAdd.add(blocktarget);
|
||||
w++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Add more blocks to blocklist so they can be 'felled'
|
||||
*/
|
||||
for(Block xx : toAdd){
|
||||
if(!blocklist.contains(xx))
|
||||
blocklist.add(xx);
|
||||
}
|
||||
if(u >= blocklist.size()){
|
||||
isdone = true;
|
||||
} else {
|
||||
isdone = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user