Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -22,8 +22,8 @@ public class CommandAliasHelpTopic extends HelpTopic {
|
||||
@Override
|
||||
public String getFullText(CommandSender forWho) {
|
||||
Preconditions.checkArgument(forWho != null, "CommandServer forWho cannot be null");
|
||||
StringBuilder sb = new StringBuilder(shortText);
|
||||
HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
|
||||
StringBuilder sb = new StringBuilder(this.shortText);
|
||||
HelpTopic aliasForTopic = this.helpMap.getHelpTopic(this.aliasFor);
|
||||
if (aliasForTopic != null) {
|
||||
sb.append("\n");
|
||||
sb.append(aliasForTopic.getFullText(forWho));
|
||||
@@ -34,15 +34,15 @@ public class CommandAliasHelpTopic extends HelpTopic {
|
||||
@Override
|
||||
public boolean canSee(CommandSender commandSender) {
|
||||
Preconditions.checkArgument(commandSender != null, "CommandServer cannot be null");
|
||||
if (amendedPermission == null) {
|
||||
HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
|
||||
if (this.amendedPermission == null) {
|
||||
HelpTopic aliasForTopic = this.helpMap.getHelpTopic(this.aliasFor);
|
||||
if (aliasForTopic != null) {
|
||||
return aliasForTopic.canSee(commandSender);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return commandSender.hasPermission(amendedPermission);
|
||||
return commandSender.hasPermission(this.amendedPermission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ public class CustomHelpTopic extends HelpTopic {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!permissionNode.equals("")) {
|
||||
return sender.hasPermission(permissionNode);
|
||||
if (!this.permissionNode.equals("")) {
|
||||
return sender.hasPermission(this.permissionNode);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ public class CustomIndexHelpTopic extends IndexHelpTopic {
|
||||
|
||||
@Override
|
||||
public String getFullText(CommandSender sender) {
|
||||
if (futureTopics != null) {
|
||||
if (this.futureTopics != null) {
|
||||
List<HelpTopic> topics = new LinkedList<HelpTopic>();
|
||||
for (String futureTopic : futureTopics) {
|
||||
HelpTopic topic = helpMap.getHelpTopic(futureTopic);
|
||||
for (String futureTopic : this.futureTopics) {
|
||||
HelpTopic topic = this.helpMap.getHelpTopic(futureTopic);
|
||||
if (topic != null) {
|
||||
topics.add(topic);
|
||||
}
|
||||
}
|
||||
setTopicsCollection(topics);
|
||||
futureTopics = null;
|
||||
this.setTopicsCollection(topics);
|
||||
this.futureTopics = null;
|
||||
}
|
||||
|
||||
return super.getFullText(sender);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class HelpTopicAmendment {
|
||||
* @return the full text
|
||||
*/
|
||||
public String getFullText() {
|
||||
return fullText;
|
||||
return this.fullText;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ public class HelpTopicAmendment {
|
||||
* @return the short text
|
||||
*/
|
||||
public String getShortText() {
|
||||
return shortText;
|
||||
return this.shortText;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ public class HelpTopicAmendment {
|
||||
* @return the topic name
|
||||
*/
|
||||
public String getTopicName() {
|
||||
return topicName;
|
||||
return this.topicName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,6 +45,6 @@ public class HelpTopicAmendment {
|
||||
* @return the permission
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
return this.permission;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,23 @@ public class HelpYamlReader {
|
||||
this.server = server;
|
||||
|
||||
File helpYamlFile = new File("help.yml");
|
||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
|
||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
|
||||
|
||||
try {
|
||||
helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile);
|
||||
helpYaml.options().copyDefaults(true);
|
||||
helpYaml.setDefaults(defaultConfig);
|
||||
this.helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile);
|
||||
this.helpYaml.options().copyDefaults(true);
|
||||
this.helpYaml.setDefaults(defaultConfig);
|
||||
|
||||
try {
|
||||
if (!helpYamlFile.exists()) {
|
||||
helpYaml.save(helpYamlFile);
|
||||
this.helpYaml.save(helpYamlFile);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
server.getLogger().log(Level.SEVERE, "Could not save " + helpYamlFile, ex);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
server.getLogger().severe("Failed to load help.yml. Verify the yaml indentation is correct. Reverting to default help.yml.");
|
||||
helpYaml = defaultConfig;
|
||||
this.helpYaml = defaultConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ public class HelpYamlReader {
|
||||
*/
|
||||
public List<HelpTopic> getGeneralTopics() {
|
||||
List<HelpTopic> topics = new LinkedList<HelpTopic>();
|
||||
ConfigurationSection generalTopics = helpYaml.getConfigurationSection("general-topics");
|
||||
ConfigurationSection generalTopics = this.helpYaml.getConfigurationSection("general-topics");
|
||||
if (generalTopics != null) {
|
||||
for (String topicName : generalTopics.getKeys(false)) {
|
||||
ConfigurationSection section = generalTopics.getConfigurationSection(topicName);
|
||||
String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String fullText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("fullText", ""));
|
||||
String shortText = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String fullText = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("fullText", ""));
|
||||
String permission = section.getString("permission", "");
|
||||
topics.add(new CustomHelpTopic(topicName, shortText, fullText, permission));
|
||||
}
|
||||
@@ -73,15 +73,15 @@ public class HelpYamlReader {
|
||||
*/
|
||||
public List<HelpTopic> getIndexTopics() {
|
||||
List<HelpTopic> topics = new LinkedList<HelpTopic>();
|
||||
ConfigurationSection indexTopics = helpYaml.getConfigurationSection("index-topics");
|
||||
ConfigurationSection indexTopics = this.helpYaml.getConfigurationSection("index-topics");
|
||||
if (indexTopics != null) {
|
||||
for (String topicName : indexTopics.getKeys(false)) {
|
||||
ConfigurationSection section = indexTopics.getConfigurationSection(topicName);
|
||||
String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String preamble = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("preamble", ""));
|
||||
String permission = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("permission", ""));
|
||||
String shortText = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String preamble = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("preamble", ""));
|
||||
String permission = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("permission", ""));
|
||||
List<String> commands = section.getStringList("commands");
|
||||
topics.add(new CustomIndexHelpTopic(server.getHelpMap(), topicName, shortText, permission, commands, preamble));
|
||||
topics.add(new CustomIndexHelpTopic(this.server.getHelpMap(), topicName, shortText, permission, commands, preamble));
|
||||
}
|
||||
}
|
||||
return topics;
|
||||
@@ -94,12 +94,12 @@ public class HelpYamlReader {
|
||||
*/
|
||||
public List<HelpTopicAmendment> getTopicAmendments() {
|
||||
List<HelpTopicAmendment> amendments = new LinkedList<HelpTopicAmendment>();
|
||||
ConfigurationSection commandTopics = helpYaml.getConfigurationSection("amended-topics");
|
||||
ConfigurationSection commandTopics = this.helpYaml.getConfigurationSection("amended-topics");
|
||||
if (commandTopics != null) {
|
||||
for (String topicName : commandTopics.getKeys(false)) {
|
||||
ConfigurationSection section = commandTopics.getConfigurationSection(topicName);
|
||||
String description = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String usage = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("fullText", ""));
|
||||
String description = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("shortText", ""));
|
||||
String usage = ChatColor.translateAlternateColorCodes(this.ALT_COLOR_CODE, section.getString("fullText", ""));
|
||||
String permission = section.getString("permission", "");
|
||||
amendments.add(new HelpTopicAmendment(topicName, description, usage, permission));
|
||||
}
|
||||
@@ -108,10 +108,10 @@ public class HelpYamlReader {
|
||||
}
|
||||
|
||||
public List<String> getIgnoredPlugins() {
|
||||
return helpYaml.getStringList("ignore-plugins");
|
||||
return this.helpYaml.getStringList("ignore-plugins");
|
||||
}
|
||||
|
||||
public boolean commandTopicsInMasterIndex() {
|
||||
return helpYaml.getBoolean("command-topics-in-master-index", true);
|
||||
return this.helpYaml.getBoolean("command-topics-in-master-index", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MultipleCommandAliasHelpTopic extends HelpTopic {
|
||||
public MultipleCommandAliasHelpTopic(MultipleCommandAlias alias) {
|
||||
this.alias = alias;
|
||||
|
||||
name = "/" + alias.getLabel();
|
||||
this.name = "/" + alias.getLabel();
|
||||
|
||||
// Build short text
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -28,20 +28,20 @@ public class MultipleCommandAliasHelpTopic extends HelpTopic {
|
||||
sb.append("/");
|
||||
sb.append(alias.getCommands()[i].getLabel());
|
||||
}
|
||||
shortText = sb.toString();
|
||||
this.shortText = sb.toString();
|
||||
|
||||
// Build full text
|
||||
fullText = ChatColor.GOLD + "Alias for: " + ChatColor.WHITE + getShortText();
|
||||
this.fullText = ChatColor.GOLD + "Alias for: " + ChatColor.WHITE + this.getShortText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(CommandSender sender) {
|
||||
if (amendedPermission == null) {
|
||||
if (this.amendedPermission == null) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Command command : alias.getCommands()) {
|
||||
for (Command command : this.alias.getCommands()) {
|
||||
if (!command.testPermissionSilent(sender)) {
|
||||
return false;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class MultipleCommandAliasHelpTopic extends HelpTopic {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return sender.hasPermission(amendedPermission);
|
||||
return sender.hasPermission(this.amendedPermission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,23 +46,23 @@ public class SimpleHelpMap implements HelpMap {
|
||||
this.yaml = new HelpYamlReader(server);
|
||||
|
||||
Predicate indexFilter = Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class));
|
||||
if (!yaml.commandTopicsInMasterIndex()) {
|
||||
if (!this.yaml.commandTopicsInMasterIndex()) {
|
||||
indexFilter = Predicates.and(indexFilter, Predicates.not(new IsCommandTopicPredicate()));
|
||||
}
|
||||
|
||||
this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.");
|
||||
this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(this.helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.");
|
||||
|
||||
registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
|
||||
this.registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized HelpTopic getHelpTopic(String topicName) {
|
||||
if (topicName.equals("")) {
|
||||
return defaultTopic;
|
||||
return this.defaultTopic;
|
||||
}
|
||||
|
||||
if (helpTopics.containsKey(topicName)) {
|
||||
return helpTopics.get(topicName);
|
||||
if (this.helpTopics.containsKey(topicName)) {
|
||||
return this.helpTopics.get(topicName);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -70,44 +70,44 @@ public class SimpleHelpMap implements HelpMap {
|
||||
|
||||
@Override
|
||||
public Collection<HelpTopic> getHelpTopics() {
|
||||
return helpTopics.values();
|
||||
return this.helpTopics.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addTopic(HelpTopic topic) {
|
||||
// Existing topics take priority
|
||||
if (!helpTopics.containsKey(topic.getName())) {
|
||||
helpTopics.put(topic.getName(), topic);
|
||||
if (!this.helpTopics.containsKey(topic.getName())) {
|
||||
this.helpTopics.put(topic.getName(), topic);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void clear() {
|
||||
helpTopics.clear();
|
||||
this.helpTopics.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getIgnoredPlugins() {
|
||||
return yaml.getIgnoredPlugins();
|
||||
return this.yaml.getIgnoredPlugins();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the general topics from help.yml and adds them to the help index.
|
||||
*/
|
||||
public synchronized void initializeGeneralTopics() {
|
||||
yaml = new HelpYamlReader(server);
|
||||
this.yaml = new HelpYamlReader(this.server);
|
||||
|
||||
// Initialize general help topics from the help.yml file
|
||||
for (HelpTopic topic : yaml.getGeneralTopics()) {
|
||||
addTopic(topic);
|
||||
for (HelpTopic topic : this.yaml.getGeneralTopics()) {
|
||||
this.addTopic(topic);
|
||||
}
|
||||
|
||||
// Initialize index help topics from the help.yml file
|
||||
for (HelpTopic topic : yaml.getIndexTopics()) {
|
||||
for (HelpTopic topic : this.yaml.getIndexTopics()) {
|
||||
if (topic.getName().equals("Default")) {
|
||||
defaultTopic = topic;
|
||||
this.defaultTopic = topic;
|
||||
} else {
|
||||
addTopic(topic);
|
||||
this.addTopic(topic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class SimpleHelpMap implements HelpMap {
|
||||
*/
|
||||
public synchronized void initializeCommands() {
|
||||
// ** Load topics from highest to lowest priority order **
|
||||
Set<String> ignoredPlugins = new HashSet<String>(yaml.getIgnoredPlugins());
|
||||
Set<String> ignoredPlugins = new HashSet<String>(this.yaml.getIgnoredPlugins());
|
||||
|
||||
// Don't load any automatic help topics if All is ignored
|
||||
if (ignoredPlugins.contains("All")) {
|
||||
@@ -125,60 +125,60 @@ public class SimpleHelpMap implements HelpMap {
|
||||
}
|
||||
|
||||
// Initialize help topics from the server's command map
|
||||
outer: for (Command command : server.getCommandMap().getCommands()) {
|
||||
if (commandInIgnoredPlugin(command, ignoredPlugins)) {
|
||||
outer: for (Command command : this.server.getCommandMap().getCommands()) {
|
||||
if (this.commandInIgnoredPlugin(command, ignoredPlugins)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Register a topic
|
||||
for (Class c : topicFactoryMap.keySet()) {
|
||||
for (Class c : this.topicFactoryMap.keySet()) {
|
||||
if (c.isAssignableFrom(command.getClass())) {
|
||||
HelpTopic t = topicFactoryMap.get(c).createTopic(command);
|
||||
if (t != null) addTopic(t);
|
||||
HelpTopic t = this.topicFactoryMap.get(c).createTopic(command);
|
||||
if (t != null) this.addTopic(t);
|
||||
continue outer;
|
||||
}
|
||||
if (command instanceof PluginCommand && c.isAssignableFrom(((PluginCommand) command).getExecutor().getClass())) {
|
||||
HelpTopic t = topicFactoryMap.get(c).createTopic(command);
|
||||
if (t != null) addTopic(t);
|
||||
HelpTopic t = this.topicFactoryMap.get(c).createTopic(command);
|
||||
if (t != null) this.addTopic(t);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
addTopic(new GenericCommandHelpTopic(command));
|
||||
this.addTopic(new GenericCommandHelpTopic(command));
|
||||
}
|
||||
|
||||
// Initialize command alias help topics
|
||||
for (Command command : server.getCommandMap().getCommands()) {
|
||||
if (commandInIgnoredPlugin(command, ignoredPlugins)) {
|
||||
for (Command command : this.server.getCommandMap().getCommands()) {
|
||||
if (this.commandInIgnoredPlugin(command, ignoredPlugins)) {
|
||||
continue;
|
||||
}
|
||||
for (String alias : command.getAliases()) {
|
||||
// Only register if this command owns the alias
|
||||
if (server.getCommandMap().getCommand(alias) == command) {
|
||||
addTopic(new CommandAliasHelpTopic("/" + alias, "/" + command.getLabel(), this));
|
||||
if (this.server.getCommandMap().getCommand(alias) == command) {
|
||||
this.addTopic(new CommandAliasHelpTopic("/" + alias, "/" + command.getLabel(), this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add alias sub-index
|
||||
Collection<HelpTopic> filteredTopics = Collections2.filter(helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.class));
|
||||
Collection<HelpTopic> filteredTopics = Collections2.filter(this.helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.class));
|
||||
if (!filteredTopics.isEmpty()) {
|
||||
addTopic(new IndexHelpTopic("Aliases", "Lists command aliases", null, filteredTopics));
|
||||
this.addTopic(new IndexHelpTopic("Aliases", "Lists command aliases", null, filteredTopics));
|
||||
}
|
||||
|
||||
// Initialize plugin-level sub-topics
|
||||
Map<String, Set<HelpTopic>> pluginIndexes = new HashMap<String, Set<HelpTopic>>();
|
||||
fillPluginIndexes(pluginIndexes, server.getCommandMap().getCommands());
|
||||
this.fillPluginIndexes(pluginIndexes, this.server.getCommandMap().getCommands());
|
||||
|
||||
for (Map.Entry<String, Set<HelpTopic>> entry : pluginIndexes.entrySet()) {
|
||||
addTopic(new IndexHelpTopic(entry.getKey(), "All commands for " + entry.getKey(), null, entry.getValue(), "Below is a list of all " + entry.getKey() + " commands:"));
|
||||
this.addTopic(new IndexHelpTopic(entry.getKey(), "All commands for " + entry.getKey(), null, entry.getValue(), "Below is a list of all " + entry.getKey() + " commands:"));
|
||||
}
|
||||
|
||||
// Amend help topics from the help.yml file
|
||||
for (HelpTopicAmendment amendment : yaml.getTopicAmendments()) {
|
||||
if (helpTopics.containsKey(amendment.getTopicName())) {
|
||||
helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText());
|
||||
for (HelpTopicAmendment amendment : this.yaml.getTopicAmendments()) {
|
||||
if (this.helpTopics.containsKey(amendment.getTopicName())) {
|
||||
this.helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText());
|
||||
if (amendment.getPermission() != null) {
|
||||
helpTopics.get(amendment.getTopicName()).amendCanSee(amendment.getPermission());
|
||||
this.helpTopics.get(amendment.getTopicName()).amendCanSee(amendment.getPermission());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,9 +186,9 @@ public class SimpleHelpMap implements HelpMap {
|
||||
|
||||
private void fillPluginIndexes(Map<String, Set<HelpTopic>> pluginIndexes, Collection<? extends Command> commands) {
|
||||
for (Command command : commands) {
|
||||
String pluginName = getCommandPluginName(command);
|
||||
String pluginName = this.getCommandPluginName(command);
|
||||
if (pluginName != null) {
|
||||
HelpTopic topic = getHelpTopic("/" + command.getLabel());
|
||||
HelpTopic topic = this.getHelpTopic("/" + command.getLabel());
|
||||
if (topic != null) {
|
||||
if (!pluginIndexes.containsKey(pluginName)) {
|
||||
pluginIndexes.put(pluginName, new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance())); //keep things in topic order
|
||||
@@ -225,7 +225,7 @@ public class SimpleHelpMap implements HelpMap {
|
||||
@Override
|
||||
public void registerHelpTopicFactory(Class commandClass, HelpTopicFactory factory) {
|
||||
Preconditions.checkArgument(Command.class.isAssignableFrom(commandClass) || CommandExecutor.class.isAssignableFrom(commandClass), "commandClass (%s) must implement either Command or CommandExecutor", commandClass.getName());
|
||||
topicFactoryMap.put(commandClass, factory);
|
||||
this.topicFactoryMap.put(commandClass, factory);
|
||||
}
|
||||
|
||||
private class IsCommandTopicPredicate implements Predicate<HelpTopic> {
|
||||
|
||||
Reference in New Issue
Block a user