System.out.println("[" + plugin.getDescription("name") + "] Enabled");
//#########################
//### CONFIG für System ###
//### Definiere Variablen
String[][] sysConfigArray = {
{"KEY_OK", "KEY_RETURN"},
{"KEY_CANCLE", "KEY_ESCAPE"},
{"guiCloseNewHome", "true"},
{"guiCloseNewTP", "true"},
{"guiCloseDelete", "false"},
{"VolumeZiel", String.valueOf(soundVolumeZiel)},
{"VolumeStart", String.valueOf(soundVolumeStart)},
{"VolumeRadiusZiel", String.valueOf(soundRadiusZiel)},
{"VolumeRadiusStart", String.valueOf(soundRadiusStart)},
//################################
//### Initialiesiere System Config
sysConfig = new TeleportationConfig("System", sysConfigArray, this, debug,conf);
debug = Integer.parseInt(sysConfig.getValue("Debug") );
soundVolumeZiel = Float.parseFloat(sysConfig.getValue("VolumeZiel").replace(",", "."));
soundVolumeStart = Float.parseFloat(sysConfig.getValue("VolumeStart").replace(",", "."));
soundRadiusZiel = Float.parseFloat(sysConfig.getValue("VolumeRadiusZiel").replace(",", "."));
soundRadiusStart = Float.parseFloat(sysConfig.getValue("VolumeRadiusStart").replace(",", "."));
if(plugin.getPluginByName("SprachAPI") != null /*&& plugin.getPluginByName("RWGui") != null*/){
MySqlDatabase = sysConfig.getValue("MySqlDatabase");
MySqlPrefix = sysConfig.getValue("MySqlPrefix");
MySqlIP = sysConfig.getValue("MySqlIP");
try{ MySqlPort = Integer.parseInt(sysConfig.getValue("MySqlPort")); }catch(NumberFormatException e){ MySqlPort = 0; }
MySqlUser = sysConfig.getValue("MySqlUser");
MySqlPW = sysConfig.getValue("MySqlPW");
sSQLite = getPath() + "/database/" + getDescription("name") + "-" + world.getName() + ".db";
if(debug>0){System.out.println("[" + plugin.getDescription("name") + "] "+"Datenbank Auswahl ");}
if(debug>2){System.out.println("[" + plugin.getDescription("name") + "] "+"Datenbank Auswahl "+"MySqlDatabase["+MySqlDatabase+"] "+"MySqlIP["+MySqlIP+"] "+"MySqlPort["+MySqlPort+"] "+"MySqlUser["+MySqlUser+"] "+"MySqlPW["+MySqlPW+"] ");}
if (!MySqlDatabase.equals("")&&!MySqlIP.equals("")&&MySqlPort>0&&!MySqlUser.equals("")&&!MySqlPW.equals("")){
SQL = getMySQLConnection(MySqlDatabase, MySqlIP, MySqlPort, MySqlUser, MySqlPW);
SQL = getSQLiteConnection(sSQLite);
if(debug>0){System.out.println("[" + plugin.getDescription("name") + "] "+"Lade DB");}
SQL.execute("CREATE TABLE IF NOT EXISTS "+(!MySqlPrefix.equals("")?MySqlPrefix+"_":"")+"HOME ("
+ "HomeID INTEGER "+(SQL.getType()==DatabaseType.MySQL?"AUTO_INCREMENT ":"PRIMARY KEY ")+"NOT NULL, "
+ "HomeName VARCHAR(64), "
+ (SQL.getType()==DatabaseType.MySQL?",PRIMARY KEY (HomeID) ":"")
SQL.execute("CREATE TABLE IF NOT EXISTS "+(!MySqlPrefix.equals("")?MySqlPrefix+"_":"")+"Teleport ("
+ "TpID INTEGER "+(SQL.getType()==DatabaseType.MySQL?"AUTO_INCREMENT ":"PRIMARY KEY ")+"NOT NULL, "
+ (SQL.getType()==DatabaseType.MySQL?",PRIMARY KEY (TpID) ":"")
if(debug>0){System.out.println("[" + plugin.getDescription("name") + "] "+"DB geladen");}
if (sysConfig.getValue("Template").toUpperCase().equals("PDA")){
String[][] sysTemplateArray = {
{"BNT1Color", "[#ffFFff]"},
{"BNT2Color", "[#FFffFF]"},
{"BNT3Color", "[#fFfFFf]"},
{"BNTdown", "bntDown.png"},
{"LCDselect", "lcdSelect.png"},
{"LCDColor", "[#fFfFfF]"},
{"TiteOffTopl", "0.025"},
{"TiteColor", "[#000000]"},
File pdir = new File(plugin.getPath() + spec+tmpl);
if (pdir.mkdir()) { if(debug>0){System.out.println("[" + plugin.getDescription("name") + "]"+" Verzeichnis erstellt. "+pdir.getName()+"|");} }
sysTemplate = new TeleportationConfig("config", sysTemplateArray, this, debug,spec+tmpl+spec+sysConfig.getValue("Template"));
}else if (sysConfig.getValue("Template").toUpperCase().equals("PAPYRUS")){
String[][] sysTemplateArray = {
{"BNT1Color", "[#000000]"},
{"BNT2Color", "[#000000]"},
{"BNT3Color", "[#000000]"},
{"BNTdown", "bntDown.png"},
{"LCDselect", "lcdSelect.png"},
{"LCDColor", "[#000000]"},
{"TiteOffTopl", "0.025"},
{"TiteColor", "[#000000]"},
File pdir = new File(plugin.getPath() + spec+tmpl);
if (pdir.mkdir()) { if(debug>0){System.out.println("[" + plugin.getDescription("name") + "]"+" Verzeichnis erstellt. "+pdir.getName()+"|");} }
sysTemplate = new TeleportationConfig("config", sysTemplateArray, this, debug,spec+tmpl+spec+sysConfig.getValue("Template"));
String[][] sysTemplateArray = {
{"BNT1Color", "[#ffFFff]"},
{"BNT2Color", "[#FFffFF]"},
{"BNT3Color", "[#fFfFFf]"},
{"BNTdown", "bntDown.png"},
{"LCDColor", "[#fFfFfF]"},
{"TiteOffTopl", "0.025"},
{"TiteColor", "[#000000]"},
File pdir = new File(plugin.getPath() + spec+tmpl);
if (pdir.mkdir()) { if(debug>0){System.out.println("[" + plugin.getDescription("name") + "]"+" Verzeichnis erstellt. "+pdir.getName()+"|");} }
sysTemplate = new TeleportationConfig("config", sysTemplateArray, this, debug,spec+tmpl+spec+sysConfig.getValue("Template"));
try{ B = Float.parseFloat(sysTemplate.getValue("HG-rSize")); }catch(NumberFormatException e){ B = 0.5f; }
H = B * PHI; X = 0.5f-(B/2); Y = 0.5f-(H/2);
try{ TiteFontSizeRow = Integer.parseInt(sysTemplate.getValue("TiteFontSize")); }catch(NumberFormatException e){ TiteFontSizeRow = 64; }
try{ TiteOffToplRow = Float.parseFloat(sysTemplate.getValue("TiteOffTopl")); }catch(NumberFormatException e){ TiteOffToplRow = 0.025f; }
TiteFontSize = (int) ( (B*TiteFontSizeRow)/0.5f );
TiteOffTopl = ( (TiteFontSize*TiteOffToplRow)/TiteFontSizeRow );
textDaten = new TeleportationClassText();
textDaten.setDebug(debug); //### gebe Debug weiter
textDaten.sDir=conf+"/"+"locale";
registerEventListener(this);
registerEventListener(new TeleportationListenerMap(this));
registerEventListener(new TeleportationListenerGUI(this));
//registerEventListener(new TeleportationListenerKonsole(this));
//registerEventListener(new TeleportationListenerSign(this));
//#######################################
//### Vorbereiten Bilder Prüfen und Laden
String tmplRoot = plugin.getPath()+spec+tmpl;
//###########################
//### Bilder Prüfen und Laden
if (sysConfig.getValue("Template").toUpperCase().equals("PDA")||sysConfig.getValue("Template").toUpperCase().equals("PAPYRUS")){
// TEMPLATE aus Vordefinierter Resouce
HG0Image = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/HG.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("HG"));
bntHomeImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bnt1.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT1"));
bntNewImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bnt2.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT2"));
bntDelImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bnt3.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT3"));
bntLcdImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bntLcd.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("LCD"));
bntUpImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bntUp.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNTup"));
bntDownImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bntDown.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNTdown"));
bntExitImage = getBild("/resources/"+sysConfig.getValue("Template").toUpperCase()+"/bntExit.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("EXIT"));
// TEMPLATE aus PDA Resouce
HG0Image = getBild("/resources/"+DIR+"/HG.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("HG"));
bntHomeImage = getBild("/resources/"+DIR+"/bnt1.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT1"));
bntNewImage = getBild("/resources/"+DIR+"/bnt2.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT2"));
bntDelImage = getBild("/resources/"+DIR+"/bnt3.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNT3"));
bntLcdImage = getBild("/resources/"+DIR+"/bntLcd.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("LCD"));
bntUpImage = getBild("/resources/"+DIR+"/bntUp.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNTup"));
bntDownImage = getBild("/resources/"+DIR+"/bntDown.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("BNTdown"));
bntExitImage = getBild("/resources/"+DIR+"/bntExit.png" ,tmplRoot+spec+sysConfig.getValue("Template")+spec+sysTemplate.getValue("EXIT"));
soundAuswahl = new SoundInformation(this, "/resources/OK.mp3");
soundTeleZiel = new SoundInformation(this, "/resources/teleport.01.s.mp3");
soundTeleStart = new SoundInformation(this, "/resources/teleport.02.s.mp3");
gameSoundKlick = "gui_click";
gameSoundGuiOff = "gui_journal_hide";
gameSoundGuiOn = "onngui_journal_show";
gameSoundDel = "gui_map_hide";
gameSoundAdd = "gui_map_show";
gameSoundNeu = "message";
gameSoundOK = "trade_success";
if (plugin.getPluginByName("SprachAPI") == null){
System.err.println("[" + plugin.getDescription("name") + "-ERR] Das Plugin 'SprachAPI' ist nicht installiert! Bitte installieren!");
registerEventListener(new TeleportationErrorSprachAPI(this));
public void onDisable() {
System.out.println("[" + plugin.getDescription("name") + "] Disabled");
public void onPlayerConnectEvent(PlayerConnectEvent event) {
if(debug>0){System.out.println("[" + plugin.getDescription("name") + "] "+"Connect ");}
Player player = event.getPlayer();
player.registerKeys(tpCRT.getKeyInputValue(sysConfig.getValue("KEY_GUI")),tpCRT.getKeyInputValue(sysConfig.getValue("KEY_OK")),tpCRT.getKeyInputValue(sysConfig.getValue("KEY_CANCLE")));
player.setListenForKeyInput(true);
//###########################
//### Reienfolge und Abstände
GuiImage HG0 = new GuiImage(HG0Image,X,Y,true,B,H,true);
float tH = (TiteFontSize*0.07f)/TiteFontSizeRow;
float pH = (1.0f)-(tH/1)/*-TiteOffTopl*/;
float bntB =0.417f, nbtH=0.064f, bntX=0.0335f, nbtY=0.084f;
float bntLX=0.75f, bntLY=0.031f;
float lcdB=0.417f, lcdH=0.064f,lcdX=0.048f,lcdY=0.084f;
float lcdLX=0.25f, lcdLY=0.031f;
GuiLabel titel = new GuiLabel(0.5f, pH, true);
//### Labels Configurieren
titel.setText(sysTemplate.getValue("TiteColor")+textDaten.getText(player, "Titel"));
titel.setFontSize(TiteFontSize);
titel.setPivot(PivotPosition.Center);
GuiImage bntHOME = new GuiImage(bntHomeImage,X+(B/2)+bntX,/*0.25f*/ nbtY*3 ,true,bntB,nbtH,true);
bntHOME.setClickable(true);
bntHOME.setMipMappingEnabled(MipMapping);
GuiImage bntNEW = new GuiImage(bntNewImage ,X+(B/2)+bntX,/*0.169f*/ nbtY*2 ,true,bntB,nbtH,true);
bntNEW.setClickable(true);
bntNEW.setMipMappingEnabled(MipMapping);
GuiImage bntDEL = new GuiImage(bntDelImage ,X+(B/2)+bntX,/*0.082f*/ nbtY*1 ,true,bntB,nbtH,true);
bntDEL.setClickable(true);
bntDEL.setMipMappingEnabled(MipMapping);
GuiLabel bntHOMEtext = new GuiLabel(bntLX,bntLY+(nbtY*3), true);
bntHOMEtext.setText(sysTemplate.getValue("BNT1Color")+textDaten.getText(player, "HOME"));
bntHOMEtext.setFontSize((int)(TiteFontSize/2));
bntHOMEtext.setPivot(PivotPosition.Center);
bntHOMEtext.setClickable(true);
HG0.addChild(bntHOMEtext);
GuiLabel bntNEWtext = new GuiLabel(bntLX,bntLY+(nbtY*2), true);
bntNEWtext.setText(sysTemplate.getValue("BNT2Color")+textDaten.getText(player, "NEW"));
bntNEWtext.setFontSize((int)(TiteFontSize/2));
bntNEWtext.setPivot(PivotPosition.Center);
bntNEWtext.setClickable(true);
HG0.addChild(bntNEWtext);
GuiLabel bntDELtext = new GuiLabel(bntLX,bntLY+(nbtY*1), true);
bntDELtext.setText(sysTemplate.getValue("BNT3Color")+textDaten.getText(player, "DEL"));
bntDELtext.setFontSize((int)(TiteFontSize/2));
bntDELtext.setPivot(PivotPosition.Center);
bntDELtext.setClickable(true);
HG0.addChild(bntDELtext);
//### Listen Elemente Erstellen
ArrayList<GuiImage> imgList = new ArrayList();
ArrayList<GuiLabel> txtList = new ArrayList();
for (int n=lcdMax;n>0;n--){
bntLCD = new GuiImage(bntLcdImage, lcdX, lcdY*n, true, lcdB, lcdH, true);
bntLCD.setClickable(true);
bntLCD.setMipMappingEnabled(MipMapping);
bntLCDtext =new GuiLabel(lcdLX,lcdLY+(lcdY*n), true);
bntLCDtext.setFontSize((int)(TiteFontSize/2));
bntLCDtext.setPivot(PivotPosition.Center);
bntLCDtext.setClickable(true);
//### Listen Elemente Vereinen
classLcdListe lcdListe = new classLcdListe(imgList,txtList);
HG0.addChild(lcdListe.guiImage.get(n));
HG0.addChild(lcdListe.guiLabel.get(n));
GuiImage bntUp = new GuiImage(bntUpImage , lcdX+(0.5f/2.2f),lcdY*1 ,true,lcdB/2.2f,lcdH,true);
bntUp.setClickable(true);
GuiImage bntDown = new GuiImage(bntDownImage , lcdX ,lcdY*1 ,true,lcdB/2.2f,lcdH,true);
bntDown.setClickable(true);
GuiTextField inpName = new GuiTextField(0.2625f, 0.475f, true, lcdB, lcdH, true);
inpName.setColor(0xffffff80);
inpName.setPivot(PivotPosition.Center);
inpName.setFontColor(0x000000ff);
inpName.setMaxCharacters(16);
inpName.setBackgroundPreset(0);
//FixMe###inpName.setListenForInput(true);
GuiImage bntExit = new GuiImage(bntExitImage , 1.0f-eB,1.0f-eH ,true,eB,eH,true);
bntExit.setClickable(true);
//### Setze Player GUI zu Atribute
player.setAttribute(sGUI_HG, HG0);
player.setAttribute(sGUI_titel, titel);
player.setAttribute(sGUI_bntHOME, bntHOME);
player.setAttribute(sGUI_bntNEW, bntNEW);
player.setAttribute(sGUI_bntDEL, bntDEL);
player.setAttribute(sGUI_bntHOMEtext, bntHOMEtext);
player.setAttribute(sGUI_bntNEWtext, bntNEWtext);
player.setAttribute(sGUI_bntDELtext, bntDELtext);
player.setAttribute(sGUI_bntUp, bntUp);
player.setAttribute(sGUI_bntDown, bntDown);
player.setAttribute(sGUI_lcdListe, lcdListe);
player.setAttribute(sGUI_lcdListeOffset, 0);
player.setAttribute(sGUI_inpName, inpName);
player.setAttribute(sGUI_bntExit, bntExit);
//### GUI zum Player hinzufügen
player.addGuiElement((GuiImage) player.getAttribute(sGUI_HG));
player.addGuiElement((GuiLabel) player.getAttribute(sGUI_titel));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntHOME));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntNEW));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntDEL));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntUp));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntDown));
player.addGuiElement((GuiLabel) player.getAttribute(sGUI_bntHOMEtext));
player.addGuiElement((GuiLabel) player.getAttribute(sGUI_bntNEWtext));
player.addGuiElement((GuiLabel) player.getAttribute(sGUI_bntDELtext));
((classLcdListe) player.getAttribute(sGUI_lcdListe)).addGuiElement(player);
player.addGuiElement((GuiTextField) player.getAttribute(sGUI_inpName));
player.addGuiElement((GuiImage) player.getAttribute(sGUI_bntExit));
((GuiImage) player.getAttribute(sGUI_HG)).setVisible(false);
((GuiImage) player.getAttribute(sGUI_bntUp)).setVisible(false);
((GuiImage) player.getAttribute(sGUI_bntDown)).setVisible(false);
((GuiTextField) player.getAttribute(sGUI_inpName)).setVisible(false);