Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
009fe731a3 |
No files matched your search
Generated
-166
@@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ArtifactsWorkspaceSettings">
|
||||
<artifacts-to-build>
|
||||
<artifact name="PacketEvents:jar" />
|
||||
</artifacts-to-build>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="56671312-5d48-415e-89e3-6da52f639a93" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
||||
</list>
|
||||
<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" />
|
||||
<option value="Enum" />
|
||||
<option value="Interface" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="MavenImportPreferences">
|
||||
<option name="importingSettings">
|
||||
<MavenImportingSettings>
|
||||
<option name="downloadDocsAutomatically" value="true" />
|
||||
<option name="downloadSourcesAutomatically" value="true" />
|
||||
</MavenImportingSettings>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectId" id="1aLTtv1mzTFDpQDYHmrwgIboWkQ" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="project.structure.last.edited" value="Modules" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="JetRunConfigurationType">
|
||||
<module name="JSLoader" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="WORKING_DIRECTORY" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
|
||||
<module name="JSLoader" />
|
||||
<option name="filePath" />
|
||||
<option name="vmParameters" />
|
||||
<option name="alternativeJrePath" />
|
||||
<option name="programParameters" />
|
||||
<option name="passParentEnvs" value="true" />
|
||||
<option name="workingDirectory" />
|
||||
<option name="isAlternativeJrePathEnabled" value="false" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="WORKING_DIRECTORY" />
|
||||
<option name="filePath" />
|
||||
<option name="vmParameters" />
|
||||
<option name="alternativeJrePath" />
|
||||
<option name="programParameters" />
|
||||
<option name="passParentEnvs" value="true" />
|
||||
<option name="workingDirectory" />
|
||||
<option name="isAlternativeJrePathEnabled" value="false" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="WORKING_DIRECTORY" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="JSLoader build" type="MavenRunConfiguration" factoryName="Maven">
|
||||
<MavenSettings>
|
||||
<option name="myGeneralSettings" />
|
||||
<option name="myRunnerSettings" />
|
||||
<option name="myRunnerParameters">
|
||||
<MavenRunnerParameters>
|
||||
<option name="profiles">
|
||||
<set />
|
||||
</option>
|
||||
<option name="goals">
|
||||
<list>
|
||||
<option value="clean" />
|
||||
<option value="package" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="pomFileName" />
|
||||
<option name="profilesMap">
|
||||
<map />
|
||||
</option>
|
||||
<option name="resolveToWorkspace" value="false" />
|
||||
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||
</MavenRunnerParameters>
|
||||
</option>
|
||||
</MavenSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="56671312-5d48-415e-89e3-6da52f639a93" name="Default Changelist" comment="" />
|
||||
<created>1586514092402</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1586514092402</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="280" y="4" key="#Project_Structure" timestamp="1586868472617">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="280" y="4" key="#Project_Structure/0.0.1600.860@0.0.1600.860" timestamp="1586868472617" />
|
||||
<state x="558" y="300" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1" timestamp="1586868346065">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="558" y="300" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1/0.0.1600.860@0.0.1600.860" timestamp="1586868346065" />
|
||||
<state x="580" y="171" key="FileChooserDialogImpl" timestamp="1586868828893">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="580" y="171" key="FileChooserDialogImpl/0.0.1600.860@0.0.1600.860" timestamp="1586868828893" />
|
||||
<state x="280" y="4" key="SettingsEditor" timestamp="1586515368359">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="280" y="4" key="SettingsEditor/0.0.1600.860@0.0.1600.860" timestamp="1586515368359" />
|
||||
<state x="182" y="91" key="new project wizard" timestamp="1587127371863">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="182" y="91" key="new project wizard/0.0.1600.860@0.0.1600.860" timestamp="1587127371863" />
|
||||
<state x="456" y="195" key="run.anything.popup" timestamp="1586766899144">
|
||||
<screen x="0" y="0" width="1600" height="860" />
|
||||
</state>
|
||||
<state x="456" y="195" key="run.anything.popup/0.0.1600.860@0.0.1600.860" timestamp="1586766899144" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,7 +2,9 @@ package me.purplex.packetevents;
|
||||
|
||||
import com.comphenix.tinyprotocol.*;
|
||||
import io.netty.channel.Channel;
|
||||
import me.purplex.packetevents.bukkitevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.events.PacketReceiveEvent;
|
||||
import me.purplex.packetevents.example.TestExample;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
@@ -37,6 +39,14 @@ public class Main extends JavaPlugin implements Listener {
|
||||
}
|
||||
};
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long now = System.currentTimeMillis();
|
||||
PacketEvents.getPacketManager().callServerTickEvent(new ServerTickEvent(now));
|
||||
}
|
||||
}, 0L, 1L);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.purplex.packetevents.bukkitevent;
|
||||
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
|
||||
|
||||
public class ServerTickEvent extends PacketEvent {
|
||||
|
||||
private long timestamp;
|
||||
public ServerTickEvent(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.purplex.packetevents.events;
|
||||
|
||||
import me.purplex.packetevents.bukkitevent.ServerTickEvent;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public interface PacketEventManager {
|
||||
@@ -10,4 +12,6 @@ public interface PacketEventManager {
|
||||
|
||||
public void registerPacketListener(PacketListener e);
|
||||
|
||||
public void callServerTickEvent(ServerTickEvent e);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.purplex.packetevents.events;
|
||||
|
||||
import me.purplex.packetevents.bukkitevent.ServerTickEvent;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PacketManager implements PacketEventManager {
|
||||
@@ -44,4 +46,22 @@ public class PacketManager implements PacketEventManager {
|
||||
public void registerPacketListener(PacketListener e) {
|
||||
this.packetListeners.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callServerTickEvent(ServerTickEvent e) {
|
||||
for (PacketListener listener : this.packetListeners) {
|
||||
Method[] methods = listener.getClass().getMethods();
|
||||
for (Method m : methods) {
|
||||
if (m.isAnnotationPresent(PacketHandler.class)) {
|
||||
if (m.getParameterTypes()[0].getSimpleName().equals(e.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, e);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package me.purplex.packetevents.example;
|
||||
|
||||
import me.purplex.packetevents.bukkitevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.events.PacketHandler;
|
||||
import me.purplex.packetevents.events.PacketListener;
|
||||
import me.purplex.packetevents.events.PacketReceiveEvent;
|
||||
import me.purplex.packetevents.events.PacketSendEvent;
|
||||
import me.purplex.packetevents.packets.Packet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TestExample implements PacketListener {
|
||||
/**
|
||||
@@ -13,6 +16,8 @@ public class TestExample implements PacketListener {
|
||||
* PacketEvents.getPacketManager().registerPacketListener(new TestExample());
|
||||
*/
|
||||
|
||||
private int tick;
|
||||
|
||||
|
||||
@PacketHandler
|
||||
public void onPacketReceive(PacketReceiveEvent e) {
|
||||
@@ -35,4 +40,15 @@ public class TestExample implements PacketListener {
|
||||
e.getPlayer().sendMessage("You took velocity!");
|
||||
}
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onServerTick(ServerTickEvent e) {
|
||||
//CALLED EVERY TICK
|
||||
tick++;
|
||||
if(tick % 20 == 0) {
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.sendMessage("One second has passed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: PacketEvents
|
||||
version: ${project.version}
|
||||
main: me.retrooper.packetevents.Main
|
||||
main: me.purplex.packetevents.Main
|
||||
authors: [purplex]
|
||||
Reference in new issue
Block a user