refactor: use this. use final and only use getters and setters
This commit is contained in:
parent
5ab70b7cb9
commit
7e194171e8
19 changed files with 248 additions and 217 deletions
|
@ -4,10 +4,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Difficulty;
|
|
||||||
import org.bukkit.GameRule;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
@ -16,7 +12,6 @@ import de.cliffbreak.varo.commands.VaroCommand;
|
||||||
import de.cliffbreak.varo.listeners.BannedActionListener;
|
import de.cliffbreak.varo.listeners.BannedActionListener;
|
||||||
import de.cliffbreak.varo.listeners.BannedItemListener;
|
import de.cliffbreak.varo.listeners.BannedItemListener;
|
||||||
import de.cliffbreak.varo.listeners.ChatListener;
|
import de.cliffbreak.varo.listeners.ChatListener;
|
||||||
import de.cliffbreak.varo.listeners.CreatureSpawnListener;
|
|
||||||
import de.cliffbreak.varo.listeners.PlayerInteractNPCListener;
|
import de.cliffbreak.varo.listeners.PlayerInteractNPCListener;
|
||||||
import de.cliffbreak.varo.listeners.EntityRegainHealthListener;
|
import de.cliffbreak.varo.listeners.EntityRegainHealthListener;
|
||||||
import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener;
|
import de.cliffbreak.varo.listeners.PlayerClientOptionsChangeListener;
|
||||||
|
@ -26,97 +21,91 @@ import de.cliffbreak.varo.listeners.PlayerPreLoginListener;
|
||||||
import de.cliffbreak.varo.managers.NPCManager;
|
import de.cliffbreak.varo.managers.NPCManager;
|
||||||
import de.cliffbreak.varo.uitls.BanUtils;
|
import de.cliffbreak.varo.uitls.BanUtils;
|
||||||
import de.cliffbreak.varo.uitls.PlayerCache;
|
import de.cliffbreak.varo.uitls.PlayerCache;
|
||||||
|
import de.cliffbreak.varo.uitls.VaroUtils;
|
||||||
|
|
||||||
public class Varo extends JavaPlugin {
|
public class Varo extends JavaPlugin {
|
||||||
|
|
||||||
public File configurationFile = new File("plugins/CliffbreakVaro", "config.yml");
|
private File configurationFile;
|
||||||
public FileConfiguration config = YamlConfiguration.loadConfiguration(this.configurationFile);
|
private FileConfiguration config;
|
||||||
public NPCManager npcManager;
|
private NPCManager npcManager;
|
||||||
public PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
public BanUtils banUtils;
|
private BanUtils banUtils;
|
||||||
|
private VaroUtils varoUtils;
|
||||||
|
|
||||||
public boolean canCreatePortal = false;
|
private boolean canCreatePortal = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
getLogger().info("CliffbreakVaro is starting...");
|
this.getLogger().info("CliffbreakVaro is starting...");
|
||||||
|
|
||||||
|
this.configurationFile = new File("plugins/CliffbreakVaro", "config.yml");
|
||||||
|
this.config = YamlConfiguration.loadConfiguration(this.configurationFile);
|
||||||
|
|
||||||
this.npcManager = new NPCManager(this);
|
this.npcManager = new NPCManager(this);
|
||||||
this.playerCache = new PlayerCache(this);
|
this.playerCache = new PlayerCache(this);
|
||||||
this.banUtils = new BanUtils(this);
|
this.banUtils = new BanUtils(this);
|
||||||
|
this.varoUtils = new VaroUtils(this);
|
||||||
|
|
||||||
// this.config.addDefault("Varo.Start", "TODO: StartDate");
|
// this.config.addDefault("Varo.Start", "TODO: StartDate");
|
||||||
this.config.addDefault("Varo.Debug", false);
|
this.config.addDefault("Varo.Debug", false);
|
||||||
this.config.addDefault("Varo.Bans", new ArrayList<String>());
|
this.config.addDefault("Varo.Bans", new ArrayList<String>());
|
||||||
this.config.options().copyDefaults(true);
|
this.config.options().copyDefaults(true);
|
||||||
this.saveConfiguration();
|
this.saveConfig();
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerPreLoginListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerPreLoginListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerJoinQuitListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerJoinQuitListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerClientOptionsChangeListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerClientOptionsChangeListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new ChatListener(), this);
|
this.getServer().getPluginManager().registerEvents(new ChatListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this);
|
this.getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new BannedItemListener(), this);
|
this.getServer().getPluginManager().registerEvents(new BannedItemListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new BannedActionListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new BannedActionListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new CreatureSpawnListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new PlayerInteractNPCListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerInteractNPCListener(this), this);
|
|
||||||
|
|
||||||
getCommand("varo").setExecutor(new VaroCommand(this));
|
this.getCommand("varo").setExecutor(new VaroCommand(this));
|
||||||
|
|
||||||
for (World world : getServer().getWorlds()) {
|
this.varoUtils.init();
|
||||||
world.setDifficulty(Difficulty.HARD);
|
|
||||||
world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
|
||||||
world.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, true);
|
|
||||||
world.setGameRule(GameRule.DISABLE_ELYTRA_MOVEMENT_CHECK, false);
|
|
||||||
world.setGameRule(GameRule.DISABLE_RAIDS, false);
|
|
||||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true);
|
|
||||||
world.setGameRule(GameRule.DO_ENTITY_DROPS, true);
|
|
||||||
world.setGameRule(GameRule.DO_FIRE_TICK, true);
|
|
||||||
world.setGameRule(GameRule.DO_INSOMNIA, false);
|
|
||||||
world.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, false);
|
|
||||||
world.setGameRule(GameRule.DO_LIMITED_CRAFTING, false);
|
|
||||||
world.setGameRule(GameRule.DO_MOB_LOOT, true);
|
|
||||||
world.setGameRule(GameRule.DO_MOB_SPAWNING, true);
|
|
||||||
world.setGameRule(GameRule.DO_PATROL_SPAWNING, true);
|
|
||||||
world.setGameRule(GameRule.DO_TILE_DROPS, true);
|
|
||||||
world.setGameRule(GameRule.DO_TRADER_SPAWNING, false);
|
|
||||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, true);
|
|
||||||
world.setGameRule(GameRule.DROWNING_DAMAGE, true);
|
|
||||||
world.setGameRule(GameRule.FALL_DAMAGE, true);
|
|
||||||
world.setGameRule(GameRule.FIRE_DAMAGE, true);
|
|
||||||
world.setGameRule(GameRule.KEEP_INVENTORY, false);
|
|
||||||
world.setGameRule(GameRule.LOG_ADMIN_COMMANDS, true);
|
|
||||||
world.setGameRule(GameRule.MOB_GRIEFING, true);
|
|
||||||
world.setGameRule(GameRule.NATURAL_REGENERATION, true);
|
|
||||||
world.setGameRule(GameRule.REDUCED_DEBUG_INFO, true);
|
|
||||||
world.setGameRule(GameRule.SEND_COMMAND_FEEDBACK, true);
|
|
||||||
world.setGameRule(GameRule.SHOW_DEATH_MESSAGES, true);
|
|
||||||
world.setGameRule(GameRule.SPECTATORS_GENERATE_CHUNKS, false);
|
|
||||||
|
|
||||||
// DEBUG specific Settings
|
|
||||||
if (this.config.getBoolean("Varo.Debug")) {
|
|
||||||
world.setDifficulty(Difficulty.PEACEFUL);
|
|
||||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
|
||||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getServer().removeRecipe(NamespacedKey.minecraft("fishing_rod"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
getLogger().info("Stopping CliffbreakVaro!");
|
this.getLogger().info("Stopping CliffbreakVaro!");
|
||||||
this.playerCache.shutdown();
|
this.playerCache.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConfiguration() {
|
@Override
|
||||||
|
public FileConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveConfig() {
|
||||||
try {
|
try {
|
||||||
getLogger().info("Saving Config...");
|
this.getLogger().info("Saving Config...");
|
||||||
this.config.save(this.configurationFile);
|
this.config.save(this.configurationFile);
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NPCManager getNPCManager() {
|
||||||
|
return npcManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerCache getPlayerCache() {
|
||||||
|
return playerCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BanUtils getBanUtils() {
|
||||||
|
return this.banUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canCreatePortal() {
|
||||||
|
return this.canCreatePortal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCanCreatePortal(final boolean canCreatePortal) {
|
||||||
|
this.canCreatePortal = canCreatePortal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,15 @@ import de.cliffbreak.varo.uitls.WebUtils;
|
||||||
|
|
||||||
public class VaroCommand implements CommandExecutor {
|
public class VaroCommand implements CommandExecutor {
|
||||||
|
|
||||||
private Varo plugin;
|
private final Varo plugin;
|
||||||
|
|
||||||
public VaroCommand(Varo plugin) {
|
public VaroCommand(final Varo plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label,
|
||||||
|
final String[] args) {
|
||||||
if (!sender.hasPermission("varo.admin")) {
|
if (!sender.hasPermission("varo.admin")) {
|
||||||
sender.sendMessage("§c§lFehler: §r§cNicht genügend Rechte für dieses Kommando.");
|
sender.sendMessage("§c§lFehler: §r§cNicht genügend Rechte für dieses Kommando.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,17 +38,17 @@ public class VaroCommand implements CommandExecutor {
|
||||||
if (args.length == 2 && args[0].equals("unban")) {
|
if (args.length == 2 && args[0].equals("unban")) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String result = WebUtils.GET("https://api.mojang.com/users/profiles/minecraft/" + args[1]);
|
final String result = WebUtils.GET("https://api.mojang.com/users/profiles/minecraft/" + args[1]);
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
sender.sendMessage("§c§lFehler: §r§cDer Spieler wurde nicht gefunden.");
|
sender.sendMessage("§c§lFehler: §r§cDer Spieler wurde nicht gefunden.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JSONObject uuidObject = (JSONObject) JSONValue.parseWithException(result);
|
final JSONObject uuidObject = (JSONObject) JSONValue.parseWithException(result);
|
||||||
if (!plugin.banUtils.isBanned(uuidObject.get("id").toString())) {
|
if (!this.plugin.getBanUtils().isBanned(uuidObject.get("id").toString())) {
|
||||||
sender.sendMessage("§c§lFehler: §r§cDer Spieler ist nicht gebannt.");
|
sender.sendMessage("§c§lFehler: §r§cDer Spieler ist nicht gebannt.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plugin.banUtils.removeBan(uuidObject.get("id").toString());
|
this.plugin.getBanUtils().removeBan(uuidObject.get("id").toString());
|
||||||
sender.sendMessage("§a§lErfolg: §r§aDer Spieler ist nun nicht mehr gebannt.");
|
sender.sendMessage("§a§lErfolg: §r§aDer Spieler ist nun nicht mehr gebannt.");
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
|
@ -57,10 +58,10 @@ public class VaroCommand implements CommandExecutor {
|
||||||
|
|
||||||
} else if (args.length == 1 && args[0].equals("start")) {
|
} else if (args.length == 1 && args[0].equals("start")) {
|
||||||
sender.sendMessage("§aStarting...");
|
sender.sendMessage("§aStarting...");
|
||||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
// p.getInventory().clear(); //TODO: uncomment after debuging
|
// p.getInventory().clear(); //TODO: uncomment after debuging
|
||||||
p.closeInventory(Reason.CANT_USE);
|
p.closeInventory(Reason.CANT_USE);
|
||||||
for (PotionEffect potion : p.getActivePotionEffects())
|
for (final PotionEffect potion : p.getActivePotionEffects())
|
||||||
p.removePotionEffect(potion.getType());
|
p.removePotionEffect(potion.getType());
|
||||||
|
|
||||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60 * 20, 1, false, false, false));
|
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60 * 20, 1, false, false, false));
|
||||||
|
@ -80,23 +81,23 @@ public class VaroCommand implements CommandExecutor {
|
||||||
|
|
||||||
} else if (args.length == 2 && args[0].equals("portal")) {
|
} else if (args.length == 2 && args[0].equals("portal")) {
|
||||||
if (args[1].equals("enable")) {
|
if (args[1].equals("enable")) {
|
||||||
this.plugin.canCreatePortal = true;
|
this.plugin.setCanCreatePortal(true);
|
||||||
sender.sendMessage("§c§lWarnung: §r§cPortale können nun von JEDEM Spieler erstellt werden.");
|
sender.sendMessage("§c§lWarnung: §r§cPortale können nun von JEDEM Spieler erstellt werden.");
|
||||||
} else if (args[1].equals("disable")) {
|
} else if (args[1].equals("disable")) {
|
||||||
this.plugin.canCreatePortal = false;
|
this.plugin.setCanCreatePortal(false);
|
||||||
sender.sendMessage("§a§lErfolg: §r§aEs können nun keine Portale mehr erstellt werden..");
|
sender.sendMessage("§a§lErfolg: §r§aEs können nun keine Portale mehr erstellt werden..");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§c§lFehler: §r§cBitte überprüfe deine Eingabe.");
|
sender.sendMessage("§c§lFehler: §r§cBitte überprüfe deine Eingabe.");
|
||||||
}
|
}
|
||||||
} else if (args.length == 1 && args[0].equals("test")) {
|
} else if (args.length == 1 && args[0].equals("test")) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
plugin.npcManager.createClone((Player) sender, false);
|
this.plugin.getNPCManager().createClone((Player) sender, false);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
|
sender.sendMessage("§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
|
||||||
}
|
}
|
||||||
} else if (args.length == 1 && args[0].equals("testremove")) {
|
} else if (args.length == 1 && args[0].equals("testremove")) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
plugin.npcManager.removeClone(((Player) sender));
|
this.plugin.getNPCManager().removeClone(((Player) sender));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
|
sender.sendMessage("§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class BannedActionListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPortalCreate(final PortalCreateEvent e) {
|
public void onPortalCreate(final PortalCreateEvent e) {
|
||||||
if (!this.plugin.canCreatePortal) {
|
if (!this.plugin.canCreatePortal()) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
public class BannedItemListener implements Listener {
|
public class BannedItemListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityPickupItem(EntityPickupItemEvent e) {
|
public void onEntityPickupItem(final EntityPickupItemEvent e) {
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
Material mat = e.getItem().getItemStack().getType();
|
final Material mat = e.getItem().getItemStack().getType();
|
||||||
if (isForbiddenMaterial(mat)) {
|
if (isForbiddenMaterial(mat)) {
|
||||||
e.getEntity().sendMessage("§cVerbotenes Item wurde entfernt.");
|
e.getEntity().sendMessage("§cVerbotenes Item wurde entfernt.");
|
||||||
e.getItem().remove();
|
e.getItem().remove();
|
||||||
|
@ -22,17 +22,17 @@ public class BannedItemListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(final InventoryClickEvent e) {
|
||||||
if (e.getCurrentItem() == null)
|
if (e.getCurrentItem() == null)
|
||||||
return;
|
return;
|
||||||
Material mat = e.getCurrentItem().getType();
|
final Material mat = e.getCurrentItem().getType();
|
||||||
if (isForbiddenMaterial(mat)) {
|
if (isForbiddenMaterial(mat)) {
|
||||||
e.getWhoClicked().sendMessage("§cVerbotenes Item kann nicht ins Inventar verschoben werden.");
|
e.getWhoClicked().sendMessage("§cVerbotenes Item kann nicht ins Inventar verschoben werden.");
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isForbiddenMaterial(Material mat) {
|
private boolean isForbiddenMaterial(final Material mat) {
|
||||||
return mat.equals(Material.ENCHANTED_GOLDEN_APPLE) || mat.equals(Material.FISHING_ROD)
|
return mat.equals(Material.ENCHANTED_GOLDEN_APPLE) || mat.equals(Material.FISHING_ROD)
|
||||||
|| mat.equals(Material.TOTEM_OF_UNDYING);
|
|| mat.equals(Material.TOTEM_OF_UNDYING);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import de.cliffbreak.varo.uitls.MessageUtils;
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChat(AsyncPlayerChatEvent e) {
|
public void onChat(final AsyncPlayerChatEvent e) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Bukkit.broadcast(MessageUtils.getRichTextComponent(e.getPlayer().getName(), e.getMessage()));
|
Bukkit.broadcast(MessageUtils.getRichTextComponent(e.getPlayer().getName(), e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package de.cliffbreak.varo.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
|
|
||||||
import de.cliffbreak.varo.Varo;
|
|
||||||
|
|
||||||
public class CreatureSpawnListener implements Listener {
|
|
||||||
|
|
||||||
private Varo plugin;
|
|
||||||
|
|
||||||
public CreatureSpawnListener(final Varo plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent e) {
|
|
||||||
LivingEntity livingEntity = e.getEntity();
|
|
||||||
if (livingEntity.getType().equals(EntityType.WANDERING_TRADER)
|
|
||||||
|| livingEntity.getType().equals(EntityType.TRADER_LLAMA)) {
|
|
||||||
plugin.getLogger().info("Denied Wandering-Trader Spawn");
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
public class EntityRegainHealthListener implements Listener {
|
public class EntityRegainHealthListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent e) {
|
public void onEntityRegainHealth(final EntityRegainHealthEvent e) {
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player) {
|
||||||
if (e.isFastRegen()) {
|
if (e.isFastRegen()) {
|
||||||
e.setAmount(0.13d);
|
e.setAmount(0.13d);
|
||||||
|
|
|
@ -10,16 +10,16 @@ import de.cliffbreak.varo.uitls.PlayerCache.PlayerCacheType;
|
||||||
|
|
||||||
public class PlayerClientOptionsChangeListener implements Listener {
|
public class PlayerClientOptionsChangeListener implements Listener {
|
||||||
|
|
||||||
private Varo plugin;
|
private final Varo plugin;
|
||||||
|
|
||||||
public PlayerClientOptionsChangeListener(Varo plugin) {
|
public PlayerClientOptionsChangeListener(final Varo plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClientOptionsChange(PlayerClientOptionsChangeEvent e) {
|
public void onPlayerClientOptionsChange(final PlayerClientOptionsChangeEvent e) {
|
||||||
String uuid = e.getPlayer().getUniqueId().toString().replace("-", "");
|
final String uuid = e.getPlayer().getUniqueId().toString().replace("-", "");
|
||||||
plugin.playerCache.setPlayerCache(uuid, PlayerCacheType.SKINPARTS, e.getSkinParts().getRaw());
|
this.plugin.getPlayerCache().setPlayerCache(uuid, PlayerCacheType.SKINPARTS, e.getSkinParts().getRaw());
|
||||||
plugin.playerCache.setPlayerCache(uuid, PlayerCacheType.MAINHAND, e.getMainHand().toString());
|
this.plugin.getPlayerCache().setPlayerCache(uuid, PlayerCacheType.MAINHAND, e.getMainHand().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package de.cliffbreak.varo.listeners;
|
package de.cliffbreak.varo.listeners;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import de.cliffbreak.varo.Varo;
|
import de.cliffbreak.varo.Varo;
|
||||||
|
|
||||||
|
@ -18,16 +18,15 @@ public class PlayerDeathListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDeath(final PlayerDeathEvent e) {
|
public void onPlayerDeath(final PlayerDeathEvent e) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
e.getEntity().kickPlayer("§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden.");
|
e.getEntity().kickPlayer("§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden.");
|
||||||
}
|
}
|
||||||
}, 20);
|
}.runTaskLater(this.plugin, 20);
|
||||||
|
|
||||||
e.getEntity().setHealth(20d); // Reset health to prevent death dialog after rejoin (if unbanned)
|
e.getEntity().setHealth(20d); // Reset health to prevent death dialog after rejoin (if unbanned)
|
||||||
e.getEntity().setGameMode(GameMode.SPECTATOR);
|
e.getEntity().setGameMode(GameMode.SPECTATOR);
|
||||||
this.plugin.banUtils.addBann(e.getEntity().getUniqueId());
|
this.plugin.getBanUtils().addBann(e.getEntity().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,17 +9,16 @@ import de.cliffbreak.varo.events.PlayerInteractNPCEvent.Type;
|
||||||
|
|
||||||
public class PlayerInteractNPCListener implements Listener {
|
public class PlayerInteractNPCListener implements Listener {
|
||||||
|
|
||||||
private Varo plugin;
|
private final Varo plugin;
|
||||||
|
|
||||||
public PlayerInteractNPCListener(Varo plugin) {
|
public PlayerInteractNPCListener(final Varo plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDamageByEntity(PlayerInteractNPCEvent e) {
|
public void onEntityDamageByEntity(final PlayerInteractNPCEvent e) {
|
||||||
// plugin.getLogger().info(e.getType().toString() + " : " + e.getId() + " : " + e.getDamage());
|
|
||||||
if (e.getType().equals(Type.ATTACK)) {
|
if (e.getType().equals(Type.ATTACK)) {
|
||||||
plugin.npcManager.addDamage(e.getId(), e.getDamage(), e.getIsCritical());
|
this.plugin.getNPCManager().addDamage(e.getId(), e.getDamage(), e.getIsCritical());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(final PlayerQuitEvent e) {
|
public void onPlayerQuit(final PlayerQuitEvent e) {
|
||||||
e.setQuitMessage(null);
|
e.setQuitMessage(null);
|
||||||
plugin.npcManager.createClone(e.getPlayer(), true);
|
this.plugin.getNPCManager().createClone(e.getPlayer(), true);
|
||||||
Bukkit.broadcast(
|
Bukkit.broadcast(
|
||||||
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server verlassen.", true));
|
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server verlassen.", true));
|
||||||
}
|
}
|
||||||
|
@ -35,17 +35,17 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||||
e.setJoinMessage(null);
|
e.setJoinMessage(null);
|
||||||
plugin.npcManager.removeClone(e.getPlayer());
|
this.plugin.getNPCManager().removeClone(e.getPlayer());
|
||||||
plugin.npcManager.syncClones(e.getPlayer());
|
this.plugin.getNPCManager().syncClones(e.getPlayer());
|
||||||
|
|
||||||
// Inject PacketReader
|
// Inject PacketReader
|
||||||
PacketReader packetReader = new PacketReader(plugin, e.getPlayer());
|
final PacketReader packetReader = new PacketReader(this.plugin, e.getPlayer());
|
||||||
packetReader.inject();
|
packetReader.inject();
|
||||||
|
|
||||||
Bukkit.broadcast(
|
Bukkit.broadcast(
|
||||||
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server betreten.", true));
|
MessageUtils.getRichTextComponent(e.getPlayer().getName(), "§f hat den Server betreten.", true));
|
||||||
|
|
||||||
if (plugin.config.getBoolean("Varo.Debug")) {
|
if (this.plugin.getConfig().getBoolean("Varo.Debug")) {
|
||||||
|
|
||||||
e.getPlayer().sendMessage("\n§7§l#### §9Cliffbreak.de - §lVaro §r§9Changelog §7§l####\n \n"
|
e.getPlayer().sendMessage("\n§7§l#### §9Cliffbreak.de - §lVaro §r§9Changelog §7§l####\n \n"
|
||||||
+ " §cWarning: §r§c Plugin is running in DEBUG mode!\n ");
|
+ " §cWarning: §r§c Plugin is running in DEBUG mode!\n ");
|
||||||
|
@ -88,7 +88,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
}
|
}
|
||||||
e.getPlayer().sendMessage(changes.pop());
|
e.getPlayer().sendMessage(changes.pop());
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 20, 20);
|
}.runTaskTimer(this.plugin, 20, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
if (event instanceof PaperServerListPingEvent) {
|
if (event instanceof PaperServerListPingEvent) {
|
||||||
handlePaperServerListPing((PaperServerListPingEvent) event);
|
handlePaperServerListPing((PaperServerListPingEvent) event);
|
||||||
} else {
|
} else {
|
||||||
plugin.getLogger().info("Error: Plugin is not running on a PaperServer");
|
this.plugin.getLogger().info("Error: Plugin is not running on a PaperServer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class PlayerPreLoginListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerPreLogin(final PlayerLoginEvent e) {
|
public void onPlayerPreLogin(final PlayerLoginEvent e) {
|
||||||
if (plugin.banUtils.isBanned(e.getPlayer().getUniqueId())) {
|
if (this.plugin.getBanUtils().isBanned(e.getPlayer().getUniqueId())) {
|
||||||
e.disallow(Result.KICK_BANNED, "§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden.");
|
e.disallow(Result.KICK_BANNED, "§4Du bist gestorben.\n \n§cDamit bist du aus §eVaro§c ausgeschieden.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class NPCManager {
|
||||||
private final Varo plugin;
|
private final Varo plugin;
|
||||||
private final ArrayList<EntityPlayer> npcs = new ArrayList<EntityPlayer>();
|
private final ArrayList<EntityPlayer> npcs = new ArrayList<EntityPlayer>();
|
||||||
private final HashMap<UUID, PlayerInventory> inventories = new HashMap<UUID, PlayerInventory>();
|
private final HashMap<UUID, PlayerInventory> inventories = new HashMap<UUID, PlayerInventory>();
|
||||||
private Scoreboard scoreboard;
|
private final Scoreboard scoreboard;
|
||||||
private Team afkTeam;
|
private Team afkTeam;
|
||||||
|
|
||||||
public NPCManager(final Varo plugin) {
|
public NPCManager(final Varo plugin) {
|
||||||
|
@ -83,7 +83,7 @@ public class NPCManager {
|
||||||
gameProfile.getProperties().put("textures", new Property("textures", properties.get("value").toString(),
|
gameProfile.getProperties().put("textures", new Property("textures", properties.get("value").toString(),
|
||||||
properties.get("signature").toString()));
|
properties.get("signature").toString()));
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
plugin.getLogger().info(e.getMessage());
|
this.plugin.getLogger().info(e.getMessage());
|
||||||
}
|
}
|
||||||
final PlayerInteractManager playerInteractManager = new PlayerInteractManager(nmsWorld);
|
final PlayerInteractManager playerInteractManager = new PlayerInteractManager(nmsWorld);
|
||||||
final EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, playerInteractManager);
|
final EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, playerInteractManager);
|
||||||
|
@ -98,27 +98,28 @@ public class NPCManager {
|
||||||
|
|
||||||
npcs.add(npc);
|
npcs.add(npc);
|
||||||
|
|
||||||
for (Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
|
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20);
|
}.runTaskLater(this.plugin, 20);
|
||||||
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
|
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
|
||||||
connection.sendPacket(
|
connection.sendPacket(
|
||||||
new PacketPlayOutEntityHeadRotation(npc, (byte) ((location.getYaw() * 256.0F) / 360.0F)));
|
new PacketPlayOutEntityHeadRotation(npc, (byte) ((location.getYaw() * 256.0F) / 360.0F)));
|
||||||
npc.getDataWatcher().set(new DataWatcherObject<>(16, DataWatcherRegistry.a),
|
npc.getDataWatcher().set(new DataWatcherObject<>(16, DataWatcherRegistry.a),
|
||||||
(byte) plugin.playerCache.getSkinParts(player.getUniqueId().toString().replace("-", "")));
|
(byte) this.plugin.getPlayerCache().getSkinParts(player.getUniqueId().toString().replace("-", "")));
|
||||||
npc.getDataWatcher().set(new DataWatcherObject<>(17, DataWatcherRegistry.a),
|
npc.getDataWatcher().set(new DataWatcherObject<>(17, DataWatcherRegistry.a),
|
||||||
plugin.playerCache.getMainHandAsByte(player.getUniqueId().toString().replace("-", "")));
|
this.plugin.getPlayerCache().getMainHandAsByte(player.getUniqueId().toString().replace("-", "")));
|
||||||
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
||||||
sendEquipmentPackets(connection, npc.getId(), player.getInventory());
|
sendEquipmentPackets(connection, npc.getId(), player.getInventory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEquipmentPackets(PlayerConnection connection, int id, PlayerInventory inventory) {
|
private void sendEquipmentPackets(final PlayerConnection connection, final int id,
|
||||||
|
final PlayerInventory inventory) {
|
||||||
connection.sendPacket(new PacketPlayOutEntityEquipment(id, EnumItemSlot.MAINHAND,
|
connection.sendPacket(new PacketPlayOutEntityEquipment(id, EnumItemSlot.MAINHAND,
|
||||||
CraftItemStack.asNMSCopy(inventory.getItemInMainHand())));
|
CraftItemStack.asNMSCopy(inventory.getItemInMainHand())));
|
||||||
connection.sendPacket(new PacketPlayOutEntityEquipment(id, EnumItemSlot.OFFHAND,
|
connection.sendPacket(new PacketPlayOutEntityEquipment(id, EnumItemSlot.OFFHAND,
|
||||||
|
@ -133,38 +134,38 @@ public class NPCManager {
|
||||||
CraftItemStack.asNMSCopy(inventory.getHelmet())));
|
CraftItemStack.asNMSCopy(inventory.getHelmet())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncClones(Player player) {
|
public void syncClones(final Player player) {
|
||||||
for (EntityPlayer npc : this.npcs) {
|
for (final EntityPlayer npc : this.npcs) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
final PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||||
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
|
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, npc));
|
||||||
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
|
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
|
||||||
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) ((npc.yaw * 256.0F) / 360.0F)));
|
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) ((npc.yaw * 256.0F) / 360.0F)));
|
||||||
npc.getDataWatcher().set(new DataWatcherObject<>(16, DataWatcherRegistry.a),
|
npc.getDataWatcher().set(new DataWatcherObject<>(16, DataWatcherRegistry.a),
|
||||||
(byte) plugin.playerCache.getSkinParts(player.getUniqueId().toString().replace("-", "")));
|
(byte) this.plugin.getPlayerCache().getSkinParts(player.getUniqueId().toString().replace("-", "")));
|
||||||
npc.getDataWatcher().set(new DataWatcherObject<>(17, DataWatcherRegistry.a),
|
npc.getDataWatcher().set(new DataWatcherObject<>(17, DataWatcherRegistry.a),
|
||||||
plugin.playerCache.getMainHandAsByte(player.getUniqueId().toString().replace("-", "")));
|
this.plugin.getPlayerCache().getMainHandAsByte(player.getUniqueId().toString().replace("-", "")));
|
||||||
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
||||||
sendEquipmentPackets(connection, npc.getId(), this.inventories.get(npc.getUniqueID()));
|
sendEquipmentPackets(connection, npc.getId(), this.inventories.get(npc.getUniqueID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNPC(int id) {
|
public boolean isNPC(final int id) {
|
||||||
for (EntityPlayer npc : this.npcs) {
|
for (final EntityPlayer npc : this.npcs) {
|
||||||
if (npc.getId() == id)
|
if (npc.getId() == id)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDamage(int id, double damage, boolean isCritical) {
|
public void addDamage(final int id, final double damage, final boolean isCritical) {
|
||||||
for (EntityPlayer npc : this.npcs) {
|
for (final EntityPlayer npc : this.npcs) {
|
||||||
if (npc.getId() == id) {
|
if (npc.getId() == id) {
|
||||||
npc.setHealth((float) (npc.getHealth() - damage));
|
npc.setHealth((float) (npc.getHealth() - damage));
|
||||||
|
|
||||||
World world = npc.getWorld().getWorld();
|
final World world = npc.getWorld().getWorld();
|
||||||
Location loc = new Location(world, npc.locX(), npc.locY(), npc.locZ());
|
final Location loc = new Location(world, npc.locX(), npc.locY(), npc.locZ());
|
||||||
if (npc.getHealth() > 0.0F) {
|
if (npc.getHealth() > 0.0F) {
|
||||||
for (Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) connectionPlayer)
|
final PlayerConnection connection = ((CraftPlayer) connectionPlayer)
|
||||||
.getHandle().playerConnection;
|
.getHandle().playerConnection;
|
||||||
connection.sendPacket(new PacketPlayOutEntityStatus(npc, (byte) 2)); // Send HURT (2) Animation
|
connection.sendPacket(new PacketPlayOutEntityStatus(npc, (byte) 2)); // Send HURT (2) Animation
|
||||||
|
@ -175,7 +176,7 @@ public class NPCManager {
|
||||||
world.playSound(loc, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0F, 1.0F);
|
world.playSound(loc, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0F, 1.0F);
|
||||||
} else {
|
} else {
|
||||||
// Send Death Animation Packet
|
// Send Death Animation Packet
|
||||||
for (Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) connectionPlayer)
|
final PlayerConnection connection = ((CraftPlayer) connectionPlayer)
|
||||||
.getHandle().playerConnection;
|
.getHandle().playerConnection;
|
||||||
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
connection.sendPacket(new PacketPlayOutEntityMetadata(npc.getId(), npc.getDataWatcher(), true));
|
||||||
|
@ -187,15 +188,15 @@ public class NPCManager {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (ItemStack item : inventories.get(npc.getUniqueID())) {
|
for (final ItemStack item : inventories.get(npc.getUniqueID())) {
|
||||||
if (item != null)
|
if (item != null)
|
||||||
world.dropItem(loc, item);
|
world.dropItem(loc, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}.runTask(plugin); // Run Task in sync to be thread safe
|
}.runTask(this.plugin); // Run Task in sync to be thread safe
|
||||||
|
|
||||||
this.plugin.banUtils.addBann(npc.getUniqueID());
|
this.plugin.getBanUtils().addBann(npc.getUniqueID());
|
||||||
Bukkit.broadcastMessage("TODO: Player(" + "??" + ") killed AFK Player (" + npc.getName() + ")");
|
Bukkit.broadcastMessage("TODO: Player(" + "??" + ") killed AFK Player (" + npc.getName() + ")");
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -203,7 +204,7 @@ public class NPCManager {
|
||||||
public void run() {
|
public void run() {
|
||||||
removeClone(npc.getUniqueID());
|
removeClone(npc.getUniqueID());
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20);
|
}.runTaskLater(this.plugin, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,15 +212,15 @@ public class NPCManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Only for debug reasons -- Remove
|
// FIXME: Only for debug reasons -- Remove
|
||||||
public void removeClone(Player player) {
|
public void removeClone(final Player player) {
|
||||||
this.afkTeam.removeEntry(player.getName());
|
this.afkTeam.removeEntry(player.getName());
|
||||||
for (int i = 0; i < this.npcs.size(); i++) {
|
for (int i = 0; i < this.npcs.size(); i++) {
|
||||||
EntityPlayer npc = this.npcs.get(i);
|
final EntityPlayer npc = this.npcs.get(i);
|
||||||
if (npc.getUniqueID().equals(player.getUniqueId())) {
|
if (npc.getUniqueID().equals(player.getUniqueId())) {
|
||||||
final WorldServer nmsWorld = ((CraftWorld) player.getWorld()).getHandle();
|
final WorldServer nmsWorld = ((CraftWorld) player.getWorld()).getHandle();
|
||||||
nmsWorld.removeEntity(npc);
|
nmsWorld.removeEntity(npc);
|
||||||
|
|
||||||
for (Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
||||||
connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
|
connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
|
||||||
}
|
}
|
||||||
|
@ -228,13 +229,13 @@ public class NPCManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeClone(UUID uuid) {
|
public void removeClone(final UUID uuid) {
|
||||||
for (int i = 0; i < this.npcs.size(); i++) {
|
for (int i = 0; i < this.npcs.size(); i++) {
|
||||||
EntityPlayer npc = this.npcs.get(i);
|
final EntityPlayer npc = this.npcs.get(i);
|
||||||
if (npc.getUniqueID().equals(uuid)) {
|
if (npc.getUniqueID().equals(uuid)) {
|
||||||
final WorldServer nmsWorld = npc.getWorldServer();
|
final WorldServer nmsWorld = npc.getWorldServer();
|
||||||
|
|
||||||
for (Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
for (final Player connectionPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
final PlayerConnection connection = ((CraftPlayer) connectionPlayer).getHandle().playerConnection;
|
||||||
connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
|
connection.sendPacket(new PacketPlayOutEntityDestroy(npc.getId()));
|
||||||
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, npc));
|
connection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, npc));
|
||||||
|
|
|
@ -9,34 +9,34 @@ public class BanUtils {
|
||||||
|
|
||||||
private final Varo plugin;
|
private final Varo plugin;
|
||||||
|
|
||||||
public BanUtils(Varo plugin) {
|
public BanUtils(final Varo plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned(UUID uuid) {
|
public boolean isBanned(final UUID uuid) {
|
||||||
return isBanned(uuid.toString().replace("-", ""));
|
return isBanned(uuid.toString().replace("-", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned(String compressedUuid) {
|
public boolean isBanned(final String compressedUuid) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final ArrayList<String> bans = (ArrayList<String>) this.plugin.config.get("Varo.Bans");
|
final ArrayList<String> bans = (ArrayList<String>) this.plugin.getConfig().get("Varo.Bans");
|
||||||
return bans.contains(compressedUuid);
|
return bans.contains(compressedUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBann(UUID uuid) {
|
public void addBann(final UUID uuid) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final ArrayList<String> bans = (ArrayList<String>) this.plugin.config.get("Varo.Bans");
|
final ArrayList<String> bans = (ArrayList<String>) this.plugin.getConfig().get("Varo.Bans");
|
||||||
bans.add(uuid.toString().replace("-", ""));
|
bans.add(uuid.toString().replace("-", ""));
|
||||||
this.plugin.config.set("Varo.Bans", bans);
|
this.plugin.getConfig().set("Varo.Bans", bans);
|
||||||
this.plugin.saveConfiguration();
|
this.plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBan(String compressedUuid) {
|
public void removeBan(final String compressedUuid) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final ArrayList<String> bans = (ArrayList<String>) this.plugin.config.get("Varo.Bans");
|
final ArrayList<String> bans = (ArrayList<String>) this.plugin.getConfig().get("Varo.Bans");
|
||||||
bans.remove(compressedUuid);
|
bans.remove(compressedUuid);
|
||||||
this.plugin.config.set("Varo.Bans", bans);
|
this.plugin.getConfig().set("Varo.Bans", bans);
|
||||||
this.plugin.saveConfiguration();
|
this.plugin.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class MessageUtils {
|
public class MessageUtils {
|
||||||
|
|
||||||
public static String getTimestampedMessage(String message) {
|
public static String getTimestampedMessage(final String message) {
|
||||||
|
|
||||||
return " §8" + getTimestamp() + " §7| " + message;
|
return " §8" + getTimestamp() + " §7| " + message;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class MessageUtils {
|
||||||
* the message to send
|
* the message to send
|
||||||
* @return TextComponent
|
* @return TextComponent
|
||||||
*/
|
*/
|
||||||
public static TextComponent getRichTextComponent(String player, String message) {
|
public static TextComponent getRichTextComponent(final String player, final String message) {
|
||||||
return getRichTextComponent(player, message, false, true);
|
return getRichTextComponent(player, message, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ public class MessageUtils {
|
||||||
* is this a service message (f.e. PlayerJoinEvent)
|
* is this a service message (f.e. PlayerJoinEvent)
|
||||||
* @return TextComponent
|
* @return TextComponent
|
||||||
*/
|
*/
|
||||||
public static TextComponent getRichTextComponent(String player, String message, boolean isServiceMessage) {
|
public static TextComponent getRichTextComponent(final String player, final String message,
|
||||||
|
final boolean isServiceMessage) {
|
||||||
return getRichTextComponent(player, message, isServiceMessage, true);
|
return getRichTextComponent(player, message, isServiceMessage, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +56,12 @@ public class MessageUtils {
|
||||||
* should a timestamp be returned?
|
* should a timestamp be returned?
|
||||||
* @return TextComponent
|
* @return TextComponent
|
||||||
*/
|
*/
|
||||||
public static TextComponent getRichTextComponent(String player, String message, boolean isServiceMessage,
|
public static TextComponent getRichTextComponent(final String player, final String message,
|
||||||
boolean useTimestamp) {
|
final boolean isServiceMessage, final boolean useTimestamp) {
|
||||||
TextComponent mainComponent = new TextComponent(" ");
|
final TextComponent mainComponent = new TextComponent(" ");
|
||||||
TextComponent timeComponent = new TextComponent("§8" + getTimestamp() + " §7| ");
|
final TextComponent timeComponent = new TextComponent("§8" + getTimestamp() + " §7| ");
|
||||||
TextComponent playerComponent = new TextComponent("§b" + player);
|
final TextComponent playerComponent = new TextComponent("§b" + player);
|
||||||
TextComponent messageComponent = new TextComponent(" §7>> §r§f" + message);
|
final TextComponent messageComponent = new TextComponent(" §7>> §r§f" + message);
|
||||||
timeComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
timeComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||||
new ComponentBuilder("§7" + getTimestampSeconds()).create()));
|
new ComponentBuilder("§7" + getTimestampSeconds()).create()));
|
||||||
playerComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
playerComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||||
|
@ -78,13 +79,13 @@ public class MessageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimestamp() {
|
private static String getTimestamp() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
return String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)) + ":"
|
return String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)) + ":"
|
||||||
+ String.format("%02d", calendar.get(Calendar.MINUTE));
|
+ String.format("%02d", calendar.get(Calendar.MINUTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimestampSeconds() {
|
private static String getTimestampSeconds() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
return String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)) + ":"
|
return String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)) + ":"
|
||||||
+ String.format("%02d", calendar.get(Calendar.MINUTE)) + ":"
|
+ String.format("%02d", calendar.get(Calendar.MINUTE)) + ":"
|
||||||
+ String.format("%02d", calendar.get(Calendar.SECOND));
|
+ String.format("%02d", calendar.get(Calendar.SECOND));
|
||||||
|
|
|
@ -26,8 +26,8 @@ import net.minecraft.server.v1_15_R1.Packet;
|
||||||
|
|
||||||
public class PacketReader {
|
public class PacketReader {
|
||||||
|
|
||||||
private Varo plugin;
|
private final Varo plugin;
|
||||||
private Player player;
|
private final Player player;
|
||||||
private Channel channel;
|
private Channel channel;
|
||||||
|
|
||||||
public PacketReader(final Varo plugin, final Player player) {
|
public PacketReader(final Varo plugin, final Player player) {
|
||||||
|
@ -58,30 +58,30 @@ public class PacketReader {
|
||||||
public void readPacket(final Packet<?> packet) {
|
public void readPacket(final Packet<?> packet) {
|
||||||
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
||||||
|
|
||||||
int id = (int) getValue(packet, "a");
|
final int id = (int) getValue(packet, "a");
|
||||||
if (!plugin.npcManager.isNPC(id)) {
|
if (!this.plugin.getNPCManager().isNPC(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Type type = Type.valueOf(getValue(packet, "action").toString());
|
final Type type = Type.valueOf(getValue(packet, "action").toString());
|
||||||
PlayerInteractNPCEvent event = new PlayerInteractNPCEvent(type, id, calculateDamage(this.player),
|
final PlayerInteractNPCEvent event = new PlayerInteractNPCEvent(type, id, calculateDamage(this.player),
|
||||||
isCriticalHit(this.player));
|
isCriticalHit(this.player));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
// noop()
|
// noop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateDamage(Player player) {
|
private double calculateDamage(final Player player) {
|
||||||
double damage = 1.0; // Default 1.0 Damage (by hand)
|
double damage = 1.0; // Default 1.0 Damage (by hand)
|
||||||
ItemStack nmsItemStack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nmsItemStack = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
Collection<AttributeModifier> attributes = nmsItemStack.getItem().a(EnumItemSlot.MAINHAND)
|
final Collection<AttributeModifier> attributes = nmsItemStack.getItem().a(EnumItemSlot.MAINHAND)
|
||||||
.get(GenericAttributes.ATTACK_DAMAGE.getName());
|
.get(GenericAttributes.ATTACK_DAMAGE.getName());
|
||||||
|
|
||||||
for (AttributeModifier am : attributes) {
|
for (final AttributeModifier am : attributes) {
|
||||||
damage += am.getAmount();
|
damage += am.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ public class PacketReader {
|
||||||
|
|
||||||
damage = damage * player.getAttackCooldown();
|
damage = damage * player.getAttackCooldown();
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchantments = player.getInventory().getItemInMainHand().getEnchantments();
|
final Map<Enchantment, Integer> enchantments = player.getInventory().getItemInMainHand().getEnchantments();
|
||||||
|
|
||||||
for (Map.Entry<Enchantment, Integer> enchantment : enchantments.entrySet()) {
|
for (final Map.Entry<Enchantment, Integer> enchantment : enchantments.entrySet()) {
|
||||||
// TODO: Add more enchantments?
|
// TODO: Add more enchantments?
|
||||||
if (enchantment.getKey().equals(Enchantment.DAMAGE_ALL))
|
if (enchantment.getKey().equals(Enchantment.DAMAGE_ALL))
|
||||||
damage += 0.5 * (enchantment.getValue() + 1);
|
damage += 0.5 * (enchantment.getValue() + 1);
|
||||||
|
@ -101,7 +101,7 @@ public class PacketReader {
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCriticalHit(Player player) {
|
private boolean isCriticalHit(final Player player) {
|
||||||
return player.getFallDistance() > 0.0F && !player.isOnGround() && !player.getLocation().getBlock().isLiquid()
|
return player.getFallDistance() > 0.0F && !player.isOnGround() && !player.getLocation().getBlock().isLiquid()
|
||||||
&& player.getPotionEffect(PotionEffectType.BLINDNESS) == null && player.getVehicle() == null
|
&& player.getPotionEffect(PotionEffectType.BLINDNESS) == null && player.getVehicle() == null
|
||||||
&& !player.isSprinting() && player.getAttackCooldown() > 0.848F;
|
&& !player.isSprinting() && player.getAttackCooldown() > 0.848F;
|
||||||
|
|
|
@ -12,16 +12,18 @@ import de.cliffbreak.varo.Varo;
|
||||||
|
|
||||||
public class PlayerCache {
|
public class PlayerCache {
|
||||||
|
|
||||||
private Varo plugin;
|
private final Varo plugin;
|
||||||
private File playerCacheFile = new File("plugins/CliffbreakVaro", "playercache.yml");
|
private final File playerCacheFile;
|
||||||
private FileConfiguration playerCache = YamlConfiguration.loadConfiguration(this.playerCacheFile);
|
private final FileConfiguration playerCache;
|
||||||
private boolean wasSaved = false;
|
private boolean wasSaved = false;
|
||||||
|
|
||||||
public PlayerCache(Varo plugin) {
|
public PlayerCache(final Varo plugin) {
|
||||||
|
this.playerCacheFile = new File("plugins/CliffbreakVaro", "playercache.yml");
|
||||||
|
this.playerCache = YamlConfiguration.loadConfiguration(this.playerCacheFile);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerCache(final String uuid, PlayerCacheType type, Object value) {
|
public void setPlayerCache(final String uuid, final PlayerCacheType type, final Object value) {
|
||||||
this.playerCache.set("Players." + uuid + "." + type.toString(), value);
|
this.playerCache.set("Players." + uuid + "." + type.toString(), value);
|
||||||
savePlayerCache();
|
savePlayerCache();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +46,7 @@ public class PlayerCache {
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
try {
|
try {
|
||||||
plugin.getLogger().info("Saving PlayerCache...");
|
this.plugin.getLogger().info("Saving PlayerCache...");
|
||||||
this.playerCache.save(this.playerCacheFile);
|
this.playerCache.save(this.playerCacheFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -54,7 +56,7 @@ public class PlayerCache {
|
||||||
private void savePlayerCache() {
|
private void savePlayerCache() {
|
||||||
if (!this.wasSaved)
|
if (!this.wasSaved)
|
||||||
try {
|
try {
|
||||||
plugin.getLogger().info("Saving PlayerCache...");
|
this.plugin.getLogger().info("Saving PlayerCache...");
|
||||||
this.playerCache.save(this.playerCacheFile);
|
this.playerCache.save(this.playerCacheFile);
|
||||||
this.wasSaved = true;
|
this.wasSaved = true;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -63,7 +65,7 @@ public class PlayerCache {
|
||||||
public void run() {
|
public void run() {
|
||||||
wasSaved = false;
|
wasSaved = false;
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20); // Only save once every second to prevent disklock
|
}.runTaskLater(this.plugin, 20); // Only save once every second to prevent disklock
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
67
varo/src/main/java/de/cliffbreak/varo/uitls/VaroUtils.java
Normal file
67
varo/src/main/java/de/cliffbreak/varo/uitls/VaroUtils.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package de.cliffbreak.varo.uitls;
|
||||||
|
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import de.cliffbreak.varo.Varo;
|
||||||
|
|
||||||
|
public class VaroUtils {
|
||||||
|
|
||||||
|
private final Varo plugin;
|
||||||
|
|
||||||
|
public VaroUtils(final Varo plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.initGameRules();
|
||||||
|
this.initRecipes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initGameRules() {
|
||||||
|
for (final World world : this.plugin.getServer().getWorlds()) {
|
||||||
|
world.setDifficulty(Difficulty.HARD);
|
||||||
|
world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
||||||
|
world.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, true);
|
||||||
|
world.setGameRule(GameRule.DISABLE_ELYTRA_MOVEMENT_CHECK, false);
|
||||||
|
world.setGameRule(GameRule.DISABLE_RAIDS, false);
|
||||||
|
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true);
|
||||||
|
world.setGameRule(GameRule.DO_ENTITY_DROPS, true);
|
||||||
|
world.setGameRule(GameRule.DO_FIRE_TICK, true);
|
||||||
|
world.setGameRule(GameRule.DO_INSOMNIA, false);
|
||||||
|
world.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, false);
|
||||||
|
world.setGameRule(GameRule.DO_LIMITED_CRAFTING, false);
|
||||||
|
world.setGameRule(GameRule.DO_MOB_LOOT, true);
|
||||||
|
world.setGameRule(GameRule.DO_MOB_SPAWNING, true);
|
||||||
|
world.setGameRule(GameRule.DO_PATROL_SPAWNING, true);
|
||||||
|
world.setGameRule(GameRule.DO_TILE_DROPS, true);
|
||||||
|
world.setGameRule(GameRule.DO_TRADER_SPAWNING, false);
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, true);
|
||||||
|
world.setGameRule(GameRule.DROWNING_DAMAGE, true);
|
||||||
|
world.setGameRule(GameRule.FALL_DAMAGE, true);
|
||||||
|
world.setGameRule(GameRule.FIRE_DAMAGE, true);
|
||||||
|
world.setGameRule(GameRule.KEEP_INVENTORY, false);
|
||||||
|
world.setGameRule(GameRule.LOG_ADMIN_COMMANDS, true);
|
||||||
|
world.setGameRule(GameRule.MOB_GRIEFING, true);
|
||||||
|
world.setGameRule(GameRule.NATURAL_REGENERATION, true);
|
||||||
|
world.setGameRule(GameRule.REDUCED_DEBUG_INFO, true);
|
||||||
|
world.setGameRule(GameRule.SEND_COMMAND_FEEDBACK, true);
|
||||||
|
world.setGameRule(GameRule.SHOW_DEATH_MESSAGES, true);
|
||||||
|
world.setGameRule(GameRule.SPECTATORS_GENERATE_CHUNKS, false);
|
||||||
|
|
||||||
|
// DEBUG specific Settings
|
||||||
|
if (this.plugin.getConfig().getBoolean("Varo.Debug")) {
|
||||||
|
world.setDifficulty(Difficulty.PEACEFUL);
|
||||||
|
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initRecipes() {
|
||||||
|
this.plugin.getServer().removeRecipe(NamespacedKey.minecraft("fishing_rod"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,12 +9,12 @@ import java.net.URL;
|
||||||
|
|
||||||
public class WebUtils {
|
public class WebUtils {
|
||||||
|
|
||||||
public static String GET(String url) throws MalformedURLException, IOException {
|
public static String GET(final String url) throws MalformedURLException, IOException {
|
||||||
HttpURLConnection connection = ((HttpURLConnection) (new URL(url)).openConnection());
|
final HttpURLConnection connection = ((HttpURLConnection) (new URL(url)).openConnection());
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
StringBuffer content = new StringBuffer();
|
final StringBuffer content = new StringBuffer();
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
content.append(inputLine);
|
content.append(inputLine);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue