Change few things to optimize

This brings no particular changes, but hopefully coding will start again soon.
I just changed two methods to dynamically get the UhcCore instance instead of taking it as an argument.
This commit is contained in:
Bea 2021-01-10 00:37:11 +01:00
parent 3928c0ae9e
commit b45f7f5a8f
9 changed files with 92 additions and 214 deletions

71
.gitignore vendored Normal file
View File

@ -0,0 +1,71 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

View File

@ -1,10 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="Lorenzo">
<words>
<w>bukkit</w>
<w>bungeecord</w>
<w>textcomponent</w>
<w>yamls</w>
</words>
</dictionary>
</component>

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ArtifactsWorkspaceSettings">
<artifacts-to-build>
<artifact name="Spigot Complete Plugin (Debugger, Listener, CommandExecutor):jar" />
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="020639be-43b7-4d76-87a9-477dde475710" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="1Y4on9waNhQGFaWTpixGA7Upjmr" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="D:/Coding/# Server per Test Plugins #/plugins" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="020639be-43b7-4d76-87a9-477dde475710" name="Default Changelist" comment="" />
<created>1582211391295</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1582211391295</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="873" y="359" key="#Auto_Import" timestamp="1582537520959">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="873" y="359" key="#Auto_Import/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582537520959" />
<state x="873" y="359" key="#Project_Structure" timestamp="1582636351073">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="873" y="359" key="#Project_Structure/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582636351073" />
<state x="1086" y="404" key="#com.intellij.ide.util.MemberChooser" timestamp="1582221814422">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="1086" y="404" key="#com.intellij.ide.util.MemberChooser/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582221814422" />
<state x="720" y="0" key="#com.intellij.refactoring.rename.AutomaticRenamingDialog" timestamp="1582312863813">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="720" y="0" key="#com.intellij.refactoring.rename.AutomaticRenamingDialog/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582312863813" />
<state x="967" y="441" key="FileChooserDialogImpl" timestamp="1582633064839">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="967" y="441" key="FileChooserDialogImpl/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582633064839" />
<state x="731" y="424" key="new project wizard" timestamp="1582711931728">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="731" y="424" key="new project wizard/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582711931728" />
<state x="937" y="331" key="run.anything.popup" timestamp="1582589527763">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="937" y="331" key="run.anything.popup/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1582589527763" />
</component>
</project>

View File

@ -27,5 +27,6 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="spigot-1.16.1" level="project" />
</component>
</module>

View File

@ -21,12 +21,19 @@ public class UhcCore extends JavaPlugin
public static Logger logger;
private PluginManager pluginManager;
private static UhcCore instance;
public static UhcCore getInstance()
{ return instance; }
// Method called when the plugin is being loaded.
@Override
public void onEnable()
{
instance = this;
// We need to run this in a task, because the plugin has to be initialized AFTER all the worlds are loaded.
// todo: after a few months, this sounds like a badly implemented idea
getServer().getScheduler().runTask(this, ()->
{

View File

@ -61,7 +61,7 @@ public class PlayerDeathRespawnListener implements Listener
{
// Spawn a Firework where the player died.
CommonValues.spawnFirework(plugin, player.getLocation(), 15L);
CommonValues.spawnFirework(player.getLocation(), 15L);
// Load the player name.
String playerName = player.getName();
@ -223,7 +223,7 @@ public class PlayerDeathRespawnListener implements Listener
for(Location loc : CommonValues.fireworksLocations)
{
debugger.sendDebugMessage(Level.INFO, "FIREWORK LOC: " + loc);
CommonValues.spawnFirework(plugin, loc, 10L);
CommonValues.spawnFirework(loc, 10L);
}

View File

@ -58,6 +58,8 @@ public class CommonValues {
public static int borderX, borderZ, borderSize;
// todo: move following methods to their separate Utils class; this one is just for caching values...
// Function to check how many players a team has.
// This function returns the total number of alive teams.
public static void updatePlayersPerTeam()
@ -100,7 +102,7 @@ public class CommonValues {
player.getInventory().setItem(4, CommonValues.teamsItem);
}
public static void spawnFirework(UhcCore plugin, Location location, long detonateDelay) {
public static void spawnFirework(Location location, long detonateDelay) {
Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
FireworkMeta fireworkMeta = firework.getFireworkMeta();
@ -109,6 +111,8 @@ public class CommonValues {
fireworkMeta.addEffect(FireworkEffect.builder().withColor(Color.RED).flicker(true).build());
firework.setFireworkMeta(fireworkMeta);
UhcCore plugin = UhcCore.getInstance();
plugin.getServer().getScheduler().runTaskLater(plugin, firework::detonate, detonateDelay);
}