@EventHandler public void onEntityDamage(EntityDamageEvent event) { if (event.isCancelled()) { return; } Entity entity = event.getEntity(); if (!(entity instanceof Player)) { return; } if (instance.getCitizensCommunicator().isNPC(entity, instance) || Utils.getInstance().isUnrestricted((Player) entity) || CombatTagComunicator.isNPC(entity)) { return; } Player player = (Player) entity; String name = player.getName().toLowerCase(); if (PlayerCache.getInstance().isAuthenticated(name)) { return; } if (!data.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } } player.setFireTicks(0); event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOWEST) public void onLowestEntityInteract(EntityInteractEvent event) { if (event.isCancelled() || event == null) { return; } if (!(event.getEntity() instanceof Player)) { return; } Player player = (Player) event.getEntity(); String name = player.getName().toLowerCase(); if (instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { return; } if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { return; } if (!data.isAuthAvailable(name)) { if (!Settings.isForcedRegistrationEnabled) { return; } } event.setCancelled(true); }
public boolean convert(CommandSender sender) { if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) { sender.sendMessage("[AuthMe] xAuth plugin not found"); return false; } if (!(new File("./plugins/xAuth/xAuth.h2.db").exists())) { sender.sendMessage( "[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data..."); } List<Integer> players = getXAuthPlayers(); if (players == null || players.isEmpty()) { sender.sendMessage("[AuthMe] Error while import xAuthPlayers"); return false; } sender.sendMessage("[AuthMe] Starting import..."); for (int id : players) { String pl = getIdPlayer(id); String psw = getPassword(id); if (psw != null && !psw.isEmpty() && pl != null) { PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0); database.saveAuth(auth); } } sender.sendMessage("[AuthMe] Import done!"); return true; }
public class LoginScreen extends GenericPopup implements Clickable { public AuthMe plugin = AuthMe.getInstance(); private SpoutCfg spoutCfg = SpoutCfg.getInstance(); private CustomButton exitBtn; private CustomButton loginBtn; private GenericTextField passBox; private GenericLabel titleLbl; private GenericLabel textLbl; private GenericLabel errorLbl; String exitTxt = spoutCfg.getString("LoginScreen.exit button"); String loginTxt = spoutCfg.getString("LoginScreen.login button"); String exitMsg = spoutCfg.getString("LoginScreen.exit message"); String title = spoutCfg.getString("LoginScreen.title"); @SuppressWarnings("unchecked") List<String> textlines = (List<String>) spoutCfg.getList("LoginScreen.text"); public SpoutPlayer splayer; public LoginScreen(SpoutPlayer player) { this.splayer = player; createScreen(); } private void createScreen() { int objects = textlines.size() + 4; int part = !(textlines.size() <= 5) ? 195 / objects : 20; int h = 3 * part / 4, w = 8 * part; titleLbl = new GenericLabel(); titleLbl .setText(title) .setTextColor(new Color(1.0F, 0, 0, 1.0F)) .setAlign(WidgetAnchor.TOP_CENTER) .setHeight(h) .setWidth(w) .setX(maxWidth / 2) .setY(25); this.attachWidget(plugin, titleLbl); int ystart = 25 + h + part / 2; for (int x = 0; x < textlines.size(); x++) { textLbl = new GenericLabel(); textLbl .setText(textlines.get(x)) .setAlign(WidgetAnchor.TOP_CENTER) .setHeight(h) .setWidth(w) .setX(maxWidth / 2) .setY(ystart + x * part); this.attachWidget(plugin, textLbl); } passBox = new GenericTextField(); passBox .setMaximumCharacters(18) .setMaximumLines(1) .setHeight(h - 2) .setWidth(w - 2) .setY(220 - h - 2 * part); passBox.setPasswordField(true); setXToMid(passBox); this.attachWidget(plugin, passBox); errorLbl = new GenericLabel(); errorLbl .setText("") .setTextColor(new Color(1.0F, 0, 0, 1.0F)) .setHeight(h) .setWidth(w) .setX(passBox.getX() + passBox.getWidth() + 2) .setY(passBox.getY()); this.attachWidget(plugin, errorLbl); loginBtn = new CustomButton(this); loginBtn.setText(loginTxt).setHeight(h).setWidth(w).setY(220 - h - part); setXToMid(loginBtn); this.attachWidget(plugin, loginBtn); exitBtn = new CustomButton(this); exitBtn.setText(exitTxt).setHeight(h).setWidth(w).setY(220 - h); setXToMid(exitBtn); this.attachWidget(plugin, exitBtn); this.setPriority(RenderPriority.Highest); } @EventHandler(priority = EventPriority.HIGHEST) public void handleClick(ButtonClickEvent event) { Button b = event.getButton(); SpoutPlayer player = event.getPlayer(); if (event.isCancelled() || event == null || event.getPlayer() == null) return; if (b.equals(loginBtn)) { plugin.management.performLogin(player, passBox.getText(), false); } else if (b.equals(exitBtn)) { event.getPlayer().kickPlayer(exitMsg); } } private void setXToMid(Widget w) { w.setX((maxWidth - w.getWidth()) / 2); } }
public static LimboCache getInstance() { if (singleton == null) { singleton = new LimboCache(AuthMe.getInstance()); } return singleton; }