Permalink
Browse files

Clans bugs and damage event bugs fixed. Started on spells.

  • Loading branch information...
Kowagatte
Kowagatte committed Mar 13, 2017
1 parent e19eb76 commit 5e681c2bd7a4fe9c7c48c83421c4e1f33dd3cbf1
@@ -14,6 +14,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import xyz.almia.cardinalsystem.Cardinal;
import xyz.almia.clansystem.Clan;
import xyz.almia.clansystem.Clans;
import xyz.almia.configclasses.ConfigManager;
import xyz.almia.messagesystem.Messages;
import xyz.almia.storagesystem.Equips;
@@ -29,6 +31,7 @@
public int characterID = 0;
FileConfiguration config;
Players players = new Players();
PlayerSetup playersetup = new PlayerSetup();
public Character(Player player, int characterID){
this.player = player;
@@ -40,6 +43,7 @@ public Character(Player player, int characterID){
public Character(UUID uuid, int characterID){
this.uuid = uuid;
this.player = Bukkit.getPlayer(uuid);
this.characterID = characterID;
ConfigManager.load(uuid+";char;"+characterID+".yml", "players/"+uuid);
this.config = ConfigManager.get(uuid+";char;"+characterID+".yml");
@@ -49,6 +53,60 @@ public Player getPlayer(){
return this.player;
}
public xyz.almia.clansystem.Rank getClanRank(){
Clans clan = getClan();
Clan clanProfile = new Clan(clan);
if(clan.equals(Clans.UNCLANNED))
return xyz.almia.clansystem.Rank.NONE;
if(clanProfile.getKing() != null){
if(clanProfile.getKing().getUsername().equals(getUsername())){
return xyz.almia.clansystem.Rank.KING;
}
}
for(Character chara : clanProfile.getClansmen()){
if(chara.getUsername().equals(getUsername())){
return xyz.almia.clansystem.Rank.CLANSMEN;
}
}
return xyz.almia.clansystem.Rank.NONE;
}
public Clans getClan(){
for(Clans clan : Clans.values()){
if(!(clan.equals(Clans.UNCLANNED))){
Clan clanProfile = new Clan(clan);
for(Character chara : clanProfile.getClansmen()){
if(chara.getUsername().equals(getUsername())){
return clan;
}
}
try{
if(clanProfile.getKingName().equals(getUsername())){
return clan;
}
}catch(Exception e) {}
}
}
return Clans.UNCLANNED;
}
public boolean isInClan(){
if(getClan().equals(Clans.UNCLANNED)){
return false;
}else{
return true;
}
}
@Deprecated
public int getSkillSlots(){
return config.getInt("skillslots");
@@ -487,6 +545,23 @@ public void addShowStat(Stat stat){
}
public void remove(){
Clans whatClan = getClan();
xyz.almia.clansystem.Clan clan = new xyz.almia.clansystem.Clan(whatClan);
if(isInClan()){
if(clan.getProposed().getUsername().equalsIgnoreCase(getUsername()))
clan.setProposed(null);
xyz.almia.clansystem.Rank rank = getClanRank();
if(rank.equals(xyz.almia.clansystem.Rank.CLANSMEN)){
clan.removeClansmen(this);
}
if(rank.equals(xyz.almia.clansystem.Rank.KING)){
clan.setKing(null);
}
}
new Account(player).logout();
config.set("username", "UNKNOWN");
config.set("rank", "PLAYER");
@@ -519,7 +594,7 @@ public void remove(){
config.set("stats.hitpoints", 0);
config.set("stats.agility", 0);
config.set("stats.intelligence", 0);
config.set("location", LocationSerializer.locationToString(player.getLocation()));
config.set("location", LocationSerializer.locationToString(player.getLocation().getWorld().getSpawnLocation()));
config.set("status", CharacterStatus.CHOOSE_USERNAME.toString());
ConfigManager.save(uuid+";char;"+characterID+".yml", "players/"+uuid);
new Treasury(this).setupBankAccount();
@@ -50,6 +50,7 @@
@EventHandler
public void onRightClickEnder(PlayerInteractEvent event){
Player player = event.getPlayer();
if(event.getClickedBlock() != null){
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(event.getClickedBlock().getType().equals(Material.ENDER_CHEST)){
@@ -14,11 +14,8 @@
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import net.blitzcube.mlapi.MultiLineAPI;
import xyz.almia.cardinalsystem.Cardinal;
import xyz.almia.clansystem.Clan;
import xyz.almia.clansystem.Clans;
import xyz.almia.utils.Message;
import xyz.almia.utils.Swears;
@@ -29,63 +26,6 @@
public PlayerSetup(){}
public xyz.almia.clansystem.Rank getClanRank(Character character){
Clans clan = getClan(character);
Clan clanProfile = new Clan(clan);
if(clan.equals(Clans.UNCLANNED))
return xyz.almia.clansystem.Rank.NONE;
if(clan.equals(Clans.EXILED))
return xyz.almia.clansystem.Rank.CLANSMEN;
if(clanProfile.getKing() != null){
if(clanProfile.getKing().getUsername().equals(character.getUsername())){
return xyz.almia.clansystem.Rank.KING;
}
}
for(Character chara : clanProfile.getClansmen()){
if(chara.getUsername().equals(character.getUsername())){
return xyz.almia.clansystem.Rank.CLANSMEN;
}
}
return xyz.almia.clansystem.Rank.NONE;
}
public Clans getClan(Character character){
for(Clans clan : Clans.values()){
Clan clanProfile = new Clan(clan);
for(Character chara : clanProfile.getClansmen()){
if(chara.getUsername().equals(character.getUsername())){
return clan;
}
}
if(!(clan.equals(Clans.UNCLANNED)) || !(clan.equals(Clans.EXILED))){
try{
if(clanProfile.getKing().getUsername().equals(character.getUsername())){
return clan;
}
}catch(Exception e) {}
}
}
return Clans.UNCLANNED;
}
public boolean isInClan(Character character){
if(getClan(character).equals(Clans.UNCLANNED)){
return false;
}else{
return true;
}
}
public List<Character> getOnlineCharacters(){
List<Character> onlinePlayers = new ArrayList<Character>();
for(Player player : Bukkit.getOnlinePlayers()){
@@ -115,7 +55,7 @@ public boolean isInClan(Character character){
public Character getCharacterFromUsername(String username){
if(username.equalsIgnoreCase("unknown"))
return null;
List<Character> characters = getOnlineCharacters();
List<Character> characters = new Players().getCharacters();
for(Character character : characters){
if(character.getUsername().equalsIgnoreCase(username)){
return character;
@@ -1,17 +1,12 @@
package xyz.almia.accountsystem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
@@ -20,8 +15,6 @@
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.util.BlockIterator;
import xyz.almia.configclasses.ConfigManager;
import xyz.almia.enchantsystem.Enchantments;
import xyz.almia.itemblueprints.Armor;
import xyz.almia.itemblueprints.Weapon;
@@ -269,7 +262,7 @@ public void startCharacterRegen(Player player){
Account account = new Account(player);
if(account.getStatus().equals(AccountStatus.LOGGEDIN)){
Character character = account.getLoadedCharacter();
int regenrate = 6; //(int)(10 - (0.2 * account.getStat(Stats.HITPOINTS)));
int regenrate = 3; //(int)(10 - (0.2 * account.getStat(Stats.HITPOINTS)));
if(regenrate < 1){
regenrate = 1;
}
@@ -282,6 +275,13 @@ public void run() {
}
}
}.runTaskTimer(plugin, 0, (int)(regenrate * 20));
new BukkitRunnable(){
public void run(){
character.regenMana();
}
}.runTaskTimer(plugin, 0, 5);
}
}
@@ -379,7 +379,6 @@ public void run() {
exp = exp/10;
player.setExp((float)exp);
character.regenMana();
character.displayMana();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(character.getMaxHealth());;
@@ -549,41 +548,6 @@ public String getName(Entity entity){
}
}
public Entity getTarget(Player player, int range) {
ConfigManager.load("blacklist.yml", "");
List<String> blacklist = ConfigManager.get("blacklist.yml").getStringList("list");
List<Material> materials = new ArrayList<Material>();
for(String s : blacklist){
materials.add(Material.valueOf(s));
}
BlockIterator bItr = new BlockIterator(player, range);
Block block;
Location loc;
int bx, by, bz;
double ex, ey, ez;
// loop through player's line of sight
while (bItr.hasNext()) {
block = bItr.next();
if(materials.contains(block.getType()))
bItr.next();
bx = block.getX();
by = block.getY();
bz = block.getZ();
// check for entities near this block in the line of sight
for (Entity e : player.getNearbyEntities(range, range, range)) {
loc = e.getLocation();
ex = loc.getX();
ey = loc.getY();
ez = loc.getZ();
if ((bx - .75 <= ex && ex <= bx + 1.75) && (bz - .75 <= ez && ez <= bz + 1.75)
&& (by - 1 <= ey && ey <= by + 2.5)) {
// entity is close enough, set target and stop
return e;
}
}
}
return null;
}
}
@@ -4,6 +4,7 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@@ -51,6 +52,8 @@
import xyz.almia.professionssystem.Smelting;
import xyz.almia.soulsystem.SoulSystem;
import xyz.almia.storagesystem.EquipHandler;
import xyz.almia.spellsystem.Target;
import xyz.almia.spellsystem.Target.TargetOptions;
public class Cardinal extends JavaPlugin{
@@ -76,10 +79,10 @@ public void run(){
if(account.getStatus().equals(AccountStatus.LOGGEDIN)){
String name = "";
if(task.getTarget(player, 30) == null){
if(new Target(TargetOptions.ENTITY, 30, player).getTarget() == null){
name = ChatColor.GRAY+"No Target";
}else{
name = task.getName(task.getTarget(player, 30));
name = task.getName((Entity)new Target(TargetOptions.ENTITY, 30, player).getTarget());
}
xyz.almia.accountsystem.Character character = account.getLoadedCharacter();
Oops, something went wrong.

0 comments on commit 5e681c2

Please sign in to comment.