Jump to content
  • 0

Code Doesnt Work ... Help 2 Min Of Your Time :)


SQL Developer

Question

Hey can someone fix for me this code .. i use L2JFrozen latest version

===================================================================
--- head-src/com/l2jfrozen/gameserver/handler/itemhandlers/VipItem.java	(revision 0)
+++ head-src/com/l2jfrozen/gameserver/handler/itemhandlers/VipItem.java	(working copy)
@@ -0,0 +1,145 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfrozen.gameserver.handler.itemhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import com.l2jfrozen.Config;
+import com.l2jfrozen.gameserver.handler.IItemHandler;
+import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
+import com.l2jfrozen.util.CloseUtil;
+import com.l2jfrozen.util.database.L2DatabaseFactory;
+
+/**
+ * @author Crystalia
+ *
+ */
+public class VipItem implements IItemHandler
+{
+
+	private static final int ITEM_IDS[] = {
+        6673
+    };
+
+	@Override
+	public int[] getItemIds()
+    {
+        return ITEM_IDS;
+    }
+
+	private void updateDatabase(L2PcInstance player, boolean newDonator)
+	{
+		Connection con = null;
+		try
+		{
+			// prevents any NPE.
+			// ----------------
+			if(player == null)
+				return;
+
+			// Database Connection
+			//--------------------------------
+			con = L2DatabaseFactory.getInstance().getConnection(false);
+			PreparedStatement stmt = con.prepareStatement(newDonator ? INSERT_DATA : DEL_DATA);
+
+			// if it is a new donator insert proper data
+			// --------------------------------------------
+			if(newDonator)
+			{
+				stmt.setInt(1, player.getObjectId());
+				stmt.setString(2, player.getName());
+				stmt.setInt(3, player.isHero() ? 1 : 0);
+				stmt.setInt(4, player.isNoble() ? 1 : 0);
+				stmt.setInt(5, 1);
+				stmt.execute();
+				stmt.close();
+				stmt = null;
+			}
+			else
+			// deletes from database
+			{
+				stmt.setInt(1, player.getObjectId());
+				stmt.execute();
+				stmt.close();
+				stmt = null;
+			}
+		}
+		catch(Exception e)
+		{
+			if(Config.ENABLE_ALL_EXCEPTIONS)
+				e.printStackTrace();
+			
+			
+		}
+		finally
+		{
+			CloseUtil.close(con);
+		}
+	}
+
+	// Updates That Will be Executed by MySQL
+	// ----------------------------------------
+	String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator) VALUES (?,?,?,?,?)";
+	String DEL_DATA = "UPDATE characters_custom_data SET donator = 0 WHERE obj_Id=?";
+	
+	@Override
+	public void useItem(L2PlayableInstance playable, L2ItemInstance item)
+	{
+		if(!(playable instanceof L2PcInstance))
+            return;
+        L2PcInstance activeChar = (L2PcInstance)playable;
+        
+        	if(activeChar.isDonator())
+        	{
+        	activeChar.sendMessage("You are already a donator.You cannot use that item.");
+        	return;
+        	playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
+        	activeChar.setDonator(true);
+        	updateDatabase(activeChar, true);
+        	activeChar.sendMessage("Thanks for using our item in order to be server's donator.");
+            activeChar.broadcastUserInfo();
+        
+		
+	}
+	
+}
\ No newline at end of file

Problem is :

    [javac] C:\Users\George\workspace\trunk\gameserver\head-src\com\l2jfrozen\gameserver\handler\itemhandlers\VipItem.java:119: error: reached end of file while parsing
    [javac] }
    [javac]  ^
    [javac] 1 error
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Done and new error come out of the box ...

  [javac] C:\Users\George\workspace\trunk\gameserver\head-src\com\l2jfrozen\gameserver\handler\itemhandlers\VipItem.java:110: error: unreachable statement
    [javac]         	playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
    [javac]         	^
    [javac] 1 error

what is wrong -.- bad bad bad code

Link to comment
Share on other sites

  • 0

Between return; and playable.Destroy put an "else"

 

return;

else

:

:

:

 

This might fix it. Note: I'm not an l2j Developer, just helping since you asked me to do so.

Link to comment
Share on other sites

  • 0
+     if(activeChar.isDonator())
+     {
+     activeChar.sendMessage("You are already a donator.You cannot use that item.");
+     return;
+     playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
+     activeChar.setDonator(true);
+     updateDatabase(activeChar, true);
+     activeChar.sendMessage("Thanks for using our item in order to be server's donator.");
+ activeChar.broadcastUserInfo();

The donator check is not closed.

     if(activeChar.isDonator())
     {
     activeChar.sendMessage("You are already a donator.You cannot use that item.");
     return;
+    }
     playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
     activeChar.setDonator(true);
     updateDatabase(activeChar, true);
     activeChar.sendMessage("Thanks for using our item in order to be server's donator.");
 activeChar.broadcastUserInfo();

And this updateDatabase is kinda bleh, but w/e.. :P

 

 

Btw, if you add that bracket, there might be an error since you added it before at the end of the file and Ninja suggested. So, remove it.

Edited by SweeTs
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • From my personal experiences 🙂   Few months ago I decided to create my own Essence project. Project needs website, and I do not specialize in frontend development (t.y. i can make web work, but it won't be pretty for eye). So I search and find a guy in Discord, which claims he can make me a good looking HTML website for 30 EUR, prove some screenshots from his previous work. I agree. 1 week later, I get my HTML website, make few changes to contents, update URLs and upload it to FTP. Site looks good, I am happy that this headache is no more.   Few months passes. I randomly crawl through other Essence server websites scouting for good ideas for my own project. Suddenly one of russians project website opens and.. it's the same website as one I have 😉 perfectly absolutely same layout, colours, etc etc etc. I contact my guy to ask what the hell, to get blocked 😉  So I find a weekend worth of my time. Find HTML5 boilerplate generator and ask it to include Bootstrap 5 and some other stuff. Open Bootstrap documentation, drink two energy drinks on instant and start working my backend-inspired HTML black magic... Once I found suiting firefly effect for header, result looked oikay for me: Absolutely no magic or beauty here, but: * Unique (and probably nobody cares to rip it) * Done for free in ~10 hours by non-frontend dev * Most modern browsers friendly * Completely static content, loads instantly. No PHP at all * Sidebar statuses (online, pvp, pk) are pulled from account manager REST API endpoint and is cached for 5 minutes. Account manager runs separately from website frontend and has access to server DB. Where could/will it get better? * Code in Vue instead of HTML - time concerns only, but Vue is superior compared to HTML/PHP for supporting desktop/mobile, easing development by miles. Need to learn how to use it properly. * Way to manage content from backend - in my instance I think account manager is not really meant for that. Vue can help here too - there are components for content building. * Currently default Bootstrap components are used. Would be nice to have custom and more vibrant buttons. Guess what, Vue can help here too.   tl;dr don't buy 30EUR website, it will be ripped or shit. you better make your own website. Be curious. I am backend developer, I obviously have general idea how frontend works. But imho everyone who can make L2 server by editing NPC HTMLs, also can make their own simple website. ChatGPT and other AIs are your friends. Bootstrap. jQuery documentations are your friends. And when you feel good and comfortable with HTML, if you like, you can continue learning Vue, or going backend. Now, as for the top sites. You really need to invest money to make new project work. I mean really, really much money. For this concept to work, top website itself must get visited. But if you can sort that your top site would be popular amongst players, then it's a really very simple concept, as far as current 2004-ish sites goes. I think simple, working concept of this, maybe without proper frontend, but with implemented backend logics (add/edit/disable server, sort by votes count (top list), vote for server with verification, callback to server endpoint - all of that can be done using Symfony in mostly 5 days, with lots of breaks for coffee and a smoke 😉. Experienced mid frontend dev would make a Vue/React frontend for it in another 5 days. it's really really simple concept 🙂  
    • Need cheap aged discord accounts ? :  https://campsite.bio/utchihaamkt DISCORD USERNAME : utchiha_market TELEGRAM : https://t.me/utchiha_market Discover new products in our exclusive server today : https://discord.gg/hoodservices
  • Topics

×
×
  • Create New...