Fix #32, add bstats metrics
This commit is contained in:
parent
9beef25970
commit
277974edae
|
@ -106,4 +106,6 @@ modules.xml
|
|||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
.attach_*
|
||||
|
||||
# End of https://www.gitignore.io/api/java,intellij+iml
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -42,8 +42,12 @@
|
|||
<pattern>net.wesjd.anvilgui</pattern>
|
||||
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.seanomik.energeticstorage.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
||||
<outputFile>/home/seanomik/Development/java/spigot-dev/test-servers/${server.version}/plugins/EnergeticStorage-v${project.version}.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -50,9 +50,14 @@
|
|||
<pattern>net.wesjd.anvilgui</pattern>
|
||||
<shadedPattern>net.seanomik.energeticstorage.anvilgui</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>net.seanomik.energeticstorage.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
||||
<outputFile>C:\Development\Java\Spigot Servers\${server.version}\plugins\EnergeticStorage-v${project.version}.jar</outputFile>
|
||||
<outputFile>/home/seanomik/Development/java/spigot-dev/test-servers/${server.version}/plugins/EnergeticStorage-v${project.version}.jar</outputFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -132,5 +137,11 @@
|
|||
<artifactId>authlib</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -15,11 +15,13 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class EnergeticStorage extends JavaPlugin implements Listener {
|
||||
private static EnergeticStorage plugin;
|
||||
public static final int BSTATS_PLUGIN_ID = 14068;
|
||||
private static HopperTask hopperTask;
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +41,8 @@ public final class EnergeticStorage extends JavaPlugin implements Listener {
|
|||
hopperTask = new HopperTask();
|
||||
hopperTask.runTaskTimerAsynchronously(this, 0L, 8L);
|
||||
}
|
||||
|
||||
Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
|
|
|
@ -154,7 +154,8 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
|||
ESSystem esSystem = openSystems.get(player.getUniqueId());
|
||||
|
||||
// Make sure no items will get copied to other players open inventory
|
||||
Inventory inv = player.getOpenInventory().getTopInventory();
|
||||
Inventory thisInv = player.getOpenInventory().getTopInventory();
|
||||
Inventory playerInv = player.getInventory();
|
||||
|
||||
// Handle type of click.
|
||||
switch (clickType) {
|
||||
|
@ -162,42 +163,21 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
|||
break;
|
||||
case SWAP:
|
||||
break;
|
||||
case INVENTORY_CLICK:
|
||||
case SHIFT_IN:
|
||||
case INTO_HALF:
|
||||
case INTO:
|
||||
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
// Add the item into the player's inventory
|
||||
int driveSlot = inv.firstEmpty();
|
||||
ItemStack oneClicked = clickedItem.clone();
|
||||
oneClicked.setAmount(1);
|
||||
inv.setItem(driveSlot, oneClicked);
|
||||
|
||||
List<ESDrive> drives = esSystem.getESDrives();
|
||||
drives.add(driveSlot - 2, new ESDrive(clickedItem));
|
||||
esSystem.setESDrives(drives);
|
||||
|
||||
// Remove the item from the players inventory
|
||||
clickedItem.setAmount(clickedItem.getAmount() - 1);
|
||||
}
|
||||
break;
|
||||
case INTO_HALF:
|
||||
case INTO:
|
||||
if (Utils.isItemValid(cursor) && Utils.isItemADrive(cursor)) {
|
||||
NBTItem clickedNBT = new NBTItem(cursor);
|
||||
|
||||
if (clickedNBT.hasKey("ES_Drive") && clickedNBT.getBoolean("ES_Drive")) {
|
||||
int firstEmpty = thisInv.firstEmpty();
|
||||
if (firstEmpty != -1) {
|
||||
thisInv.setItem(firstEmpty, clickedItem);
|
||||
playerInv.removeItem(clickedItem);
|
||||
|
||||
List<ESDrive> drives = esSystem.getESDrives();
|
||||
if (drives.contains(null)) {
|
||||
drives.set(drives.indexOf(null), new ESDrive(cursor));
|
||||
} else {
|
||||
drives.add(new ESDrive(cursor));
|
||||
}
|
||||
drives.add(new ESDrive(clickedItem));
|
||||
esSystem.setESDrives(drives);
|
||||
initializeItems(player, esSystem);
|
||||
|
||||
event.setCancelled(true);
|
||||
cursor.setAmount(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -209,18 +189,21 @@ public class ESDriveGUI implements InventoryHolder, Listener {
|
|||
|
||||
Reference.ES_TERMINAL_GUI.openInventory(player, esSystem);
|
||||
} else if (slot != 1 && slot != 7 && slot != 8) {
|
||||
if (Utils.isItemADrive(clickedItem)) {
|
||||
List<ESDrive> drives = esSystem.getESDrives();
|
||||
drives.set(slot - 2, null);
|
||||
esSystem.setESDrives(drives);
|
||||
if (Utils.isItemValid(clickedItem) && Utils.isItemADrive(clickedItem)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
event.setCancelled(false);
|
||||
int firstEmpty = playerInv.firstEmpty();
|
||||
if (firstEmpty != -1) {
|
||||
playerInv.setItem(firstEmpty, clickedItem);
|
||||
thisInv.removeItem(clickedItem);
|
||||
|
||||
List<ESDrive> drives = esSystem.getESDrives();
|
||||
drives.set(slot - 2, null);
|
||||
esSystem.setESDrives(drives);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INVENTORY_CLICK:
|
||||
event.setCancelled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue