⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cipserver.java

📁 笑傲江湖用JAVA开发的网络小游戏采用CS开发模式开发的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		gl.setConstraints(labelSendTR,gbc);
		//panelMain.add(labelSendTR);
		
		gbc.gridwidth=1;
		gl.setConstraints(textSendTR,gbc);
		panelMain.add(textSendTR);
		
		gbc.gridwidth=1;
		gbc.weightx=0.3;
		gbc.weighty=0;
		gl.setConstraints(buttonSendTR,gbc);
		panelMain.add(buttonSendTR);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(buttonSendQZTR,gbc);
		panelMain.add(buttonSendQZTR);
		
		gbc.weightx=0;
		gbc.weighty=0;
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(labelSendSetAdmin,gbc);
		panelMain.add(labelSendSetAdmin);
		
		gbc.gridwidth=1;
		gl.setConstraints(textSendSetAdmin,gbc);
		panelMain.add(textSendSetAdmin);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(buttonSendSetAdmin,gbc);
		panelMain.add(buttonSendSetAdmin);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(textSL,gbc);
		panelMain.add(textSL);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(textPM,gbc);
		panelMain.add(textPM);
		
		gbc.gridwidth=1;
		gl.setConstraints(labelKB,gbc);
		panelMain.add(labelKB);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(textSuperAdminPass,gbc);
		panelMain.add(textSuperAdminPass);
		
		gbc.gridwidth=1;
		gl.setConstraints(buttonSendClsSLPM,gbc);
		panelMain.add(buttonSendClsSLPM);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(buttonSendCls,gbc);
		panelMain.add(buttonSendCls);
		
		gbc.gridwidth=1;
		gl.setConstraints(buttonSendQTR,gbc);
		panelMain.add(buttonSendQTR);
		
		gbc.gridwidth=GridBagConstraints.REMAINDER;
		gl.setConstraints(buttonSendClose,gbc);
		panelMain.add(buttonSendClose);
		
		//panelMain.add(panelOperation);
		
		buttonSendAD.addActionListener(this);
		buttonSendPMAll.addActionListener(this);
		buttonSendU238.addActionListener(this);
		buttonSendTR.addActionListener(this);
		buttonSendQZTR.addActionListener(this);
		buttonSendQTR.addActionListener(this);
		buttonSendSetAdmin.addActionListener(this);
		buttonSendClsSLPM.addActionListener(this);
		buttonSendCls.addActionListener(this);
		buttonSendClose.addActionListener(this);
		
		frameMain.setSize(600,570);
		frameMain.setVisible(true);
		
		//frameMain.setDefaultCloseOperation(frameMain.EXIT_ON_CLOSE);
		frameMain.setDefaultCloseOperation(0);
		
		text.setEditable(false);
		textSL.setEditable(false);
		textPM.setEditable(false);
		
		try
		{
			server=new ServerSocket(setUsePost);
			serverThread=new Thread(this);
			serverThread.start();
			InetAddress address=InetAddress.getLocalHost();
			text.append("("+dateSystemTime+")"+"【祝贺笑傲江湖】服务器测试版v1.0"+"\n");
			text.append("("+dateSystemTime+")"+"制作:欧阳山 测试:欧阳山 瞿亚初"+"\n");
			text.append("("+dateSystemTime+")"+"技术支持:congsoft@yahoo.com.cn"+"\n");
			text.append("("+dateSystemTime+")"+"江湖总站:http://cxajh.126.com"+"\n");
			text.append("("+dateSystemTime+")"+"官方网站:http://oysoys.126.com"+"\n");
			text.append("("+dateSystemTime+")"+"官方论坛:http://bbscip.126.com"+"\n");
	        text.append("("+dateSystemTime+")"+address+"\n");
	        text.append("("+dateSystemTime+")"+"江湖服务器主机名称:"+address.getHostName()+"\n");
	        text.append("("+dateSystemTime+")"+"江湖服务器IP地址:"+address.getHostAddress()+"\n");
	        text.append("("+dateSystemTime+")"+"江湖服务器端口是:"+setUsePost+"\n");
	        text.append("("+dateSystemTime+")"+"江湖六扇门掌门(即:江湖站长):CIP\n");
			text.append("("+dateSystemTime+")"+"江湖管理员:"+adminAll+"\n");
			text.append("("+dateSystemTime+")"+"江湖服务器启动成功!监听客户端连接中..."+"\n");
			textSL.append("("+dateSystemTime+")"+"〖私聊〗监视..."+"\n");
			textPM.append("("+dateSystemTime+")"+"〖千里传音〗监视..."+"\n");
			autoSave();
		}
		catch(BindException e)
		{
			calendar=new GregorianCalendar();
			dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			text.append("("+dateSystemTime+")"+"服务器启动失败!请确定当前没有启动其它服务器!或者请换个端口试试!谢谢!");
			autoSave();
			return;
		}
		catch(IOException e){System.out.println("server=new ServerSocket(1001); IOException\n"+e);}
		list.clear();
		list.addItem("当前有0人连接服务器");
		System.out.println("6");
		list.addItem("在聊天室内的在线列表");
		System.out.println("7");
		list.addItem("——————————");
		String stringAutoSaveAddOnlineUser="";
		for (int i=0;i<list.getItemCount();i++)
		{
			stringAutoSaveAddOnlineUser=stringAutoSaveAddOnlineUser+"|"+list.getItem(i);
		}
		autoSaveAddOnlineUser(stringAutoSaveAddOnlineUser);
	}
	public void run()
	{
		try
		{
			while(true)
			{
				fromClient=server.accept();
				Connect con=new Connect(this,fromClient,onlineuser);
				//onlineuser.addElement(con);
			}
		}
		catch(IOException e){System.out.println("fromClient=server.accept(); IOException\n"+e);}
	}
	public void displayOnlineUser(String operation,String user)
	{
		System.out.println("1");
		/*System.out.println("在线列表");
		System.out.println("--------");*/
		System.out.println(onlineuser.size());
		System.out.println("2");
		list.clear();
		System.out.println("3");
		OnlineUser onlineuserlist=new OnlineUser();
		System.out.println("4");
		String stringOnlineUserList="";
		System.out.println("5");
		//list.addItem("      在线列表 ");
		list.addItem("当前有"+onlineuser.size()+"人连接服务器");
		int onlineuserI=onlineuser.size();
		System.out.println("6");
		list.addItem("在聊天室内的在线列表");
		System.out.println("7");
		list.addItem("——————————");
		System.out.println("8");
		for(int i=0;i<onlineuserI;i++)
		{
			onlineuserI=onlineuser.size();
			System.out.println("9");
			Connect obj2=(Connect)onlineuser.elementAt(i);
			System.out.println("10");
			list.addItem(obj2.custName);
			System.out.println("11");
			stringOnlineUserList=obj2.custName;
			System.out.println("12");
			onlineuserlist.OnlineUserList=onlineuserlist.OnlineUserList+"|"+stringOnlineUserList;
			if (operation.equals("Login"))
				onlineuserlist.newuser=stringOnlineUserList;
			else if(operation.equals("Exit"))
				onlineuserlist.exituser=user;
			else if(operation.equals("QZTR"))
				onlineuserlist.exituser=user;
			onlineuserlist.operation=operation;
			onlineuserlist.custIP=obj2.custIP;
			System.out.println("13");
			System.out.println(onlineuserlist.OnlineUserList);
			System.out.println("14");
		}
		try
		{
			System.out.println("15");
			for(int i=0;i<onlineuser.size();i++)
			{

				System.out.println("16");
				Connect obj3=(Connect)onlineuser.elementAt(i);
				if (obj3.custName.equals(user))
				{
					onlineuserlist.Q="〖";
					onlineuserlist.H="〗";
				}
				System.out.println("17");
				obj3.objectOut.writeObject(onlineuserlist);
				System.out.println("18");
			}
		}
		catch(IOException e){System.out.println("displayOnlineUser IOException\n"+e);}
		String stringAutoSaveAddOnlineUser="";
		for (int i=0;i<list.getItemCount();i++)
		{
			stringAutoSaveAddOnlineUser=stringAutoSaveAddOnlineUser+"|"+list.getItem(i);
		}
		autoSaveAddOnlineUser(stringAutoSaveAddOnlineUser);
	}
	
	public void Send_AD(String ADMessage)
	{
		AD ad=new AD();
		String SystemAD="";
		SystemAD=ADMessage;
		if (SystemAD.length()==0)
		{
			SystemAD="";
			JOptionPane.showMessageDialog(null,"系统公告不能为空!");
		}
		else
		{
			calendar=new GregorianCalendar();
			dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			text.append("("+dateSystemTime+")"+"系统公告发布成功!刚才发布的系统公告内容为:"+SystemAD+"\n");
			autoSaveAddSuperOperation("("+dateSystemTime+")"+"系统公告发布成功!刚才发布的系统公告内容为:"+SystemAD);
			autoSave();
			ad.AD=SystemAD;
			SystemADall=SystemAD;
			try
			{
				for(int i=0;i<onlineuser.size();i++)
				{
					Connect objAD=(Connect)onlineuser.elementAt(i);
					objAD.objectOut.writeObject(ad);
					objAD.objectOut.flush();
				}
			}
			catch(IOException e){System.out.println("Send_AD IOException\n"+e);}
		}
	}
	public void Send_PMAll(String PMAllMessage)
	{
		if (PMAllMessage.length()==0)
		{
			PMAllMessage="";
			JOptionPane.showMessageDialog(null,"群千里传音不能为空!");
		}
		else
		{
			PM obj=new PM();
			obj.fromwho="CIP";
			obj.towho="";
			obj.PMinformation=PMAllMessage;
			obj.PMXQ="";
			calendar=new GregorianCalendar();
			dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			text.append("("+dateSystemTime+")"+"群千里传音发布成功!刚才发布的群千里传音内容为:"+PMAllMessage+"\n");
			autoSaveAddSuperOperation("("+dateSystemTime+")"+"群千里传音发布成功!刚才发布的群千里传音内容为:"+PMAllMessage);
			autoSave();
			try
			{
				for(int i=0;i<onlineuser.size();i++)
				{
					Connect objPM=(Connect)onlineuser.elementAt(i);
					objPM.objectOut.writeObject(obj);
					objPM.objectOut.flush();
				}
			}
			catch(IOException e){System.out.println("client_Chat IOException\n"+e);}
		}
	}
	public void Send_U238(String U238Message)
	{
		U238 u238=new U238();
		String SystemU238=U238Message;
		if (SystemU238.length()==0)
		{
			SystemU238="";
			JOptionPane.showMessageDialog(null,"目标错误!投〖特大核能飞弹〗失败!");
		}
		else
		{
			calendar=new GregorianCalendar();
			dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			text.append("("+dateSystemTime+")"+"投〖特大核能飞弹〗成功!刚才您投给的人是:"+SystemU238+"\n");
			autoSaveAddSuperOperation("("+dateSystemTime+")"+"投〖特大核能飞弹〗成功!刚才您投给的人是:"+SystemU238);
			autoSave();
			u238.FromName="";
			u238.U238=SystemU238;
			u238.U238N=99999;
			u238.U="1";//1表示为:投特大核能飞弹
			u238.WhatOperation="原子弹";
			try
			{
				for(int i=0;i<onlineuser.size();i++)
				{
					Connect objAD=(Connect)onlineuser.elementAt(i);
					objAD.objectOut.writeObject(u238);
					objAD.objectOut.flush();
				}
			}
			catch(IOException e){System.out.println("Send_U238 IOException\n"+e);}
		}
	}
	
	public void Send_TR(String TRMessage,String twho,String YNQZTR)
	{
		U238 u238=new U238();
		String SystemU238=TRMessage;
		if (((SystemU238.length()==0)&&(!(twho.equals("all"))))||(SystemU238.equals("cip")))
		{
			SystemU238="";
			JOptionPane.showMessageDialog(null,"目标错误!踢人失败!");
		}
		else
		{
			calendar=new GregorianCalendar();
			dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
			if (twho.equals("all"))
			{
				text.append("("+dateSystemTime+")"+"群踢人成功!除了六扇门掌门CIP无法群踢以外!其它的所有人均被踢出江湖了!\n");
				autoSaveAddSuperOperation("("+dateSystemTime+")"+"群踢人成功!除了六扇门掌门CIP无法群踢以外!其它的所有人均被踢出江湖了!");
			}
			else
			{
				if (YNQZTR.equals("1"))
				{
					text.append("("+dateSystemTime+")"+"强制踢人成功!您刚才强制踢的人是:"+SystemU238+"\n");
					autoSaveAddSuperOperation("("+dateSystemTime+")"+"强制踢人成功!您刚才强制踢的人是:"+SystemU238);
				}
				else
				{
					text.append("("+dateSystemTime+")"+"踢人成功!您刚才踢的人是:"+SystemU238+"\n");
					autoSaveAddSuperOperation("("+dateSystemTime+")"+"踢人成功!您刚才踢的人是:"+SystemU238);
				}
			}
			autoSave();
			u238.FromName="";
			u238.U238=SystemU238;
			u238.U238N=99999;
			u238.Twho=twho;
			u238.WhatOperation="踢人";
			u238.YNQZTR="0";
			if (YNQZTR.equals("1"))
			{
				u238.YNQZTR="1";
			}
			try
			{
				for(int i=0;i<onlineuser.size();i++)
				{
					Connect objAD=(Connect)onlineuser.elementAt(i);
					objAD.objectOut.writeObject(u238);
					objAD.objectOut.flush();
				}
				if (YNQZTR.equals("1"))
				{
					for(int i=0;i<onlineuser.size();i++)
					{
						Connect objAD=(Connect)onlineuser.elementAt(i);
						if (objAD.custName.equals(TRMessage))
						{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -