Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
katorly committed Mar 11, 2022
1 parent 66d12fe commit 904fa59
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 79 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Starlin_L2
[![License](https://img.shields.io/badge/license-CC%20BY--NC--ND--4.0-green?style=flat-square)](http://creativecommons.org/licenses/by-nc-nd/4.0) [![Pull Requests](https://img.shields.io/github/issues-pr-closed/katorlys/Starlin_L2?style=flat-square)](https://github.com/katorlys/Starlin_L2/pulls) [![Issues](https://img.shields.io/github/issues-closed/katorlys/Starlin_L2?style=flat-square)](https://github.com/katorlys/Starlin_L2/issues) [![Lines](https://img.shields.io/tokei/lines/github/katorlys/Starlin_L2?style=flat-square)](https://github.com/katorlys/Starlin_L2) [![Build](https://img.shields.io/github/workflow/status/katorlys/Starlin_L2/Build?style=flat-square)](https://github.com/katorlys/Starlin_L2/actions/workflows/build.yml) [![Codacy](https://img.shields.io/codacy/grade/b187c52b9b754ed8a670a3017201c05f?style=flat-square)](https://app.codacy.com/gh/katorlys/Starlin_L2)
# StarlinUtils
[![License](https://img.shields.io/badge/license-CC%20BY--NC--ND--4.0-green?style=flat-square)](http://creativecommons.org/licenses/by-nc-nd/4.0) [![Pull Requests](https://img.shields.io/github/issues-pr-closed/katorlys/StarlinUtils?style=flat-square)](https://github.com/katorlys/StarlinUtils/pulls) [![Issues](https://img.shields.io/github/issues-closed/katorlys/StarlinUtils?style=flat-square)](https://github.com/katorlys/StarlinUtils/issues) [![Lines](https://img.shields.io/tokei/lines/github/katorlys/StarlinUtils?style=flat-square)](https://github.com/katorlys/StarlinUtils) [![Build](https://img.shields.io/github/workflow/status/katorlys/StarlinUtils/Build?style=flat-square)](https://github.com/katorlys/StarlinUtils/actions/workflows/build.yml) [![Codacy](https://img.shields.io/codacy/grade/b187c52b9b754ed8a670a3017201c05f?style=flat-square)](https://app.codacy.com/gh/katorlys/StarlinUtils)

## Introduction
Starlin_L2 Minecraft Spigot plugin made for StarlinWorld (星林宇宙) server.<br>
StarlinUtils Minecraft Spigot plugin made for StarlinWorld (星林宇宙) server.<br>

Main functions:<br>
- Prevent players from stucking in the Nether Portal when logging in.
Expand All @@ -12,11 +12,14 @@ Main functions:<br>
- Record player's first-join time and monthly online time.
- Record the server's monthly players.
![](https://cdn.jsdelivr.net/gh/katorly/Gallery001/plugins/2022-01-20_14.52.png)
- Conveniently manage player's fly.
- Conveniently manage player's flying permission.
- Displays the help document when player excutes `/help`.
- Modifys colored concretes' recipe into the following **shapeless** recipe:
![](https://cdn.jsdelivr.net/gh/katorly/Gallery001/plugins/2022_03_11_11.28.30.PNG)

## Commands
- `/l2 time [player]` Displays the first-join time and total online time of the excutor or the specific player.
- `/su time [player]` Displays the first-join time and total online time of the excutor or the specific player.
- `/su info` Displays information about the player who excutes the command.
- `/help` Displays the help document.
For server OPs,
- `/givefly <player>` Gives a specific player fly.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<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">
<modelVersion>4.0.0</modelVersion>

<artifactId>starlin_l2</artifactId>
<artifactId>StarlinUtils</artifactId>
<groupId>com.github.katorly</groupId>
<version>1.0.4</version>
<version>1.0.5</version>

<!-- Repositories -->
<repositories>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.github.katorly.starlin_l2;
package com.github.katorly.starlinutils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import com.github.katorly.starlin_l2.backup.ConfigReader;
import com.github.katorly.starlin_l2.backup.Messager;
import com.github.katorly.starlin_l2.utils.PlayTime;
import com.github.katorly.starlinutils.backup.ConfigReader;
import com.github.katorly.starlinutils.backup.Messager;
import com.github.katorly.starlinutils.utils.PlayTime;

import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -30,21 +30,21 @@ public void onPlayerJoin(PlayerJoinEvent e) throws ParseException {
PlayTime.initialize(e.getPlayer()); //Get player's join time and check whether player has joined before.

long t = System.currentTimeMillis();
FileConfiguration monthly = starlin_l2.monthly.getConfig(); //Record monthly players.
FileConfiguration monthly = StarlinUtils.monthly.getConfig(); //Record monthly players.
String pname = e.getPlayer().getName();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM");
String timenow = dateFormat.format(t);
if (!starlin_l2.monthly.getConfig().contains(timenow)) {
if (!StarlinUtils.monthly.getConfig().contains(timenow)) {
List<String> plist = new ArrayList<String>();
plist.add(pname);
monthly.set(timenow, plist);
ConfigReader.save(starlin_l2.monthly);
ConfigReader.save(StarlinUtils.monthly);
} else {
List<String> plist = monthly.getStringList(timenow);
if (!plist.contains(pname)) {
plist.add(pname);
monthly.set(timenow, plist);
ConfigReader.save(starlin_l2.monthly);
ConfigReader.save(StarlinUtils.monthly);
}
}

Expand All @@ -71,7 +71,7 @@ public void run() {
String x0 = String.format("%.2f", x); String y0 = String.format("%.2f", y); String z0 = String.format("%.2f", z);
Messager.sendMessage(p, "&b&l星林宇宙 &r&8>> &7下界门位置: " + x0 + ", " + y0 + ", " + z0);
}
}.runTaskLater(starlin_l2.INSTANCE, 4L);
}.runTaskLater(StarlinUtils.INSTANCE, 4L);
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/com/github/katorly/starlinutils/Recipe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.katorly.starlinutils;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;

public class Recipe {
public static void registerConcreteRecipe() { //Add colored concrete recipe onEnable
Recipe.concreteRecipe(Material.BLACK_CONCRETE, Material.BLACK_DYE);
Recipe.concreteRecipe(Material.BLUE_CONCRETE, Material.BLUE_DYE);
Recipe.concreteRecipe(Material.BROWN_CONCRETE, Material.BROWN_DYE);
Recipe.concreteRecipe(Material.CYAN_CONCRETE, Material.CYAN_DYE);
Recipe.concreteRecipe(Material.GRAY_CONCRETE, Material.GRAY_DYE);
Recipe.concreteRecipe(Material.GREEN_CONCRETE, Material.GREEN_DYE);
Recipe.concreteRecipe(Material.LIGHT_BLUE_CONCRETE, Material.LIGHT_BLUE_DYE);
Recipe.concreteRecipe(Material.LIGHT_GRAY_CONCRETE, Material.LIGHT_GRAY_DYE);
Recipe.concreteRecipe(Material.LIME_CONCRETE, Material.LIME_DYE);
Recipe.concreteRecipe(Material.MAGENTA_CONCRETE, Material.MAGENTA_DYE);
Recipe.concreteRecipe(Material.ORANGE_CONCRETE, Material.ORANGE_DYE);
Recipe.concreteRecipe(Material.PINK_CONCRETE, Material.PINK_DYE);
Recipe.concreteRecipe(Material.PURPLE_CONCRETE, Material.PURPLE_DYE);
Recipe.concreteRecipe(Material.RED_CONCRETE, Material.RED_DYE);
Recipe.concreteRecipe(Material.WHITE_CONCRETE, Material.WHITE_DYE);
Recipe.concreteRecipe(Material.YELLOW_CONCRETE, Material.YELLOW_DYE);
}

public static void concreteRecipe(Material concrete, Material dye) { //8*colored concrete = 1*dye + 8*stones.
ShapelessRecipe concreteRecipe = new ShapelessRecipe(new NamespacedKey(StarlinUtils.INSTANCE, concrete.toString() + "_recipe"), new ItemStack(concrete, 8));
concreteRecipe = concreteRecipe.addIngredient(1, dye).addIngredient(8, Material.STONE);
Bukkit.addRecipe(concreteRecipe);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package com.github.katorly.starlin_l2;
package com.github.katorly.starlinutils;

import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import com.github.katorly.starlin_l2.backup.ConfigReader;
import com.github.katorly.starlin_l2.utils.PlayTime;
import com.github.katorly.starlin_l2.commands.*;
import com.github.katorly.starlinutils.backup.ConfigReader;
import com.github.katorly.starlinutils.commands.*;
import com.github.katorly.starlinutils.festival.AprilFools;
import com.github.katorly.starlinutils.utils.PlayTime;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class starlin_l2 extends JavaPlugin {
public static starlin_l2 INSTANCE;
public starlin_l2() {
public class StarlinUtils extends JavaPlugin {
public static StarlinUtils INSTANCE;
public StarlinUtils() {
INSTANCE = this;
}

Expand All @@ -28,25 +29,27 @@ public starlin_l2() {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new EventListener(),this);
getServer().getPluginManager().registerEvents(new AprilFools(),this);
config = new ConfigReader(this,"","config.yml");
config.saveDefaultConfig();
timedata = new ConfigReader(this,"","timedata.yml");
monthly = new ConfigReader(this,"","monthly.yml");
Bukkit.getPluginCommand("l2").setExecutor(new l2());
Bukkit.getPluginCommand("l2").setTabCompleter(new l2());
Bukkit.getPluginCommand("su").setExecutor(new su());
Bukkit.getPluginCommand("su").setTabCompleter(new su());
Bukkit.getPluginCommand("help").setExecutor(new help());
Bukkit.getPluginCommand("givefly").setExecutor(new givefly());
Bukkit.getPluginCommand("givefly").setTabCompleter(new givefly());
Bukkit.getPluginCommand("listfly").setExecutor(new listfly());
Bukkit.getPluginCommand("delfly").setExecutor(new delfly());
Bukkit.getPluginCommand("delfly").setTabCompleter(new delfly());
Bukkit.getLogger().info("[starlin_l2] Repo: https://github.com/katorlys/Starlin_L2");
Bukkit.getLogger().info("[starlin_l2] Starlin_L2 enabled! Made for StarlinWorld server only.");
Recipe.registerConcreteRecipe(); //Add colored concrete
Bukkit.getLogger().info("[StarlinUtils] Repo: https://github.com/katorlys/StarlinUtils");
Bukkit.getLogger().info("[StarlinUtils] StarlinUtils enabled! Made for StarlinWorld server only.");
for (Player p : Bukkit.getOnlinePlayers()) {
try {
PlayTime.initialize(p);
} catch (ParseException e) {
Bukkit.getLogger().severe("[starlin_l2] Error counting player's monthly play time.");
Bukkit.getLogger().severe("[StarlinUtils] Error counting player's monthly play time.");
e.printStackTrace();
}
}
Expand All @@ -58,14 +61,15 @@ public void onDisable() {
try {
PlayTime.settle(p);
} catch (ParseException e) {
Bukkit.getLogger().severe("[starlin_l2] Error counting player's monthly play time.");
Bukkit.getLogger().severe("[StarlinUtils] Error counting player's monthly play time.");
e.printStackTrace();
}
}
Bukkit.clearRecipes();
HandlerList.unregisterAll(this);
ConfigReader.save(config);
ConfigReader.save(timedata);
ConfigReader.save(monthly);
Bukkit.getLogger().info("[starlin_l2] Starlin_L2 disabled!");
Bukkit.getLogger().info("[StarlinUtils] StarlinUtils disabled!");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.katorly.starlin_l2.backup;
package com.github.katorly.starlinutils.backup;

import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.katorly.starlin_l2.backup;
package com.github.katorly.starlinutils.backup;
import java.util.Objects;

import org.bukkit.Bukkit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.katorly.starlin_l2.commands;
package com.github.katorly.starlinutils.commands;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.github.katorly.starlin_l2.backup.Messager;
import com.github.katorly.starlinutils.backup.Messager;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.katorly.starlin_l2.commands;
package com.github.katorly.starlinutils.commands;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.github.katorly.starlin_l2.backup.Messager;
import com.github.katorly.starlinutils.backup.Messager;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.katorly.starlin_l2.commands;
package com.github.katorly.starlinutils.commands;

import com.github.katorly.starlin_l2.starlin_l2;
import com.github.katorly.starlin_l2.backup.Messager;
import com.github.katorly.starlinutils.StarlinUtils;
import com.github.katorly.starlinutils.backup.Messager;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -11,7 +11,7 @@
public class help implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
FileConfiguration config = starlin_l2.config.getConfig();
FileConfiguration config = StarlinUtils.config.getConfig();
if (command.getName().equalsIgnoreCase("help")) { //Displays the help document when player excutes "/help".
Messager.senderMessage(sender, "&b&l星林宇宙 &r&8>> &7新手指南: &f" + config.getString("help-document"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.katorly.starlin_l2.commands;
package com.github.katorly.starlinutils.commands;

import com.github.katorly.starlin_l2.backup.Messager;
import com.github.katorly.starlinutils.backup.Messager;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand Down
Loading

0 comments on commit 904fa59

Please sign in to comment.