2013-10-08 23:22:03 +02:00
package com.sekwah.advancedportals ;
2018-03-26 10:35:16 +02:00
import com.sekwah.advancedportals.api.events.WarpEvent ;
2016-07-29 00:09:30 +02:00
import com.sekwah.advancedportals.api.portaldata.PortalArg ;
2016-03-29 13:35:34 +02:00
import com.sekwah.advancedportals.listeners.Listeners ;
2016-08-01 03:31:31 +02:00
import com.sekwah.advancedportals.portals.AdvancedPortal ;
2015-02-08 14:08:50 +01:00
import com.sekwah.advancedportals.portals.Portal ;
2018-03-26 10:35:16 +02:00
import org.bukkit.* ;
2013-10-08 23:22:03 +02:00
import org.bukkit.command.Command ;
import org.bukkit.command.CommandExecutor ;
import org.bukkit.command.CommandSender ;
2013-12-14 22:29:24 +01:00
import org.bukkit.command.TabCompleter ;
2013-10-08 23:22:03 +02:00
import org.bukkit.entity.Player ;
import org.bukkit.inventory.ItemStack ;
import org.bukkit.inventory.PlayerInventory ;
import org.bukkit.inventory.meta.ItemMeta ;
2017-06-11 19:32:53 +02:00
import org.bukkit.material.Wool ;
2014-02-23 22:52:04 +01:00
import org.bukkit.metadata.FixedMetadataValue ;
2013-10-09 23:42:03 +02:00
2015-03-25 23:51:29 +01:00
import java.util.* ;
2013-10-19 15:49:28 +02:00
2013-12-14 22:29:24 +01:00
public class AdvancedPortalsCommand implements CommandExecutor , TabCompleter {
2017-09-01 13:14:58 +02:00
private final ArrayList < String > blockMaterialList = new ArrayList < > ( ) ;
2016-03-29 13:38:03 +02:00
private AdvancedPortalsPlugin plugin ;
private int portalArgsStringLength = 0 ;
// TODO recode the portal args to be put into a hashmap and use a string array
// to store all possible portal arguments. Makes code shorter and possibly more efficient.
//private HashMap<String, String> portalArgs = new HashMap<>();
public AdvancedPortalsCommand ( AdvancedPortalsPlugin plugin ) {
this . plugin = plugin ;
2017-09-01 13:14:58 +02:00
for ( Material material : Material . values ( ) ) {
this . blockMaterialList . add ( " triggerblock: " + material . name ( ) ) ;
}
2016-03-29 13:38:03 +02:00
plugin . getCommand ( " advancedportals " ) . setExecutor ( this ) ;
}
@SuppressWarnings ( " deprecation " )
@Override
public boolean onCommand ( CommandSender sender , Command cmd , String command , String [ ] args ) {
2018-03-26 10:35:16 +02:00
//System.out.printf("%s %s %s %s%n", sender, cmd, command, args );
2016-03-29 13:38:03 +02:00
ConfigAccessor config = new ConfigAccessor ( plugin , " config.yml " ) ;
2016-08-01 01:49:46 +02:00
ConfigAccessor portalConfig = new ConfigAccessor ( plugin , " portals.yml " ) ;
2017-07-14 01:56:39 +02:00
if ( ! ( sender instanceof Player ) ) {
sender . sendMessage ( PluginMessages . customPrefixFail + " You cannot use commands with the console. " ) ;
return true ;
}
2016-08-01 01:49:46 +02:00
Player player = ( Player ) sender ;
PlayerInventory inventory = player . getInventory ( ) ;
2017-07-12 14:27:22 +02:00
2016-03-29 13:38:03 +02:00
if ( sender . hasPermission ( " advancedportals.portal " ) ) {
2016-08-01 01:49:46 +02:00
if ( args . length > 0 ) { switch ( args [ 0 ] . toLowerCase ( ) ) {
2018-03-26 10:35:16 +02:00
case " warp " :
if ( args . length = = 2 & & player . hasPermission ( " advancedportals.portal.warp " ) ) {
for ( AdvancedPortal portal : Portal . portals ) {
if ( args [ 1 ] . equalsIgnoreCase ( portal . getName ( ) ) ) {
2018-07-12 14:49:20 +02:00
if ( portal . inPortal . contains ( player . getUniqueId ( ) ) ) return true ;
2018-03-26 10:35:16 +02:00
WarpEvent warpEvent = new WarpEvent ( player , portal ) ;
plugin . getServer ( ) . getPluginManager ( ) . callEvent ( warpEvent ) ;
if ( ! warpEvent . isCancelled ( ) ) Portal . activate ( player , portal ) ;
break ;
}
}
}
sendMenu ( player , " Help Menu: Warp " , " \ u00A76/ " + command + " warp <name> \ u00A7a- teleport to warp name " ) ;
break ;
2016-08-01 01:49:46 +02:00
case " selector " :
2016-03-29 13:38:03 +02:00
String ItemID = config . getConfig ( ) . getString ( " AxeItemId " ) ;
Material WandMaterial = Material . getMaterial ( ItemID ) ;
if ( WandMaterial = = null ) {
WandMaterial = Material . IRON_AXE ;
}
ItemStack regionselector = new ItemStack ( WandMaterial ) ;
ItemMeta selectorname = regionselector . getItemMeta ( ) ;
2017-06-11 23:26:16 +02:00
selectorname . setDisplayName ( " \ u00A7ePortal Region Selector " ) ;
2016-03-29 13:38:03 +02:00
selectorname . setLore ( Arrays . asList ( " \ u00A7rThis wand with has the power to help "
, " \ u00A7r create portals bistowed upon it! " ) ) ;
regionselector . setItemMeta ( selectorname ) ;
inventory . addItem ( regionselector ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " You have been given a \ u00A7ePortal Region Selector \ u00A7a! " ) ;
2016-08-01 01:49:46 +02:00
break ;
case " portalblock " :
2016-08-04 04:23:38 +02:00
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
2017-06-11 19:32:53 +02:00
ItemStack portalBlock = new Wool ( DyeColor . PURPLE ) . toItemStack ( 1 ) ;
ItemMeta blockName = portalBlock . getItemMeta ( ) ;
blockName . setDisplayName ( " \ u00A75Portal Block Placer " ) ;
2017-06-11 23:26:16 +02:00
blockName . setLore ( Arrays . asList ( " \ u00A7rThis wool is made of a magical substance " ,
" \ u00A7rRight Click: Place portal block " ,
" \ u00A7rLeft Click: Rotate portal block " ) ) ;
2017-06-11 19:32:53 +02:00
portalBlock . setItemMeta ( blockName ) ;
inventory . addItem ( portalBlock ) ;
2016-03-29 13:38:03 +02:00
2017-06-11 19:32:53 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " You have been given a \ u00A7ePortal Block \ u00A7a! " ) ;
break ;
case " endportalblock " :
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
portalBlock = new Wool ( DyeColor . BLACK ) . toItemStack ( 1 ) ;
blockName = portalBlock . getItemMeta ( ) ;
blockName . setDisplayName ( " \ u00A78End Portal Block Placer " ) ;
2017-06-11 23:26:16 +02:00
blockName . setLore ( Arrays . asList ( " \ u00A7rThis wool is made of a magical substance " ,
" \ u00A7rRight Click: Place portal block " ) ) ;
2017-06-11 19:32:53 +02:00
portalBlock . setItemMeta ( blockName ) ;
inventory . addItem ( portalBlock ) ;
sender . sendMessage ( PluginMessages . customPrefix + " You have been given a \ u00A7ePortal Block \ u00A7a! " ) ;
break ;
case " gatewayblock " :
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
portalBlock = new Wool ( DyeColor . BLACK ) . toItemStack ( 1 ) ;
blockName = portalBlock . getItemMeta ( ) ;
blockName . setDisplayName ( " \ u00A78Gateway Block Placer " ) ;
2017-06-11 23:26:16 +02:00
blockName . setLore ( Arrays . asList ( " \ u00A7rThis wool is made of a magical substance " ,
" \ u00A7rRight Click: Place portal block " ) ) ;
2017-06-11 19:32:53 +02:00
portalBlock . setItemMeta ( blockName ) ;
2016-03-29 13:38:03 +02:00
inventory . addItem ( portalBlock ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " You have been given a \ u00A7ePortal Block \ u00A7a! " ) ;
2016-08-01 01:49:46 +02:00
break ;
case " create " :
2016-03-29 13:38:03 +02:00
if ( player . hasMetadata ( " Pos1World " ) & & player . hasMetadata ( " Pos2World " ) ) {
2016-08-04 04:23:38 +02:00
if ( player . getMetadata ( " Pos1World " ) . get ( 0 ) . asString ( ) . equals ( player . getMetadata ( " Pos2World " ) . get ( 0 ) . asString ( ) )
& & player . getMetadata ( " Pos1World " ) . get ( 0 ) . asString ( ) . equals ( player . getLocation ( ) . getWorld ( ) . getName ( ) ) ) {
2016-03-29 13:38:03 +02:00
if ( args . length > = 2 ) { // may make this next piece of code more efficient, maybe check against a list of available variables or something
// TODO change system to use arrays and hashmaps
boolean hasName = false ;
boolean hasTriggerBlock = false ;
boolean hasDestination = false ;
boolean isBungeePortal = false ;
boolean needsPermission = false ;
boolean executesCommand = false ;
String destination = null ;
String portalName = null ;
String triggerBlock = null ;
String serverName = null ;
String permission = null ;
String portalCommand = null ;
ArrayList < PortalArg > extraData = new ArrayList < > ( ) ;
for ( int i = 1 ; i < args . length ; i + + ) {
if ( args [ i ] . toLowerCase ( ) . startsWith ( " name: " ) & & args [ i ] . length ( ) > 5 ) {
hasName = true ;
portalName = args [ i ] . replaceFirst ( " name: " , " " ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " name: " ) ) {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You must include a name for the portal that isnt nothing! " ) ;
2016-03-29 13:38:03 +02:00
return true ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " destination: " ) & & args [ i ] . length ( ) > 12 ) {
hasDestination = true ;
destination = args [ i ] . toLowerCase ( ) . replaceFirst ( " destination: " , " " ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " desti: " ) & & args [ i ] . length ( ) > 6 ) {
hasDestination = true ;
destination = args [ i ] . toLowerCase ( ) . replaceFirst ( " desti: " , " " ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " triggerblock: " ) & & args [ i ] . length ( ) > 13 ) {
hasTriggerBlock = true ;
triggerBlock = args [ i ] . toLowerCase ( ) . replaceFirst ( " triggerblock: " , " " ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " triggerblock: " ) & & args [ i ] . length ( ) > 13 ) {
hasTriggerBlock = true ;
triggerBlock = args [ i ] . toLowerCase ( ) . replaceFirst ( " triggerblock: " , " " ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " bungee: " ) & & args [ i ] . length ( ) > 7 ) { // not completely implemented
isBungeePortal = true ;
serverName = args [ i ] . toLowerCase ( ) . replaceFirst ( " bungee: " , " " ) ;
//extraData.add(new PortalArgs("bungee", serverName));
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " permission: " ) & & args [ i ] . length ( ) > 11 ) { // not completely implemented
needsPermission = true ;
permission = args [ i ] . toLowerCase ( ) . replaceFirst ( " permission: " , " " ) ;
extraData . add ( new PortalArg ( " permission " , permission ) ) ;
} else if ( args [ i ] . toLowerCase ( ) . startsWith ( " command: " ) & & args [ i ] . length ( ) > 8 ) { // not completely implemented
executesCommand = true ;
portalCommand = parseArgVariable ( args , i , " command: " ) ;
i + = this . portalArgsStringLength - 1 ;
2017-12-18 03:29:13 +01:00
if ( portalCommand . startsWith ( " # " ) & & ! ( this . plugin . getSettings ( ) . hasCommandLevel ( " c " )
2017-08-06 01:10:06 +02:00
& & ( sender . hasPermission ( " advancedportals.createportal.commandlevel.console " ) )
2017-12-18 03:29:13 +01:00
| | ( this . plugin . getSettings ( ) . hasCommandLevel ( " k " ) & & sender . isOp ( ) ) ) ) {
2017-04-20 04:31:25 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You need permission to make a console command portal! " ) ;
return true ;
}
2017-12-18 03:29:13 +01:00
else if ( portalCommand . startsWith ( " ! " ) & & ! ( this . plugin . getSettings ( ) . hasCommandLevel ( " o " )
2017-08-06 01:10:06 +02:00
& & ( sender . hasPermission ( " advancedportals.createportal.commandlevel.op " ) )
2017-12-18 03:29:13 +01:00
| | ( this . plugin . getSettings ( ) . hasCommandLevel ( " p " ) & & sender . isOp ( ) ) ) ) {
2017-04-20 04:31:25 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You need permission to make a op command portal! " ) ;
return true ;
}
2017-12-18 03:29:13 +01:00
else if ( portalCommand . startsWith ( " ^ " ) & & ! ( this . plugin . getSettings ( ) . hasCommandLevel ( " p " )
2017-08-06 01:10:06 +02:00
& & ( sender . hasPermission ( " advancedportals.createportal.commandlevel.perms " ) )
2017-12-18 03:29:13 +01:00
| | ( this . plugin . getSettings ( ) . hasCommandLevel ( " e " ) & & sender . isOp ( ) ) ) ) {
2017-04-20 04:55:14 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You need permission to make a all perms command portal! " ) ;
return true ;
}
2016-03-29 13:38:03 +02:00
extraData . add ( new PortalArg ( " command.1 " , portalCommand ) ) ;
}
}
if ( ! hasName ) {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You must include a name for the portal that you are creating in the variables! " ) ;
2016-03-29 13:38:03 +02:00
return true ;
}
World world = org . bukkit . Bukkit . getWorld ( player . getMetadata ( " Pos1World " ) . get ( 0 ) . asString ( ) ) ;
Location pos1 = new Location ( world , player . getMetadata ( " Pos1X " ) . get ( 0 ) . asInt ( ) , player . getMetadata ( " Pos1Y " ) . get ( 0 ) . asInt ( ) , player . getMetadata ( " Pos1Z " ) . get ( 0 ) . asInt ( ) ) ;
Location pos2 = new Location ( world , player . getMetadata ( " Pos2X " ) . get ( 0 ) . asInt ( ) , player . getMetadata ( " Pos2Y " ) . get ( 0 ) . asInt ( ) , player . getMetadata ( " Pos2Z " ) . get ( 0 ) . asInt ( ) ) ;
ConfigAccessor desticonfig = new ConfigAccessor ( plugin , " destinations.yml " ) ;
2017-07-14 01:15:08 +02:00
String destiPosX = desticonfig . getConfig ( ) . getString ( destination + " .pos.X " ) ;
2016-03-29 13:38:03 +02:00
if ( ! Portal . portalExists ( portalName ) ) {
player . sendMessage ( " " ) ;
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefix + " \ u00A7e You have created a new portal with the following details: " ) ;
2016-03-29 13:38:03 +02:00
player . sendMessage ( " \ u00A7aname: \ u00A7e " + portalName ) ;
if ( hasDestination ) {
2017-07-12 14:27:22 +02:00
if ( destiPosX = = null ) {
player . sendMessage ( " \ u00A7cdestination: \ u00A7e " + destination + " (destination does not exist) " ) ;
return true ;
}
else {
player . sendMessage ( " \ u00A7adestination: \ u00A7e " + destination ) ;
}
2016-03-29 13:38:03 +02:00
} else {
2017-07-12 14:27:22 +02:00
player . sendMessage ( " \ u00A7cdestination: \ u00A7eN/A (will not teleport to a location) " ) ;
2016-03-29 13:38:03 +02:00
}
if ( isBungeePortal ) {
player . sendMessage ( " \ u00A7abungee: \ u00A7e " + serverName ) ;
}
if ( needsPermission ) {
player . sendMessage ( " \ u00A7apermission: \ u00A7e " + permission ) ;
} else {
player . sendMessage ( " \ u00A7apermission: \ u00A7e(none needed) " ) ;
}
if ( executesCommand ) {
player . sendMessage ( " \ u00A7acommand: \ u00A7e " + portalCommand ) ;
}
2017-07-12 14:27:22 +02:00
Material triggerBlockMat ;
2016-03-29 13:38:03 +02:00
if ( hasTriggerBlock ) {
triggerBlockMat = Material . getMaterial ( triggerBlock . toUpperCase ( ) ) ;
if ( triggerBlockMat ! = null ) {
player . sendMessage ( " \ u00A7atriggerBlock: \ u00A7e " + triggerBlock . toUpperCase ( ) ) ;
PortalArg [ ] portalArgs = new PortalArg [ extraData . size ( ) ] ;
portalArgs = extraData . toArray ( portalArgs ) ;
player . sendMessage ( Portal . create ( pos1 , pos2 , portalName , destination , triggerBlockMat , serverName , portalArgs ) ) ;
} else {
hasTriggerBlock = false ;
ConfigAccessor Config = new ConfigAccessor ( plugin , " config.yml " ) ;
player . sendMessage ( " \ u00A7ctriggerBlock: \ u00A7edefault( " + Config . getConfig ( ) . getString ( " DefaultPortalTriggerBlock " ) + " ) " ) ;
player . sendMessage ( " \ u00A7cThe block " + triggerBlock . toUpperCase ( ) + " is not a valid block name in minecraft so the trigger block has been set to the default! " ) ;
PortalArg [ ] portalArgs = new PortalArg [ extraData . size ( ) ] ;
portalArgs = extraData . toArray ( portalArgs ) ;
player . sendMessage ( Portal . create ( pos1 , pos2 , portalName , destination , serverName , portalArgs ) ) ;
}
} else {
ConfigAccessor Config = new ConfigAccessor ( plugin , " config.yml " ) ;
player . sendMessage ( " \ u00A7atriggerBlock: \ u00A7edefault( " + Config . getConfig ( ) . getString ( " DefaultPortalTriggerBlock " ) + " ) " ) ;
PortalArg [ ] portalArgs = new PortalArg [ extraData . size ( ) ] ;
portalArgs = extraData . toArray ( portalArgs ) ;
player . sendMessage ( Portal . create ( pos1 , pos2 , portalName , destination , serverName , portalArgs ) ) ;
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " A portal by that name already exists! " ) ;
2016-03-29 13:38:03 +02:00
}
// add code to save the portal to the portal config and reload the portals
player . sendMessage ( " " ) ;
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You need to at least add the name of the portal as a variable, \ u00A7cType \ u00A7e/portal variables \ u00A7c "
2016-03-29 13:38:03 +02:00
+ " for a full list of currently available variables and an example command! " ) ;
}
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " The points you have selected need to be in the same world! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " You need to have two points selected to make a portal! " ) ;
2016-03-29 13:38:03 +02:00
}
2016-08-01 01:49:46 +02:00
break ;
case " variables " :
2017-09-01 13:14:58 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " \ u00A77Variables \ u00A7c: \ u00A7aname, triggerBlock, desti, destination, bungee, permission, command " ) ;
2016-03-29 13:38:03 +02:00
sender . sendMessage ( " " ) ;
sender . sendMessage ( " \ u00A7aExample command: \ u00A7e/portal create name:test triggerId:portal " ) ;
2016-08-01 01:49:46 +02:00
break ;
2018-08-29 01:26:23 +02:00
case " wand " :
2016-08-01 01:49:46 +02:00
case " select " :
2016-03-29 13:38:03 +02:00
// TODO finish the select command and the hit block to replace!
if ( ! player . hasMetadata ( " selectingPortal " ) ) {
if ( args . length > 1 ) {
if ( Portal . portalExists ( args [ 1 ] ) ) {
player . setMetadata ( " selectedPortal " , new FixedMetadataValue ( plugin , args [ 1 ] ) ) ;
2018-07-05 03:27:16 +02:00
player . sendMessage ( PluginMessages . customPrefix + " You have selected \ u00A7e " + args [ 1 ] + " \ u00A7a. " ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " No portal by the name \ u00A7e " + args [ 1 ] + " \ u00A7c exists (maybe you got the caps wrong) \ n Try typing \ u00A7e/portal select \ u00A7c and hit inside the apropriate portals area! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefix + " Hit a block inside the portal region to select the portal! " ) ;
2016-03-29 13:38:03 +02:00
player . setMetadata ( " selectingPortal " , new FixedMetadataValue ( plugin , true ) ) ;
}
} else {
player . removeMetadata ( " selectingPortal " , plugin ) ;
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " Portal selection cancelled! " ) ;
2016-03-29 13:38:03 +02:00
}
2016-08-01 01:49:46 +02:00
break ;
2017-06-13 19:54:18 +02:00
case " unselect " :
if ( player . hasMetadata ( " selectedPortal " ) ) {
player . sendMessage ( PluginMessages . customPrefix + " You have unselected \ u00A7e " + player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( )
+ " \ u00A7a. " ) ;
}
else {
player . sendMessage ( PluginMessages . customPrefixFail + " You had no portal selected! " ) ;
}
2016-08-01 01:49:46 +02:00
case " gui " :
2016-03-29 13:38:03 +02:00
if ( args . length > 1 ) {
if ( args [ 1 ] . toLowerCase ( ) . equals ( " remove " ) & & args . length > 2 ) {
sender . sendMessage ( " " ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " Are you sure you would like to remove the portal \ u00A7e " + args [ 2 ] + " \ u00A7c? " ) ;
2016-03-29 13:38:03 +02:00
sender . sendMessage ( " " ) ;
2016-08-04 04:23:38 +02:00
plugin . compat . sendRawMessage ( " { \" text \" : \" \" , \" extra \" :[{ \" text \" : \" \ u00A7e[Yes] \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , " +
" \" value \" : \" Confirm removing this portal \" }, \" clickEvent \" :{ \" action \" : \" run_command \" , \" value \" : \" /portal remove " + args [ 2 ] + " \" }}, " +
" { \" text \" : \" \" },{ \" text \" : \" \ u00A7e[No] \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , \" value \" : \" Cancel removing this portal \" } " +
" , \" clickEvent \" :{ \" action \" : \" run_command \" , \" value \" : \" /portal edit " + args [ 2 ] + " \" }}]} " , player ) ;
2016-03-29 13:38:03 +02:00
sender . sendMessage ( " " ) ;
}
}
2016-08-01 01:49:46 +02:00
break ;
case " edit " :
2016-03-29 13:38:03 +02:00
if ( args . length > 1 ) {
2016-04-24 18:54:14 +02:00
if ( Portal . portalExists ( args [ 1 ] ) ) {
player . setMetadata ( " selectedPortal " , new FixedMetadataValue ( plugin , args [ 1 ] ) ) ;
2016-03-29 13:38:03 +02:00
portalEditMenu ( sender , portalConfig , args [ 1 ] ) ;
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal by the name \ u00A7e " + args [ 1 ] + " \ u00A7c exists! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
if ( player . hasMetadata ( " selectedPortal " ) ) {
String portalName = player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( ) ;
String posX = portalConfig . getConfig ( ) . getString ( portalName + " .pos1.X " ) ;
if ( posX ! = null ) {
portalEditMenu ( sender , portalConfig , portalName ) ;
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal you had selected no longer seems to exist! " ) ;
2016-03-29 13:38:03 +02:00
player . removeMetadata ( " selectedPortal " , plugin ) ;
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal has been defined or selected! " ) ;
2016-03-29 13:38:03 +02:00
}
}
2016-08-01 01:49:46 +02:00
break ;
case " rename " :
2016-03-29 13:38:03 +02:00
// not finished yet /
if ( args . length > 1 ) {
if ( player . hasMetadata ( " selectedPortal " ) ) {
String portalName = player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( ) ;
if ( portalName . toLowerCase ( ) ! = args [ 1 ] . toLowerCase ( ) ) {
String posX = portalConfig . getConfig ( ) . getString ( portalName + " .pos1.X " ) ;
String newPortalPosX = portalConfig . getConfig ( ) . getString ( args [ 1 ] + " .pos1.X " ) ;
if ( posX ! = null & & newPortalPosX = = null ) {
Portal . rename ( portalName , args [ 1 ] ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " The portal \ u00A7e " + portalName + " \ u00A7a has been renamed to \ u00A7e " + args [ 1 ] + " \ u00A7a. " ) ;
2016-03-29 13:38:03 +02:00
player . setMetadata ( " selectedPortal " , new FixedMetadataValue ( plugin , args [ 1 ] ) ) ;
} else if ( newPortalPosX ! = null ) {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " There is already a portal with the name \ u00A7e " + args [ 1 ] + " \ u00A7c! " ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal you had selected no longer seems to exist! " ) ;
2016-03-29 13:38:03 +02:00
player . removeMetadata ( " selectedPortal " , plugin ) ;
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal you have selected is already called that! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal has been defined or selected! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " You must select a portal first and then type \ u00A7e/portal rename (new name) \ u00A7c! " ) ;
2016-03-29 13:38:03 +02:00
}
2016-08-01 01:49:46 +02:00
break ;
case " command " :
2016-03-29 13:38:03 +02:00
if ( player . hasMetadata ( " selectedPortal " ) ) {
String portalName = player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( ) ;
if ( args . length > 1 ) {
// TODO add the command autocompletes, add, remove and show
if ( args [ 1 ] . toLowerCase ( ) . equals ( " add " ) ) {
if ( args . length > 2 ) {
String portalCommand = args [ 2 ] ;
for ( int i = 3 ; i < args . length ; i + + ) {
portalCommand + = args [ i ] ;
}
if ( Portal . addCommand ( portalName , portalCommand ) ) {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " Command added to portal! " ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " Failed to add command to portal! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " You must actually specify a command to execute! " ) ;
2016-03-29 13:38:03 +02:00
}
} else if ( args [ 1 ] . toLowerCase ( ) . equals ( " remove " ) ) {
// Specify what line to remove
} else if ( args [ 1 ] . toLowerCase ( ) . equals ( " show " ) ) {
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " You must specify to \ u00A7eadd \ u00A7c or \ u00A7eremove a command! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " You must specify to \ u00A7eadd \ u00A7c or \ u00A7eremove \ u00A7c a command! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
}
2016-08-01 01:49:46 +02:00
break ;
case " remove " :
2016-03-29 13:38:03 +02:00
if ( args . length > 1 ) {
String posX = portalConfig . getConfig ( ) . getString ( args [ 1 ] + " .pos1.X " ) ;
if ( posX ! = null ) {
Portal . remove ( args [ 1 ] ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal \ u00A7e " + args [ 1 ] + " \ u00A7c has been removed! " ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal by that name exists! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
if ( player . hasMetadata ( " selectedPortal " ) ) {
String portalName = player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( ) ;
String posX = portalConfig . getConfig ( ) . getString ( portalName + " .pos1.X " ) ;
if ( posX ! = null ) {
Portal . remove ( portalName ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal \ u00A77 " + portalName + " \ u00A7c has been removed! " ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " The portal you had selected no longer seems to exist! " ) ;
2016-03-29 13:38:03 +02:00
player . removeMetadata ( " selectedPortal " , plugin ) ;
}
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal has been defined or selected! " ) ;
2016-03-29 13:38:03 +02:00
}
}
2016-08-01 01:49:46 +02:00
break ;
case " help " :
2017-06-13 19:54:18 +02:00
helpCommand ( sender , command , args ) ;
2016-08-01 01:49:46 +02:00
break ;
case " show " :
2016-03-29 13:38:03 +02:00
if ( args . length > 1 ) {
String posX = portalConfig . getConfig ( ) . getString ( args [ 1 ] + " .pos1.X " ) ;
if ( posX ! = null ) {
2017-07-20 16:28:00 +02:00
Selection . show ( player , this . plugin , args [ 1 ] ) ;
2016-03-29 13:38:03 +02:00
} else {
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefixFail + " No portal by that name exists! " ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-01 02:22:58 +02:00
if ( player . hasMetadata ( " selectedPortal " ) ) {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefix + " Your currently selected portal has been shown, it will dissapear shortly! " ) ;
2017-07-20 16:28:00 +02:00
Selection . show ( player , this . plugin , player . getMetadata ( " selectedPortal " ) . get ( 0 ) . asString ( ) ) ;
2016-08-01 02:22:58 +02:00
} else if ( player . hasMetadata ( " Pos1World " ) & & player . hasMetadata ( " Pos2World " ) ) {
2016-08-04 04:23:38 +02:00
if ( player . getMetadata ( " Pos1World " ) . get ( 0 ) . asString ( ) . equals ( player . getMetadata ( " Pos2World " ) . get ( 0 ) . asString ( ) )
& & player . getMetadata ( " Pos1World " ) . get ( 0 ) . asString ( ) . equals ( player . getLocation ( ) . getWorld ( ) . getName ( ) ) ) {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefix + " Your currently selected area has been shown, it will dissapear shortly! " ) ;
2017-07-20 16:28:00 +02:00
Selection . show ( player , this . plugin , null ) ;
2016-03-29 13:38:03 +02:00
}
} else {
2016-08-02 05:51:16 +02:00
player . sendMessage ( PluginMessages . customPrefixFail + " No regions selected! " ) ;
2016-03-29 13:38:03 +02:00
}
}
2016-08-01 03:31:31 +02:00
break ;
2016-08-01 01:49:46 +02:00
case " reload " :
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " Reloaded values! " ) ;
2016-03-29 13:38:03 +02:00
Listeners . reloadValues ( plugin ) ;
Portal . loadPortals ( ) ;
2016-08-01 01:49:46 +02:00
break ;
2016-08-01 03:31:31 +02:00
case " list " :
2016-08-04 04:23:38 +02:00
String message = PluginMessages . customPrefix + " \ u00A77Portals \ u00A7c: \ u00A7a " ;
2016-08-04 04:37:19 +02:00
LinkedList < String > portals = new LinkedList < > ( ) ;
2017-05-19 07:09:57 +02:00
for ( AdvancedPortal portal : Portal . portals ) {
2017-06-13 19:06:48 +02:00
portals . add ( portal . getName ( ) ) ;
2016-08-04 04:37:19 +02:00
}
Collections . sort ( portals ) ;
for ( Object portalName : portals . toArray ( ) ) {
message = message + " " + portalName ;
2016-08-01 03:31:31 +02:00
}
player . sendMessage ( message ) ;
break ;
2016-08-01 01:49:46 +02:00
default :
2016-03-29 13:38:03 +02:00
PluginMessages . UnknownCommand ( sender , command ) ;
2016-08-04 04:37:19 +02:00
}
2016-03-29 13:38:03 +02:00
} else {
PluginMessages . UnknownCommand ( sender , command ) ;
}
} else {
PluginMessages . NoPermission ( sender , command ) ;
}
return true ;
}
2017-06-13 19:54:18 +02:00
private void helpCommand ( CommandSender sender , String command , String [ ] args ) {
// Add pages if there starts to become too many
if ( args . length = = 1 ) {
sendMenu ( sender , " Help Menu " ,
" \ u00A76/ " + command + " selector \ u00A7a- gives you a region selector " ,
" \ u00A76/ " + command + " create \ u00A7c[tags] \ u00A7a- creates a portal with a selection " ,
" \ u00A76/ " + command + " portalblock \ u00A7a- gives you a portal block " ,
2017-07-23 21:41:43 +02:00
" \ u00A76/ " + command + " endportalblock \ u00A7a- gives you an end portal block " ,
" \ u00A76/ " + command + " gatewayblock \ u00A7a- gives you a gateway block " ,
2017-06-13 19:54:18 +02:00
" \ u00A76/ " + command + " select \ u00A7a- selects an existing portal " ,
" \ u00A76/ " + command + " unselect \ u00A7a- unselects the current portal " ,
" \ u00A76/ " + command + " command \ u00A7a- adds or removes commands from the selected portal " ,
" \ u00A76/ " + command + " help \ u00A7a- shows this help section " ,
" \ u00A76/ " + command + " help <arg> \ u00A7a- shows help for the specified arg " ,
" \ u00A76/ " + command + " remove \ u00A7a- removes a portal " ,
" \ u00A76/ " + command + " list \ u00A7a- lists all the current portals " ,
2018-03-26 10:35:16 +02:00
" \ u00A76/ " + command + " warp <name> \ u00A7a- teleport to warp name " ,
2017-06-13 19:54:18 +02:00
" \ u00A76/ " + command + " variables \ u00A7a- lists all available tags " ) ;
}
else if ( args . length > 1 ) {
if ( args [ 1 ] . toLowerCase ( ) . equals ( " help " ) ) {
sendMenu ( sender , " Help Command " ,
" Shows the help section. You can also use a single argument after it to show the " +
" help section for the corresponding command. " ) ;
}
else if ( args [ 1 ] . toLowerCase ( ) . equals ( " portalblock " ) ) {
sendMenu ( sender , " Help Command " ,
" Gives you a special wool block to place portal blocks. " ,
" " ,
" \ u00A7eLeft Click: \ u00A76Rotates the hit portal block " ,
" \ u00A7eRight Click: \ u00A76Placed a portal block " ) ;
}
else if ( args [ 1 ] . toLowerCase ( ) . equals ( " endportalblock " ) ) {
sendMenu ( sender , " Help Command " ,
" Gives you a special wool block to place end portal blocks. " ,
" " ,
" \ u00A7eRight Click: \ u00A76Placed a end portal block " ) ;
}
else if ( args [ 1 ] . toLowerCase ( ) . equals ( " gatewayblock " ) ) {
sendMenu ( sender , " Help Command " ,
" Gives you a special wool block to place gateway blocks. " ,
" " ,
" \ u00A7eRight Click: \ u00A76Placed a gateway block " ) ;
}
else {
sender . sendMessage ( PluginMessages . customPrefix + " Either \ u00A7e " + args [ 1 ] + " \ u00A7a is not a command or a help page has not been added yet. " ) ;
}
}
}
private void sendMenu ( CommandSender sender , String title , String . . . lines ) {
sender . sendMessage ( PluginMessages . customPrefix + " " + title ) ;
sender . sendMessage ( " \ u00A7e \ u00A7m----------------------------------- " ) ;
for ( String line : lines ) {
sender . sendMessage ( " \ u00A7a " + line ) ;
}
sender . sendMessage ( " \ u00A7e \ u00A7m----------------------------------- " ) ;
}
2016-03-29 13:38:03 +02:00
private String parseArgVariable ( String [ ] args , int currentArg , String argStarter ) {
String variableString = args [ currentArg ] . replaceFirst ( argStarter , " " ) ;
this . portalArgsStringLength = 1 ;
if ( variableString . charAt ( 0 ) = = '"' ) {
variableString = variableString . substring ( 1 , variableString . length ( ) ) ;
if ( variableString . charAt ( variableString . length ( ) - 1 ) ! = '"' ) {
currentArg + + ;
for ( ; currentArg < args . length ; currentArg + + ) {
variableString + = " " + args [ currentArg ] ;
this . portalArgsStringLength + = 1 ;
if ( variableString . charAt ( variableString . length ( ) - 1 ) = = '"' ) {
variableString = variableString . substring ( 0 , variableString . length ( ) - 1 ) ;
break ;
}
}
} else {
variableString = variableString . substring ( 0 , variableString . length ( ) - 1 ) ;
}
}
return variableString ;
}
private void portalEditMenu ( CommandSender sender , ConfigAccessor portalConfig , String portalName ) {
// make the text gui with the json message for a list of edit commands to be clicked or hovered
// put \" for a " in the json messages
// sadly there is no newline code so these three lines will have to be copied and pasted for each line
// use the usual messages for normal lines but anything that needs special features make sure you use the
// chat steriliser
sender . sendMessage ( " " ) ;
2016-08-02 05:51:16 +02:00
sender . sendMessage ( PluginMessages . customPrefix + " Editing: \ u00A7e " + portalName ) ;
2016-03-29 13:38:03 +02:00
2016-08-04 04:23:38 +02:00
sender . sendMessage ( " \ u00A7apos1 \ u00A7e: " + portalConfig . getConfig ( ) . getString ( portalName + " .pos1.X " )
+ " , " + portalConfig . getConfig ( ) . getString ( portalName + " .pos1.Y " ) + " , " + portalConfig . getConfig ( ) . getString ( portalName + " .pos1.Z " ) ) ;
sender . sendMessage ( " \ u00A7apos2 \ u00A7e: " + portalConfig . getConfig ( ) . getString ( portalName + " .pos2.X " )
+ " , " + portalConfig . getConfig ( ) . getString ( portalName + " .pos2.Y " ) + " , " + portalConfig . getConfig ( ) . getString ( portalName + " .pos2.Z " ) ) ;
2016-03-29 13:38:03 +02:00
String destination = portalConfig . getConfig ( ) . getString ( portalName + " .destination " ) ;
if ( destination ! = null ) {
sender . sendMessage ( " \ u00A7adestination \ u00A7e: " + destination ) ;
} else {
sender . sendMessage ( " \ u00A7cdestination \ u00A7e: null " ) ;
}
String trigger = portalConfig . getConfig ( ) . getString ( portalName + " .triggerblock " ) ;
if ( trigger ! = null ) {
sender . sendMessage ( " \ u00A7atriggerBlock \ u00A7e: " + trigger ) ;
} else {
sender . sendMessage ( " \ u00A7ctriggerBlock \ u00A7e: null " ) ;
}
if ( portalConfig . getConfig ( ) . getString ( portalName + " .portalArgs.command.1 " ) ! = null ) {
int commands = 0 ;
String command = portalConfig . getConfig ( ) . getString ( portalName + " .portalArgs.command.1 " ) ;
// TODO possibly change code so it counds number of subvalues rather than a loop.
while ( command ! = null ) {
command = portalConfig . getConfig ( ) . getString ( portalName + " .portalArgs.command. " + + + commands ) ;
}
if ( - - commands > 1 ) {
sender . sendMessage ( " \ u00A7acommands \ u00A7e: " + commands + " commands " ) ;
} else {
sender . sendMessage ( " \ u00A7acommands \ u00A7e: " + commands + " command " ) ;
}
} else {
sender . sendMessage ( " \ u00A7ccommands \ u00A7e: none " ) ;
}
sender . sendMessage ( " " ) ;
Player player = ( Player ) sender ;
2016-08-04 04:23:38 +02:00
plugin . compat . sendRawMessage ( " { \" text \" : \" \ u00A7aFunctions \ u00A7e: \" , " +
2017-06-10 08:27:27 +02:00
" \" extra \" :[{ \" text \" : \" \ u00A7eRemove \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , \" value \" : \" Remove the selected portal \" }, \" clickEvent \" :{ \" action \" : \" run_command \" , \" value \" : \" /portal gui remove " + portalName + " \" }} "
+ " ,{ \" text \" : \" \" },{ \" text \" : \" \ u00A7eShow \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , \" value \" : \" Show the selected portal \" }, \" clickEvent \" :{ \" action \" : \" run_command \" , \" value \" : \" /portal show " + portalName + " \" }} "
2016-03-29 13:38:03 +02:00
+ " ,{ \" text \" : \" \" },{ \" text \" : \" \ u00A7eRename \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , \" value \" : \" Change the name of the portal \" }, \" clickEvent \" :{ \" action \" : \" suggest_command \" , \" value \" : \" /portal rename \" }} "
2017-06-11 20:14:35 +02:00
+ " ,{ \" text \" : \" \" },{ \" text \" : \" \ u00A7eTeleport \" , \" hoverEvent \" :{ \" action \" : \" show_text \" , \" value \" : \" Teleport to the set destination \ n(If there is one) \" }, \" clickEvent \" :{ \" action \" : \" run_command \" , \" value \" : \" /desti warp " + destination + " \" }}]} " , player ) ;
2016-03-29 13:38:03 +02:00
sender . sendMessage ( " " ) ;
}
@Override
public List < String > onTabComplete ( CommandSender sender , Command cmd , String command , String [ ] args ) {
LinkedList < String > autoComplete = new LinkedList < String > ( ) ;
2017-07-20 16:28:00 +02:00
if ( sender . hasPermission ( " advancedportals.createportal " ) ) {
2017-06-13 19:54:18 +02:00
if ( args . length = = 1 | | ( args . length = = 2 & & args [ 0 ] . toLowerCase ( ) . equals ( " help " ) ) ) {
autoComplete . addAll ( Arrays . asList ( " create " , " list " , " portalblock " , " select " , " unselect " , " command " , " selector "
2018-03-26 10:35:16 +02:00
, " show " , " gatewayblock " , " endportalblock " , " variables " , " wand " , " remove " , " rename " , " help " , " bukkitpage " , " helppage " , " warp " ) ) ;
2016-03-29 13:38:03 +02:00
} else if ( args [ 0 ] . toLowerCase ( ) . equals ( " create " ) ) {
boolean hasName = false ;
boolean hasTriggerBlock = false ;
boolean hasDestination = false ;
boolean isBungeePortal = false ;
boolean needsPermission = false ;
boolean hasCommand = false ;
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
for ( int i = 1 ; i < args . length ; i + + ) {
String argTag = getTag ( args [ i ] . toLowerCase ( ) ) ;
if ( argTag . length ( ) + 1 < args [ i ] . length ( ) ) {
switch ( argTag ) {
case " name " :
hasName = true ;
break ;
case " destination " :
hasDestination = true ;
break ;
case " desti " :
hasDestination = true ;
break ;
case " triggerblock " :
hasTriggerBlock = true ;
break ;
case " bungee " :
isBungeePortal = true ;
break ;
case " permission " :
needsPermission = true ;
break ;
case " command " :
hasCommand = true ;
break ;
}
}
}
if ( ! hasName ) {
autoComplete . add ( " name: " ) ;
}
if ( ! hasTriggerBlock ) {
autoComplete . add ( " triggerblock: " ) ;
2017-09-01 13:14:58 +02:00
autoComplete . addAll ( this . blockMaterialList ) ;
2016-03-29 13:38:03 +02:00
}
if ( ! hasDestination ) {
autoComplete . add ( " destination: " ) ;
autoComplete . add ( " desti: " ) ;
}
if ( ! isBungeePortal ) {
autoComplete . add ( " bungee: " ) ;
}
if ( ! needsPermission ) {
autoComplete . add ( " permission: " ) ;
}
if ( ! hasCommand ) {
autoComplete . add ( " command: " ) ;
}
}
}
2018-03-26 10:35:16 +02:00
if ( args . length = = 2 & & args [ 0 ] . equalsIgnoreCase ( " warp " ) ) {
for ( AdvancedPortal portal : Portal . portals ) {
String perm = portal . getArg ( " permission " ) ;
if ( perm = = null | | sender . hasPermission ( perm ) ) {
autoComplete . add ( portal . getName ( ) ) ;
}
}
}
2016-03-29 13:38:03 +02:00
Collections . sort ( autoComplete ) ;
for ( Object result : autoComplete . toArray ( ) ) {
if ( ! result . toString ( ) . startsWith ( args [ args . length - 1 ] ) ) {
autoComplete . remove ( result ) ;
}
}
return autoComplete ;
}
private String getTag ( String arg ) {
int indexOfSplitter = arg . indexOf ( ':' ) ;
if ( indexOfSplitter > 0 ) {
return arg . substring ( 0 , indexOfSplitter ) ;
}
return " " ;
}
2016-01-19 23:31:16 +01:00
2015-11-19 23:43:42 +01:00
}