-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
164 additions
and
211 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,47 @@ | ||
package com.mengcraft.script; | ||
|
||
import com.mengcraft.script.util.Utils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import javax.script.Bindings; | ||
import java.util.function.BiConsumer; | ||
|
||
/** | ||
* Created on 16-10-17. | ||
*/ | ||
@RequiredArgsConstructor | ||
public class HandledCommand implements CommandExecutor { | ||
|
||
private final ScriptPlugin script; | ||
private final String label; | ||
private final BiConsumer<CommandSender, Bindings> executor; | ||
private final String permission; | ||
|
||
public boolean execute(CommandSender sender, Bindings params) { | ||
if (permission == null || sender.hasPermission(permission)) { | ||
executor.accept(sender, params); | ||
return true; | ||
} else { | ||
sender.sendMessage(ChatColor.RED + "你没有执行权限"); | ||
} | ||
return false; | ||
} | ||
|
||
|
||
public boolean remove() { | ||
return script.remove(this); | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] params) { | ||
return execute(sender, Utils.fromJava(params)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.