Example #1
0
		static void
		_handle_def_gm (player *pl, world *w, command_reader& reader)
		{
			if (!reader.has_next ())
		    {
		    	if (!pl->has ("command.world.world.get-perms"))
		    		{
		    			pl->message (messages::not_allowed ());
		    			return;
		    		}
		    	
		      pl->message ("§6Displaying " + w->get_colored_name () + "§e'§6s default gamemode§e:");
		      pl->message ("§7    " + std::string ((w->def_gm == GT_CREATIVE) ? "Creative" : "Survival"));
		      return;
		    }
		  
		  const std::string arg1 = reader.next ().as_str ();
		  if (sutils::iequals (arg1, "set"))
		    {
		    	if (!pl->has ("command.world.world.def-gm"))
		    		{
		    			pl->message ("§c * §7You are not allowed to do that§c.");
		    			return;
		    		}
		    	
		      if (!reader.has_next ())
          	{
          		pl->message ("§c * §7Usage§f: §e/world def-gm set §cnew-def-gm");
          		return;
          	}
          
          std::string val = reader.rest ();
          gamemode_type new_gm = GT_SURVIVAL;
          if (sutils::iequals (val, "survival"))
          	;
          else if (sutils::iequals (val, "creative"))
          	new_gm = GT_CREATIVE;
          else
          	{
          		pl->message ("§c * §7Invalid gamemode§f: §c" + val);
          		return;
          	}
          
          pl->get_world ()->def_gm = (int)new_gm;
          pl->message (w->get_colored_name () + "§f'§es default gamemode has been set to§f:");
          pl->message_spaced ("§f  > §7" + std::string ((new_gm == GT_SURVIVAL) ? "Survival" : "Creative"));
		    }
		  else
		    {
		      pl->message ("§c * §7Invalid sub-command§f: §cdef-gm." + arg1);
		      return;
		    }
		}
Example #2
0
		static void
		_handle_def_inv (player *pl, world *w, command_reader& reader)
		{
			if (!reader.has_next ())
				{
					if (!pl->has ("command.world.world.get-perms"))
		    		{
		    			pl->message (messages::not_allowed ());
		    			return;
		    		}
		    	
		    	pl->message ("§6Displaying " + w->get_colored_name () + "§e'§6s default inventory§e:");
		    	if (!w->use_def_inv)
		    		pl->message ("§7    Default inventory disabled");
		    	else
		    		pl->message ("§7    " + w->def_inv);
		    	return;
				}
			
			std::string arg = reader.next ();
			if (sutils::iequals (arg, "set"))
				{
					if (!pl->has ("command.world.world.def-inv"))
						{
							pl->message (messages::not_allowed ());
							return;
						}
					
					if (!reader.has_next ())
						{
							pl->message ("§c * §7Usage§f: §e/world def-inv set §cdef-inv...");
							return;
						}
					
					w->def_inv = reader.rest ();
					pl->message (w->get_colored_name () + "§f's §edefault inventory has been set to§f:");
					pl->message ("§7 | " + w->def_inv);
				}
			else if (sutils::iequals (arg, "clear"))
				{
					if (!pl->has ("command.world.world.def-inv"))
						{
							pl->message (messages::not_allowed ());
							return;
						}
					
					w->def_inv = "";
					pl->message (w->get_colored_name () + "§f's §edefault inventory has been cleared§f.");
				}
			else if (sutils::iequals (arg, "disable"))
				{
					if (!pl->has ("command.world.world.def-inv"))
						{
							pl->message (messages::not_allowed ());
							return;
						}
					
					if (!w->use_def_inv)
						{
							pl->message ("§c * §7Default inventories are already disabled in this world§c.");
							return;
						}
					
					w->def_inv = "";
					w->use_def_inv = false;
					pl->message ("§eDefault inventories in " + w->get_colored_name () + " §ehave been disabled§f.");
				}
			else if (sutils::iequals (arg, "enable"))
				{
					if (!pl->has ("command.world.world.def-inv"))
						{
							pl->message (messages::not_allowed ());
							return;
						}
					
					if (w->use_def_inv)
						{
							pl->message ("§c * §7Default inventories are already enabled in this world§c.");
							return;
						}
					
					w->use_def_inv = true;
					pl->message ("§eDefault inventories in " + w->get_colored_name () + " §ehave been enabled§f.");
				}
			else
				{
					pl->message ("§c * §7Invalid sub-command§f: §cdef-inv." + arg);
				}
		}
Example #3
0
		static void
		_handle_build_perms (player *pl, command_reader& reader)
		{
			if (!reader.has_next ())
				{
					pl->message ("§c * §7Usage§f:");
					pl->message ("§c * (1) §e/zone build-perms §czone-name");
					pl->message ("§c * (2) §e/zone build-perms §czone-name §eset §cperms");
					pl->message ("§c * (3) §e/zone build-perms §czone-name §eclear");
					return;
				}
			
			std::string zone_name = reader.next ();
			if (zone_name.size () < 3 || zone_name[0] != 'z' || zone_name[1] != '@')
				{
					pl->message ("§c * §7Invalid zone name§f: §c" + zone_name);
					return;
				}
			zone_name.erase (0, 2);
			
			zone *zn = pl->get_world ()->get_zones ().find (zone_name);
			if (!zn)
				{
					pl->message ("§c * §7Unknown zone§f: §cz@" + zone_name);
					return;
				}
			zone_name = zn->get_name ();
			
			if (!reader.has_next ())
				{
					pl->message ("§9Displaying build perms for zone §3z@§b" + zone_name);
					if (zn->get_security ().get_build_perms ().empty ())
						pl->message ("§8    not set");
					else
						pl->message ("§7    " + zn->get_security ().get_build_perms ());
					return;
				}
			else
				{
					std::string arg = reader.next ();
					if (sutils::iequals (arg, "set"))
						{
							if (!reader.has_next ())
								{
									pl->message ("§c * §7Usage§f: §e/zone build-perms §czone-name §eset §cperms");
									return;
								}
							
							std::string perms = reader.rest ();
							zn->get_security ().set_build_perms (perms);
							pl->message ("§eZone §3z@§b" + zone_name + "§e's build perms have been set to§f:");
							pl->message ("§f  > §7" + perms);
						}
					else if (sutils::iequals (arg, "clear"))
						{
							zn->get_security ().set_build_perms ("");
							pl->message ("§eZone §3z@§b" + zone_name + "§e's build perms have been cleared");
						}
					else
						{
							pl->message ("§c * Invalid sub-command§f: §cbuild-perms." + arg);
						}
				}
		}
Example #4
0
		static void
		_handle_join_perms (player *pl, world *w, command_reader& reader)
		{
		  if (!reader.has_next ())
		    {
		    	if (!pl->has ("command.world.world.get-perms"))
		    		{
		    			pl->message ("§c * §7You are not allowed to do that§c.");
		    			return;
		    		}
		    	
		      std::ostringstream ss;
		      ss << "§6Displaying " << w->get_colored_name () << "§e'§6s join permissions§e:";
		      pl->message (ss.str ());
		      ss.str (std::string ());
		      
		      const std::string& perms = w->security ().get_join_perms ();
		      if (perms.empty ())
		        ss << "§8    not set";
		      else
		        ss << "§7    " << perms;
		      pl->message (ss.str ());
		      return;
		    }
		  
		  const std::string arg1 = reader.next ().as_str ();
		  if (sutils::iequals (arg1, "set"))
		    {
		    	if (!pl->has ("command.world.world.set-perms"))
		    		{
		    			pl->message ("§c * §7You are not allowed to do that§c.");
		    			return;
		    		}
		    	
		      if (!reader.has_next ())
          	{
          		pl->message ("§c * §7Usage§f: §e/world join-perms set §cnew-join-perms");
          		return;
          	}
          
          std::string val = reader.rest ();
          w->security ().set_join_perms (val);
          
          pl->message (w->get_colored_name () + "§f'§es join-perms has been set to§f:");
          pl->message_spaced ("§f  > §7" + val);
		    }
		  else if (sutils::iequals (arg1, "clear"))
		  	{
		  		if (!pl->has ("command.world.world.set-perms"))
		    		{
		    			pl->message ("§c * §7You are not allowed to do that§c.");
		    			return;
		    		}
		    	
		  		w->security ().set_join_perms ("");
		  		pl->message (w->get_colored_name () + "§f'§es join-perms has been cleared");
		  	}
		  else
		    {
		      pl->message ("§c * §7Invalid sub-command§f: §cjoin-perms." + arg1);
		      return;
		    }
		}
Example #5
0
		static void
		_handle_leave_msg (player *pl, command_reader& reader)
		{
			if (!reader.has_next ())
				{
					pl->message ("§c * §7Usage§f:");
					pl->message ("§c * (1) §e/zone leave-msg §czone-name");
					pl->message ("§c * (2) §e/zone leave-msg §czone-name §eset §cmsg");
					pl->message ("§c * (3) §e/zone leave-msg §czone-name §eclear");
					return;
				}
			
			std::string zone_name = reader.next ();
			if (zone_name.size () < 3 || zone_name[0] != 'z' || zone_name[1] != '@')
				{
					pl->message ("§c * §7Invalid zone name§f: §c" + zone_name);
					return;
				}
			zone_name.erase (0, 2);
			
			zone *zn = pl->get_world ()->get_zones ().find (zone_name);
			if (!zn)
				{
					pl->message ("§c * §7Unknown zone§f: §cz@" + zone_name);
					return;
				}
			zone_name = zn->get_name ();
			
			if (!reader.has_next ())
				{
					pl->message ("§9Displaying the leave message for zone §3z@§b" + zone_name);
					if (zn->get_leave_msg ().empty ())
						pl->message ("§8    not set");
					else
						pl->message ("§7    " + zn->get_leave_msg ());
					return;
				}
			else
				{
					std::string arg = reader.next ();
					if (sutils::iequals (arg, "set"))
						{
							if (!reader.has_next ())
								{
									pl->message ("§c * §7Usage§f: §e/zone leave-msg §czone-name §eset §cmsg");
									return;
								}
							
							std::string msg = "§b" + reader.rest ();
							zn->set_leave_msg (msg);
							pl->message ("§eZone §3z@§b" + zone_name + "§e's leave message has been set to§f:");
							pl->message ("§f  > §7" + msg);
						}
					else if (sutils::iequals (arg, "clear"))
						{
							zn->set_leave_msg ("");
							pl->message ("§eZone §3z@§b" + zone_name + "§e's leave message has been cleared");
						}
					else
						{
							pl->message ("§c * Invalid sub-command§f: §cleave-msg." + arg);
						}
				}
		}