Jump to content

Recommended Posts

Posted

Καλησπεριζω τα μελη του mxc ειναι το πρωτο μου Java Code Share και ελπιζω να ειναι καλο και να βρειι πολλα ατομα χαρουμενα διοτι απο τη μια υπαρχει αυτη η εντολη αλλα δεν πολη δουλευει σωστα η ειναι bugαρισμενει.Λοιπον ας αρχισω την παρουσιαση του και πως θα την βαλλουμε μεσα στο pack μας:

Δημηουργουμε ενα νεο Java αρχειο με το ονομα "DelevelCmd.java" και το βαζουμε μεσα στον φακελο "voicedcommandhandlers" και αντιγραφουμε το κοδικα στο αρχειο οπου δημιουργισαμε

package com.l2jprotocol.gameserver.handler.voicedcommandhandlers;

import com.l2jprotocol.Config;
import com.l2jprotocol.gameserver.datatables.SkillTable;
import com.l2jprotocol.gameserver.datatables.xml.ExperienceData;
import com.l2jprotocol.gameserver.handler.IVoicedCommandHandler;
import com.l2jprotocol.gameserver.managers.SiegeManager;
import com.l2jprotocol.gameserver.model.actor.instance.L2PcInstance;
import com.l2jprotocol.gameserver.model.entity.siege.Siege;
import com.l2jprotocol.gameserver.model.L2Skill;

/**
* @author LastWarrior_Dev_Team
*/

public class DelevelCmd implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
		"delevel"
};

public static final int ZONE_PEACE = 2;

/* (non-Javadoc)
 * @see com.l2jprotocol.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(String, com.l2jprotocol.gameserver.model.L2PcInstance), String)
 */
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	if(command.startsWith("delevel"))
	{
		requestDelevel(activeChar);
	}
	return true;
}

public boolean requestDelevel (L2PcInstance activeChar)
	{
		Siege siege = SiegeManager.getInstance().getSiege(activeChar);

		// Check the activeChar's level.
		if (activeChar.getLevel() < Config.DELEVEL_MIN_LEVEL)
		{
			activeChar.sendMessage("You do not meet the level requirement for Delevel!");
			return false;
		}	
		// Check activeChar if have SubClass
		else if (activeChar.isSubClassActive())
		{
			activeChar.sendMessage("Please switch to your Main Class before attempting Delevel.");
			return false;
		}	
		// Check activeChar if in Peace Zone
		else if(!activeChar.isInsideZone(ZONE_PEACE))
		{
			activeChar.sendMessage("You can only Delevel in peace zone.");
			return false;
		}
		 // Check activeChar is death/fake death and movement disable 
		else if(activeChar.isMovementDisabled() || activeChar.isAlikeDead())
		{	activeChar.sendMessage("You can't Delevel on death mode");
			return false; 
		}
		// Check if activeChar is in Siege
		else if(siege != null && siege.getIsInProgress())
		{
			activeChar.sendMessage("You are in siege, you can't Delevel.");
			return false;
		}
		// Check if activeChar is a Cursed Weapon owner
		else if(activeChar.isCursedWeaponEquiped())
		{
			activeChar.sendMessage("You can't Delevel! You are currently holding a cursed weapon.");
			return false;
		}
		// Check if activeChar is in Duel
		else if(activeChar.isInDuel())
		{
			activeChar.sendMessage("You can't Delevel You are in a duel!");
			return false;
		}
		// Check is in DimensionsRift
		else if(activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
		{
			activeChar.sendMessage("You can't Delevel! You are in the dimensional rift.");
			return false;
		}
		// Check to see if the activeChar is in an event
		else if(activeChar.isInFunEvent())
		{
			activeChar.sendMessage("You can't Delevel! You are in event now.");
			return false;
		}
		// Check activeChar is in Olympiade
		else if(activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() != -1)
		{
			activeChar.sendMessage("You can't Delevel! Your are fighting in Olympiad!");
			return false;
		}
		// Check activeChar is in observer mode
		else if(activeChar.inObserverMode())
		{
			activeChar.sendMessage("You can't Delevel in Observer mode!");
			return false;
		}
		// Check activeChar have karma/pk/pvp status
		if(activeChar.getKarma() > 0 || activeChar.getPvpFlag() > 0)
		{
			activeChar.sendMessage("player in PVP or with Karma can't use the Delevel command!");
			return false;
		}			
		// Check if activeChar have no one in target
		else if(activeChar.getTarget() == null)
		{
			activeChar.sendMessage("You can't have any one in your target when Delevel only your self.");
			return false;
		}
		// If activeChar have not any of theis can delevel
		delevelstart(activeChar);
		return true;
	}

public boolean delevelstart(L2PcInstance activeChar)
{
	try
	{
		double actual_hp = activeChar.getCurrentHp();
		double actual_cp = activeChar.getCurrentCp();				
		int max_level = ExperienceData.getInstance().getMaxLevel();				
		// Protections
		Integer returnToLevel = Config.DELEVEL_TO_LEVEL;
		if (returnToLevel < 1)
			returnToLevel = 1;
		if (returnToLevel > max_level)
			returnToLevel = max_level;				
		// Resets character to first class.
		activeChar.setClassId(activeChar.getBaseClass());				
		activeChar.broadcastUserInfo();				
		final byte lvl = Byte.parseByte(returnToLevel + "");				
		final long pXp = activeChar.getStat().getExp();
		final long tXp = ExperienceData.getInstance().getExpForLevel(lvl);		
		if (pXp > tXp)
		{
			activeChar.getStat().removeExpAndSp(pXp - tXp, 0);
		}
		else if (pXp < tXp)
		{
			activeChar.getStat().addExpAndSp(tXp - pXp, 0);
		}
		// Remove the activeChar's current skills.
		for (L2Skill skill : activeChar.getAllSkills())
		{
			activeChar.removeSkill(skill);
		}
		// Give activeChars their eligible skills.
		activeChar.giveAvailableSkills();		
		// restore Hp-Mp-Cp
		activeChar.setCurrentCp(actual_cp);
		activeChar.setCurrentMp(activeChar.getMaxMp());
		activeChar.setCurrentHp(actual_hp);
		activeChar.broadcastStatusUpdate();
		// Updates the activeChar's information in the Character Database.
		activeChar.store();
		// Update skill list
		activeChar.sendSkillList();
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	return true;
}

@Override
public String[] getVoicedCommandList()
{
	return VOICED_COMMANDS;
}

}

Το κανουμε save :) μετα παμε στο αρχειο "voicedcommandhandlers.java" οπου θα ειναι ενας φακελος πισω με το ονομα "handler".

αφου ανοιξουμε το αρχειο "voicedcommandhandlers.java" ψαχουμε να βρουμε που κανει "register" τα voicecommands μας,οταν τα βρουμε παμε στο τελευταιο "register" και βαζουμε αυτες τις 4 γραμουλες

	if (Config.DELEVEL_ENABLE)
	{
		registerVoicedCommandHandler(new DelevelCmd());
	}

Aυτο το κανουμε για να διαβασει ο σερβερ την νεα εντολη "delevel".

Αφου ολοκληρωσουμε αυτο το σημειο κανουμε save...Πανε να βρουμε αλλο ενα αρχειο της java με ονομα Config.Java οπου βρισκεται στο root του σερβερ μας παντα...:/Μολις το βρουμε το ανοιγουμε και προσθετουμε αυτους τους κοδικες οπου θα ειναι τα config του "delevel"

                //============================================================
	public static boolean DELEVEL_ENABLE;
	public static int DELEVEL_MIN_LEVEL;
	public static int DELEVEL_TO_LEVEL;
	//============================================================
	public static void loadDELEVELconfig()
	{
		final String DELEVEL_SYSTEM = FService.DELEVEL_FILE;
		try
		{
			Properties DELEVELSettings = new Properties();
			InputStream is = new FileInputStream(new File(DELEVEL_SYSTEM));
			DELEVELSettings.load(is);
			is.close();

			/** Delevel System **/
			DELEVEL_ENABLE= Boolean.parseBoolean(DELEVELSettings.getProperty("Delevel_Enable","False"));
			DELEVEL_MIN_LEVEL = Integer.parseInt(DELEVELSettings.getProperty("Delevel_Min_Level", "80"));
			DELEVEL_TO_LEVEL = Integer.parseInt(DELEVELSettings.getProperty("Delevel_RETURN_TO_LEVEL", "40"));
		}
		catch(Exception e)
		{
			e.printStackTrace();
			throw new Error("Failed to Load " + DELEVEL_SYSTEM + " File.");
		}
	}

μολις κανουμε την εισαγωγει παμε τρεμα κατω σχεδω στο αρχειο Config.java ωστε να δηλωσουμε τις μεταβλητες για να μπορει ο σερβερ να τις ανακαλεσει

αυτο θα το κανουμε με την εισαγωγει αυτης της λεξεις "loadDELEVELconfig();" οπου θα την βαλουμε μαζι με τις αλλες :)

		loadChampionConfig();
		loadWeddingConfig();
		loadREBIRTHConfig();
		loadAWAYConfig();
		loadBankingConfig();
		loadPCBPointConfig();
		loadOfflineConfig();
		loadPowerPack();
		loadVoteSystemConfig();
		loadDELEVELconfig(); <-------θα την βαλουμε

Τελος με το Config.Java ας κανουμε ενα save.

Τωρα παμε να δημιουργισουμε το αρχειο delevel.properties και να δηλωσουμε την διαδρομη του ωστε να αλλαζουμε τα config του delevel command

Για αρχη ας παμε στο αρχειο Fservice.java οπου λογικα θα ειναι στον ιδιο φακελο με το Config.java και το ανουγουμε και βαζουμε αυτον τον κοδικα

public static final String DELEVEL_FILE = "./config/fun/delevel.properties";

κανουμε ενα save!!! Εχουμε τελειωσει με τα java files το μονο που μας μενει ειναι να φτιαξουμε το αρχειο "delevel.properties" και ειμαστε ετοιμη...Για αυτο παμε στον φακελο "Server/config/fun/ και εδω θα φτιαξουμε το αρχειο delevel.properties" διοτι συμφωνα με τον πρωηγουμενο κοδικα εδω δηλωνουμε την παρουσια του εσεις μπορειτε να το πατε αλλου αρκει να το δηλωσεται μετα.. αφου το δημιουργησουμε το ανοιγουμε και βαζουμε αυτα μεσα

# ==================================== #
#            Delevel System            #
# ==================================== #

# Enable Delevel system
# If set it true then allow players to use 
# command .delevel to delevel ther levels
Delevel_Enable = false

# Minimum level for Deleve
Delevel_Min_Level = 80

# Return to level? (Default = 40)
Delevel_RETURN_TO_LEVEL = 40

αυτο ηταν κανουμε ενα save και ειμαστε ετοιμη...Δοκιμασμενο στο δικο μου σερβερ...αν σας εχω μπερδεψει ζητω συγνωμη αλλα ειναι το πρωτο μου share και οσο να πουμε εχω λιγο τρακ :P

 

 

Posted

kali prospa9ia file, ala pistevw oti 9a itane kalitera an to ekanes 3erw go .delevel 60 kai na se kanei 60 lvl

 

nvm, ty for share

Posted

Eyxaristo :) polu file m gia ayto exw kanei kai to arxeio delevel.properties gia na to ri9mizoyn apo kei ;) yparxoun polles parages kai ides

  • 3 weeks later...
  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • This update resaves 25_25 from the original (with sounds) (without the cave below) Some emitter fixes (removed waterfalls with high-poly meshes) The geodata is old, but it works Everything else is unchanged Download P.S. The effect files are taken from the high client for Interlude, so if you're experiencing critical skills, use the default ones for your Version.  
    • GX-Ext Which file of the svn files should i edit to make blow skills to have 100% chance so i can add the settings in the IlExt.ini? because when im changing it from the skilldata.txt it just helps
    • 我们感谢您的 反馈 并希望让服务变得更加 优秀! 如果您使用过我们的服务并愿意分享您的体验(任何体验——积极或建设性),请在Trustpilot上留下评价,并获得$1作为感谢。 链接: https://www.trustpilot.com/review/socnet.pro 如何获得奖励: 1. 前往Trustpilot并留下您的评价 2. 向我们发送发布确认截图,以及带有与评价用户名一致的授权账户截图。 3. 指定哪个商店应收到这 $1 奖励。根据商店不同,可能需要您的用户名/电子邮箱。 您的反馈帮助我们成长,并让项目对社区中的每一位成员变得更好。感谢您与我们同行! 条款: 此活动仅适用于一个唯一用户。不允许多账号行为。 项目有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram 方便访问商店。 虚拟号码服务: 前往 用于购买 Telegram Stars 的 Telegram 机器人: 前往 – 在 Telegram 中快捷且优惠地购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们想向您展示当前的 促销和特别优惠列表 用于购买我们提供的产品与服务: 1. 您可在首次购买时使用优惠码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣——只需在我们网站注册后,按照模板填写您的用户名:“SEND ME BONUS, MY USERNAME IS...”并在我们的论坛主题中发布! 3. 首次启动 SMM 面板可获得 $1:只需在我们的网站(Support)提交主题为 “Get Trial Bonus” 的工单。 4. 我们的 Telegram 频道以及 Stars 购买机器人中每周都有 Telegram Stars 抽奖! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock