use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by Trichtern.
the class WorldsCommand method getPermissionInput.
public void getPermissionInput(Player player, boolean closeInventory) {
BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_setpermission_error"));
return;
}
new PlayerChatInput(plugin, player, "enter_world_permission", input -> {
buildWorld.setPermission(input.trim());
playerManager.forceUpdateSidebar(buildWorld);
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.sendMessage(plugin.getString("worlds_setpermission_set").replace("%world%", buildWorld.getName()));
if (closeInventory) {
player.closeInventory();
} else {
player.openInventory(plugin.getEditInventory().getInventory(player, buildWorld));
}
});
}
use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.
the class WorldsCommand method getAddBuilderInput.
public void getAddBuilderInput(Player player, boolean closeInventory) {
BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_addbuilder_error"));
return;
}
new PlayerChatInput(plugin, player, "enter_player_name", input -> {
String builderName = input.trim();
Player builderPlayer = Bukkit.getPlayer(builderName);
Builder builder;
UUID builderId;
if (builderPlayer == null) {
builderId = UUIDFetcher.getUUID(builderName);
if (builderId == null) {
player.sendMessage(plugin.getString("worlds_addbuilder_player_not_found"));
player.closeInventory();
return;
}
builder = new Builder(builderId, builderName);
} else {
builder = new Builder(builderPlayer);
builderId = builderPlayer.getUniqueId();
}
if (buildWorld.getCreatorId() != null && buildWorld.getCreatorId().equals(builderId)) {
player.sendMessage(plugin.getString("worlds_addbuilder_already_creator"));
player.closeInventory();
return;
}
if (buildWorld.isBuilder(builderId)) {
player.sendMessage(plugin.getString("worlds_addbuilder_already_added"));
player.closeInventory();
return;
}
buildWorld.addBuilder(builder);
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.sendMessage(plugin.getString("worlds_addbuilder_added").replace("%builder%", builderName));
if (closeInventory) {
player.closeInventory();
} else {
player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
}
});
}
use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.
the class WorldsCommand method getRemoveBuilderInput.
public void getRemoveBuilderInput(Player player, boolean closeInventory) {
BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_removebuilder_error"));
return;
}
new PlayerChatInput(plugin, player, "enter_player_name", input -> {
String builderName = input.trim();
Player builderPlayer = Bukkit.getPlayer(builderName);
UUID builderId;
if (builderPlayer == null) {
builderId = UUIDFetcher.getUUID(builderName);
if (builderId == null) {
player.sendMessage(plugin.getString("worlds_removebuilder_player_not_found"));
player.closeInventory();
return;
}
} else {
builderId = builderPlayer.getUniqueId();
}
if (buildWorld.getCreatorId() != null && buildWorld.getCreatorId().equals(builderId)) {
player.sendMessage(plugin.getString("worlds_removebuilder_not_yourself"));
player.closeInventory();
return;
}
if (!buildWorld.isBuilder(builderId)) {
player.sendMessage(plugin.getString("worlds_removebuilder_not_builder"));
player.closeInventory();
return;
}
buildWorld.removeBuilder(builderId);
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.sendMessage(plugin.getString("worlds_removebuilder_removed").replace("%builder%", builderName));
if (closeInventory) {
player.closeInventory();
} else {
player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
}
});
}
use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.
the class WorldsCommand method getPermissionInput.
public void getPermissionInput(Player player, boolean closeInventory) {
BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_setpermission_error"));
return;
}
new PlayerChatInput(plugin, player, "enter_world_permission", input -> {
buildWorld.setPermission(input.trim());
playerManager.forceUpdateSidebar(buildWorld);
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.sendMessage(plugin.getString("worlds_setpermission_set").replace("%world%", buildWorld.getName()));
if (closeInventory) {
player.closeInventory();
} else {
player.openInventory(plugin.getEditInventory().getInventory(player, buildWorld));
}
});
}
use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by Trichtern.
the class WorldsCommand method getAddBuilderInput.
public void getAddBuilderInput(Player player, boolean closeInventory) {
BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
if (buildWorld == null) {
player.closeInventory();
player.sendMessage(plugin.getString("worlds_addbuilder_error"));
return;
}
new PlayerChatInput(plugin, player, "enter_player_name", input -> {
String builderName = input.trim();
Player builderPlayer = Bukkit.getPlayerExact(builderName);
Builder builder;
UUID builderId;
if (builderPlayer == null) {
builderId = UUIDFetcher.getUUID(builderName);
if (builderId == null) {
player.sendMessage(plugin.getString("worlds_addbuilder_player_not_found"));
player.closeInventory();
return;
}
builder = new Builder(builderId, builderName);
} else {
builder = new Builder(builderPlayer);
builderId = builderPlayer.getUniqueId();
}
if (builderId.equals(player.getUniqueId()) && buildWorld.isCreator(player)) {
player.sendMessage(plugin.getString("worlds_addbuilder_already_creator"));
player.closeInventory();
return;
}
if (buildWorld.isBuilder(builderId)) {
player.sendMessage(plugin.getString("worlds_addbuilder_already_added"));
player.closeInventory();
return;
}
buildWorld.addBuilder(builder);
XSound.ENTITY_PLAYER_LEVELUP.play(player);
player.sendMessage(plugin.getString("worlds_addbuilder_added").replace("%builder%", builderName));
if (closeInventory) {
player.closeInventory();
} else {
player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
}
});
}
Aggregations