Skip to content

Commit 4994ddb

Browse files
committed
Merge branch 'master' into cosmetics
# Conflicts: # pom.xml
2 parents a41e5a7 + df66391 commit 4994ddb

File tree

73 files changed

+1528
-1183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1528
-1183
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up JDK 16
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 16
18+
- name: Mavenを使ってビルド
19+
run: mvn --batch-mode --update-snapshots verify
20+
- name: original-*.jarを削除
21+
run: rm target/original-*.jar
22+
- name: パッケージをビルドの成果物としてリリース
23+
uses: softprops/action-gh-release@v1
24+
with:
25+
tag_name: release-v${{ github.run_number }}
26+
files: target/*.jar

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,5 @@
145145
<version>2.0.1</version>
146146
<scope>compile</scope>
147147
</dependency>
148-
<dependency>
149-
<groupId>xyz.xenondevs</groupId>
150-
<artifactId>particle</artifactId>
151-
<version>1.8.1</version>
152-
</dependency>
153148
</dependencies>
154149
</project>

src/main/java/com/github/elic0de/thejpspit/spigot/TheJpsPit.java renamed to src/main/java/com/github/elic0de/thejpspit/TheJpsPit.java

Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
package com.github.elic0de.thejpspit.spigot;
1+
package com.github.elic0de.thejpspit;
22

33
import co.aikar.commands.PaperCommandManager;
44
import com.fatboyindustrial.gsonjavatime.Converters;
5-
import com.github.elic0de.thejpspit.spigot.command.PitCommand;
6-
import com.github.elic0de.thejpspit.spigot.command.SpawnCommand;
7-
import com.github.elic0de.thejpspit.spigot.config.PitPreferences;
8-
import com.github.elic0de.thejpspit.spigot.database.Database;
9-
import com.github.elic0de.thejpspit.spigot.database.SqLiteDatabase;
10-
import com.github.elic0de.thejpspit.spigot.game.Game;
11-
import com.github.elic0de.thejpspit.spigot.hook.EconomyHook;
12-
import com.github.elic0de.thejpspit.spigot.hook.Hook;
13-
import com.github.elic0de.thejpspit.spigot.hook.VaultEconomyHook;
14-
import com.github.elic0de.thejpspit.spigot.item.ItemManager;
15-
import com.github.elic0de.thejpspit.spigot.item.items.*;
16-
import com.github.elic0de.thejpspit.spigot.listener.CombatTagger;
17-
import com.github.elic0de.thejpspit.spigot.listener.EventListener;
18-
import com.github.elic0de.thejpspit.spigot.network.PluginMessageReceiver;
19-
import com.github.elic0de.thejpspit.spigot.nms.PacketManager;
20-
import com.github.elic0de.thejpspit.spigot.nms.PacketManager1_19_R1;
21-
import com.github.elic0de.thejpspit.spigot.player.PitPlayer;
22-
import com.github.elic0de.thejpspit.spigot.player.PitPlayerManager;
23-
import com.github.elic0de.thejpspit.spigot.queue.QueueManager;
24-
import com.github.elic0de.thejpspit.spigot.task.QueueTask;
25-
import com.github.elic0de.thejpspit.spigot.util.KillAssistHelper;
26-
import com.github.elic0de.thejpspit.spigot.util.KillRatingHelper;
27-
import com.github.elic0de.thejpspit.spigot.villager.VillagerNPCManager;
28-
import com.github.elic0de.thejpspit.spigot.villager.villagers.ShopVillager;
5+
import com.github.elic0de.thejpspit.command.PitChatCommand;
6+
import com.github.elic0de.thejpspit.command.PitCommand;
7+
import com.github.elic0de.thejpspit.command.SpawnCommand;
8+
import com.github.elic0de.thejpspit.config.PitPreferences;
9+
import com.github.elic0de.thejpspit.config.Settings;
10+
import com.github.elic0de.thejpspit.database.Database;
11+
import com.github.elic0de.thejpspit.database.SqLiteDatabase;
12+
import com.github.elic0de.thejpspit.hook.PlaceholderHook;
13+
import com.github.elic0de.thejpspit.leveler.Levels;
14+
import com.github.elic0de.thejpspit.listener.CombatTagger;
15+
import com.github.elic0de.thejpspit.player.PitPlayer;
16+
import com.github.elic0de.thejpspit.player.PitPlayerManager;
17+
import com.github.elic0de.thejpspit.game.Game;
18+
import com.github.elic0de.thejpspit.hook.EconomyHook;
19+
import com.github.elic0de.thejpspit.hook.Hook;
20+
import com.github.elic0de.thejpspit.hook.VaultEconomyHook;
21+
import com.github.elic0de.thejpspit.item.ItemManager;
22+
import com.github.elic0de.thejpspit.listener.BlockPlaceListener;
23+
import com.github.elic0de.thejpspit.listener.EventListener;
24+
import com.github.elic0de.thejpspit.util.KillAssistHelper;
25+
import com.github.elic0de.thejpspit.util.KillRatingHelper;
26+
import com.github.elic0de.thejpspit.villager.VillagerNPCManager;
27+
import com.github.elic0de.thejpspit.villager.villagers.ShopVillager;
2928
import com.google.gson.Gson;
3029
import com.google.gson.GsonBuilder;
30+
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
31+
import net.william278.annotaml.Annotaml;
3132
import org.bukkit.Bukkit;
3233
import org.bukkit.GameRule;
33-
import org.bukkit.attribute.Attribute;
3434
import org.bukkit.plugin.PluginManager;
3535
import org.bukkit.plugin.java.JavaPlugin;
3636

37-
38-
37+
import java.io.File;
38+
import java.io.IOException;
39+
import java.lang.reflect.InvocationTargetException;
3940
import java.util.ArrayList;
4041
import java.util.List;
4142
import java.util.Optional;
@@ -45,19 +46,16 @@
4546
public final class TheJpsPit extends JavaPlugin {
4647

4748
private static TheJpsPit instance;
49+
private Settings settings;
4850
private Game game;
4951
private Database database;
5052
private KillRatingHelper ratingHelper;
5153

5254
private KillAssistHelper assistKillHelper;
53-
private QueueManager queueManager;
54-
private QueueTask queueTask;
5555
private List<Hook> hooks = new ArrayList<>();
5656

5757
private Optional<PitPreferences> pitPreferences;
5858

59-
private PacketManager packetManager;
60-
6159
public static TheJpsPit getInstance() {
6260
return instance;
6361
}
@@ -67,9 +65,25 @@ public void onLoad() {
6765
instance = this;
6866
}
6967

68+
private void loadConfig() throws RuntimeException {
69+
try {
70+
this.settings = Annotaml.create(new File(getDataFolder(), "config.yml"), Settings.class).get();
71+
} catch (IOException | InvocationTargetException | InstantiationException |
72+
IllegalAccessException e) {
73+
getLogger().log(Level.SEVERE, "Failed to load configuration files", e);
74+
throw new RuntimeException(e);
75+
}
76+
}
77+
78+
public void reload() {
79+
loadConfig();
80+
Levels.initialize();
81+
}
82+
7083
@Override
7184
public void onEnable() {
7285
// Initialize TheJpsPit
86+
this.loadConfig();
7387
saveConfig();
7488
final AtomicBoolean initialized = new AtomicBoolean(true);
7589
game = new Game();
@@ -88,17 +102,9 @@ public void onEnable() {
88102

89103
assistKillHelper = new KillAssistHelper();
90104
ratingHelper = new KillRatingHelper(0);
91-
queueManager = new QueueManager();
92-
queueTask = new QueueTask();
93105

94106
setPreferences();
95-
setPacketManager();
96-
97-
getServer().getMessenger()
98-
.registerIncomingPluginChannel(this, PluginMessageReceiver.BUNGEE_CHANNEL_ID,
99-
new PluginMessageReceiver());
100-
getServer().getMessenger()
101-
.registerOutgoingPluginChannel(this, PluginMessageReceiver.BUNGEE_CHANNEL_ID);
107+
//setPacketManager();
102108

103109
registerCommands();
104110
registerListener();
@@ -111,7 +117,7 @@ public void onEnable() {
111117
world.setGameRule(GameRule.KEEP_INVENTORY, true);
112118
});
113119

114-
createItems();
120+
ItemManager.createItems();
115121
createNPCs();
116122

117123
Bukkit.getOnlinePlayers().forEach(player -> {
@@ -129,7 +135,6 @@ public void onEnable() {
129135
if (updateNeeded) {
130136
database.updateUserData(pitPlayer);
131137
}
132-
133138
});
134139
}
135140

@@ -144,7 +149,7 @@ private void setPreferences() {
144149
this.pitPreferences = preferences;
145150
}
146151

147-
private void setPacketManager() {
152+
/* private void setPacketManager() {
148153
final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].trim();
149154
PacketManager packetManager;
150155
switch (serverVersion) {
@@ -155,7 +160,7 @@ private void setPacketManager() {
155160
throw new RuntimeException("Failed to create version specific server accessor");
156161
}
157162
this.packetManager = packetManager;
158-
}
163+
}*/
159164

160165
private void registerCommands() {
161166
PaperCommandManager commandManager = new PaperCommandManager(this);
@@ -164,26 +169,23 @@ private void registerCommands() {
164169

165170
commandManager.registerCommand(new PitCommand());
166171
commandManager.registerCommand(new SpawnCommand());
172+
commandManager.registerCommand(new PitChatCommand());
167173
}
168174

169175
private void registerListener() {
170176
new EventListener();
171177
new CombatTagger();
178+
new BlockPlaceListener();
172179
}
173180

174181
private void registerHooks() {
175182
final PluginManager plugins = Bukkit.getPluginManager();
176183
if (plugins.getPlugin("Vault") != null) {
177184
this.registerHook(new VaultEconomyHook(this));
178185
}
179-
}
180-
181-
private void createItems() {
182-
ItemManager.register(new ItemDiamondSword());
183-
ItemManager.register(new ItemDiamondChestPlate());
184-
ItemManager.register(new ItemDiamondBoots());
185-
ItemManager.register(new ItemObsidian());
186-
ItemManager.register(new ItemVividSword());
186+
if (plugins.getPlugin("PlaceholderAPI") != null) {
187+
new PlaceholderHook().register();
188+
}
187189
}
188190

189191
private void createNPCs() {
@@ -192,18 +194,18 @@ private void createNPCs() {
192194

193195
@Override
194196
public void onDisable() {
195-
pitPreferences.ifPresent(preferences -> database.updatePitPreferences(preferences));
196197
// Plugin shutdown logic
197198
if (database != null) {
198199
database.terminate();
199200
}
200201
game.getTask().stop();
201202

202-
queueTask.stop();
203-
204203
getServer().getMessenger().unregisterOutgoingPluginChannel(this);
205204
getServer().getMessenger().unregisterIncomingPluginChannel(this);
206205

206+
// 置かれたブロックを削除
207+
BlockPlaceListener.restoreBlocks();
208+
207209
Bukkit.getOnlinePlayers().forEach(player -> {
208210
final PitPlayer pitPlayer = PitPlayerManager.getPitPlayer(player);
209211
game.leave(pitPlayer);
@@ -214,6 +216,10 @@ public void onDisable() {
214216
Bukkit.getScheduler().cancelTasks(this);
215217
}
216218

219+
public Settings getSettings() {
220+
return settings;
221+
}
222+
217223
private List<Hook> getHooks() {
218224
return hooks;
219225
}
@@ -254,17 +260,10 @@ public KillAssistHelper getAssistKillHelper() {
254260
return assistKillHelper;
255261
}
256262

257-
public QueueManager getQueueManager() {
258-
return queueManager;
259-
}
260-
261263
public Optional<PitPreferences> getPitPreferences() {
262264
return pitPreferences;
263265
}
264266

265-
public PacketManager getPacketManager() {
266-
return packetManager;
267-
}
268267

269268
public Gson getGson() {
270269
return Converters.registerOffsetDateTime(new GsonBuilder().excludeFieldsWithoutExposeAnnotation()).create();

src/main/java/com/github/elic0de/thejpspit/bungee/RequestReceiveListener.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/com/github/elic0de/thejpspit/bungee/TheJpsPit.java

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.github.elic0de.thejpspit.command;
2+
3+
import co.aikar.commands.BaseCommand;
4+
import co.aikar.commands.annotation.CommandAlias;
5+
import com.github.elic0de.thejpspit.TheJpsPit;
6+
import com.github.elic0de.thejpspit.gui.PitChatMenu;
7+
import com.github.elic0de.thejpspit.player.PitPlayer;
8+
import com.github.elic0de.thejpspit.player.PitPlayerManager;
9+
import org.bukkit.entity.Player;
10+
11+
public class PitChatCommand extends BaseCommand {
12+
private final TheJpsPit pit = TheJpsPit.getInstance();
13+
14+
@CommandAlias("pitchat")
15+
public void onChat(Player player) {
16+
final PitPlayer pitPlayer = PitPlayerManager.getPitPlayer(player);
17+
PitChatMenu.create(pit, "PitChat").show(pitPlayer);
18+
}
19+
}

0 commit comments

Comments
 (0)