Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //get the area and output the owers name
- @EventMethod
- public void onPlayerEnterChunk(PlayerEnterChunkEvent evt) throws SQLException{
- Player player = evt.getPlayer();
- String Playername = player.getName();
- GuiLabel Display = (GuiLabel) player.getAttribute("AreaDisplay");
- GuiLabel Display1 = (GuiLabel) player.getAttribute("AreaDisplay1");
- GuiLabel Display2 = (GuiLabel) player.getAttribute("AreaDisplay2");
- Display.setText("");
- Display1.setText("");
- Display2.setText("");
- Vector3i AreaIDV = evt.getNewChunkCoordinates();
- int AreaIDx = (int) AreaIDV.x;
- int AreaIDy = (int) AreaIDV.y;
- int AreaIDz = (int) AreaIDV.z;
- String AreaID = ""+AreaIDx+AreaIDy+AreaIDz+"";
- Database database = getSQLiteConnection(getPath() + "/" + "database.db");
- try(ResultSet result = database.executeQuery("SELECT * FROM `AdminSettings` WHERE `ID` = '1'")){
- if(!result.next()){
- database.executeUpdate("INSERT INTO `AdminSettings` (AreaNum) VALUES ('1000');");
- }
- }
- // set the code to run every 3 sec
- Runnable reload = new Runnable() {
- public void run() {
- try(ResultSet result = database.executeQuery("SELECT * FROM `AdminSettings` WHERE `ID` = '1'")){
- String AreaNum = result.getString("AreaNum");
- Display1.setText(" Areas Allowed = "+AreaNum+" ");
- } catch (SQLException ex) {
- Logger.getLogger(WorldProtection.class.getName()).log(Level.SEVERE, null, ex);
- }
- try(ResultSet result = database.executeQuery("SELECT COUNT(*) FROM `Areas` WHERE `AreaOwner` = '"+ Playername +"'")){
- String Count = result.getString("COUNT(*)");
- Display2.setText(" Areas owned = "+Count+" ");
- } catch (SQLException ex) {
- Logger.getLogger(WorldProtection.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- };
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
- executor.scheduleAtFixedRate(reload, 0, 3, TimeUnit.SECONDS);
- // end of time code
- try(ResultSet result = database.executeQuery("SELECT * FROM `Areas` WHERE `AreaID` = '"+ AreaID +"'")){
- if(result.next()){
- String AreaOwner = result.getString("AreaOwner");
- Display.setText(" Area "+AreaID+" owned by "+AreaOwner+" ");
- return;
- }
- if(!result.next()){
- Display.setText(" Area "+ AreaID +" Unprotected ");
- return;
- }
- } catch (SQLException ex) {
- Logger.getLogger(WorldProtection.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- the error
- PLUGIN EXCEPTION (WorldProtection, 1.0.0, Yahgiggle) ---->
- java.lang.NullPointerException
- at worldprotection.WorldProtection.onPlayerEnterChunk(WorldProtection.java:191)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
- at java.lang.reflect.Method.invoke(Unknown Source)
- at pluginapi.PluginEventHandler.triggerEvent(SourceFile:201)
- at aU.f.a(SourceFile:315)
- at aU.f.messageReceived(SourceFile:119)
- at k.e.a(SourceFile:109)
- at k.c.run(SourceFile:65)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement