diff --git a/Core/pom.xml b/Core/pom.xml index 35a349e15..47474a82b 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -4,7 +4,7 @@ de.tor.dswb dsworkbench - 3.7 + 3.71 4.0.0 diff --git a/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.form b/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.form index 28083d4a7..ce40753d2 100644 --- a/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.form +++ b/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.form @@ -8,9 +8,6 @@ - - - diff --git a/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.java b/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.java index f9a6f7e4e..0e7049542 100644 --- a/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.java +++ b/Core/src/main/java/de/tor/tribes/ui/windows/DSWorkbenchMainFrame.java @@ -2443,7 +2443,8 @@ private void fireDSWorkbenchClosingEvent(java.awt.event.WindowEvent evt) {//GEN- logger.error("Failed to store profile settings on shutdown"); } dispose(); - MainShutdownHook.getSingleton().run(); + new Thread(MainShutdownHook.getSingleton()).run(); + JOptionPaneHelper.showInformationBox(this, "Beende ...", "Beende ..."); }//GEN-LAST:event_fireDSWorkbenchClosingEvent private void fireGraphicPackChangedEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireGraphicPackChangedEvent diff --git a/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.form b/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.form index dd1e7bffd..725764e55 100644 --- a/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.form +++ b/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.form @@ -243,13 +243,16 @@ + + + - + - + @@ -298,15 +301,15 @@ - + - + - + diff --git a/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.java b/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.java index 4d44e5abd..99be23efd 100644 --- a/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.java +++ b/Core/src/main/java/de/tor/tribes/ui/wiz/red/ResourceDistributorFinishPanel.java @@ -320,7 +320,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { gridBagConstraints.weighty = 0.7; jPanel1.add(jTransportsPanel, gridBagConstraints); - jFinalDistributionPanel.setPreferredSize(new java.awt.Dimension(314, 100)); + jFinalDistributionPanel.setMinimumSize(new java.awt.Dimension(200, 46)); + jFinalDistributionPanel.setPreferredSize(new java.awt.Dimension(350, 100)); jFinalDistributionPanel.setLayout(new java.awt.BorderLayout()); jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultierende Rohstoffverteilung")); @@ -344,13 +345,13 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; - gridBagConstraints.weightx = 1.0; + gridBagConstraints.weightx = 0.8; gridBagConstraints.weighty = 0.3; jPanel1.add(jFinalDistributionPanel, gridBagConstraints); jFinalStatusPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Sonstige Informationen")); - jFinalStatusPanel.setMinimumSize(new java.awt.Dimension(195, 100)); - jFinalStatusPanel.setPreferredSize(new java.awt.Dimension(195, 100)); + jFinalStatusPanel.setMinimumSize(new java.awt.Dimension(220, 100)); + jFinalStatusPanel.setPreferredSize(new java.awt.Dimension(220, 100)); jFinalStatusPanel.setLayout(new java.awt.GridBagLayout()); jLabel2.setText("Errechnete Transporte"); @@ -424,7 +425,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; - gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 0.2; gridBagConstraints.weighty = 0.3; jPanel1.add(jFinalStatusPanel, gridBagConstraints); diff --git a/Core/src/main/java/de/tor/tribes/util/BuildingSettings.java b/Core/src/main/java/de/tor/tribes/util/BuildingSettings.java index c1f1844cb..64aa6cbb4 100644 --- a/Core/src/main/java/de/tor/tribes/util/BuildingSettings.java +++ b/Core/src/main/java/de/tor/tribes/util/BuildingSettings.java @@ -194,8 +194,14 @@ public static boolean isBuildingLevelValid(String pBuilding, int pLevel) { * returns false if building was not found */ public static boolean isBuildingLevelValid(int pBuildingID, int pLevel) { - if(pLevel > MAX_LEVEL[pBuildingID]) return false; - if(pLevel < MIN_LEVEL[pBuildingID]) return false; + if(pLevel > MAX_LEVEL[pBuildingID]) { + logger.debug("Level too hight {} / {} / {}", pBuildingID, pLevel, MAX_LEVEL[pBuildingID]); + return false; + } + if(pLevel < MIN_LEVEL[pBuildingID]) { + logger.debug("Level too low {} / {} / {}", pBuildingID, pLevel, MIN_LEVEL[pBuildingID]); + return false; + } return true; } diff --git a/Core/src/main/java/de/tor/tribes/util/ClipboardWatch.java b/Core/src/main/java/de/tor/tribes/util/ClipboardWatch.java index 883019309..73ba5ddd6 100644 --- a/Core/src/main/java/de/tor/tribes/util/ClipboardWatch.java +++ b/Core/src/main/java/de/tor/tribes/util/ClipboardWatch.java @@ -21,6 +21,8 @@ import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; +import java.io.BufferedInputStream; +import java.io.InputStream; import java.util.Timer; import java.util.TimerTask; import java.util.zip.CRC32; @@ -54,7 +56,6 @@ public static synchronized ClipboardWatch getSingleton() { setPriority(MIN_PRIORITY); } private Clip clip = null; - private AudioClip ac = null; private synchronized void playNotification() { if (!GlobalOptions.getProperties().getBoolean("clipboard.notification")) { @@ -69,14 +70,12 @@ public void run() { clip.stop(); clip.setMicrosecondPosition(0); } - if (ac != null) { - ac.stop(); - } try { if (clip == null) { clip = AudioSystem.getClip(); - AudioInputStream inputStream = AudioSystem.getAudioInputStream(ClockFrame.class.getResourceAsStream("/res/Ding.wav")); + InputStream data = new BufferedInputStream(ClockFrame.class.getResourceAsStream("/res/Ding.wav")); + AudioInputStream inputStream = AudioSystem.getAudioInputStream(data); clip.open(inputStream); } clip.start(); diff --git a/Core/src/main/java/de/tor/tribes/util/Constants.java b/Core/src/main/java/de/tor/tribes/util/Constants.java index b7f1fb452..660439f74 100644 --- a/Core/src/main/java/de/tor/tribes/util/Constants.java +++ b/Core/src/main/java/de/tor/tribes/util/Constants.java @@ -24,7 +24,7 @@ * @author Torridity */ public class Constants { - public final static double VERSION = 3.7; + public final static double VERSION = 3.71; public final static String VERSION_ADDITION = ""; public final static Color DS_BACK = new Color(225, 213, 190); public final static Color DS_BACK_LIGHT = new Color(239, 235, 223); diff --git a/Core/src/main/java/de/tor/tribes/util/ReportServer.java b/Core/src/main/java/de/tor/tribes/util/ReportServer.java index 207088024..add66eb9e 100644 --- a/Core/src/main/java/de/tor/tribes/util/ReportServer.java +++ b/Core/src/main/java/de/tor/tribes/util/ReportServer.java @@ -173,12 +173,16 @@ public void run() { url = url.substring((url.startsWith("/")?1:0)); String report = null; - //workaround for finding start & end because "&", "/" are not escaped in URL - report = url.substring(url.indexOf("&report=") + 8, url.indexOf("&user=")); - - report = URLDecoder.decode(report, "UTF-8"); - logger.debug("Report raw: {}", report); + try { + //workaround for finding start & end because "&", "/" are not escaped in URL + report = url.substring(url.indexOf("&report=") + 8, url.indexOf("&user=")); + report = URLDecoder.decode(report, "UTF-8"); + logger.debug("Report raw: {}", report); + } catch(Exception e) { + report = null; + } + if (PluginManager.getSingleton().executeObstReportParser(report)) { logger.debug("Successfully parsed report. Sending response."); w.write("HTTP/1.0 200 OK"); diff --git a/Core/src/main/java/de/tor/tribes/util/ServerSettings.java b/Core/src/main/java/de/tor/tribes/util/ServerSettings.java index 84feef40b..4ad13d301 100644 --- a/Core/src/main/java/de/tor/tribes/util/ServerSettings.java +++ b/Core/src/main/java/de/tor/tribes/util/ServerSettings.java @@ -58,8 +58,8 @@ public class ServerSettings { public static final int NOBLESYSTEM_GOLD_COINS = 1; private int nobleSystem = 0; - private boolean haulActive = true; - private boolean haulLimitActive = false; + private int haulType = 1; + private int haulLimitActive = 0; private int haulBase = 0; private int haulMax = 0; @@ -210,8 +210,8 @@ public boolean loadSettings(String pServerID) { logger.debug(" - reading haul values"); try { - this.haulActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls")) != 0; - this.haulLimitActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/farm_limit")) == 1; + this.haulType = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls")); + this.haulLimitActive = Integer.parseInt(JDomUtils.getNodeValue(d, "game/farm_limit")); this.haulBase = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls_base")); this.haulMax = Integer.parseInt(JDomUtils.getNodeValue(d, "game/hauls_max")); } catch (Exception inner) { @@ -319,11 +319,15 @@ public int getBarbarianPoints() { } public boolean isHaulActive() { - return haulActive; + return haulType != 0; + } + + public int getHaulType() { + return haulType; } public boolean isHaulLimitActive() { - return haulLimitActive; + return haulLimitActive != 0; } public int getHaulLimitBase() { diff --git a/Core/src/main/java/de/tor/tribes/util/village/KnownVillage.java b/Core/src/main/java/de/tor/tribes/util/village/KnownVillage.java index 0518997ac..72701a591 100644 --- a/Core/src/main/java/de/tor/tribes/util/village/KnownVillage.java +++ b/Core/src/main/java/de/tor/tribes/util/village/KnownVillage.java @@ -220,7 +220,7 @@ public void setBuildingLevelByName(String pBuilding, int pLevel) { return; } - if(BuildingSettings.isBuildingLevelValid(pBuilding, pLevel)) { + if(!BuildingSettings.isBuildingLevelValid(pBuilding, pLevel)) { logger.error("Building level invalid " + pBuilding + ": " + pLevel); return; } @@ -266,6 +266,7 @@ public int getFarmSpace() { int buildingPop = 0; for(int i = 0; i < BuildingSettings.BUILDING_NAMES.length; i++) { + logger.trace("Building Farm {} / {} / {}", i, buildings[i], BuildingSettings.getPopUsageById(i, buildings[i])); buildingPop += BuildingSettings.getPopUsageById(i, buildings[i]); } diff --git a/Core/src/main/java/de/tor/tribes/util/xml/JDomUtils.java b/Core/src/main/java/de/tor/tribes/util/xml/JDomUtils.java index 01165e8a9..b978c250d 100644 --- a/Core/src/main/java/de/tor/tribes/util/xml/JDomUtils.java +++ b/Core/src/main/java/de/tor/tribes/util/xml/JDomUtils.java @@ -64,9 +64,12 @@ public static Document getOldDocument(File xmlFile) throws Exception { } public static Document getOldDocument(InputStream inStream) throws Exception { - InputStream s1 = IOUtils.toInputStream(""); - InputStream s2 = IOUtils.toInputStream(""); - return getDocument(new java.io.SequenceInputStream(new java.io.SequenceInputStream(s1, inStream), s2)); + String data = IOUtils.toString(inStream); + + if(data.startsWith("") + 2); + } + return getDocument("" + data + ""); } public static List getNodes(Document document, String path) { diff --git a/ParserPlugin/pom.xml b/ParserPlugin/pom.xml index df6945fc8..e5eff7be1 100644 --- a/ParserPlugin/pom.xml +++ b/ParserPlugin/pom.xml @@ -4,7 +4,7 @@ de.tor.dswb dsworkbench - 3.7 + 3.71 4.0.0 diff --git a/ParserPlugin/src/main/java/de/tor/tribes/util/parser/BuildingParser.java b/ParserPlugin/src/main/java/de/tor/tribes/util/parser/BuildingParser.java index b7a8646e8..93f33ffa7 100644 --- a/ParserPlugin/src/main/java/de/tor/tribes/util/parser/BuildingParser.java +++ b/ParserPlugin/src/main/java/de/tor/tribes/util/parser/BuildingParser.java @@ -78,13 +78,13 @@ public boolean parse(String pData) { if(v == null) continue; logger.debug("Got village '" + v + "'"); - String split[] = line.split("\t"); + String split[] = line.trim().split("\t"); if(split.length < 2 + availableBuildings.size()) continue; try { int[] levels = new int[availableBuildings.size()]; for(int i = 0; i < levels.length; i++) { - levels[i] = Integer.parseInt(split[i + 3].trim()); + levels[i] = Integer.parseInt(split[i + 2].trim()); } if(logger.isDebugEnabled()) { diff --git a/pom.xml b/pom.xml index c67af2b7c..967b4393b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dsworkbench DSWorkbench pom - 3.7 + 3.71 Parent project for DS Workbench. The project contains two modules: core and plugins which are put together