mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-20 03:04:44 -05:00
Don't hardcode join titles
This commit is contained in:
parent
ddd6fa76f4
commit
3a3b450921
6 changed files with 62 additions and 26 deletions
|
@ -650,6 +650,8 @@ public class Main extends JavaPlugin {
|
||||||
this.nonSolidBlockList.addAll(nonSolidDoubleBlockList);
|
this.nonSolidBlockList.addAll(nonSolidDoubleBlockList);
|
||||||
this.nonSolidBlockList.addAll(nonSolidSingularBlockList);
|
this.nonSolidBlockList.addAll(nonSolidSingularBlockList);
|
||||||
this.nonSolidBlockList.addAll(nonSolidWallMountedBlockList);
|
this.nonSolidBlockList.addAll(nonSolidWallMountedBlockList);
|
||||||
|
|
||||||
|
saveResource("config.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pw.kaboom.extras;
|
package pw.kaboom.extras;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -7,6 +9,9 @@ import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
@ -17,18 +22,24 @@ class CommandPrefix implements CommandExecutor {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage("Command has to be run by a player");
|
||||||
} else {
|
} else {
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
final JavaPlugin plugin = JavaPlugin.getPlugin(Main.class);
|
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||||
|
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
|
try {
|
||||||
} else if (args[0].equalsIgnoreCase("off")) {
|
if (args.length == 0) {
|
||||||
plugin.getConfig().set(player.getUniqueId().toString(), null);
|
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <prefix|off>");
|
||||||
plugin.saveConfig();
|
} else if (args[0].equalsIgnoreCase("off")) {
|
||||||
player.sendMessage("You no longer have a tag");
|
prefixConfig.set(player.getUniqueId().toString(), null);
|
||||||
} else {
|
prefixConfig.save(configFile);
|
||||||
plugin.getConfig().set(player.getUniqueId().toString(), String.join(" ", args));
|
player.sendMessage("You no longer have a tag");
|
||||||
plugin.saveConfig();
|
} else {
|
||||||
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
prefixConfig.set(player.getUniqueId().toString(), String.join(" ", args));
|
||||||
|
prefixConfig.save(configFile);
|
||||||
|
player.sendMessage("You now have the tag: " + ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
player.sendMessage("Something went wrong while saving the prefix. Please check console.");
|
||||||
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -5,12 +5,13 @@ import java.util.ArrayList;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Nameable;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CommandBlock;
|
import org.bukkit.block.CommandBlock;
|
||||||
import org.bukkit.block.ShulkerBox;
|
|
||||||
|
|
||||||
import org.bukkit.block.data.Levelled;
|
import org.bukkit.block.data.Levelled;
|
||||||
|
|
||||||
|
@ -73,13 +74,21 @@ class BlockPhysics implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
final Material material = event.getChangedType();
|
final Material material = event.getChangedType();
|
||||||
|
final BlockState blockState = event.getSourceBlock().getState();
|
||||||
|
final BlockState blockStateSource = event.getSourceBlock().getState();
|
||||||
|
|
||||||
|
/*if (event.getSourceBlock().getBlockData().getAsString().length() > 3019) {
|
||||||
|
event.getSourceBlock().setType(Material.AIR);
|
||||||
|
} else if (event.getBlock().getBlockData().getAsString().length() > 3019) {
|
||||||
|
event.getBlock().setType(Material.AIR);
|
||||||
|
}*/
|
||||||
|
|
||||||
if (material == Material.FARMLAND) {
|
if (material == Material.FARMLAND) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (event.getSourceBlock().getState() instanceof CommandBlock) {
|
} else if (blockState instanceof CommandBlock) {
|
||||||
event.getSourceBlock().getState().update();
|
blockState.update();
|
||||||
} else if (event.getBlock().getState() instanceof CommandBlock) {
|
} else if (blockStateSource instanceof CommandBlock) {
|
||||||
event.getBlock().getState().update();
|
blockStateSource.update();
|
||||||
} else if (event.getBlock().isLiquid()) {
|
} else if (event.getBlock().isLiquid()) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
final World world = block.getWorld();
|
final World world = block.getWorld();
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package pw.kaboom.extras;
|
package pw.kaboom.extras;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -32,11 +36,14 @@ class PlayerChat implements Listener {
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final File configFile = new File(JavaPlugin.getPlugin(Main.class).getDataFolder(), "prefixes.yml");
|
||||||
|
final FileConfiguration prefixConfig = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
if (JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString()) != null) {
|
if (prefixConfig.getString(player.getUniqueId().toString()) != null) {
|
||||||
final String prefix = ChatColor.translateAlternateColorCodes(
|
final String prefix = ChatColor.translateAlternateColorCodes(
|
||||||
'&',
|
'&',
|
||||||
JavaPlugin.getPlugin(Main.class).getConfig().getString(player.getUniqueId().toString())
|
prefixConfig.getString(player.getUniqueId().toString())
|
||||||
);
|
);
|
||||||
|
|
||||||
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
event.setFormat(prefix + ChatColor.RESET + " " + player.getDisplayName().toString() + ChatColor.RESET + ": " + ChatColor.RESET + "%2$s");
|
||||||
|
|
|
@ -62,6 +62,8 @@ class PlayerConnection implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerJoin(PlayerJoinEvent event) {
|
void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final String title = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinTitle");
|
||||||
|
final String subtitle = JavaPlugin.getPlugin(Main.class).getConfig().getString("playerJoinSubtitle");
|
||||||
final int fadeIn = 10;
|
final int fadeIn = 10;
|
||||||
final int stay = 160;
|
final int stay = 160;
|
||||||
final int fadeOut = 5;
|
final int fadeOut = 5;
|
||||||
|
@ -87,13 +89,16 @@ class PlayerConnection implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendTitle(
|
if (title != null ||
|
||||||
ChatColor.GRAY + "Welcome to Kaboom!",
|
subtitle != null) {
|
||||||
"Free OP • Anarchy • Creative",
|
player.sendTitle(
|
||||||
fadeIn,
|
title,
|
||||||
stay,
|
subtitle,
|
||||||
fadeOut
|
fadeIn,
|
||||||
);
|
stay,
|
||||||
|
fadeOut
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
playerJoinTitle: "§7Welcome to Kaboom!"
|
||||||
|
playerJoinSubtitle: "Free OP • Anarchy • Creative"
|
Loading…
Reference in a new issue