Jump to content

Recommended Posts

Posted (edited)

Well i had 30 minute free so i coded a faction for aCis, in which you can set unlimited factions no just 2.

The code contain the Npc Instance, exceptions and stuff like that.  I will update the code more soon.. 

 

Ps. i havent tested or idk if it works in some part so if you want apply the patch and write me.. 

 

Code here

 

Update 2.0 Code

Update 3.0 Code (Optimized code, fixed some things, added reward with no config yet) 18/1/2016

 

Sql files: 

/*
MySQL Data Transfer
Source Host: localhost
Source Database: acis
Target Host: localhost
Target Database: acis
Date: 17/1/2017 6:47:13 μμ
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for faction
-- ----------------------------
DROP TABLE IF EXISTS `faction`;
CREATE TABLE `faction` (
  `factionId` int(5) DEFAULT NULL,
  `factionName` text,
  `factionPos` text,
  `factionColor` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records 
-- ----------------------------
INSERT INTO `faction` VALUES ('1', 'Angels', '555;555;5555', 00FF00);
INSERT INTO `faction` VALUES ('2', 'Demons', '5125;51251;512', FF0000);

/*
MySQL Data Transfer
Source Host: localhost
Source Database: acis
Target Host: localhost
Target Database: acis
Date: 17/1/2017 6:48:01 μμ
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for characters
-- ----------------------------
DROP TABLE IF EXISTS `characters`;
CREATE TABLE `characters` (
  `account_name` varchar(45) DEFAULT NULL,
  `obj_Id` int(10) unsigned NOT NULL DEFAULT '0',
  `char_name` varchar(35) NOT NULL,
  `level` tinyint(3) unsigned DEFAULT NULL,
  `maxHp` mediumint(8) unsigned DEFAULT NULL,
  `curHp` mediumint(8) unsigned DEFAULT NULL,
  `maxCp` mediumint(8) unsigned DEFAULT NULL,
  `curCp` mediumint(8) unsigned DEFAULT NULL,
  `maxMp` mediumint(8) unsigned DEFAULT NULL,
  `curMp` mediumint(8) unsigned DEFAULT NULL,
  `face` tinyint(3) unsigned DEFAULT NULL,
  `hairStyle` tinyint(3) unsigned DEFAULT NULL,
  `hairColor` tinyint(3) unsigned DEFAULT NULL,
  `sex` tinyint(3) unsigned DEFAULT NULL,
  `heading` mediumint(9) DEFAULT NULL,
  `x` mediumint(9) DEFAULT NULL,
  `y` mediumint(9) DEFAULT NULL,
  `z` mediumint(9) DEFAULT NULL,
  `exp` bigint(20) unsigned DEFAULT '0',
  `expBeforeDeath` bigint(20) unsigned DEFAULT '0',
  `sp` int(10) unsigned NOT NULL DEFAULT '0',
  `karma` int(10) unsigned DEFAULT NULL,
  `pvpkills` smallint(5) unsigned DEFAULT NULL,
  `pkkills` smallint(5) unsigned DEFAULT NULL,
  `clanid` int(10) unsigned DEFAULT NULL,
  `race` tinyint(3) unsigned DEFAULT NULL,
  `classid` tinyint(3) unsigned DEFAULT NULL,
  `base_class` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `deletetime` bigint(20) DEFAULT NULL,
  `cancraft` tinyint(3) unsigned DEFAULT NULL,
  `title` varchar(16) DEFAULT NULL,
  `rec_have` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `rec_left` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `accesslevel` mediumint(9) DEFAULT '0',
  `online` tinyint(3) unsigned DEFAULT NULL,
  `onlinetime` int(11) DEFAULT NULL,
  `char_slot` tinyint(3) unsigned DEFAULT NULL,
  `lastAccess` bigint(20) unsigned DEFAULT NULL,
  `clan_privs` mediumint(8) unsigned DEFAULT '0',
  `wantspeace` tinyint(3) unsigned DEFAULT '0',
  `isin7sdungeon` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `punish_level` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `punish_timer` int(10) unsigned NOT NULL DEFAULT '0',
  `power_grade` tinyint(3) unsigned DEFAULT NULL,
  `nobless` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `hero` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `subpledge` smallint(6) NOT NULL DEFAULT '0',
  `last_recom_date` bigint(20) unsigned NOT NULL DEFAULT '0',
  `lvl_joined_academy` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `apprentice` int(10) unsigned NOT NULL DEFAULT '0',
  `sponsor` int(10) unsigned NOT NULL DEFAULT '0',
  `varka_ketra_ally` tinyint(4) NOT NULL DEFAULT '0',
  `clan_join_expiry_time` bigint(20) unsigned NOT NULL DEFAULT '0',
  `clan_create_expiry_time` bigint(20) unsigned NOT NULL DEFAULT '0',
  `death_penalty_level` smallint(5) unsigned NOT NULL DEFAULT '0',
  `factionid` int(5) DEFAULT '0',
  PRIMARY KEY (`obj_Id`),
  KEY `clanid` (`clanid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Npc Html (for test):

<html><head><body><center>
<font color=AAAAAA>Faction Manager</font><br>
<br>
Welcome, which path are you gonna follow?
<button value="Angels" action="bypass -h npc_%objectId%_1" back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df" width=125 height=21>
<button value="Demons" action="bypass -h npc_%objectId%_2" back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df" width=125 height=21>
<font color="cc9900"><img src="L2UI_CH3.herotower_deco" width=256 height=32></font><br1>
</center>
</body>
</head>
</html>

Edited by AccessDenied
  • Upvote 2
Posted

Time to check some Java 8 stuff

I work in java 7 since i use l2jfreya from 2009 maybe you're right but ill update it anyway. In which part you refer to ?

 

Posted

i will test. thanks for share. +1 :)

np, anything u find report it here. 

 

I'll update it and add dynamic html faction show and reward via xmllization. 

Posted (edited)

Factions on enum.

+   public Collection<L2PcInstance> getFactionPlayers(int id)
+   {
+       Map<Integer, L2PcInstance> players = new ConcurrentHashMap<>();

NONONONONONONONO

Edited by Tryskell
Posted

Factions on enum.

+   public Collection<L2PcInstance> getFactionPlayers(int id)
+   {
+       Map<Integer, L2PcInstance> players = new ConcurrentHashMap<>();

NONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONONONONONONONONONONONONONONONONONJONO

How u suggest it?

Posted (edited)

How u suggest it?

 

Use .stream().filter( or at least a basic List<L2PcInstance>.

 

About Faction enum, I did similar thing for SevenSigns (and I do whenever I can now)

	public enum CabalType
	{
		NORMAL("No Cabal", "No Cabal"),
		DUSK("dusk", "Revolutionaries of Dusk"),
		DAWN("dawn", "Lords of Dawn");
		
		private final String _shortName;
		private final String _fullName;
		
		private CabalType(String shortName, String fullName)
		{
			_shortName = shortName;
			_fullName = fullName;
		}
		
		public String getShortName()
		{
			return _shortName;
		}
		
		public String getFullName()
		{
			return _fullName;
		}
		
		public static final CabalType VALUES[] = values();
	}

which avoid a lot of idiot methods like (or getFactionName, or whatever generic)

+   public Location getFactionLocation(L2PcInstance player)
+   {
+       int factionId = player.getFactionId();
+       Location loc = null;
+      
+       for (FactionHolder faction : factions.values())
+       {
+           if (faction.getFactionId() == factionId)
+           {
+               loc = faction.getFactionLoc();
+           }
+       }
+      
+       return loc;
+   }
Edited by Tryskell
Posted (edited)

I work in java 7 since i use l2jfreya from 2009 maybe you're right but ill update it anyway. In which part you refer to ?

 

First thing I noticed, you can avoid all this:

 

private static class TeleToBase implements Runnable
{


L2PcInstance _player = null;


public TeleToBase(L2PcInstance player)
{
_player = player;
}


@Override
public void run()
{
if (_player !=null)
{
Faction.getInstance().teleToBase(_player);
_player.sendMessage("Have a nice gameplay!");
}
}


}

using a lambda expression:

 

ThreadPoolManager.getInstance().scheduleGeneral(() -> player.teleToLocation(x, y, z), 5000);

 

 

Since you use a singleton on Faction, you should load the factions in a constructor, that's the whole point.

Plus, in loadFaction() method, if (result.next()) should be while (result.next()). But you should use xml for the factions' data.

+	public void teleToBase(L2PcInstance player)
+	{
+		int factionId = player.getFactionId();
+		
+		for (FactionHolder faction : factions.values())
+		{
+			if (faction.getFactionId() == factionId)
+			{
+				Location loc = faction.getFactionLoc();
+				player.teleToLocation(loc, 0);
+			}
+		}
+	} 

Can be done:

+	public void teleToBase(L2PcInstance player)
+	{
+		if (factions.containsKey(player.getFactionId())
+			player.teleToLocation(factions.get(player.getFactionId()).getFactionLoc(), 0);
+	} 

Same thing for onPlayerEnter() and getFactionLocation() (here again you can avoid 2 methods to get the faction's location by making a getFaction() method that can be used in many instances) method.

 

 

On L2FactionInstance, after calling player.setFactionId(), you should store the player in database because in some cases (critical error, dc) the faction he chose isn't going to be saved and he will have to choose again. Use player.store().

Edited by An4rchy
Posted

First thing I noticed, you can avoid all this:

 

private static class TeleToBase implements Runnable
{


L2PcInstance _player = null;


public TeleToBase(L2PcInstance player)
{
_player = player;
}


@Override
public void run()
{
if (_player !=null)
{
Faction.getInstance().teleToBase(_player);
_player.sendMessage("Have a nice gameplay!");
}
}


}

using a lambda expression:

 

ThreadPoolManager.getInstance().scheduleGeneral(() -> player.teleToLocation(x, y, z), 5000);

 

 

Since you use a singleton on Faction, you should load the factions in a constructor, that's the whole point.

Plus, in loadFaction() method, if (result.next()) should be while (result.next()). But you should use xml for the factions' data.

+	public void teleToBase(L2PcInstance player)
+	{
+		int factionId = player.getFactionId();
+		
+		for (FactionHolder faction : factions.values())
+		{
+			if (faction.getFactionId() == factionId)
+			{
+				Location loc = faction.getFactionLoc();
+				player.teleToLocation(loc, 0);
+			}
+		}
+	} 

Can be done:

+	public void teleToBase(L2PcInstance player)
+	{
+		if (factions.containsKey(player.getFactionId())
+			player.teleToLocation(factions.get(player.getFactionId()).getFactionLoc(), 0);
+	} 

Same thing for onPlayerEnter() and getFactionLocation() (here again you can avoid 2 methods to get the faction's location by making a getFaction() method that can be used in many instances) method.

 

 

On L2FactionInstance, after calling player.setFactionId(), you should store the player in database because in some cases (critical error, dc) the faction he chose isn't going to be saved and he will have to choose again. Use player.store().

 

I know i'll change it in V3.0 but im used in Java 7 since i work as i mentionted in old freya revision since 2010

 

make with config for 3.0 update :)

 

Configurations such as? Cause the configs are pretty much those in navicat. Color, name, location e.t.c the only config ill add will be for reward

Posted (edited)

Is this code tested?

Loading Factions from db it will load just the first result from ResultSet.

 

Change if(rs.next()) to while(rs.next())

Edited by `Son
Posted

I know i'll change it in V3.0 but im used in Java 7 since i work as i mentionted in old freya revision since 2010

 

It's not just about the Java 8 I mentioned, you can improve your code in numerous ways, not only those I mentioned.

 

Gl.

Posted (edited)

Is this code tested?

Loading Factions from db it will load just the first result from ResultSet.

 

Change if(rs.next()) to while(rs.next())

 

You just proved that you skipped the 3 lines i wrote. I said the code is not tested so please write me problems e.t.c to update it..

Also yes i saw that it load only 1 faction cause i added if instead of while. ill update it tomorrow along with reward.

 

It's not just about the Java 8 I mentioned, you can improve your code in numerous ways, not only those I mentioned.

 

Gl.

 

I know i could even make it Runnable and no make new class but the lamba expression is exclusively in j8 which i dont use. Habbit

But ill change it tomorrow along with 1-2 mistakes i did

Edited by AccessDenied
Guest
This topic is now closed to further replies.

  • Posts

    • Hi. Can you describe the task in more detail? I think many people here work with IntelliJ IDEA.
    • https://jmp.sh/MaCC5Gqa Combat animation synchronization: Bow/Sword. Added arrow flight and sword-to-monster effects.
    • The holidays are over and we’re back to work (well… we never really stopped 🙂 ). The server has been online without a single restart since December 26, running smoothly and without issues. That’s because we care, and we’ll keep caring. Many of us remember the old days: helping new players, building clans from zero, catching up together, and having fun without rushing. With that spirit in mind, Newbie Bonuses are now live and we strongly encourage everyone to help newcomers catch up and enjoy the journey. L2Elixir was never about short-term hype. It’s about community, stability, and bringing back what made Lineage II special.   🎁 Newbie Bonuses Characters created since December 25 & all new players receive a Newbie Box (Return Hero) (Rune EXP/SP +50% for 5 days, Random 48-hour Costume) 2nd Class Transfer cost reduced from 3kk to 1kk — join Academies! 3rd Class Transfer enabled, available only for classes already in the Hall of Fame. 🛡️ Anti-Bot Implemented BOT-CHECKER v2, more checks, and general improvements. Added extra checks during PvP. New Auto-Check system for suspicious behavior (penalties apply if third-party software is detected). Fixed Bot Report Button not refreshing. ⚙️ General After critical errors or force disconnects, characters will remain No Carrier for a few minutes. Added Cursed Bone to Helvetia (QoL). Enabled on-screen Clan War kill notifications. Fixed buff store issues when entering characters. Fixed party drop owner calculation (please report any issues). 🧙 NPCs Harit Lizardman, Grunt, and Archer now level up SC up to stage 5. 🎉 Events Fixed trigger skills not working during Events. Fixed Health / Shield packs not disappearing in some cases. Fixed summon remaining time not refreshing after Events. Added a second Team vs Team map to reduce routine. Added another Save the King map. Christmas Event cleanup completed. Players in Observe Mode can no longer register for Events. 📜 Quests Fate’s Whisper Fixed and corrected messages. Enchanted B-grade weapons can now be exchanged as per retail. Added missing Social Victory animation on quest completion. 🗺️ Geodata Fixed falling issues in Castle zones.   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs
    • NEW SEASON START 23.01.2026 Get ready for the ultimate High Five adventure on L2Exoplanet.net!   • The last two previous Seasons are now merged into the Core Server. • The Core Server remains our main long-term world. • All future Seasonal Servers will be merged into Core after they end. • No characters or items will be lost – everything stays safe!     GRAND OPENING:  23.01.2026 at 20:00 GMT+1 BETA TEST:    16.01.2026    Client: High Five Rates: x10   Website: https://l2exoplanet.net Facebook: https://www.facebook.com/L2-Exoplanet-106811564103836 Discord: https://discord.gg/4fzhW7ZSPc         Game Rates    Experience: x10  Skill Points: x10  Adena: x5  Drop: x8  Spoil: x8  Quest: x5  Raid Boss Drop: x5  Fame: x2  Epaulette: x8  Manor: x8      Safe Enchant: +3  Maximum Enchant: +16  Normal Scroll Chance: 60%  Blessed Scroll Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%      Game Settings    Multibox - 3 game clients per HWID  Autoloot  Autolearn Skills Auto Farm  NPC Buffer   Buff Slots (24+4/12)  Buff Duration (2h)  Olympiad Period 7days (new heroes appear every monday)  Seven Signs Period  Class Transfer for Adena  Max Sub-Class 3  Sub-Class Max Level 85  Essence Interface  Champions System  Vote Reward System  Dayli Reward System  PC Points Reward (500PC = 1 Donate Coin)      Epic Bosses Respawn Times     Queen Ant:  24 Hours +/- 4 Hours   Beleth: 3 Days +/- 8 Hours   Baium: 3 Days +/- 8 Hours   Antharas: 4 Days +/- 8 Hours   Valakas:  5 Days +/- 8 Hours     Instance Info     Normal Freya = 6 Players   Hard Freya = 12 Players   Frintezza = 6 Players   Zaken 83 Day = 6 Players   Zaken 60 Day = 6 Players   Zaken Nightly = 9 Players   Tiat = 6 Players   Beleth = 12 Players
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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