AuthMe 3.0
//Changes 3.0:// * Repackaging from uk.org.whoami.authme to fr.xephi.authme, please developpers, update! * Rewrite some of parts of the plugin * Some code was already perfect , also did not change it :p * Full support for phpbb3 * Add full support for WordPress + passwordHash: WORDPRESS * Completely rewrite Management system for inventories and tp issues, Thanks to : [[http://dev.bukkit.org/profiles/Possible/|Possible]] * Rework on /passpartu command * Completely rewrite the password encryption method * Add a way for developers to add their own Password Encryption Method on AuthMe via event way (please see fr.xephi.authme.events.PasswordEncryptionEvent) * Add an auto purge with players.dat removing method and essentials files removing ( if you want authme to hook with an another plugin let me know ) * Complete Hook with BungeeCord by removing the /server command before login * message_lang.yml will never be overwritten with English Strings , but correctly update the message_lang.yml when needed to * Fix a lot of issues mentioned in tickets , commants , or by mp, Thanks for all your reports!
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package fr.xephi.authme.gui;
|
||||
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
|
||||
public interface Clickable {
|
||||
public void handleClick(ButtonClickEvent event);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package fr.xephi.authme.gui;
|
||||
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class CustomButton extends GenericButton
|
||||
{
|
||||
public Clickable handleRef = null;
|
||||
|
||||
public CustomButton(Clickable c) {
|
||||
handleRef = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
handleRef.handleClick(event);
|
||||
}
|
||||
|
||||
public CustomButton setMidPos(int x, int y)
|
||||
{
|
||||
this.setX(x)
|
||||
.setY(y)
|
||||
.shiftXPos(-(width / 2))
|
||||
.shiftYPos(-(height / 2));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package fr.xephi.authme.gui.screens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.gui.Button;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.GenericTextField;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.gui.Clickable;
|
||||
import fr.xephi.authme.gui.CustomButton;
|
||||
import fr.xephi.authme.settings.SpoutCfg;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user