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

    • the links are offiline, could you reupload them please, if you have other versions of h5 or c6 could you share them too, thanks!
    • Good afternoon everyone, we’ll get a couple of strong players in the CP, more details can be found here https://mw2.community/topic/211276-awr-team/  
    • so i bought this crap of the server few years back and i just found it laying around on my pc and i thought i should share it, if i remember correctly this crap has a lot of bugs that people abuse 🙂   https://drive.google.com/file/d/13QWg8pi4BPbGbTmlygZ078LjL6Fb0J2a/view?usp=sharing source   https://drive.google.com/file/d/13QWg8pi4BPbGbTmlygZ078LjL6Fb0J2a/view?usp=sharing system    
    • Error: Unable to access jarfile libs\Geodata_Converter_v01.jar
    • Since last massive leak as explained as 07/09 (notably all development branches), I don't accept anymore financial newcomers that easily. People will have to contribute 100 cookies worth of contributions (bug reports/fixes) as a first step to be accepted as Donator. Free user can join after sharing over 200 cookies out of contributions, compared to 100 cookies before. You can say thanks to RusAcis, and notably his worthless leader, UnleashedForce. The size of users will continue to shrink if more leaks occur, until true helpers only will be left. New prices are as following : Joining price: 200€ + 100 cookies, or 200 cookies This fee has to be paid if you are joining aCis project. Next month, and all other months, you will have to donate only basic monthly donation. Monthly price: 10€ / 10 cookies This fee has to be paid every month. I won't accept any new join fee before the 100 cookies contribution. Your money will be instantly sent back. Also, in the same shape of idea, actual supporters/donators have to be active to stay in sources. It doesn't have to be a particular amount, you just have to share from time to time *anything*. I don't accept anymore silent ppl. Only useful people will be kept.
  • Topics

×
×
  • Create New...