fix code examples

This commit is contained in:
Andre_601 2021-07-22 12:56:56 +02:00 committed by GitHub
parent e16287405b
commit fa717c34ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,12 +123,15 @@ public class SomeExpansion extends PlaceholderExpansion {
public String onRequest(OfflinePlayer player, String params) { public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("name")) { if(params.equalsIgnoreCase("name")) {
return player == null ? null : player.getName(); // "name" requires the player to be valid return player == null ? null : player.getName(); // "name" requires the player to be valid
}
if(params.equalsIgnoreCase("placeholder1")) { if(params.equalsIgnoreCase("placeholder1")) {
return "Placeholder Text 1"; return "Placeholder Text 1";
}
if(params.equalsIgnoreCase("placeholder2")) { if(params.equalsIgnoreCase("placeholder2")) {
return "Placeholder Text 2"; return "Placeholder Text 2";
}
return null; // Placeholder is unknown by the Expansion return null; // Placeholder is unknown by the Expansion
} }
@ -200,9 +203,11 @@ public class SomeExpansion extends PlaceholderExpansion {
public String onRequest(OfflinePlayer player, String params) { public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("placeholder1")){ if(params.equalsIgnoreCase("placeholder1")){
return plugin.getConfig().getString("placeholders.placeholder1", "default1"); return plugin.getConfig().getString("placeholders.placeholder1", "default1");
}
if(params.equalsIgnoreCase("placeholder2")){ if(params.equalsIgnoreCase("placeholder2")){
return plugin.getConfig().getString("placeholders.placeholder2", "default2"); return plugin.getConfig().getString("placeholders.placeholder2", "default2");
}
return null; // Placeholder is unknown by the expansion return null; // Placeholder is unknown by the expansion
} }
@ -272,9 +277,11 @@ private SomePlugin plugin;
public String onRequest(OfflinePlayer player, String params) { public String onRequest(OfflinePlayer player, String params) {
if(params.equalsIgnoreCase("placeholder1")){ if(params.equalsIgnoreCase("placeholder1")){
return plugin.getConfig().getString("placeholders.placeholder1", "default1"); return plugin.getConfig().getString("placeholders.placeholder1", "default1");
}
if(params.equalsIgnoreCase("placeholder2")) { if(params.equalsIgnoreCase("placeholder2")) {
return plugin.getConfig().getString("placeholders.placeholder2", "default2"); return plugin.getConfig().getString("placeholders.placeholder2", "default2");
}
return null; // Placeholder is unknown by the Expansion return null; // Placeholder is unknown by the Expansion
} }
@ -358,11 +365,12 @@ public class SomeExpansion extends PlaceholderExpansion implements Relational {
return null; // We require both Players to be online return null; // We require both Players to be online
if(params.equalsIgnoreCase("friend")) { if(params.equalsIgnoreCase("friend")) {
if(plugin.areFriends(one, two)) if(plugin.areFriends(one, two)) {
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are friends!"; return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are friends!";
else } else {
return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are not friends!"; return ChatColor.GREEN + one.getName() + " and " + two.getName() + " are not friends!";
} }
}
return null; // Placeholder is unknown by the Expansion return null; // Placeholder is unknown by the Expansion
} }