Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new executor, and a renewed executor (#195)
* Fix for #TP not allowing other arguments than x,y,z coordinates * New executor, #KICK This #KICK Executor simply use to kick player. 1) kick sender - Not giving any argument #KICK 2) kick sender with custom kick message - giving only one argument #KICK "You are kicked" 3) kick specific player - giving only one argument #KICK player("Pro_Snape") 4) kick specific player with custom kick message - giving two arguments #KICK player("Pro_Snape") "You are kicked lmao" Tested. * Made #CLEARCHAT to accept Player instance as arg. This commit makes #CLEARCHAT able to accept Player instance. **1)** Clear specific player's chat #CLEARCHAT player("Pro_Snape") * error fixes print error if there are more than two arguments. * error fixes add validation check when args's length is more than 2. * Add some test of KICK Executor same as title. * error fixes same as title. * error fixes just knew eq() and anyString() don't work, also some elses. * some errors keep fixed some error fixed. Mokito -> Mockito * one more errror. same as last commit, Mokito -> Mockito * Final KICK.js error fix final one * final KICK.js test script fix same as title. * Actually this js should be built after the test script same as title. * final CLEARCHAT.js test script same as title * times() is static one, fixed error same as title * add some more test, also fixed what gerzytet said. same as title. * fix what gerzytet said. fix == to ===. * Error fixes * Added one more test for ClearChat same as title. * Actually OfflinePlayer does not needed to be imported. * add some var prefix, and fixed stray == to === same as title. * added var prefix same as title.
- Loading branch information
1 parent
febd1c7
commit 0ae0cac
Showing
3 changed files
with
136 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2018 wysohn | ||
* | ||
* 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/>. | ||
*******************************************************************************/ | ||
function KICK(args) { | ||
var plType = Java.type("org.bukkit.entity.Player") | ||
if(args.length === 0){ | ||
if(player === null){ | ||
throw new Error("Too few arguments! You should enter at least on argument if you use KICK executor from console.") | ||
}else { | ||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', "&c[TR] You've been kicked from the server.")); | ||
return null; | ||
} | ||
}else if(args.length === 1) { | ||
var undefinedArgument = args[0] | ||
if(undefinedArgument === null) | ||
throw new Error("Unexpected Error: parameter does not match - player: null") | ||
|
||
if(args[0] instanceof plType) { | ||
var definedToPlayer = undefinedArgument; | ||
definedToPlayer.kickPlayer(ChatColor.translateAlternateColorCodes(Char('&'), "&c[TR] You've been kicked from the server.")); | ||
return null; | ||
} else if(typeof undefinedArgument === "string"){ | ||
var msg = undefinedArgument; | ||
player.kickPlayer(ChatColor.translateAlternateColorCodes(Char('&'), msg)); | ||
return null; | ||
}else { | ||
throw new Error("Found unexpected type of argument: "+ undefinedArgument); | ||
} | ||
}else if(args.length === 2) { | ||
var pl = args[0] | ||
var str = args[1] | ||
if(!(pl instanceof plType) || !(typeof str === "string")){ | ||
throw new Error("Found unexpected type of argument(s) - player: "+pl+" | msg: "+ str) | ||
}else { | ||
pl.kickPlayer(ChatColor.translateAlternateColorCodes(Char('&'), str)) | ||
return null; | ||
} | ||
}else if(args.length > 2){ | ||
throw new Error("Too many arguments! KICK Executor accepts up to two arguments.") | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters