Jump to content

[Gr]Delevel Command For Interlude With Protect


Recommended Posts

Καλησπεριζω τα μελη του 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

 

 

Link to comment
Share on other sites

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • add <aCar name="admin_search" accessLevel="7" params="" desc=""/> to data/xml/adminCommands
    • Instead of using encedc on it, try renaming it to "Icon.u" instead of "Icon.utx", and put it in your System folder. If it still crashes, the problem might be with your unrealed.
    • How's the project doing? Is there any news? It really interesting 🤔
    • thx for answer, i tried and woks encrypting, but i still having crashes 😞 i changed the icon in skillgrp.dat from "icon.skill0003" to "Myicons.misil" as i saved the file before endec and nothing. this is the report i got
    • New Season coming May 2024! First post updated      Website: L2Kain.net  Discord: https://discord.gg/l2kain  Wiki: https://info.kain.ws/   Important Dates   Server Start: TBD  Open Beta Test: 10th of May 2024!   Basic Information     Briefly about the concept of the server! We decided to move away from the standard Mid-Rate server concept and keep the mechanics of our beloved Lineage 2 that everyone loves! Massive battles for epic bosses, battles for profitable farming locations, resource spoilage and equipment crafting, daily instances, a balanced economy and much more. This server is build as a Craft-PvP concept. The goal is to gather players with a variety of preferences in the game and make a high-quality and interesting server with alternative character development options. We are well aware that "grinding" is an integral part of the game, but we diluted the boring and the same type of farming with interesting solutions and non-standard mechanics!   We have prepared a new High Five x25 on Modern Client for you. This server will be another step in the development of the platform and the project as a whole! Your appeals to those. support was not ignored, which means the new server will be even better than the previous one!      ⭐ Promotions and Bonuses for new players!     ⭐ Events and Giveaways daily!   ⭐ Rewards for Voting!   ℹ️ Server Rates Learn more about server rates! Server rates are configured in such a way that farming is best rewarded. Adena, drops, quests, various rewards and prices in the game store are well balanced among themselves!   Basic Server Rates:  ⭐ Experience & Skill Points - x25  ⭐ Adena Drop - x15 & Fixed Chance 66%  ⭐ Drop Rates - x10  ⭐ Spoil Rates - x10   Crafting keys, recipes drop & spoil with fixed amount from 2 to 3 and increased chances on all locations and quests  related to farm them.  ⭐ Quest Rates - x5  ⭐ Fortresses & Sieges - x5  ⭐ Raid Bosses & Epic Bosses - x1  ⭐ Weight Limit - x10      Connect with Us:  Discord: https://discord.gg/l2kain  Facebook: https://www.facebook.com/KainLineage2  TikTok: https://www.tiktok.com/@l2kain.net  YouTube: https://www.youtube.com/@Lineage2Kain
  • Topics

×
×
  • Create New...