Skip to content

Commit a7cb86b

Browse files
committed
1.0.0-SNAPSHOT
1 parent 0993aeb commit a7cb86b

File tree

16 files changed

+241
-2
lines changed

16 files changed

+241
-2
lines changed

.gitpod.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
vscode:
3+
extensions:
4+
- vscjava.vscode-java-dependency
5+
- vscjava.vscode-java-test
6+
- vscjava.vscode-maven
7+
- redhat.java
8+
- vscjava.vscode-java-pack
9+
- vscjava.vscode-java-debug
10+
- redhat.fabric8-analytics

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic"
3+
}

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# NAME
2-
[![License](https://img.shields.io/badge/license-GPLv3-blue?style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0.html) ![Pull Requests](https://img.shields.io/github/issues-pr-closed/katorlys/NAME?style=for-the-badge) ![Issues](https://img.shields.io/github/issues-closed/katorlys/NAME?style=for-the-badge)
1+
# Starlin_L2
2+
[![License](https://img.shields.io/badge/license-CC%20BY--NC--ND--4.0-green?style=for-the-badge)](http://creativecommons.org/licenses/by-nc-nd/4.0) ![Pull Requests](https://img.shields.io/github/issues-pr-closed/katorlys/Starlin_L2?style=for-the-badge) ![Issues](https://img.shields.io/github/issues-closed/katorlys/Starlin_L2?style=for-the-badge)
33

44
## Introduction
5+
Starlin_L2 Minecraft Spigot plugin made for StarlinWorld (星林宇宙) server.<br>
6+
7+
Main functions:<br>
8+
- Prevent players from stucking in the Nether Portal when logging in.
9+
- Prevent crops from being trampled.

starlin_l2/pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>starlin_l2</artifactId>
6+
<groupId>com.github.katorly</groupId>
7+
<version>1.0-SNAPSHOT</version>
8+
9+
<!-- Repositories -->
10+
<repositories>
11+
<repository>
12+
<id>spigot-repo</id>
13+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
14+
</repository>
15+
</repositories>
16+
17+
<!-- Dependencies -->
18+
<dependencies>
19+
<!--Spigot API-->
20+
<dependency>
21+
<groupId>org.spigotmc</groupId>
22+
<artifactId>spigot-api</artifactId>
23+
<version>1.18.1-R0.1-SNAPSHOT</version>
24+
<type>jar</type>
25+
<scope>provided</scope>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>3.8.1</version>
35+
<configuration>
36+
<source>1.7</source>
37+
<target>1.7</target>
38+
</configuration>
39+
</plugin>
40+
<plugin>
41+
<artifactId>maven-antrun-plugin</artifactId>
42+
<configuration>
43+
<tasks>
44+
<copy file="target/starlin_l2-1.0-SNAPSHOT.jar" todir="/Users/Aditya/Desktop/spigot/plugins"/>
45+
</tasks>
46+
</configuration>
47+
<executions>
48+
<execution>
49+
<phase>install</phase>
50+
<goals>
51+
<goal>run</goal>
52+
</goals>
53+
</execution>
54+
</executions>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
</project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.github.katorly.starlin_l2;
2+
3+
import com.github.katorly.starlin_l2.backup.MessageSender;
4+
5+
import org.bukkit.Location;
6+
import org.bukkit.Material;
7+
import org.bukkit.World;
8+
import org.bukkit.entity.Player;
9+
import org.bukkit.event.EventHandler;
10+
import org.bukkit.event.Listener;
11+
import org.bukkit.event.block.Action;
12+
import org.bukkit.event.player.PlayerInteractEvent;
13+
import org.bukkit.event.player.PlayerJoinEvent;
14+
15+
public class EventListener implements Listener {
16+
@EventHandler
17+
public void onCropTrample(PlayerInteractEvent e) {
18+
if (e.getAction() == Action.PHYSICAL && e.getClickedBlock().getType() == Material.FARMLAND) {
19+
e.setCancelled(true);
20+
}
21+
}
22+
23+
@EventHandler
24+
public void onPlayerJoin(PlayerJoinEvent e) {
25+
Player p = e.getPlayer();
26+
Location l = p.getLocation();
27+
World w = l.getWorld();
28+
double x = l.getX(); double y= l.getY(); double z = l.getZ();
29+
Location l_xl = new Location(w, x + 1, y, z);
30+
Location l_xr = new Location(w, x - 1, y, z);
31+
Location l_up = new Location(w, x, y + 1, z);
32+
Location l_down = new Location(w, x, y - 1, z);
33+
Location l_zl = new Location(w, x, y, z + 1);
34+
Location l_zr = new Location(w, x, y, z - 1);
35+
if ((l.getBlock().getType() == Material.NETHER_PORTAL)
36+
|| (l_xl.getBlock().getType() == Material.NETHER_PORTAL) || (l_xr.getBlock().getType() == Material.NETHER_PORTAL)
37+
|| (l_up.getBlock().getType() == Material.NETHER_PORTAL) || (l_down.getBlock().getType() == Material.NETHER_PORTAL)
38+
|| (l_zl.getBlock().getType() == Material.NETHER_PORTAL) || (l_zr.getBlock().getType() == Material.NETHER_PORTAL)) {
39+
p.chat("/spawn");
40+
MessageSender.sendMessage(p, "&b&l星林宇宙 &r&8>> &7检测到您在下界门处登录, 为防止您无法正常登录, 已将您传送到主城!");
41+
}
42+
}
43+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.github.katorly.starlin_l2.backup;
2+
3+
import java.util.Objects;
4+
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.entity.Player;
7+
8+
public class MessageSender {
9+
/**
10+
* Replace "&" with "§" to fix color messages.
11+
*
12+
* @param string
13+
* @return
14+
*/
15+
public static String Color(String string) {
16+
return Objects.requireNonNull(string).replace("&", "§");
17+
}
18+
19+
/**
20+
* Send message to a player.
21+
*
22+
* @param player
23+
* @param message
24+
*/
25+
public static void sendMessage(Player player, String message) {
26+
player.sendMessage(MessageSender.Color(message));
27+
}
28+
29+
/**
30+
* Send message to all online players.
31+
*
32+
* @param message
33+
*/
34+
public static void broadcastMessage(String message) {
35+
for (Player player : Bukkit.getOnlinePlayers()) {
36+
player.sendMessage(MessageSender.Color(message));
37+
}
38+
}
39+
40+
/**
41+
* Send message to console and all online players.
42+
*
43+
* @param message
44+
*/
45+
public static void broadcastMessageAll(String message) {
46+
Bukkit.broadcastMessage(MessageSender.Color(message));
47+
}
48+
49+
/**
50+
* Send title to a player.
51+
*
52+
* @param player
53+
* @param title
54+
* @param subtitle
55+
*/
56+
public static void sendTitle(Player player, String title, String subtitle) {
57+
player.sendTitle(MessageSender.Color(title), MessageSender.Color(subtitle), 10, 40, 20); // Show title 2s
58+
}
59+
60+
/**
61+
* Send title to all online players.
62+
*
63+
* @param title
64+
* @param subtitle
65+
*/
66+
public static void broadcastTitle(String title, String subtitle) {
67+
for (Player player : Bukkit.getOnlinePlayers()) {
68+
player.sendTitle(MessageSender.Color(title), MessageSender.Color(subtitle), 10, 40, 20); // Show title 2s
69+
}
70+
}
71+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.github.katorly.starlin_l2;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.event.HandlerList;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
public class starlin_l2 extends JavaPlugin {
8+
public static starlin_l2 INSTANCE;
9+
10+
public starlin_l2() {
11+
INSTANCE = this;
12+
}
13+
14+
@Override
15+
public void onEnable() {
16+
getServer().getPluginManager().registerEvents(new EventListener(),this);
17+
Bukkit.getLogger().fine("Starlin_L2 enabled! Made for StarlinWorld server only.");
18+
Bukkit.getLogger().info("Author: Katorly");
19+
}
20+
21+
@Override
22+
public void onDisable() {
23+
HandlerList.unregisterAll(this);
24+
Bukkit.getLogger().fine("Starlin_L2 disabled!");
25+
}
26+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: starlin_l2
2+
version: "1.0-SNAPSHOT"
3+
author: Katorly
4+
main: com.github.katorly.starlin_l2.starlin_l2
5+
api-version: "1.18"
6+
description: A Spigot plugin made for StarlinWorld.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)