当前位置: 首页>>代码示例>>Java>>正文


Java SimpleCommandMap.getCommands方法代码示例

本文整理汇总了Java中org.bukkit.command.SimpleCommandMap.getCommands方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleCommandMap.getCommands方法的具体用法?Java SimpleCommandMap.getCommands怎么用?Java SimpleCommandMap.getCommands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.command.SimpleCommandMap的用法示例。


在下文中一共展示了SimpleCommandMap.getCommands方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inject

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
/**
 * 
 * @author jiongjionger,Vlvxingze
 */

public static void inject(Plugin plg) {
	if (plg != null) {
		try {
			SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
			for (Command command : simpleCommandMap.getCommands()) {
				if (command instanceof PluginCommand) {
					PluginCommand pluginCommand = (PluginCommand) command;
					if (plg.equals(pluginCommand.getPlugin())) {
						FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
						FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
						CommandInjector commandInjector = new CommandInjector(plg, commandField.get(pluginCommand), tabField.get(pluginCommand));
						commandField.set(pluginCommand, commandInjector);
						tabField.set(pluginCommand, commandInjector);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:27,代码来源:CommandInjector.java

示例2: uninject

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
public static void uninject(Plugin plg) {
	if (plg != null) {
		try {
			SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
			for (Command command : simpleCommandMap.getCommands()) {
				if (command instanceof PluginCommand) {
					PluginCommand pluginCommand = (PluginCommand) command;
					if (plg.equals(pluginCommand.getPlugin())) {
						FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
						FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
						CommandExecutor executor = commandField.get(pluginCommand);
						if (executor instanceof CommandInjector) {
							commandField.set(pluginCommand, ((CommandInjector) executor).getCommandExecutor());
						}
						TabCompleter completer = tabField.get(pluginCommand);
						if (completer instanceof CommandInjector) {
							tabField.set(pluginCommand, ((CommandInjector) executor).getTabCompleter());
						}
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:27,代码来源:CommandInjector.java

示例3: getCommandTimingsByPlugin

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) {
	Map<String, MonitorRecord> record = new HashMap<>();
	if (plg == null) {
		return record;
	}
	try {
		SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
		for (Command command : simpleCommandMap.getCommands()) {
			if (command instanceof PluginCommand) {
				PluginCommand pluginCommand = (PluginCommand) command;
				if (plg.equals(pluginCommand.getPlugin())) {
					FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
					CommandExecutor executor = commandField.get(pluginCommand);
					if (executor instanceof CommandInjector) {
						CommandInjector commandInjector = (CommandInjector) executor;
						record = mergeRecordMap(record, commandInjector.getMonitorRecordMap());
					}

				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return record;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:27,代码来源:MonitorUtils.java

示例4: getCommandTimingsByPlugin

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) {
	Map<String, MonitorRecord> record = new HashMap<>();
	if (plg == null) {
		return record;
	}
	try {
		SimpleCommandMap simpleCommandMap = Reflection
				.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class)
				.get(Bukkit.getPluginManager());
		for (Command command : simpleCommandMap.getCommands()) {
			if (command instanceof PluginCommand) {
				PluginCommand pluginCommand = (PluginCommand) command;
				if (plg.equals(pluginCommand.getPlugin())) {
					FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class,
							"executor", CommandExecutor.class);
					CommandExecutor executor = commandField.get(pluginCommand);
					if (executor instanceof CommandInjector) {
						CommandInjector commandInjector = (CommandInjector) executor;
						record = mergeRecordMap(record, commandInjector.getMonitorRecordMap());
					}

				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return record;
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:30,代码来源:MonitorUtils.java

示例5: inject

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
public static void inject(Plugin toInjectPlugin) {
        PluginManager pluginManager = Bukkit.getPluginManager();
        SimpleCommandMap commandMap = Reflection
                .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
        for (Command command : commandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
                Plugin plugin = pluginCommand.getPlugin();
                if (plugin.equals(toInjectPlugin)) {
                    FieldAccessor<CommandExecutor> executorField = Reflection
                            .getField(PluginCommand.class, "executor", CommandExecutor.class);
                    FieldAccessor<TabCompleter> completerField = Reflection
                            .getField(PluginCommand.class, "completer", TabCompleter.class);

                    CommandExecutor executor = executorField.get(pluginCommand);
                    TabCompleter completer = completerField.get(pluginCommand);

                    CommandInjector commandInjector = new CommandInjector(executor, completer);

                    executorField.set(pluginCommand, commandInjector);
                    completerField.set(pluginCommand, commandInjector);
                }
            }

            //idea: inject also vanilla commands?
//            if (command instanceof VanillaCommand) {
//
//            }
        }
    }
 
开发者ID:games647,项目名称:LagMonitor,代码行数:31,代码来源:CommandInjector.java

示例6: uninject

import org.bukkit.command.SimpleCommandMap; //导入方法依赖的package包/类
public static void uninject(Plugin toUninject) {
    PluginManager pluginManager = Bukkit.getPluginManager();
    SimpleCommandMap commandMap = Reflection
            .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
    for (Command command : commandMap.getCommands()) {
        if (command instanceof PluginCommand) {
            PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
            Plugin plugin = pluginCommand.getPlugin();
            if (plugin.equals(toUninject)) {
                FieldAccessor<CommandExecutor> executorField = Reflection
                        .getField(PluginCommand.class, "executor", CommandExecutor.class);
                FieldAccessor<TabCompleter> completerField = Reflection
                        .getField(PluginCommand.class, "completer", TabCompleter.class);

                CommandExecutor executor = executorField.get(pluginCommand);
                if (executor instanceof CommandInjector) {
                    executorField.set(pluginCommand, ((CommandInjector) executor).originalExecutor);
                }

                TabCompleter completer = completerField.get(pluginCommand);
                if (completer instanceof CommandInjector) {
                    completerField.set(pluginCommand, ((CommandInjector) completer).originalCompleter);
                }
            }
        }
    }
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:28,代码来源:CommandInjector.java


注:本文中的org.bukkit.command.SimpleCommandMap.getCommands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。