All pastes #926806 Raw Edit

rofl

public text v1 · immutable
·published 2008-03-03 21:10 UTC
rendered paste body
package net.sf.l2j.gameserver.custom;

import java.sql.PreparedStatement;
import java.util.Collection;

import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.L2GameServerPacket;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.datatables.SkillTreeTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2SkillLearn;

import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.Announcements;

public class sourceModifications
{ 
    //Delarations\\
    
    //==========\\
	/**
     * check player skills and remove unlegit ones excludes cursed weapon
     * skills
     */
    
    public void checkAllowedSkills(L2PcInstance player)
    {
	   boolean foundskill = false;
	   if (!player.isGM())
	   {
	    Collection<L2SkillLearn> skillTree = SkillTreeTable.getInstance().getAllowedSkills(player.getClassId());
	    // loop through all skills of player
	    for (L2Skill skill : player.getAllSkills())
	    {
		  int skillid = skill.getId();
		  // int skilllevel = skill.getLevel();
		  foundskill = false;
		  // loop through all skills in players skilltree
		  for (L2SkillLearn temp : skillTree)
		  {
		      // if the skill was found and the level is possible to
		      // obtain for his class everything is ok
		      if (temp.getId() == skillid)
		      {
		    	foundskill = true;
		      }
		  }
		  // exclude noble skills
		  if (player.isNoble() && (skillid >= 325) && (skillid <= 327))
		  {
		      foundskill = true;
		  }
		  if (player.isNoble() && (skillid >= 1323) && (skillid <= 1327))
		  {
		      foundskill = true;
		  }
		  // exclude hero skills
		  if (player.isHero() && (skillid >= 395) && (skillid <= 396))
		  {
		      foundskill = true;
		  }
		  if (player.isHero() && (skillid >= 1374) && (skillid <= 1376))
		  {
		      foundskill = true;
		  }
		  // exclude cursed weapon skills
		  if (player.isCursedWeaponEquipped() && (skillid == 3630 || skillid == 3631))
		  {
		      foundskill = true;
		  }
		  // exclude clan skills
		  if ((player.getClan() != null) && (skillid >= 370) && (skillid <= 391))
		  {
		      foundskill = true;
		  }
		  // exclude seal of ruler / build siege hq
	  	  if ((player.getClan() != null) && (skillid >= 246) && (skillid <= 247))
		    {
		      if (player.getClan().getLeaderId() == player.getObjectId())
		      {
		  	foundskill = true;
	 	      }
	  	  }
	  	  // exclude fishing skills and common skills + dwarfen craft
  		  if ((skillid >= 1312) && (skillid <= 1322))
	  	  {
		      foundskill = true;
		  }
		  if ((skillid >= 1368) && (skillid <= 1373))
		  {
		      foundskill = true;
		  }
		  // exclude sa / enchant bonus / penality etc. skills
		  if ((skillid >= 3000) && (skillid < 7000))
		  {
		      foundskill = true;
		  }
		  // exclude divine inspiration
		  if (skillid == 1405)
		  {
			  foundskill = true;
		  }
		  // remove skill and do a log message
		  if (!foundskill)
		  {
		      player.removeSkill(skill);
		      player.sendMessage("Skill " + skill.getName() + " removed and GM informed!");
		  }
	    }
	   }
	  }
    public void checkSkillsOnEnter(L2PcInstance player)
    {
	   if (Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
	   {
	    checkAllowedSkills(player);
	   }
	   
    }
}