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

Commit

Permalink
Inital release.
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
MlgmXyysd authored Feb 20, 2018
1 parent 9b27cfb commit 7972a94
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
configuration:
auto-broadcast-enabled: true
broadcast-interval-time: 1
language:
msg-signal-1: "\u00a7aSet "
msg-signal-2: " times experience for "
msg-signal-3: " minute(s) successfully!"
msg-getexp-1: "\u00a7a"
msg-getexp-2: " times experience activities is holding, You have got "
msg-getexp-3: " experience(s)!"
msg-expired: "\u00a74Multi experience activity has expired!"
msg-holding-1: "\u00a7a"
msg-holding-2: " times experience activities is holding, Duration time "
msg-holding-3: " minute(s)!"
msg-broadcast-1: "\u00a7aNow "
msg-broadcast-2: " times experience activities has opened, Duration of "
msg-broadcast-3: " minute(s)!"
usage: "\u00a7eUsage: /multiexp enable [multiple] [minute]"
multiexp:
enabled: false
multiple: 2
tick-time: 0

12 changes: 12 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: MultiExperience
main: org.meowcat.MultiExperience.Main
author: MeowCat Studio MlgmXyysd
version: 1.0.0
commands:
multiexp:
permission: multiexp.admin
description: Multi Experience Plugin Info
usage: /<command> enable [multiple] [minute]
permissions:
multiexp.admin:
default: op
31 changes: 31 additions & 0 deletions src/org/meowcat/MultiExperience/ExpListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.meowcat.MultiExperience;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerExpChangeEvent;

public class ExpListener implements Listener {

FileConfiguration getConfig = Main.plugin.getConfig();

@EventHandler
public void ExperienceListener(PlayerExpChangeEvent event) {
if (getConfig.getBoolean("multiexp.enabled")) {
long CurrentTime = System.currentTimeMillis();
long MultiTime = getConfig.getLong("multiexp.tick-time");
if (CurrentTime <= MultiTime) {
float Multiple = (float) getConfig.getDouble("multiexp.multiple");
int PickedExp = event.getAmount();
float CalculatedExp = PickedExp * Multiple;
String message = getConfig.getString("language.msg-getexp-1") + Multiple + getConfig.getString("language.msg-getexp-2") + CalculatedExp + getConfig.getString("language.msg-getexp-3");
event.setAmount(Math.round(CalculatedExp));
event.getPlayer().sendMessage(message);
} else {
getConfig.set("multiexp.enabled", false);
String expired = getConfig.getString("language.msg-expired");
Main.plugin.getServer().broadcastMessage(expired);
}
}
}
}
37 changes: 37 additions & 0 deletions src/org/meowcat/MultiExperience/ExpThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.meowcat.MultiExperience;

import org.bukkit.configuration.file.FileConfiguration;

public class ExpThread extends Thread {

FileConfiguration getConfig = Main.plugin.getConfig();

@Override
public void run()
{
while (Main.plugin.isEnabled()) {
try {
sleep(getConfig.getInt("configuration.broadcast-interval-time") * 60000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
if (!Main.plugin.isEnabled()) {
return;
}
if (getConfig.getBoolean("multiexp.enabled")) {
long CurrentTime = System.currentTimeMillis();
long MultiTime = getConfig.getLong("multiexp.tick-time");
if (CurrentTime <= MultiTime) {
long RemainingTime = (MultiTime - CurrentTime) / 60000;
double Multiple = getConfig.getDouble("multiexp.multiple");
String broadcast = getConfig.getString("language.msg-holding-1") + Multiple + getConfig.getString("language.msg-holding-2") + Math.floor(RemainingTime) + getConfig.getString("language.msg-holding-3");
Main.plugin.getServer().broadcastMessage(broadcast);
}
else {
getConfig.set("multiexp.enabled", false);
}
}
}
}
}
69 changes: 69 additions & 0 deletions src/org/meowcat/MultiExperience/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.meowcat.MultiExperience;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {

public static Main plugin;

@Override
public void onEnable() {
saveDefaultConfig();
plugin = this;
ExpListener listener = new ExpListener();
getServer().getPluginManager().registerEvents(listener, plugin);
boolean isBroadcast = getConfig().getBoolean("configuration.auto-broadcast-enabled");
if (isBroadcast) {
ExpThread ExpThread = new ExpThread();
ExpThread.start();
}
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Multi Experience by MeowCat Studio");
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Offical Website http://www.meowcat.org/");
}

@Override
public void onDisable() {
saveConfig();
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Multi Experience by MeowCat Studio");
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Offical Website http://www.meowcat.org/");
}

@Override
public boolean onCommand(CommandSender player, Command command, String label, String[] arguments) {
if (arguments.length > 0) {
if (arguments[0].equalsIgnoreCase("enable")) {
float Multiple = 2;
long MultiTime = 60;
long CurrentTime = System.currentTimeMillis();
if (arguments.length > 1) {
Multiple = Float.valueOf(arguments[1]);
if (arguments.length > 2) {
MultiTime = Long.valueOf(arguments[2]);
}
}
long RemainingTime = MultiTime * 60000 + CurrentTime;
getConfig().set("multiexp.enabled", true);
getConfig().set("multiexp.multiple", Multiple);
getConfig().set("multiexp.tick-time", RemainingTime);
String message = getConfig().getString("language.msg-signal-1") + Multiple + getConfig().getString("language.msg-signal-2") + MultiTime + getConfig().getString("language.msg-signal-3");
String broadcast = getConfig().getString("language.msg-broadcast-1") + Multiple + getConfig().getString("language.msg-broadcast-2") + MultiTime + getConfig().getString("language.msg-broadcast-3");
player.sendMessage(message);
getServer().broadcastMessage(broadcast);
} else {
String usage = getConfig().getString("language.usage");
player.sendMessage(usage);
}
} else {
String usage = getConfig().getString("language.usage");
player.sendMessage("¡ìbMulti Experience by MeowCat Studio");
player.sendMessage("¡ìbhttp://www.meowcat.org/");
player.sendMessage(usage);
}
return true;
}
}

0 comments on commit 7972a94

Please sign in to comment.